Google Classroom
GeoGebraGeoGebra Classroom

Displaying function with substituted input value

This is a file with example commands and scripts on how to show function in x with substitution of x with variable slider n value and displaying the substitutions and output value of f(n) Useful for showing to beginning students learning functions.
The Geogebra scripting in the button helps to set up all the objects needed to produced and displayed. The essential commands relied upon were the text and list commands like TextToUnicode and UnicodeToText, FormulaText, Insert, Remove, RemoveUndefined. Script for Enumerating Functions # function : f f(x) = 2 x^2+x-1+1/x # variable input n n = 2 # InputBoxFunction for f InputBoxFunction=InputBox(f) SetCaption(InputBoxFunction,Text["Input f(x) ="]) #output textEnumFunction for enumerated function # #textFromFunction = FormulaText[f] textFromFunction = FormulaText[f] # #L_r is to replace x with characters (n) #L_r = {40, 110, 41} #L_r is not being used, instead L_n is used # #L_n the unicode list representing value n in brackets ie. (n) value to replace x # slider n value is being captured in text as textFormulaValue = Text["("+n+")"] textFormulaValue = Text["("+n+")"] #List of unicode characters representing functions L_n = TextToUnicode(textFormulaValue) L_n = TextToUnicode(textFormulaValue) # #L_3 = TextToUnicode(textFromFunction) L_3 = TextToUnicode(textFromFunction) # # L_4 to L_9 is used to replace x (Unicode value 120) with variable n as (n) value # (n) in unicode is computed from L_n = TextToUnicode(textFormulaValue) #L_4 = Remove(Insert(L_n, L_3, IndexOf(120, L_3)), {120}) #L_5 = Remove(Insert(L_n, L_4, IndexOf(120, L_4)), {120}) #L_6 = Remove(Insert(L_n, L_5, IndexOf(120, L_5)), {120}) #L_7 = Remove(Insert(L_n, L_6, IndexOf(120, L_6)), {120}) #L_8 = Remove(Insert(L_n, L_7, IndexOf(120, L_7)), {120}) #L_9 = Remove(Insert(L_n, L_8, IndexOf(120, L_8)), {120}) #L_{10} = RemoveUndefined({L_3, L_4, L_5, L_6, L_7,L_8,L_9}) #L_{11} = Element(L_{10}, Length(L_{10})) # L_4 = Remove(Insert(L_n, L_3, IndexOf(120, L_3)), {120}) L_5 = Remove(Insert(L_n, L_4, IndexOf(120, L_4)), {120}) L_6 = Remove(Insert(L_n, L_5, IndexOf(120, L_5)), {120}) L_7 = Remove(Insert(L_n, L_6, IndexOf(120, L_6)), {120}) L_8 = Remove(Insert(L_n, L_7, IndexOf(120, L_7)), {120}) L_9 = Remove(Insert(L_n, L_8, IndexOf(120, L_8)), {120}) L_{10} = RemoveUndefined({L_3, L_4, L_5, L_6, L_7,L_8,L_9}) L_{11} = Element(L_{10}, Length(L_{10})) #output : #textEnumFunction= FormulaText(UnicodeToText(L_{11}), true) textEnumFunction= FormulaText(UnicodeToText(L_{11}), true) #Texts textShowEnumeratedFunction and textShowFunction are manually done due to styling #problem for f(x) for f to be non cursive #Show point P (n, f(n)) P = (n, f(n))