# Brandon Grey & Zachary Stone # Limits at Infinity # Math 151 Honors # Fall 2011 # Instructor: Philip Yasskin restart; with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); TypeTools[AddType]( laurentpolynom, proc( expr, n::posint, var::name) type( expand(var^n*expr), polynom(rational,var) ) end proc ): NewProblem:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local Num, Den, Fn; Num:=sort(randpoly(x,degree=3,terms=3)); Den:=sort(randpoly(x,degree=3,terms=3)); CurrNum:=Num; CurrDen:=Den; Fn:=Num/Den; Term:=x^degree(Den); Num1:=Num&*Term^(-1); Den1:=Den&*Term^(-1); Num2 :=expand(Num/Term); Den2:=expand(Den/Term); LimLeft:=limit(Fn,x=-infinity); LimRight:=limit(Fn,x=infinity); LeftCorrect:=false; RightCorrect:=false; Set(MMLLimLeft1=Limit(Fn,x=-infinity)); Set(MMLLimRight1=Limit(Fn,x=infinity)); Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyTerm="", replyTerm(background)=white); Set(replyBox="", replyBox(background)=white); Set(replyNum="", replyNum(background)=white); Set(replyDen="", replyDen(background)=white); Set(replyLimLeft="", replyLimLeft(background)=white); Set(replyLimRight="", replyLimRight(background)=white); Set(TFTerm=""); Set(TFNum=""); Set(TFDen=""); Set(TFLimLeft=""); Set(TFLimRight=""); Set(Plotbutton(enabled)=false): Set(myplot=plot([Fn, LimLeft, LimRight], x=-15..15, -50..50, discont=true, thickness=[3, 1, 1], color=[red, blue, blue], linestyle=[solid, dash, dash])); end proc: HintTerm:=proc() Set(replyBox="Look for the highest power of x in the denominator.", replyBox(background)="Orange", replyBox(foreground)=black): Set(replyTerm="", replyTerm(background)=white); end proc: CheckTerm:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Term; user_Term:=Get(TFTerm::polynom, corrections=true, update=true); if user_Term=Term then Set(replyTerm="Correct", replyTerm(background)=green, replyTerm(foreground)=black); CurrNum:=Num1; CurrDen:=Den1; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyBox="Yayayayayayayayayayayayayayayayayayayayayayayaya!! Go onto the next one.", replyBox(background)="green", replyBox(foreground)=black): else Set(replyTerm="Incorrect", replyTerm(background)=red, replyTerm(foreground)=white); Set(replyBox="Geeeet Outta Heere!!", replyBox(background)="red", replyBox(foreground)=white): end if; end proc: ShowTerm:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; Set(TFTerm=Term); CurrNum:=Num1; CurrDen:=Den1; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyTerm="Shown", replyTerm(background)=yellow, replyTerm(foreground)=black); Set(replyBox="", replyBox(background)=white); end proc: PrevNum:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Num2; user_Num2:=Get(TFNum::laurentpolynom(99,x), corrections=true, update=true); CurrNum:=user_Num2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); end proc: HintNum:=proc() Set(replyBox="Divide the numerator by the highest power in the denominator. When dividing powers subtract exponents.", replyBox(background)="Orange", replyBox(foreground)=black): Set(replyNum="", replyNum(background)=white); end proc: CheckNum :=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Num2; user_Num2:=Get(TFNum::laurentpolynom(99,x), corrections=true, update=true); if simplify(user_Num2-Num2)=0 then Set(replyNum="Correct", replyNum(background)=green, replyNum(foreground)=black); CurrNum:=Num2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyBox="Waaaaaahhhhhh!! Go onto the next one.", replyBox(background)=green, replyBox(foreground)=black): else Set(replyNum="Incorrect", replyNum(background)=red, replyNum(foreground)=white); Set(replyBox="Geeeet Outta Heere?", replyBox(background)=red, replyBox(foreground)=white): end if; end proc: ShowNum:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; Set(TFNum=Num2 ); CurrNum:=Num2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyNum="Shown", replyNum(background)=yellow, replyNum(foreground)=black); Set(replyBox="",replyBox(background)=white); end proc: PrevDen:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Den2; user_Den2:=Get(TFDen::laurentpolynom(99,x), corrections=true, update=true); CurrDen:=user_Den2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); end proc: HintDen:=proc() Set(replyBox="Divide the denominator by the its highest power of x. When dividing powers subtract exponents.", replyBox(background)="Orange", replyBox(foreground)=black): end proc: CheckDen:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Den2; user_Den2:=Get(TFDen::laurentpolynom(99,x), corrections=true, update=true); if simplify(user_Den2-Den2)=0 then CurrDen:=Den2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyDen="Correct", replyDen(background)=green, replyDen(foreground)=black); Set(replyBox="Yayayayayayayayayayayayayayayayayayayayayayayayayaya!! Go onto the next one.", replyBox(background)=green, replyBox(foreground)=black): else Set(replyDen="Incorrect", replyDen(background)=red, replyDen(foreground)=white); Set(replyBox="Geeeet Outta Heere!", replyBox(background)=red, replyBox(foreground)=white): end if; end proc: ShowDen:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; Set(TFDen=Den2 ); CurrDen:=Den2; Set(MMLLimLeft2=Limit(CurrNum/CurrDen,x=-infinity)); Set(MMLLimRight2=Limit(CurrNum/CurrDen,x=infinity)); Set(replyDen="Shown", replyDen(background)=yellow, replyDen(foreground)=black); Set(replyBox="",replyBox(background)=white); end proc: HintLim:=proc() Set(replyBox="Cancel out the x variables and substitute in infinity for x. A constant divided by infinity is 0.", replyBox(background)="Orange", replyBox(foreground)=black): Set(replyLimLeft="", replyLimLeft(background)=white); Set(replyLimRight="", replyLimRight(background)=white); end proc: CheckLL:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; local user_Term; user_Term:=Get(TFLimLeft::polynom, corrections=true, update=true); if user_Term=LimLeft then Set(replyLimLeft="Correct", replyLimLeft(background)=green, replyLimLeft(foreground)=black); Set(replyBox="Waaaaaahhhhh!! Go onto the next one.", replyBox(background)="green", replyBox(foreground)=black): LeftCorrect:=true; if RightCorrect=true then Set(Plotbutton(enabled)=true); end if; else Set(replyLimLeft="Incorrect", replyLimLeft(background)=red, replyLimLeft(foreground)=white); Set(replyBox="Geeeet Outta Heere!!!", replyBox(background)="red", replyBox(foreground)=white); end if; end proc: ShowLL:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; Set(TFLimLeft=LimLeft); Set(replyLimLeft="Shown", replyLimLeft(background)=yellow, replyLimLeft(foreground)=black); Set(replyBox="",replyBox(background)=white); LeftCorrect:=true; if RightCorrect=true then Set(Plotbutton(enabled)=true); end if: end proc: CheckLR:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight,LeftCorrect, RightCorrect; local user_Term; user_Term:=Get(TFLimRight::polynom, corrections=true, update=true); if user_Term=LimRight then Set(replyLimRight="Correct", replyLimRight(background)=green, replyLimRight(foreground)=black); Set(replyBox="Yayayayayayayayayayayayayayayayayayayayayaya!! Click the Plot button to see the function's graph.", replyBox(background)="green", replyBox(foreground)=black): RightCorrect:=true: if LeftCorrect=true then Set(Plotbutton(enabled)=true): end if: else Set(replyLimRight="Incorrect", replyLimRight(background)=red, replyLimRight(foreground)=white); Set(replyBox="Geeeet Outta Heere!!!!", replyBox(background)="red", replyBox(foreground)=white); end if; end proc: ShowLR:=proc() global Term, CurrNum, CurrDen, Num1 , Den1, Num2 , Den2, LimLeft, LimRight, LeftCorrect, RightCorrect; Set(replyLimRight="Shown", replyLimRight(background)=yellow, replyLimRight(foreground)=black); Set(TFLimRight=LimRight); Set(replyBox="", replyBox(background)=white); Set(replyBox="", replyBox(background)=white); RightCorrect:=true: if LeftCorrect=true then Set(Plotbutton(enabled)=true): end if: end proc: LimitInf:=Maplet(onstartup=RunWindow(MAIN), Window[MAIN](title="Limits at Infinity", [ [ halign=none, Button("New Limits", Evaluate(function="NewProblem"), background=magenta), HorizontalGlue(), "GOAL: Compute", MathMLViewer[MMLLimLeft1](width=200, height=60), "and", MathMLViewer[MMLLimRight1](width=200, height=60), HorizontalGlue(), Button[Quit]("Quit", onclick=Shutdown(), background=pink) ], [ border=true, halign=none, caption="Step 1: Identify the largest term in the denominator (simplified):", "What is the highest power of x?", TextField[TFTerm](width=10, background=turquoise), HorizontalGlue(), Button("Hint", Evaluate(function="HintTerm"), background="Orange"), Button("Check", Evaluate(function="CheckTerm"), background=green), TextField[replyTerm](width=5, editable=false, background=white), Button("Show", Evaluate(function="ShowTerm"), background=yellow) ], BoxColumn( border=true, halign=none, caption="Step 2: Divide the numerator and denominator by the term:", [ halign=none, "New Numerator: ", TextField[TFNum](width=15,background=turquoise), HorizontalGlue(), Button("Preview", Evaluate(function="PrevNum"),background=turquoise), Button("Hint", Evaluate(function="HintNum"),background="Orange"), Button("Check", Evaluate(function="CheckNum"),background=green), TextField[replyNum](width=5, editable=false,background=white), Button("Show", Evaluate(function="ShowNum"),background=yellow) ], [ halign=none, "New Denominator:", TextField[TFDen](width=15,background=turquoise), HorizontalGlue(), Button("Preview", Evaluate(function="PrevDen"),background=turquoise), Button("Hint", Evaluate(function="HintDen"),background="Orange"), Button("Check", Evaluate(function="CheckDen"),background=green), TextField[replyDen](width=5, editable=false,background=white), Button("Show", Evaluate(function="ShowDen"),background=yellow) ] ), [ border=true, halign=none, caption="Step 3: Compute the limits using the new numerator and denominator:", [ valign=none, inset=0, spacing=0, [ halign=none, MathMLViewer[MMLLimLeft2](width=300, height=100), "=", TextField[TFLimLeft](width=10, background=turquoise), HorizontalGlue() ], [ halign=none, HorizontalGlue(), Button("Hint", Evaluate(function="HintLim"),background="Orange"), Button("Check", Evaluate(function="CheckLL"),background=green), TextField[replyLimLeft](width=5, editable=false,background=white), Button("Show", Evaluate(function="ShowLL"),background=yellow), HorizontalGlue() ] ], [ valign=none, inset=0, spacing=0, [ halign=none, MathMLViewer[MMLLimRight2](width=300, height=100), "=", TextField[TFLimRight](width=10, background=turquoise), HorizontalGlue() ], [ halign=none, HorizontalGlue(), Button("Hint", Evaluate(function="HintLim"),background="Orange"), Button("Check", Evaluate(function="CheckLR"),background=green), TextField[replyLimRight](width=5, editable=false,background=white), Button("Show", Evaluate(function="ShowLR"),background=yellow), HorizontalGlue(), Button[Plotbutton]("Plot", enabled=false, Evaluate(), onclick=RunWindow(PLOT), background=tan) ] ] ], TextBox[replyBox](width=40, height=2, background=white), [ inset=0, spacing=0, "Instructor: Philip Yasskin", "Programmers: Brandon Grey & Zachary Stone", "Copyright: Yasskin 2011" ] ] ), Window[PLOT](title="Plot of f(x)", [ [ background=tan, Plotter[myplot](width=300, height=300) ], Button("Close", CloseWindow(PLOT), background=pink) ] ) ): Maplets[Display]( LimitInf );