# Tangent Line to the Parametric Curve Maplet # # Chase Caruth # MATH 151-202 # November 22, 2005 # restart: with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); randomize(): lightorange:="#FFB300": right:= ["Bullseye!", "Great!", "That's absolutely right!", "You're unstoppable!", "Correct!", "You nailed that one!", "YES!", "Way to go!", "I knew you could do it!", "Perfecto!", "You're awesome!", "That's amazing!", "You're a math whiz!", "Whoop!", "Nice job!", "That's right!", "That's the way!", "I like the sound of that!", "Ding! That's correct!", "You're a genius!", "Right on the mark!", "Brick...house!", "Oh yeah!", "Wonderful!", "Excellent!", "You got it!", "Can I get a what what!", "Holla!", "You're incredible!"]: wrong:=["Try again.", "Nope. I'm sorry.", "C'mon, you can do it.", "You can do better.", "You're close.", "Look closer.", "Put on your thinking cap.", "Better luck next time.", "Keep trying.", "Never give up.", "Try again. I have faith in you.", "Try harder."]: final:=["You know your parametric equations! Move on to the next curve!", "You're doing so awesome! Keep on keepin' on!", "Wow! That's awesome! Don't stop now!", "You got all of them right! Way to go! Go on to the next curve!", "You're doing great! Keep on truckin'!", "Oh yeah! Try the next curve!"]: hint:=["Now try it yourself.", "There it is. Now figure it out.", "The hint is great, but try it yourself.", "That was practice. Try it again.", "Don't settle for the hint. Work it out."]: ParamTanLine:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN]('title'="Find the Tangent Line to the Parametric Curve", [ halign=none, [ Button("New Curve", Evaluate('function' = "ask")), HorizontalGlue(), Button("Quit", Shutdown()) ], [ "The goal of this maplet is to find the vector equation for the line tangent to the curve", HorizontalGlue() ], [ HorizontalGlue(), "r(t) =", MathMLViewer['curve']('width'=250, 'height'=60), "at t =", TextField['given_t']("a", 'width'=10, 'editable'=false), HorizontalGlue() ], [ Label[Lra]("Find r(a):"), TextField['answer1']('width'=10, background=turquoise), HorizontalGlue(), Button("Submit", Evaluate('function' = "check1")), TextField['response1']('width'=25, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show1")) ], [ "Find r'(t): ", TextField['answer2']('width'=15, background=turquoise), HorizontalGlue(), Button("Submit", Evaluate('function' = "check2")), TextField['response2']('width'=25, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show2")) ], [ Label[Lrpa]("Find r'(a):"), TextField['answer3']('width'=10, background=turquoise), HorizontalGlue(), Button("Submit", Evaluate('function' = "check3")), TextField['response3']('width'=25, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show3")) ], [ "Enter the vector equation of the tangent line:", HorizontalGlue() ], [ "[x,y] =", TextField['answer4']('width'=20, background=turquoise), HorizontalGlue(), Button("Submit", Evaluate('function' = "check4")), TextField['response4']('width'=25, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show4")) ], [ TextField['reply']('width'=40, 'editable'='false', background=white) ], ["This Maplet was designed by Chase Caruth, Class of 2009. Copyright 2005" ] ] ) ): ask:=proc() local gen1, gen2, gen3, a, b, c, d, exponent_x, exponent_y, x, y; global eq, t0; gen1:=rand(-5..5): gen2:=rand(1..3): gen3:=rand(-2..2): a:=gen1(); b:=gen1(); c:=gen1(); d:=gen1(); exponent_x:=gen2(); exponent_y:=gen2(); while(a=0 or c=0) do a:=gen1(); c:=gen1(); end do; x:=a*t^exponent_x + b*t^gen2(); y:=c*t^exponent_y + d*t^gen2(); eq:= [x, y]; Set('curve'=MathML[Export](eq)); t0:=gen3(); Set('given_t'=t0); Set('Lra'(caption)=cat("Find r(", t0 , "):")); Set('Lrpa'(caption)=cat("Find r'(", t0 , "):")); Set('answer1'=""): Set('response1'="", 'response1'(background)=white); Set('answer2'=""): Set('response2'="", 'response2'(background)=white); Set('answer3'=""): Set('response3'="", 'response3'(background)=white); Set('answer4'=""): Set('response4'="", 'response4'(background)=white); Set('reply'="", 'reply'(background)=white); end proc: check1:=proc() local useranswer1, rightrand, wrongrand; global correctanswer1; rightrand := rand(1..nops(right)): wrongrand := rand(1..nops(wrong)): useranswer1:=Get('answer1'::anything, corrections=true, update=true): correctanswer1:=subs(t=t0,eq); Set('reply'="", 'reply'(background)=white); if useranswer1=correctanswer1 then Set('response1'=right[rightrand()], 'response1'(background)=green); else Set('response1'=wrong[wrongrand()], 'response1'(background)=red); end if; end proc: show1:=proc() local hintrand; global correctanswer1; hintrand := rand(1..nops(hint)): correctanswer1:=subs(t=t0,eq); Set('answer1'=correctanswer1); Set('response1'=hint[hintrand()], 'response1'(background)=lightorange); Set('reply'="", 'reply'(background)=white); end proc: check2:=proc() local useranswer2, correctanswer2, rightrand, wrongrand; rightrand := rand(1..nops(right)): wrongrand := rand(1..nops(wrong)): useranswer2:=Get('answer2'::anything, corrections=true, update=true): correctanswer2:=diff(eq,t); Set('reply'="", 'reply'(background)=white); if useranswer2=correctanswer2 then Set('response2'=right[rightrand()], 'response2'(background)=green); else Set('response2'=wrong[wrongrand()], 'response2'(background)=red); end if; end proc: show2:=proc() local correctanswer2, hintrand; correctanswer2:=diff(eq,t); hintrand := rand(1..nops(hint)): Set('answer2'=correctanswer2); Set('response2'=hint[hintrand()], 'response2'(background)=lightorange); Set('reply'="", 'reply'(background)=white); end proc: check3:=proc() local useranswer3, rightrand, wrongrand; global correctanswer3; rightrand := rand(1..nops(right)): wrongrand := rand(1..nops(wrong)): useranswer3:=Get('answer3'::anything, corrections=true, update=true): correctanswer3:=subs(t=t0, diff(eq,t)); Set('reply'="", 'reply'(background)=white); if useranswer3=correctanswer3 then Set('response3'=right[rightrand()], 'response3'(background)=green); else Set('response3'=wrong[wrongrand()], 'response3'(background)=red); end if; end proc: show3:=proc() local hintrand; global correctanswer3; hintrand := rand(1..nops(hint)): correctanswer3:=subs(t=t0, diff(eq,t)); Set('answer3'=correctanswer3); Set('response3'=hint[hintrand()], 'response3'(background)=lightorange); Set('reply'="", 'reply'(background)=white); end proc: check4:=proc() local useranswer4, rightrand, wrongrand, finalrand; global correctanswer4; rightrand := rand(1..nops(right)): wrongrand := rand(1..nops(wrong)): finalrand := rand(1..nops(final)): useranswer4:=Get('answer4'::anything, corrections=true, update=true): correctanswer4:=[correctanswer1[1]+correctanswer3[1]*t, correctanswer1[2]+correctanswer3[2]*t]; if useranswer4=correctanswer4 then Set('response4'=right[rightrand()], 'response4'(background)=green); Set('reply'=final[finalrand()], 'reply'(background)=green); else Set('response4'=wrong[wrongrand()], 'response4'(background)=red); Set('reply'="", 'reply'(background)=white); end if; end proc: show4:=proc() local hintrand; global correctanswer4; hintrand := rand(1..nops(hint)): correctanswer4:=[correctanswer1[1]+correctanswer3[1]*t, correctanswer1[2]+correctanswer3[2]*t]; Set('answer4'=correctanswer4); Set('response4'=hint[hintrand()], 'response4'(background)=lightorange); Set('reply'="", 'reply'(background)=white); end proc: Display( ParamTanLine );