restart: with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); randomize(): ReflectionsofFunctions:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN]('title'="Reflections of Functions", [ [ background=wheat, [ [ Button("New Function", onclick=Evaluate('function' = "Ask_Question")), Button("Close", Shutdown(), background=pink) ], [ "The graph of a function y = f(x) is shown at the right:" ], [ HorizontalGlue(), "Which of the following is the graph of", TextField['question']("", width=10), HorizontalGlue() ] ], Plotter['PL0'](plot(0,x=-10..10, y=-10..10), 'width'=250, 'height'=250) ], [ [ background=wheat, Plotter['PL1'](plot1, 'width'=250, 'height'=250), RadioButton['RP1']("Plot # 1", 'value'='false', 'group'='BG1', 'background'=turquoise) ], [ background=wheat, Plotter['PL2'](plot2, 'width'=250, 'height'=250), RadioButton['RP2']("Plot # 2", 'value'='false', 'group'='BG1', 'background'=turquoise) ], [ background=wheat, Plotter['PL3'](plot3, 'width'=250, 'height'=250), RadioButton['RP3']("Plot # 3", 'value'='false', 'group'='BG1', 'background'=turquoise) ] ], [ Button("Check",Evaluate('function' = "Check_Answer"), background=turquoise), Button("Show", Evaluate('function' = "Show_Answer"), background=turquoise), TextBox['PlotComment']("", width=40) ], [ "Programmers: Mirochna & Naizer Copyright P. Yasskin 2005" ] ] ), ButtonGroup['BG1']() ): Fns:=[ (x+1)^3, (x-2)^2, x^3-1, ln(x), exp(x), x^(1/2), x+2, -(x+1)^2, 1/(x+1), 2^(x-2) ]; rand10:=rand(1..10): rand3:=rand(1..3): Ask_Question := proc() local f, f1, f2, f3, p0, p1, p2, p3; global Fns, x, ans, rand3, rand10; ans:=rand3(); if ans = 1 then (Set('question' = "y = f(-x)")) end if; if ans = 2 then (Set('question' = "y = -f(x)")) end if; if ans = 3 then (Set('question' = "y = -f(-x)")) end if; f:=Fns[rand10()]; p0:=plot(f,x=-3..3, y=-3..3); Set(PL0=p0); f1:=subs(x=-x,f); f2:=-f; f3:=subs(x=-x,f2); p1:=plot(f1,x=-3..3, y=-3..3); p2:=plot(f2,x=-3..3, y=-3..3); p3:=plot(f3,x=-3..3, y=-3..3); Set(PL1=p1); Set(PL2=p2); Set(PL3=p3); Set('RP1' = 'false'); Set('RP2' = 'false'); Set('RP3' = 'false'); Set('PlotComment' = ""): end proc: Check_Answer := proc() local plotans; global ans; plotans:=0; if Get('RP1') then plotans:=1 end if; if Get('RP2') then plotans:=2 end if; if Get('RP3') then plotans:=3 end if; if plotans = 0 then Set('PlotComment' = "Please select a plot.") elif plotans = ans then Set('PlotComment' = "Good Job! You are correct"): else Set('PlotComment' = "You did not pick the correct plot. Try again. "): end if; end proc: Show_Answer := proc() global ans; if ans=1 then Set('RP1' = 'true') end if; if ans=2 then Set('RP2' = 'true') end if; if ans=3 then Set('RP3' = 'true') end if; end proc: Display(ReflectionsofFunctions):