restart: with(Maplets[Elements]):with(Maplets[Tools]): StartEngine(); lightorange:="#FFB300": randomize(): great := [ " Bullseye. ", " Great. ", " That's absolutely right. ", " Awesome. You're unstoppable. ", " Correct. ", " You got it! ", " Way to go. ", " Don't stop now. ", " I knew you could do it! ", " Perfect. You're unstoppable. ", " Awesome! ", " Good job! You really know what you are doing. ", " You're a genious. ", " Excellent! ", " Oh yeah! ", " That was fantastic! " ]: randgreat := rand(1..nops(great)): nextquest := [ "Keep it up.", "Keep going.", "On to the next problem.", "Try another function.", "Identify another shifted function." ]: randnext := rand(1..nops(nextquest)): sorry := [ " Sorry, that's not right. ", " Nope, but don't give up. ", " Not quite, it's a little off. ", " D'oh! ", " Really close. You'll get it next time. ", " Nice try, but your answer is wrong. ", " Ask your neighbor for help. ", " So, that was just practice. ", " Better luck next time. ", " Oops. ", " Better luck next time. ", " Tisk, tisk. It's a tough one. ", " It takes a lot of wrongs to make a right. ", " Even Einstein didn't get everything right. ", " Oh man, you were so close. " ]: randsorry := rand(1..nops(sorry)): tryagain := [ "Fix your answer and check it again.", "Give it another try.", "Try again.", "Please try again." ]: randtry := rand(1..nops(tryagain)): showit := [ " OK That's just practice. But try doing it yourself.", " That's fine for practice. Try doing it yourself.", " Think about it and enter an answer yourself.", " Next time, compute an answer yourself.", " So that was practice. Try doing it yourself." ]: randshow := rand(1..nops(showit)): func:=[ x -> sin(x), x -> cos(x), x -> tan (x), x -> cot(x), x -> sec(x), x -> csc(x) ]: colour:=maroon: colour2:=white: colour3:=plum: randfunc := rand(1..nops(func)): hshifts:=[0, Pi, Pi/2, 3*Pi/2, Pi/4, 3*Pi/4, 5*Pi/4, 7*Pi/4, Pi/6, Pi/3, 2*Pi/3, 5*Pi/6, 7*Pi/6, 4*Pi/3, 5*Pi/3, 11*Pi/6]; randhshift:=rand(1..16): randvshift:=rand(-3..3): Show_Shifted_Graph := proc() local p1; global hshift, vshift, answer, x, func, randfunc, randhshift, randvshift; hshift := hshifts[randhshift()]; vshift := randvshift(); answer := func[randfunc()](x - hshift) + vshift; p1:=plot(answer, x=-2*Pi..2*Pi, -5..5, discont=true, scaling=constrained, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ], color=blue, thickness=2, numpoints=99): Set('PL1' = plots[display](p1)): Set('reply' = "This is the graph of one of the 6 basic trig functions shifted left or right by multiples of Pi/6 or Pi/4 and/or shifted up or down by an integer.\n\nEnter its formula below.", reply(background)=white, reply(foreground)=black): Set('TF1' = ""): Set('Bcheck'(enabled)=true, 'Bcheck'(background)=colour3); Set('Bshow'(enabled)=true, 'Bshow'(background)=colour3); end proc: Check_Answer := proc() local user_answer, p1, p2; global answer, x, great, randgreat, sorry, randsorry; user_answer := Get('TF1'::algebraic, corrections=true, update=true): if simplify(normal(expand(answer - user_answer)))<> 0 then p1:=plot(answer, x=-2*Pi..2*Pi, -5..5, discont=true, scaling=constrained, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ], color=blue, thickness=2, numpoints=99): p2:=plot(user_answer, x=-2*Pi..2*Pi, -5..5, discont=true, scaling=constrained, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ], color=red, thickness=2, numpoints=99): Set('PL1' = plots[display]( p1,p2 )): Set('reply' = cat(sorry[randsorry()], "The new plot shows the ORIGINAL FUNCTION in BLUE and YOUR ANSWER in RED. Modify your answer and Check Your Answer again."), reply(background)=violet, reply(foreground)=white): else p1:=plot(answer, x=-2*Pi..2*Pi, -5..5, discont=true, scaling=constrained, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ], color=green, thickness=2, numpoints=99): Set('PL1' = plots[display]( p1 )): Set('reply' = cat(great[randgreat()], nextquest[randnext()], " Click on Show Shifted Graph."), reply(background)=green, reply(foreground)=black): end if; end proc: Show_Answer := proc() global answer, x; Set('TF1' = answer): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black): end proc: Shift_Trig_Function := Maplet(onstartup = RunWindow(MAIN), Font[helv10]("helvetica",10), Window[MAIN]( 'title'="Shifting Trigonometric Functions", 'defaultbutton'='Bcheck', BoxColumn( halign=none, background=colour, BoxRow( background=colour, inset=0, spacing=0, BoxColumn( background=colour, inset=0, spacing=0, border=true, halign=none, Button['BShowShiftGraph']("Show\nShifted Graph", Evaluate('function' = "Show_Shifted_Graph"), background=turquoise), Button("Show\n6 Basic Functions", onclick=RunWindow(BASIC6), background=colour3) ), BoxColumn( background=colour, inset=0, spacing=0, border=true, halign=none, Plotter['PL1'](plot(0, x=-2*Pi..2*Pi, -5..5, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]), 'width'=275, 'height'=275) ) ), BoxRow( background=colour, inset=0, spacing=0, border=true, TextBox['reply']("Click on Show 6 Basic Functions to see the graphs of 6 basic trigonometric functions.\n\nClick on Show Shifted Graph to see one of the 6 basic trig functions shifted up or down and/or left or right.", 'width'=50, 'height'=5, 'editable' = 'false', background=white) ), BoxRow( background=colour2, "Answer = ", TextField['TF1']('width'=20, background=colour3) ), BoxRow( background=colour, inset=0, spacing=0, border=true, HorizontalGlue(), Button['Bcheck']("Check Answer", Evaluate('function' = "Check_Answer"), enabled=false), HorizontalGlue(), Button['Bshow']("Show Answer", Evaluate(function = 'Show_Answer'), enabled=false), HorizontalGlue(), Button("Quit", Shutdown(), background=colour3), HorizontalGlue() ), [ "Programmer: Cornforth & Rechard Copyright P. Yasskin 2005" ] )), Window[BASIC6]( 'title'="Basic 6 Trigonometric Functions", BoxColumn( halign=none, background=colour, inset=0, spacing=0, [ background=colour2, inset=15, "Look at each graph and learn its basic shape:", HorizontalGlue(), Button("Close", CloseWindow(BASIC6), background=colour3) ], BoxRow( background=colour, inset=0, BoxColumn( background=colour, inset=0, spacing=0, border=true, caption="Basic functions", Button("Show sin(x)", width=120, background=colour3, onclick=A1), Button("Show cos(x)", width=120, background=colour3, onclick=A2), Button("Show tan(x)", width=120, background=colour3, onclick=A3), Button("Show cot(x)", width=120, background=colour3, onclick=A4), Button("Show sec(x)", width=120, background=colour3, onclick=A5), Button("Show csc(x)", width=120, background=colour3, onclick=A6) ), BoxColumn(background=colour, inset=0, spacing=0, border=true, caption="Plot", Plotter['PL6'](plot(0, x=-2*Pi..2*Pi, -5..5, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]), 'width'=275, 'height'=275) ) ) )), Action[A1](SetOption('PL6' = plot(sin(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))), Action[A2](SetOption('PL6' = plot(cos(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))), Action[A3](SetOption('PL6' = plot(tan(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, discont=true, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))), Action[A4](SetOption('PL6' = plot(cot(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, discont=true, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))), Action[A5](SetOption('PL6' = plot(sec(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, discont=true, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))), Action[A6](SetOption('PL6' = plot(csc(x), x=-2*Pi..2*Pi, -5..5, thickness=3, color=blue, discont=true, tickmarks=[ [-6.28="-2Pi", -3.14="-Pi", 3.14="Pi", 6.28="2Pi"], [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] ]))) ): Maplets[Display]( Shift_Trig_Function );