# Rebecca Jones & Timothy Hopper # Limits of Sums # Math 152 Honors Section 202 # Spring 2012 restart; with(Maplets[Tools]): with(Maplets[Elements]): StartEngine(); randomize(): coefficient:=rand(0..10): New_Function:=proc() global fn, coefficient1,coefficient2,coefficient3,coefficient4, AnswerStep2,AnswerStep3,AnswerStep1a,AnswerStep1b,AnswerStep1c, AnswerStep1d; coefficient1:=coefficient(): coefficient2:=coefficient(): coefficient3:=coefficient(): coefficient4:=coefficient(): fn:=coefficient1*i^3/n^4 + coefficient2*i^2/n^3 + coefficient3*i/n^2 + coefficient4/n: Set(MathMLProblem(value)=(L = Limit(Sum(fn, i=1..n),n=infinity))): AnswerStep1a:=coefficient1*(n^2)*((n+1)^2)/4: AnswerStep1b:=coefficient2*n*(n+1)*(2*n+1)/6: AnswerStep1c:=coefficient3*n*(n+1)/2: AnswerStep1d:=coefficient4*n: AnswerStep2:=factor(AnswerStep1a/(n^4)+AnswerStep1b/(n^3)+AnswerStep1c/n^2+AnswerStep1d/n): AnswerStep2:=expand(numer(AnswerStep2))/denom(AnswerStep2); AnswerStep3:=limit(AnswerStep2,n=infinity): Set(reply1="", reply1(background)=white): Set(reply2="", reply2(background)=white): Set(reply3="", reply3(background)=white): Set(reply="", reply(background)=white): Set(ncube=""): Set(nsqr=""): Set(n=""): Set(one=""): Set(answ2=""): Set(finalim=""): end proc: CheckStep_1:=proc() local userinput1,userinput2,userinput3,userinput4; userinput1:=parse(Get(ncube)): userinput2:=parse(Get(nsqr)): userinput3:=parse(Get(n)): userinput4:=parse(Get(one)): if (userinput1-AnswerStep1a=0 and userinput2-AnswerStep1b=0 and userinput3-AnswerStep1c=0 and userinput4-AnswerStep1d=0) then Set(reply="Correct! Good Job!", reply(background)=green, reply(foreground)=black): Set(reply1="Correct", reply1(background)=green, reply1(foreground)=black): else Set(reply="Nope! Sorry, that is incorrect!", reply(background)=red, reply(foreground)=white): Set(reply1="Incorrect", reply1(background)=red, reply1(foreground)=white): end if: end proc: Show_1:=proc() Set(ncube=AnswerStep1a): Set(nsqr=AnswerStep1b): Set(n=AnswerStep1c): Set(one=AnswerStep1d): Set(reply="Step 1 shown", reply(background)=yellow, reply(foreground)=black): Set(reply1="Shown", reply1(background)=yellow, reply1(foreground)=black): end proc: CheckStep_2:=proc() global userinput; userinput:=parse(Get(answ2)): if userinput-AnswerStep2=0 then Set(reply="Correct! Good Job!", reply(background)=green, reply(foreground)=black): Set(reply2="Correct", reply2(background)=green, reply2(foreground)=black): else Set(reply="Nope! Sorry, that is incorrect!", reply(background)=red, reply(foreground)=white): Set(reply2="Incorrect", reply2(background)=red, reply2(foreground)=white): end if: end proc: Show_2:=proc() Set(answ2=AnswerStep2): Set(reply="Step 2 shown"): Set(reply(background)=yellow): Set(reply(foreground)=black): Set(reply2="Shown"): Set(reply2(background)=yellow): Set(reply2(foreground)=black): end proc: CheckStep_3:=proc() global userinput; userinput:=parse(Get(finalim)): if userinput-AnswerStep3=0 then Set(reply="Correct! Good Job!", reply(background)=green, reply(foreground)=black): Set(reply3="Correct", reply3(background)=green, reply3(foreground)=black): else Set(reply="Nope! Sorry, that is incorrect!", reply(background)=red, reply(foreground)=white): Set(reply3="Incorrect", reply3(background)=red, reply3(foreground)=white): end if: end proc: Show_3:=proc() Set(finalim=AnswerStep3): Set(reply="Step 3 shown"): Set(reply(background)=yellow): Set(reply(foreground)=black): Set(reply3="Shown"): Set(reply3(background)=yellow): Set(reply3(foreground)=black): end proc: limitsum:=Maplet(onstartup=RunWindow(MAIN), Window[MAIN](title="Limits of Sums", [ [ halign=none, Button("New Sum",Evaluate(function="New_Function"),background=magenta), HorizontalGlue(), [ border=true, caption="Compute L:", MathMLViewer[MathMLProblem](value=(L = Limit(f(n),n=infinity)) , width=400, height=60, fontsize=10) ], HorizontalGlue(), Button("Quit",Shutdown(),background=pink) ], BoxColumn( border=true, caption="Step 1: Replace the sums of the i^k's:", [ halign=none, MathMLViewer[MathMLCoef1](value=(L = Limit(1/n^4,n=infinity)), width=100, height=60, fontsize=10), TextField[ncube](width=15,background=cyan), " + ", MathMLViewer[MathMLCoef2](value=(1/n^3), width=45, height=60, fontsize=10), TextField[nsqr](width=15,background=cyan), " + ", MathMLViewer[MathMLCoef3](value=(1/n^2), width=45, height=60, fontsize=10), TextField[n](width=9,background=cyan), " + ", MathMLViewer[MathMLCoef4](value=(1/n), width=40, height=60, fontsize=10), TextField[one](width=4,background=cyan) ], [ halign=none, " ", HorizontalGlue(), Button("Hint", RunWindow(HINT),background=Orange), Button("Check", Evaluate(function="CheckStep_1"),background=green), TextField[reply1](width=6,background=white), Button("Show", Evaluate(function="Show_1"),background=yellow) ] ), [ halign=none, border=true, caption="Step 2: Put the terms over a common denominator and simplify:", MathMLViewer[MathMLStep2](value=(L = Limit("",n=infinity)) , width=15, height=40, fontsize=10), TextField[answ2](width=40,background=cyan), HorizontalGlue(), Button("Hint", RunWindow(HINT2),background=Orange), Button("Check", Evaluate(function="CheckStep_2"),background=green), TextField[reply2](width=6,background=white), Button("Show", Evaluate(function="Show_2"),background=yellow) ], [ halign=none, border=true, "L =", caption="Step 3: Compute the limit:", TextField[finalim](width=30,background=cyan), HorizontalGlue(), Button("Hint", RunWindow(HINT3),background=Orange), Button("Check", Evaluate(function="CheckStep_3"),background=green), TextField[reply3](width=6,background=white), Button("Show", Evaluate(function="Show_3"),background=yellow) ], [ TextField[reply](width=50, background=white) ], [ halign=none, "Instructor: Philip Yasskin", HorizontalGlue(), "Programmers: Rebecca Jones & Timothy Hopper", HorizontalGlue(), "Copyright 2012, P. Yasskin" ] ] ), Window[HINT](title="Formulas", [ [ Button("Close", CloseWindow(HINT), background=pink) ], [ "Sum 1 = n" ], [ "Sum i = n(n+1)/2" ], [ "Sum i^2 = n(n+1)(2n+1)/6" ], [ "Sum i^3 = (n^2(n+1)^2)/4" ], [ "Sum i^4 = (n(2n+1)(n+1)(3n^2+3n-1))/30" ] ] ), Window[HINT2](title="Hint", [ [ Button("Close", CloseWindow(HINT2), background=pink) ], [ "After putting the terms over a common denominator," ], [ "expand the numerator, combine terms and cancel." ] ] ), Window[HINT3](title="Hint", [ [ Button("Close", CloseWindow(HINT3), background=pink) ], [ "To find the limit, remember as n goes to infinity 1/n goes to zero." ] ] ) ): Maplets[Display](limitsum);