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 := [ "Try the hint.", "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 to do it yourself.", " Read the note and enter an answer yourself.", " Use the calculator and compute an answer yourself.", " So that was practice. Work it out yourself." ]: randshow := rand(1..nops(showit)):rand14 := rand(1..4): rand24 := rand(2..4): rand19:=rand(1..9): rand12:=rand(1..2): rand220:=rand(2..20): rand2179:=rand(21..79): rand8098:=rand(80..98): rand2060:=rand(20..60): rand7090:=rand(70..90): round1d:=x->.1*(round(10*x)): round2d:=x->.01*(round(100*x)): round5d:=x->.00001*(round(100000*x)): New_Graph := proc() local deg, dif, p, q, d, M, new_bs, new_msecs; global rand24, rand19, rand12, rand220, rand2179, rand8098, rand2060, rand7090, pta, x, f, df, fa, dfa, mtan, ftan, plot1, nbs; options `Copyright 2002-04, Philip B. Yasskin, Texas A&M Univ.`; deg := rand12(); pta := rand14(); dif:=0; nbs:=1; f := (-1)^(rand12()) * (rand12()*x^2+(-1)^(rand12()) *rand24()*x+(-1)^(rand12()) *rand24()); df := diff(f,x); p:=fsolve(f=0,x); q:=fsolve(df=0,x); d:=sort([-2, pta, p, q, 102]); dif:= min(seq(d[i+1]-d[i], i=1..nops(d)-1)); M:=max(op(map(r->abs(eval(f,x=r)),[q]))); f := f; fa := eval(f,x=pta); df := diff(f,x); dfa:=eval(df,x=pta); mtan := dfa; ftan := fa+dfa*(x-pta); plot1 := plot([f,ftan], x=0..5, y=-40..40, title="Graph of y = f(x) and\nthe tangent line at x = a.", color=[black,green]); Set('PL0' = plot1): Set('TBpta' = pta): Set('TBfa' = fa): Set('Slideb' = pta): Set('TBptb' = " "): Set('TBfb' = " "): Set('TBmsec' = " ", 'TBmsec'(enabled)=false, 'TBmsec'(background)=wheat): Set('msecck'=" ", 'msecck'(background)=white, 'msecck'(foreground) = black): Set('Bmsecck'(enabled)=false, 'Bmsecck'(background)=wheat); Set('Bmsecsh'(enabled)=false, 'Bmsecsh'(background)=wheat); Set('TBmtan' = " ", 'TBmtan'(enabled)=false, 'TBmtan'(background)=wheat): Set('mtanck'=" ", 'mtanck'(background)=white, 'mtanck'(foreground) = black): Set('Bmtanck'(enabled)=false, 'Bmtanck'(background)=wheat); Set('Bmtansh'(enabled)=false, 'Bmtansh'(background)=wheat); Set('reply' = " ", 'reply'(background)=white, 'reply'(foreground) = black): Set('CalcIn' = " "): Set('CalcOut' = " "): new_bs := ["b", "______", convert(pta,string)]; new_msecs := ["msec", "______", "xxx"]; Set('LBbs'(itemlist)=new_bs): Set('LBmsecs'(itemlist)=new_msecs): Set('Bsort'(enabled)=false, 'Bsort'(background)=wheat); end proc: Set_b := proc() local deg, dif, p, q, d, M; global pta, ptb, fa, fb, msec, fsec, plot2; options `Copyright 2002-04, Philip B. Yasskin, Texas A&M Univ.`; ptb := Get('Slideb'::realcons, corrections=true, update=true): Set('TBmsec' = " ", 'TBmsec'(enabled)=true, 'TBmsec'(background)=turquoise): Set('msecck'=" ", 'msecck'(background)=white, 'msecck'(foreground) = black): Set('Bmsecck'(enabled)=true, 'Bmsecck'(background)=turquoise); Set('Bmsecsh'(enabled)=true, 'Bmsecsh'(background)=turquoise); Set('TBmtan' = " "): Set('mtanck'=" ", 'mtanck'(background)=white, 'mtanck'(foreground) = black): if ptb=pta then Set('TBptb' = pta): Set('TBfb' = fa): Set('PL0' = plot1): Set('reply' = "If b=a, then there is only one point and there is no secant line. \nFurther, msec is undefined because you would be dividing by zero.", 'reply'(background) = lightorange, 'reply'(foreground) = black): else fb := eval(f,x=ptb); Set('TBptb' = ptb): Set('TBfb' = fb): msec := evalf((fb-fa)/(ptb-pta)); fsec := fa+msec*(x-pta); plot2 := plot([f,ftan,fsec], x=0..5, y=-40..40, title="Graph of y = f(x), the tangent line at x = a\nand the secant line between x = a and x = b.", color=[black,green,blue]); Set('PL0' = plot2): Set('reply' = " ", 'reply'(background)=white, 'reply'(foreground) = black): end if; end proc: Set_b2 := proc() local deg, dif, p, q, d, M; global pta, ptb, fa, fb, msec, fsec, plot2; options `Copyright 2004, Philip B. Yasskin, Texas A&M Univ.`; ptb := Get('TBptb'::realcons, corrections=true, update=true): Set('Slideb' = round(ptb)): Set('TBmsec' = " ", 'TBmsec'(enabled)=true, 'TBmsec'(background)=turquoise): Set('msecck'=" ", 'msecck'(background)=white, 'msecck'(foreground) = black): Set('Bmsecck'(enabled)=true, 'Bmsecck'(background)=turquoise); Set('Bmsecsh'(enabled)=true, 'Bmsecsh'(background)=turquoise); Set('TBmtan' = " "): Set('mtanck'=" ", 'mtanck'(background)=white, 'mtanck'(foreground) = black): if ptb=pta then Set('TBptb' = pta): Set('TBfb' = fa): Set('PL0' = plot1): Set('reply' = "If b=a, then there is only one point and there is no secant line. \nFurther, msec is undefined because you would be dividing by zero.", 'reply'(background) = lightorange, 'reply'(foreground) = black): else fb := eval(f,x=ptb); Set('TBptb' = ptb): Set('TBfb' = fb): msec := evalf((fb-fa)/(ptb-pta)); fsec := fa+msec*(x-pta); plot2 := plot([f,ftan,fsec], x=0..5, y=-50..50, title="Graph of y = f(x), the tangent line at x = a\nand the secant line between x = a and x = b.", color=[black,green,blue]); Set('PL0' = plot2): Set('reply' = " ", 'reply'(background)=white, 'reply'(foreground) = black): end if; end proc: Check_msec := proc() local user_msec, old_bs, old_msecs, new_bs, new_msecs; global pta, ptb, msec, round5d, nbs; options `Copyright 2004, Philip B. Yasskin, Texas A&M Univ.`; user_msec := Get('TBmsec'::anything, corrections=true, update=true): if pta<>ptb then if type(user_msec, realcons) then if simplify(normal(abs(msec - user_msec)))<=0.01 then Set('msecck' = " correct ", 'msecck'(background)=green, 'msecck'(foreground) = black): Set('reply' = "Try values of b closer to a until you can determine mtan.", 'reply'(background)=green, 'reply'(foreground) = black): old_bs := Get('LBbs'(itemlist)): old_msecs := Get('LBmsecs'(itemlist)): new_bs := ["b", "______", op(old_bs[3..nbs+2]), convert(ptb,string)]; new_msecs := ["msec", "______", op(old_msecs[3..nbs+2]), convert(round5d(msec),string)]; Set('LBbs'(itemlist)=new_bs): Set('LBmsecs'(itemlist)=new_msecs): nbs:=nbs+1; Set('TBmtan' = " ", 'TBmtan'(enabled)=true, 'TBmtan'(background)=turquoise): Set('Bmtanck'(enabled)=true, 'Bmtanck'(background)=turquoise); Set('Bmtansh'(enabled)=true, 'Bmtansh'(background)=turquoise); Set('Bsort'(enabled)=true, 'Bsort'(background)=turquoise); else Set('msecck' = "incorrect", 'msecck'(background)=red, 'msecck'(foreground) = white): Set(reply = "Read the note and use the calculator to compute msec.", 'reply'(background)=red, 'reply'(foreground) = white): end if; else Set('msecck' = "incorrect", 'msecck'(background)=red, 'msecck'(foreground) = white): Set('reply' = "ERROR: msec must be entered as a real number.", 'reply'(background)=red, 'reply'(foreground) = white): end if; else if user_msec in {undefined,"undefined"} then Set('msecck' = " correct ", 'msecck'(background)=green, 'msecck'(foreground) = black): else Set('msecck' = "incorrect", 'msecck'(background)=red, 'msecck'(foreground) = white): end if; Set('reply' = "Since b=a, msec is undefined because you would be dividing by zero.\nFurther, there is only one point and there is no secant line.", 'reply'(background)=lightorange, 'reply'(foreground) = black): end if; end proc: Show_msec := proc() global msec, round5d, showit, randshow; options `Copyright 2004, Philip B. Yasskin, Texas A&M Univ.`; Set('msecck'=" ", 'msecck'(background)=white, 'msecck'(foreground) = black): if pta<>ptb then Set('TBmsec' = round5d(msec)): Set('reply' = showit[randshow()], 'reply'(background)=lightorange, 'reply'(foreground) = black): else Set('TBmsec' = 'undefined'): Set('reply' = "Since b=a, msec is undefined because you would be dividing by zero.\nFurther, there is only one point and there is no secant line.", 'reply'(background)=lightorange, 'reply'(foreground) = black): end if; end proc: Sort_bs := proc() local old_bs, new_bs, old_msecs, new_msecs, old_pairs, new_pairs; global nbs; options `Copyright 2004, Philip B. Yasskin, Texas A&M Univ.`; old_bs := Get('LBbs'(itemlist))[3..nbs+2]: old_msecs := Get('LBmsecs'(itemlist))[3..nbs+2]: old_pairs := {seq([old_bs[i],old_msecs[i]],i=1..nbs)}; nbs := nops(old_pairs); new_pairs := sort([op(old_pairs)], (p,q)->evalb(p[1]