# equation of a function

## graph of a random defined function and the corresponding equation

In next applet a graph of a random defined first degree function is shown. The user has to select the corresponding equation in a drop-down list. See how it works and make it yourself following the construction steps.

## Construction Steps

 ﻿1 ﻿ ﻿Type the command listab=Shuffle[{-3, -2, -1, 1, 2, 3}] to create listab ﻿2-3 ﻿ ﻿Type the commands a = listab(1) and b = listab(2) to create a and b. ﻿4-7 ﻿ ﻿Define the functions f1, f2, f3 and f4 as: f1(x) = Polynomial[a x + b], f2(x) = Polynomial[a x - b] f3(x) = Polynomial[-a x + b], f4(x) = Polynomial[-a x - b] Hide the graphs. ﻿8 ﻿ ﻿Type the command listf={f1, f2, f3, f4} to create a list that contains the four functions. ﻿9 ﻿ ﻿Type the command sol = RandomBetween[1, 4] to create the number sol. ﻿10 ﻿ ﻿Type the command f(x)= Element[listf, sol] to define the function f shown in the Graphics. ﻿11-14 ﻿ ﻿Select the Text Tool and create four dynamic texts with the equations on the functions. ﻿15 ﻿ ﻿Type the command listans ={"", text1, text2, text3, text4} and draw it as a drop-down list. ﻿16 ﻿ ﻿Type the command ans= SelectedIndex[listans] - 1 to create the number ans. ﻿17 ﻿ ﻿Select the Button Tool and create a button with Caption new exercise and commands: UpdateConstruction[] to recalculate all random defined objects SetValue[listans,1] to reset the drop-down list to its initial blank position.
To give feedback you can define the dynamic colors of the list as follows: