# Integrating Acceleration to Find Velocity and Position # # Chase Caruth and Matt Neely # MATH 152-201 # 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!"]: rightrand := rand(1..nops(right)): 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."]: wrongrand := rand(1..nops(wrong)): final:=["You know your stuff! Move on to the next one!", "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 problem!", "You're doing great! Keep on truckin'!", "Oh yeah! Try the next function!"]: finalrand := rand(1..nops(final)): 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."]: hintrand := rand(1..nops(hint)): constanthintC:=["So close. Don't forget the constant.", "Plus C?", "You're off by a constant.", "Remember the constant."]: constCrand := rand(1..nops(constanthintC)): constanthintK:=["So close. Don't forget the constant.", "Plus K?", "You're off by a constant.", "Remember the constant."]: constKrand := rand(1..nops(constanthintK)): gen1:=rand(-2..2): gen2:=rand(2..4): gen3:=rand(0..3): ask:=proc() local a, b, c ,d, tempeq; global gen1, gen2, gen3, acc, pos, vel, t0, r0, v0, correctanswer1, correctanswer2, correctanswer3, correctanswer4, correctanswer5, correctanswer6; a:=gen1(); b:=gen1(); while(a=0 and b=0) do a:=gen1(); b:=gen1(); end do; c:=gen2(); d:=gen2(); while(c=d) do d:=gen2(); end do; pos:=a*t^c + b*t^d; vel:=diff(pos,t); acc:=diff(vel,t); t0:=gen3(); r0:=gen3(); v0:=gen3(); correctanswer1:=vel+C; tempeq:=correctanswer1=v0; tempeq:=subs(t=t0,tempeq); correctanswer2:=solve(tempeq,C); correctanswer3:=subs(C=correctanswer2,correctanswer1); correctanswer4:=pos+correctanswer2*t+K; tempeq:=correctanswer4=r0; tempeq:=subs(t=t0,tempeq); correctanswer5:=solve(tempeq,K); correctanswer6:=subs(K=correctanswer5, correctanswer4); Set('curve'(value)=MathML[Export]('a(t)' = acc)); Set('given_r'= convert(x(t0) = r0, string)); Set('given_v'= convert(v(t0) = v0, string)); 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('answer5'=""): Set('response5'="", 'response5'(background)=white); Set('answer6'=""): Set('response6'="", 'response6'(background)=white); Set('reply'="", 'reply'(background)=white); end proc: check1:=proc() local useranswer1, constantcheck; global rightrand, wrongrand, constCrand, correctanswer1; useranswer1:=Get('answer1'::anything, corrections=true, update=true): constantcheck:=correctanswer1-C; Set('reply'="", 'reply'(background)=white); if useranswer1=correctanswer1 then Set('response1'=" Correct ", 'response1'(background)=green); Set('reply'=right[rightrand()], 'reply'(background)=green); elif useranswer1=constantcheck then Set('response1'=" Warning ", 'response1'(background)=lightorange); Set('reply'=constanthintC[constCrand()], 'reply'(background)=lightorange); else Set('response1'="Incorrect", 'response1'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show1:=proc() global hintrand, correctanswer1; Set('answer1'=correctanswer1); Set('response1'=" Shown ", 'response1'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: check2:=proc() local useranswer2, tempeq; global rightrand, wrongrand, correctanswer2; useranswer2:=Get('answer2'::anything, corrections=true, update=true): Set('reply'="", 'reply'(background)=white); if useranswer2=correctanswer2 then Set('response2'=" Correct ", 'response2'(background)=green); Set('reply'=right[rightrand()], 'reply'(background)=green); else Set('response2'="Incorrect", 'response2'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show2:=proc() global hintrand, correctanswer2; Set('answer2'=correctanswer2); Set('response2'=" Shown ", 'response2'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: check3:=proc() local useranswer3; global rightrand, wrongrand, correctanswer3; useranswer3:=Get('answer3'::anything, corrections=true, update=true): Set('reply'="", 'reply'(background)=white); if useranswer3=correctanswer3 then Set('response3'=" Correct ", 'response3'(background)=green); Set('reply'=right[rightrand()], 'reply'(background)=green); else Set('response3'="Incorrect", 'response3'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show3:=proc() global hintrand, correctanswer3; Set('answer3'=correctanswer3); Set('response3'=" Shown ", 'response3'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: check4:=proc() local useranswer4, constantcheck; global rightrand, wrongrand, constKrand, correctanswer4; useranswer4:=Get('answer4'::anything, corrections=true, update=true): constantcheck:=correctanswer4-K; Set('reply'="", 'reply'(background)=white); if useranswer4=correctanswer4 then Set('response4'=" Correct ", 'response4'(background)=green); Set('reply'=right[rightrand()], 'reply'(background)=green); elif useranswer4=constantcheck then Set('response4'=" Warning ", 'response4'(background)=lightorange); Set('reply'=constanthintK[constKrand()], 'reply'(background)=lightorange); else Set('response4'="Incorrect", 'response4'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show4:=proc() global hintrand, correctanswer4; Set('answer4'=correctanswer4); Set('response4'=" Shown ", 'response4'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: check5:=proc() local useranswer5; global rightrand, wrongrand, correctanswer5; useranswer5:=Get('answer5'::anything, corrections=true, update=true): Set('reply'="", 'reply'(background)=white); if useranswer5=correctanswer5 then Set('response5'=" Correct ", 'response5'(background)=green); Set('reply'=right[rightrand()], 'reply'(background)=green); else Set('response5'="Incorrect", 'response5'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show5:=proc() global hintrand, correctanswer5; Set('answer5'=correctanswer5); Set('response5'=" Shown ", 'response5'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: check6:=proc() local useranswer6; global rightrand, wrongrand, finalrand, correctanswer6; useranswer6:=Get('answer6'::anything, corrections=true, update=true): Set('reply'="", 'reply'(background)=white); if useranswer6=correctanswer6 then Set('response6'=" Correct ", 'response6'(background)=green); Set('reply'=final[finalrand()], 'reply'(background)=green); else Set('response6'="Incorrect", 'response6'(background)=red); Set('reply'=wrong[wrongrand()], 'reply'(background)=red); end if; end proc: show6:=proc() global hintrand, correctanswer6; Set('answer6'=correctanswer6); Set('response6'=" Shown ", 'response6'(background)=lightorange); Set('reply'=hint[hintrand()], 'reply'(background)=lightorange); end proc: AccelVelPos:=Maplet(onstartup = RunWindow(MAIN), Font[helv10]("helvetica",10), Window[MAIN]('title'="Integrating Acceleration to Find Velocity and Position", [ halign=none, [ Button("New Function", Evaluate('function' = "ask")), HorizontalGlue(), Button("Quit", Shutdown()) ], [ border=true, caption="Goal: Find the position of a particle given that its acceleration, initial position and initial velocity are:", MathMLViewer['curve'](value=MathML[Export](a(t) = a), 'width'=150, 'height'=35), HorizontalGlue(), TextField['given_r']("x(0) = x0", 'width'=10, 'editable'='false', background=white), HorizontalGlue(), TextField['given_v']("v(0) = v0", 'width'=10, 'editable'='false', background=white) ], [ border=true, caption="Find the velocity with a constant of integration C:", "v(t) =", TextField['answer1']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function' = "check1")), TextField['response1']('width'=10, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show1")) ], [ border=true, caption="Find C using the initial velocity:", "C = ", TextField['answer2']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function'= "check2")), TextField['response2']('width'=10, 'editable'='false', background=white), Button("Show", Evaluate('function'="show2")) ], [ border=true, caption="Substitute C into the velocity:", "v(t) =", TextField['answer3']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function' = "check3")), TextField['response3']('width'=10, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show3")) ], [ border=true, caption="Find the position with a constant of integration K:", "x(t) =", TextField['answer4']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function' = "check4")), TextField['response4']('width'=10, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show4")) ], [ border=true, caption="Find K using the initial position:", "K = ", TextField['answer5']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function' = "check5")), TextField['response5']('width'=10, 'editable'='false',background=white), Button("Show", Evaluate('function' = "show5")) ], [ border=true, caption="Substitute K into the position: ", "x(t) =", TextField['answer6']('width'=25, background=turquoise), HorizontalGlue(), Button("Check", Evaluate('function' = "check6")), TextField['response6']('width'=10, 'editable'='false', background=white), Button("Show", Evaluate('function' = "show6")) ], [ TextField['reply']('width'=40, 'editable'='false', background=white) ], BoxRow('background'="#DDFFFF", 'inset'=0, 'spacing'=0, Label("Programmers: Chase Caruth / Matt Neely", 'font'=helv10), HorizontalGlue(), Label("Copyright 2006, D.B. Meade and P.B. Yasskin", 'font'=helv10), HorizontalGlue(), Label("v. 1.2a May 2006", 'font'=helv10) ) ] ) ): Display( AccelVelPos );