restart: with(Maplets[Elements]):with(Maplets[Tools]):StartEngine(); lightorange:="#FFB300": randomize(): great := [ " Bullseye. ", " Right on the mark. ", " Great. ", " That's absolutely right. ", " Awesome. You're unstoppable. ", " Correct. ", " WOW, nailed that one. ", " You got it! ", " YES! Right on. ", " Way to go. ", " Don't stop now. ", " I knew you could do it! ", " Perfect. You're unstoppable. ", " Radical Dude. ", " Power house. ", " Sweet! Keep on Rockin'. ", " You rock! ", " You got those mad skills. ", " Awesome! ", " Wowzers! That was great! ", " Awesome man! ", " Good job! You really know what you are doing. ", " You're awesome kid. ", " Tearing it up. ", " Right on the money. ", " High Five!!!!! ", " Cool Beans. ", " What a nerd! ", " You're so money. ", " You're a genious. ", " You hit the nail on the head. ", " Excellent! ", " If I had a cookie, I'd give it to you. ", " You're a winner. ", " That's a winner. ", " Whoop! Way to go. ", " That's the way, ah ha ah ha, I like it. ", " Oh yeah! ", " You're the bomb! ", " That was fantastic! ", " Oh Snap! ", " That's krunk! " ]: randgreat := rand(1..nops(great)): nextquest := [ "Keep it up.", "Keep going.", "On to the next function.", "Try another function.", "Find another tangent line." ]: randnext := rand(1..nops(nextquest)): sorry := [ " Sorry, that's not right. ", " Nope, but don't give up. ", " Not quite, it's a little off. ", " Bummer, thought you would get it this time. ", " Close, but no cigar. ", " Slightly off. ", " If you need help, please ask a human. ", " I don't know where you went wrong. ", " Sorry, killer problem. ", " No, but don't blow it off. ", " D'oh! ", " That's whack. ", " Yikes! Really close. You'll get it next time. ", " Pucha! Thought you would get it this time. ", " Nice try, but your answer is wrong. ", " Ask your neighbor for help. ", " Brutal kid. ", " That won't fly. ", " So close and yet so far. ", " So, that was just practice. ", " Ooooh...close. ", " A swing and a miss. ", " Better luck next time. ", " Oops. ", " Tilt. Play again. ", " I know you can do better. ", " Sorry Charlie. ", " 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. ", " Today's not your lucky day. ", " Don't quit your day job. ", " You're colder than a polar bear's toenail. " ]: randsorry := rand(1..nops(sorry)): tryagain := [ "Check your algebra.", "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.", " So that was practice. Try doing it yourself." ]: randshow := rand(1..nops(showit)): randpoint:= rand(-3..4): randsym:= rand(1..12): As:= [a,b,c,p,q,r,s,t,u,v,w,z]: New_Function:= proc() local OK; global func, pta, randsym, As, randpoint, funca, funch, funcah, funcsec, funcsecsimp, functan; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; OK:= false: while not OK do OK:= true; func:= randpoly(x, coeffs=rand(-10..10), degree=2);func:=func-eval(func, x=0): if diff(func,x) = 0 then OK:= false; end if; end do; if Get('RB2') then pta:= As[randsym()]; else pta:= randpoint(); end if; funca:= eval(func, x=pta): funch:= subs(x=h, func): # to check for wrong answers funcah:= subs(x=pta+h, func): # How do we keep it from simplifying? funcsec:= (funcah - funca) / h: # How do we keep it from simplifying? funcsecsimp:= simplify((funcah - funca) / h): functan:= simplify(eval(diff(func,x), x=pta)): Set('fMML' = "f(x) = func"): Set('pointMML' = "x = pta"): Set('fain' = cat("f(", convert(pta,string), ")")): Set('fahin' = cat("f(", convert(pta,string), " + h)")): Set('secMML' = "m[sec] = (f(pta+h) - f(pta)) / h"): Set('fa' = " "): Set('fack' = " ", 'fack'(background)=white, 'fack'(foreground) = black): Set('fah' = " "): Set('fahck' = " ", 'fahck'(background)=white, 'fahck'(foreground) = black): Set('msec' = " "): Set('msecck' = " ", 'msecck'(background)=white, 'msecck'(foreground) = black): Set('msecsimp' = " "): Set('msecsimpck' = " ", 'msecsimpck'(background)=white, 'msecsimpck'(foreground) = black): Set('mtan' = " "): Set('mtanck' = " ", 'mtanck'(background)=white, 'mtanck'(foreground) = black): Set('reply' = " ", 'reply'(background)=white, 'reply'(foreground) = black); Set('Bfack'(enabled)=true, Bfack(background)=turquoise); Set('Bfash'(enabled)=true, Bfash(background)=turquoise); Set('Bfahck'(enabled)=true, Bfahck(background)=turquoise); Set('Bfahsh'(enabled)=true, Bfahsh(background)=turquoise); Set('Bmsecck'(enabled)=true, Bmsecck(background)=turquoise); Set('Bmsecsh'(enabled)=true, Bmsecsh(background)=turquoise); Set('Bmsecsimpck'(enabled)=true, Bmsecsimpck(background)=turquoise); Set('Bmsecsimpsh'(enabled)=true, Bmsecsimpsh(background)=turquoise); Set('Bmtanck'(enabled)=true, Bmtanck(background)=turquoise); Set('Bmtansh'(enabled)=true, Bmtansh(background)=turquoise); end proc: Check_fa:= proc() local user_fa; global funca; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; user_fa:= Get('fa'::algebraic, corrections=true, update=true): if simplify(normal(funca - user_fa)) <> 0 then Set('fack' = "incorrect", 'fack'(background) = red, 'fack'(foreground) = white): Set('reply' = "Check your arithmetic and try again.", 'reply'(background)=red, 'reply'(foreground) = white): else Set('fack' = " correct ", 'fack'(background) = green, 'fack'(foreground) = black): Set('reply' = " ", 'reply'(background)=white, 'reply'(foreground) = black): end if; end proc: Show_fa:= proc() global funca; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; Set('fa' = funca): Set('fack' = " ", 'fack'(background) = white, 'fack'(foreground) = black): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): end proc: Check_fah:= proc() local user_fah; global funca, funch, funcah; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; user_fah:= Get('fah'::algebraic, corrections=true, update=true): if simplify(normal(funcah - user_fah)) = 0 then Set('fahck' = " correct ", 'fahck'(background)=green, 'fahck'(foreground) = black): Set('reply' = "Now compute the slope of the secant line. You don't need to simplify yet.", 'reply'(background)=green, 'reply'(foreground) = black): elif simplify(normal((funca + funch) - user_fah)) = 0 then Set('fahck' = "incorrect", 'fahck'(background)=red, 'fahck'(foreground) = white): Set('reply' = cat("Remember, f(", convert(pta,string), "+ h) is not the same as f(", convert(pta,string), ") + f(h). Replace x with (", convert(pta,string), "+ h) and then carry out the appropriate arithmetic."), 'reply'(background)=red, 'reply'(foreground) = white): elif simplify(normal((funca + h) - user_fah)) = 0 then Set('fahck' = "incorrect", 'fahck'(background)=red, 'fahck'(foreground) = white): Set('reply' = cat("Remember, f(", convert(pta,string), "+ h) is not the same as f(", convert(pta,string), ") + h. Replace x with (", convert(pta,string), "+ h) and then carry out the appropriate arithmetic."), 'reply'(background)=red, 'reply'(foreground) = white): else Set('fahck' = "incorrect", 'fahck'(background)=red, 'fahck'(foreground) = white): Set('reply' = cat("f(", convert(pta,string), "+ h) means you must replace every x by (", convert(pta,string), "+ h). Then carry out the appropriate arithmetic. Try again."), 'reply'(background)=red, 'reply'(foreground) = white): end if; end proc: Show_fah:= proc() global funcah; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; Set('fah' = funcah): Set('fahck' =" ", 'fahck'(background)=white, 'fahck'(foreground) = black): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): end proc: Check_msec:= proc() local user_msec; global funcsec; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; user_msec:= Get('msec'::algebraic, corrections=true, update=true): if simplify(normal(funcsec - user_msec)) <> 0 then Set('msecck' = "incorrect", 'msecck'(background) = red, 'msecck'(foreground) = white): Set('reply' = "Check your algebra and try again.", 'reply'(background)=red, 'reply'(foreground) = white): else Set('msecck' = " correct ", 'msecck'(background) = green, 'msecck'(foreground) = black): Set('reply' = "Now simplify the slope of the secant line.", 'reply'(background)=green, 'reply'(foreground) = black): end if; end proc: Show_msec:= proc() global funcsec; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; Set('msec' = funcsec): Set('msecck' =" ", 'msecck'(background)=white, 'msecck'(foreground) = black): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): end proc: Check_msecsimp:= proc() local user_msecsimp; global funcsecsimp; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; user_msecsimp:= Get('msecsimp'::algebraic, corrections=true, update=true): if simplify(normal(funcsecsimp - user_msecsimp)) <> 0 then Set('msecsimpck' = "incorrect", 'msecsimpck'(background)=red, 'msecsimpck'(foreground) = white): Set('reply' = "Check your algebra and try again.", 'reply'(background)=red, 'reply'(foreground) = white): else Set('msecsimpck' = " correct ", 'msecsimpck'(background)=green, 'msecsimpck'(foreground) = black): Set('reply' = "Finally find the slope of the tangent line, by taking the limit as h goes to zero. HINT: Just plug in h=0.", 'reply'(background)=green, 'reply'(foreground) = black): end if; end proc: Show_msecsimp:= proc() global funcsecsimp; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; Set('msecsimp' = funcsecsimp): Set('msecsimpck' =" ", 'msecsimpck'(background)=white, 'msecsimpck'(foreground) = black): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): end proc: Check_mtan:= proc() local user_mtan; global functan; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; user_mtan:= Get('mtan'::algebraic, corrections=true, update=true): if searchtext("h", convert(user_mtan,string)) <> 0 or searchtext("lim", convert(user_mtan,string)) <> 0 then Set('mtanck' = "incorrect", 'mtanck'(background)=red, 'mtanck'(foreground) = white): Set('reply' = "To compute the limit as h approaches zero, substitute h = 0 into the function and simplify accordingly.", 'reply'(background)=red, 'reply'(foreground) = white): elif simplify(normal(functan - user_mtan)) <> 0 then Set('mtanck' = "incorrect", 'mtanck'(background)=red, 'mtanck'(foreground) = white): Set('reply' = cat(sorry[randsorry()], tryagain[randtry()]), 'reply'(background)=red, 'reply'(foreground) = black): else Set('mtanck' = " correct ", 'mtanck'(background)=green, 'mtanck'(foreground) = black): Set('reply' = cat(great[randgreat()], nextquest[randnext()]), 'reply'(background)=green, 'reply'(foreground) = black): end if; end proc: Show_mtan:= proc() global functan; options `Copyright 2004-05, Philip B. Yasskin, Texas A&M Univ.`; Set('mtan' = functan): Set('mtanck' =" ", 'mtanck'(background)=white, 'mtanck'(foreground) = black): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): end proc: Sec2TanAlgebraic := Maplet(onstartup = RunWindow(MAIN), Font[helv10]("helvetica",10), Window[MAIN]( 'title'="From Secant Slopes to Tangent Slope, using a Formula", 'defaultbutton'='BHint', [ halign=none, background=wheat, [ background=wheat, Button['Bnew']("New Function", Evaluate('function' = "New_Function"), background=turquoise), RadioButton['RB1']("Numeric", 'value'=true, background=wheat, 'group'='BG1'), RadioButton['RB2']("Symbolic", 'value'=false, background=wheat, 'group'='BG1'), HorizontalGlue(), Button['BHint']("Hint", Evaluate('function' = "Hint"), background=turquoise, visible=false), Button("Quit", Shutdown(), background=pink) ], BoxRow(inset=0, spacing=0, border=true, background=wheat, caption="Goal: Find the slope of the tangent line from the slopes of the secant lines for the function:", HorizontalGlue(), MathMLViewer[fMML]('value'=MathML[Export](f(x) = ` `), 'width'=300, 'height'=60), "at the point", MathMLViewer[pointMML]('value'=MathML[Export](x = a), 'width'=80, 'height'=60), HorizontalGlue() ), BoxColumn( halign=none, inset=0, spacing=0, border=true, background=wheat, caption="Step 1 - Determine f(a) and f(a+h).", [ background=wheat, "Enter:", TextField['fain'](" f(a) ", 'width'=7, editable=false, background=white), "=", TextField['fa']('width'=35, 'background'=turquoise), HorizontalGlue(), Button['Bfack']("Check", Evaluate('function' = "Check_fa"), background=wheat, enabled=false), TextField['fack']('width'=6, editable=false, background=white), Button['Bfash']("Show", Evaluate('function' = "Show_fa"), background=wheat, enabled=false) ], [ background=wheat, "Enter:", TextField['fahin'](" f(a+h) ", 'width'=7, editable=false, background=white), "=", TextField['fah']('width'=35, 'background'=turquoise), HorizontalGlue(), Button['Bfahck']("Check", Evaluate('function' = "Check_fah"), background=wheat, enabled=false), TextField['fahck']('width'=6, editable=false, background=white), Button['Bfahsh']("Show", Evaluate('function' = "Show_fah"), background=wheat, enabled=false) ] ), BoxRow(inset=0, spacing=0, border=true, background=wheat, caption="Step 2a - Compute the slope of the secant line.", MathMLViewer[secMML]('value'=MathML[Export](m[sec] = (f(a+h) - f(a)) / h), 'width'=175, 'height'=50), "=", TextField['msec']('width'=30, 'background'=turquoise), HorizontalGlue(), Button['Bmsecck']("Check", Evaluate('function' = "Check_msec"), background=wheat, enabled=false), TextField['msecck']('width'=6, editable=false, background=white), Button['Bmsecsh']("Show", Evaluate('function' = "Show_msec"), background=wheat, enabled=false) ), BoxRow(inset=0, spacing=0, border=true, background=wheat, caption="Step 2b - Simplify the previous expression.", MathMLViewer[secsimpMML]('value'=MathML[Export](m[sec]), 'width'=75, 'height'=33), "=", TextField['msecsimp']('width'=30, 'background'=turquoise), HorizontalGlue(), Button['Bmsecsimpck']("Check", Evaluate('function' = "Check_msecsimp"), background=wheat, enabled=false), TextField['msecsimpck']('width'=6, editable=false, background=white), Button['Bmsecsimpsh']("Show", Evaluate('function' = "Show_msecsimp"), background=wheat, enabled=false) ), BoxRow(inset=0, spacing=0, border=true, background=wheat, caption="Step 3 - Enter the slope of the tangent line.", MathMLViewer[mtanMML]('value'=MathML[Export](m[tan] = Limit(m[sec],h=0)), 'width'=175, 'height'=50), "=", TextField['mtan']('width'=30, 'background'=turquoise), HorizontalGlue(), Button['Bmtanck']("Check", Evaluate('function' = "Check_mtan"), background=wheat, enabled=false), TextField['mtanck']('width'=6, editable=false, background=white), Button['Bmtansh']("Show", Evaluate('function' = "Show_mtan"), background=wheat, enabled=false) ), TextBox['reply']('width'=70, 'height'=2, 'editable'='false', background=white ), BoxColumn('background'="#DDFFFF", 'inset'=0, 'spacing'=0, BoxRow('background'="#DDFFFF", 'inset'=0, 'spacing'=0, Label("Programmers: PBY / DBM", 'font'=helv10), HorizontalGlue(), Label("Copyright 2004-05, D.B. Meade and P.B. Yasskin", 'font'=helv10), HorizontalGlue(), Label("v. 1.1 Sept 2005", 'font'=helv10) ), BoxRow('background'="#DDFFFF", 'inset'=0, 'spacing'=0, Label("Asst Programmer: Ash Maruyama", 'font'=helv10), HorizontalGlue() ) ) ]), ButtonGroup['BG1']() ): Maplets[Display]( Sec2TanAlgebraic );