# Daniel Frazier and John Hill Price # Computing Infinite Limits by Finding Signs of Factors # Math 151 Honors # Fall 2011 # Instructor: Phillip Yasskin restart: with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); randomize(): rand12:=rand(1..2): randx0:=rand(1..5): randwhich:=rand(1..7): sides:=[left,right]: ineqs:=["<",">"]: bigsmalls:=["smaller","bigger"]: NewLimit:=proc() global bigsmall,x0,f,NewNum,NewDen,NearNum,NearDen, Neither; local whichside,side,ineq,PMhalf,b,c,d,which,Newf; whichside:=rand12(); side:=sides[whichside]; ineq:=ineqs[whichside]; bigsmall:=bigsmalls[whichside]; PMhalf:=whichside-3/2; x0:=randx0(); b:=randx0(); c:=randx0(); d:=randx0(); which:=randwhich(); if which=1 then f:=expand((x-b)*(x-c))/expand((x-d)*(x-x0)); elif which=2 then f:=expand((x-b)*(x-c))/expand((x-x0)*(x-x0)); elif which=3 then f:=expand(x*(x-b)*(x-c))/expand((x-d)*(x-x0)); elif which=4 then f:=expand(x*(x-b)*(x-c))/expand((x-x0)*(x-x0)); elif which=5 then f:=expand((x-b)*(x-c))/expand(x*(x-d)*(x-x0)); elif which=6 then f:=expand((x-b)*(x-c))/expand(x*(x-x0)*(x-x0)); elif which=7 then while b=x0 do b:=randx0(); end do; f:=expand((x-b)*(x-x0))/expand((x-x0)*(x-x0)); end if; Newf:=factor(f); NewNum:=numer(Newf); NewDen:=denom(Newf); NearNum:=eval(NewNum,x=x0+PMhalf); NearDen:=eval(NewDen,x=x0+PMhalf); if eval(NewDen,x=x0)=0 then Neither:=false; else Neither:=true; end if; Set(MMLLim=Limit(f,x=x0,side)); Set(Lsigns(caption)=sprintf("Step 2: Determine the sign of the numerator and denominator when x %s %a.", ineq, x0) ); Set(TFNewNum=""); Set(TFNewDen=""); Set(replyNewNumDen="",replyNewNumDen(background)=white); Set(RBNump=false); Set(RBNumm=false); Set(RBDenp=false); Set(RBDenm=false); Set(replyNumDenSign="",replyNumDenSign(background)=white); Set(RBLimp=false); Set(RBLimm=false); Set(RBLimn=false); Set(replyLimSign="",replyLimSign(background)=white); Set(reply="",reply(background)=white); Set(PlotButton(enabled)=false): Set(myplot=plot(f, x=-15..15, -50..50, discont=true, thickness=2, color=blue)); end proc: HintNewNumDen:=proc() Set(reply="Factor the numerator and denominator and cancel like terms.", reply(background)=Orange, reply(foreground)=black): end proc: CheckNewNumDen:=proc() global x0,f,NewNum,NewDen,NearNum,NearDen, Neither; local user_NewNum,user_NewDen; user_NewNum:=Get(TFNewNum::polynom(integer,x), corrections=true, update=true); user_NewDen:=Get(TFNewDen::polynom(integer,x), corrections=true, update=true); if simplify(user_NewNum-NewNum)=0 and simplify(user_NewDen-NewDen)=0 then Set(replyNewNumDen="Correct", replyNewNumDen(background)=green, replyNewNumDen(foreground)=black); Set(reply="", reply(background)=white); elif simplify(user_NewNum-NewNum)=0 then Set(replyNewNumDen="Incorrect", replyNewNumDen(background)=red, replyNewNumDen(foreground)=white); Set(reply="You got the numerator right, but take a look at the denominator again!", reply(background)=red, reply(foreground)=white); elif simplify(user_NewDen-NewDen)=0 then Set(replyNewNumDen="Incorrect", replyNewNumDen(background)=red, replyNewNumDen(foreground)=white); Set(reply="You got the denominator right, but take a look at the numerator again!", reply(background)=red, reply(foreground)=white); else Set(replyNewNumDen="Incorrect", replyNewNumDen(background)=red, replyNewNumDen(foreground)=white); Set(reply="Both are incorrect, but try again!", reply(background)=red, reply(foreground)=white); end if; end proc: ShowNewNumDen:=proc() global x0,f,NewNum,NewDen,NearNum,NearDen, Neither; Set(TFNewNum=NewNum); Set(TFNewDen=NewDen); Set(replyNewNumDen="Shown", replyNewNumDen(background)=yellow, replyNewNumDen(foreground)=black); Set(reply="", reply(background)=white); end proc: HintNumDenSign:=proc() global bigsmall,x0; Set(reply=sprintf("Determine the sign of each factor in the numerator and denominator when x is slightly %s then %a.",bigsmall, x0), reply(background)=Orange, reply(foreground)=black): end proc: CheckNumDenSign:=proc() global x0,f,NewNum,NewDen,NearNum,NearDen, Neither; local userNump,userNumm,userDenp,userDenm; userNump:=Get(RBNump): userNumm:=Get(RBNumm): userDenp:=Get(RBDenp): userDenm:=Get(RBDenm): if NearNum>0 and NearDen>0 then if userNump and userDenp then Set(replyNumDenSign="Correct", replyNumDenSign(background)=green, replyNumDenSign(foreground)=black); Set(reply="", reply(background)=white); else Set(replyNumDenSign="Incorrect", replyNumDenSign(background)=red, replyNumDenSign(foreground)=white); Set(reply="Uh oh! Take another look at those signs!", reply(background)=red, reply(foreground)=white); end if; elif NearNum<0 and NearDen<0 then if userNumm and userDenm then Set(replyNumDenSign="Correct", replyNumDenSign(background)=green, replyNumDenSign(foreground)=black); Set(reply="", reply(background)=white); else Set(replyNumDenSign="Incorrect", replyNumDenSign(background)=red, replyNumDenSign(foreground)=white); Set(reply="Uh oh! Take another look at those signs!", reply(background)=red, reply(foreground)=white); end if; elif NearNum<0 and NearDen>0 then if userNumm and userDenp then Set(replyNumDenSign="Correct", replyNumDenSign(background)=green, replyNumDenSign(foreground)=black); Set(reply="", reply(background)=white); else Set(replyNumDenSign="Incorrect", replyNumDenSign(background)=red, replyNumDenSign(foreground)=white); Set(reply="Uh oh! Take another look at those signs!", reply(background)=red, reply(foreground)=white); end if; else (* NearNum>0 and NearDen<0 *) if userNump and userDenm then Set(replyNumDenSign="Correct", replyNumDenSign(background)=green, replyNumDenSign(foreground)=black); Set(reply="", reply(background)=white); else Set(replyNumDenSign="Incorrect", replyNumDenSign(background)=red, replyNumDenSign(foreground)=white); Set(reply="Uh oh! Take another look at those signs!", reply(background)=red, reply(foreground)=white); end if; end if; end proc: ShowNumDenSign:=proc() global bigsmall,x0,f,NewNum,NewDen,NearNum,NearDen, Neither; if NearNum>0 then Set(RBNump=true): else Set(RBNumm=true): end if; if NearDen>0 then Set(RBDenp=true): else Set(RBDenm=true): end if; Set(replyNumDenSign="Shown", replyNumDenSign(background)=yellow, replyNumDenSign(foreground)=black); Set(reply="", reply(background)=white); end proc: HintLimSign:=proc() Set(reply="Make sure the denominator equals zero at the limit. If so, determine the sign based on the numerator and denominator.", reply(background)=Orange, reply(foreground)=black): end proc: CheckLimSign:=proc() global x0,f,NewNum,NewDen,NearNum,NearDen, Neither; local userLimp,userLimm,userLimn; userLimp:=Get(RBLimp): userLimm:=Get(RBLimm): userLimn:=Get(RBLimn): if Neither then if userLimn then Set(replyLimSign="Correct", replyLimSign(background)=green, replyLimSign(foreground)=black); Set(reply="Way to go! Verify your answer in the plot.", reply(background)=green, reply(foreground)=black); Set(PlotButton(enabled)=true); else Set(replyLimSign="Incorrect", replyLimSign(background)=red, replyLimSign(foreground)=white); Set(reply="Uh oh! Make sure the denominator equals zero and take a look at the signs!", reply(background)=red, reply(foreground)=white); end if; elif NearNum>0 and NearDen>0 or NearNum<0 and NearDen<0 then if userLimp then Set(replyLimSign="Correct", replyLimSign(background)=green, replyLimSign(foreground)=black); Set(reply="Great job! Verify your answer in the plot.", reply(background)=green, reply(foreground)=black); Set(PlotButton(enabled)=true); else Set(replyLimSign="Incorrect", replyLimSign(background)=red, replyLimSign(foreground)=white); Set(reply="Uh oh! Make sure the denominator equals zero and take a look at the signs!", reply(background)=red, reply(foreground)=white); end if; else if userLimm then Set(replyLimSign="Correct", replyLimSign(background)=green, replyLimSign(foreground)=black); Set(reply="Congratulations! Verify your answer in the plot.", reply(background)=green, reply(foreground)=black); Set(PlotButton(enabled)=true); else Set(replyLimSign="Incorrect", replyLimSign(background)=red, replyLimSign(foreground)=white); Set(reply="Uh oh! Make sure the denominator equals zero and take a look at the signs!", reply(background)=red, reply(foreground)=white); end if; end if; end proc: ShowLimSign:=proc() global x0,f,NewNum,NewDen,NearNum,NearDen, Neither; if Neither then Set(RBLimn=true): elif NearNum>0 and NearDen>0 or NearNum<0 and NearDen<0 then Set(RBLimp=true): else Set(RBLimm=true): end if: Set(replyLimSign="Shown", replyLimSign(background)=yellow, replyLimSign(foreground)=black); Set(reply="", reply(background)=white); Set(PlotButton(enabled)=true); end proc: InfiniteLimits:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN](title="Computing Infinite Limits by Finding Signs of Factors", [ [ halign=none, Button("New Limit", Evaluate(function="NewLimit"), background=magenta), HorizontalGlue(), Button("Quit", Shutdown(), background=pink) ], [ border=true, caption="Goal: Determine if the limit is + infinity or - infinity.", MathMLViewer[MMLLim](value=Limit('f'(x),x='a',left), width=300,height=60) ], [ border=true, halign=none, caption="Step 1: Factor the numerator and denominator and cancel common factors:", [ halign=none, valign=none, [ halign=none, inset=0, "New Numerator: ", TextField[TFNewNum](width=20, background=turquoise) ], [ halign=none, inset=0, "New Denominator:", TextField[TFNewDen](width=20, background=turquoise) ] ], HorizontalGlue(), Button("Hint", Evaluate(function="HintNewNumDen"), background="Orange"), Button("Check", Evaluate(function="CheckNewNumDen"), background=green), TextField[replyNewNumDen](width=6, editable=false, background=white), Button("Show", Evaluate(function="ShowNewNumDen"), background=yellow) ], BoxColumn( border=true, halign=none, [ halign=none, inset=0, Label[Lsigns]("Step 2: Determine the sign of the numerator and denominator when x < a."), HorizontalGlue() ], [ halign=none, inset=0, "Numerator", RadioButton[RBNump]("+",group=BGNum), RadioButton[RBNumm]("-",group=BGNum), HorizontalGlue(), "Denominator", RadioButton[RBDenp]("+",group=BGDen), RadioButton[RBDenm]("-",group=BGDen), HorizontalGlue(), Button("Hint", Evaluate(function="HintNumDenSign"), background="Orange"), Button("Check", Evaluate(function="CheckNumDenSign"), background=green), TextField[replyNumDenSign](width=6, editable=false, background=white), Button("Show", Evaluate(function="ShowNumDenSign"), background=yellow) ] ), [ border=true, halign=none, caption="Step 3: Evaluate the limit", RadioButton[RBLimp]("+ Infinity",group=BGLim), RadioButton[RBLimm]("- Infinity",group=BGLim), RadioButton[RBLimn]("Neither",group=BGLim), HorizontalGlue(), Button("Hint", Evaluate(function="HintLimSign"), background="Orange"), Button("Check", Evaluate(function="CheckLimSign"), background=green), TextField[replyLimSign](width=6, editable=false, background=white), Button("Show", Evaluate(function="ShowLimSign"), background=yellow) ], [ TextBox[reply](width=60, height=2, editable=false, background=white), Button[PlotButton]("Plot", enabled=false, RunWindow(PLOT), background=tan) ], [ inset=0, spacing=0, "Instructor: Philip Yasskin", "Programmers: Daniel Frazier and John Hill Price", "Copyright: Yasskin 2011" ] ] ), Window[PLOT](title="Plot of f(x)", [ Plotter[myplot](width=300, height=300), Button("Close", CloseWindow(PLOT), background="pink") ] ), ButtonGroup[BGNum](), ButtonGroup[BGDen](), ButtonGroup[BGLim]() ): Maplets[Display]( InfiniteLimits );