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 integral.", "Try another integral.", "Compute another integral." ]: 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 doing it yourself.", " Think about it and enter an answer yourself.", " Next time, compute an answer yourself.", " So that was practice. Try doing it yourself." ]: randshow := rand(1..nops(showit)): vars:= [x, t, theta, phi]: dvars:=[dx, dt, dtheta, dphi]: randvar:= rand(1..nops(vars)): rand02:=rand(0..2): randcase:=rand(1..4): As:=[0,Pi/6,Pi/4,Pi/3,Pi/2,2*Pi/3,3*Pi/4,5*Pi/6]: Bs:=[Pi/6,Pi/4,Pi/3,Pi/2,2*Pi/3,3*Pi/4,5*Pi/6,Pi]: randAs:=rand(1..nops(As)): randBs:=rand(1..nops(Bs)): ChLim:=false: LimsOK:=false: IndefOK:=false: #case 1 sin^m=2p+1 odd, cos^n=2q even integrandx[1]:=sin(var)^m*cos(var)^n; usub[1]:=cos(var); dusub[1]:=-sin(var); integrandu[1]:=-(1-u^2)^p*u^n; #case 2 sin^m=2p even, cos^n=2q+1 odd integrandx[2]:=sin(var)^m*cos(var)^n; usub[2]:=sin(var); dusub[2]:=cos(var); integrandu[2]:=u^m*(1-u^2)^q; #case 3 sec^m=2p+1 odd tan^n=2q+1 odd integrandx[3]:=sec(var)^m*tan(var)^n; usub[3]:=sec(var); dusub[3]:=sec(var)*tan(var); integrandu[3]:=u^(m-1)*(u^2-1)^q; #case 4 sec^m=2p+2 even tan^n=2q even integrandx[4]:=sec(var)^m*tan(var)^n; usub[4]:=tan(var); dusub[4]:=sec(var)^2; integrandu[4]:=(1+u^2)^p*u^n; Show_Integral:= proc(DefParam) global vars, dvars, randvar, var, dvar, rand02, randAs, randBs, p, q, m, n, integrandx, integrandu, usub, dusub, A, B, uA, uB, IntegDefx, IntegDefu, IntegDefux, Integx, Integu, IntegValx, IntegValu, IntegDefVal, case, LimsOK, IndefOK, Def; local vari, usubi, outeri, OK; options `Copyright 2006, Philip B. Yasskin, Texas A&M Univ.`; vari:=randvar(); var:= vars[vari]; dvar:= dvars[vari]; case:=randcase(); p:=rand02(); q:=rand02(); if case=1 then #sin^m=2p+1 odd, cos^n=2q even m:=2*p+1; n:=2*q; elif case=2 then #sin^m=2p even, cos^n=2q+1 odd m:=2*p; n:=2*q+1; elif case=3 then #case 3 sec^m=2p+1 odd tan^n=2q+1 odd m:=2*p+1; n:=2*q+1; elif case=4 then #sec^m=2p+2 even tan^n=2q even m:=2*p+2; n:=2*q; end if; Integx := Int( integrandx[case], var); Integu := Int( integrandu[case], u); IntegValu := value(Integu) + C; IntegValx := eval(IntegValu,u=usub[case]); Def:=DefParam; LimsOK:=false: IndefOK:=false: if Def then A:=As[randAs()]; B:=Bs[randBs()]; while evalf(B)<=evalf(A) do B:=Bs[randBs()]; end do; while (case=3 or case=4) and (A=Pi/2 or B=Pi/2) do A:=As[randAs()]; B:=Bs[randBs()]; while evalf(B)<=evalf(A) do B:=Bs[randBs()]; end do; end do; IntegDefx:=Int(integrandx[case], var=A..B); uA:=eval(usub[case],var=A); uB:=eval(usub[case],var=B); IntegDefu := Int(integrandu[case], u=uA..uB); IntegDefux := Int(integrandu[case], u=(var=A)..B); IntegDefVal:=value(Eval(IntegValx, var=A..B)); Set(LCLvsSB(enabled)=true); Set(RBChLim(enabled)=true); Set(RBSubBk(enabled)=true); Set(LIntegDefVal(enabled)=true); Set('MMLint' = MathML[Export](" J" = IntegDefx)); if ChLim then Set(LSumDef(caption)="Changing Limits"); Set('MMLsumdef1' = MathML[Export](" J" = IntegDefx)); Set('MMLsumdef2' = MathML[Export](" " = IntegDefu)); Set('MMLsumdef3' = MathML[Export](" " = Eval(IntegValu-C, u=uA..uB))); else Set(LSumDef(caption)="Substituting Back"); Set('MMLsumdef1' = MathML[Export](" J" = IntegDefx)); Set('MMLsumdef2' = MathML[Export](" " = IntegDefux)); Set('MMLsumdef3' = MathML[Export](" " = Eval(IntegValx-C, var=A..B))); end if; Set('Lxb'(caption) = cat(" ", var, " =")); Set('TFxb' = B); Set('TFuB' = cat("g(", convert(B,string), ")")); Set('Lxa'(caption) = cat(" ", var, " =")); Set('TFxa' = A); Set('TFuA' = cat("g(", convert(A,string), ")")); Set('TFIntegDefVal'(enabled)=true, 'TFIntegDefVal'(background)=turquoise); Set(BPreIntegDefVal(enabled)=true, BPreIntegDefVal(background)=turquoise); Set(BCkIntegDefVal(enabled)=true, BCkIntegDefVal(background)=turquoise); Set('IntegDefValck'(enabled)=true, 'IntegDefValck'(background)=white, IntegDefValck(foreground)=black); Set(BShIntegDefVal(enabled)=true, BShIntegDefVal(background)=turquoise); if not Get('CBDef') then Set('MMLintdef' = MathML[Export](" J" = IntegDefx)); Set('MMLintindef' = MathML[Export](" I" = Integx)); Set(ADEFintro(run)=true); end if; else Set(RBSubBk=true); ChLimSubBk(); Set(LCLvsSB(enabled)=false); Set(RBChLim(enabled)=false); Set(RBSubBk(enabled)=false); Set(LIntegDefVal(enabled)=false); Set('MMLint' = MathML[Export](" I" = Integx)); Set('TFIntegDefVal'(enabled)=false, 'TFIntegDefVal'(background)=wheat); Set(BPreIntegDefVal(enabled)=false, BPreIntegDefVal(background)=wheat); Set(BCkIntegDefVal(enabled)=false, BCkIntegDefVal(background)=wheat); Set('IntegDefValck'(enabled)=false, IntegDefValck(background)=wheat); Set(BShIntegDefVal(enabled)=false, BShIntegDefVal(background)=wheat); end if; Set('TFu' = cat("g(", var, ")")); Set('TFdu' = cat("g ' (", var, ") * d", var)); Set('uduck' = "", 'uduck'(background)=white, uduck(foreground)=black); Set('TFIntegu' = ""); Set('Integuck' = "", 'Integuck'(background)=white, Integuck(foreground)=black); Set('TFIntegValu' = ""); Set('IntegValuck' = "", 'IntegValuck'(background)=white, IntegValuck(foreground)=black); Set('TFIntegValx' = ""); Set('IntegValxck' = "", 'IntegValxck'(background)=white, IntegValxck(foreground)=black); Set('ChLimck' = "", 'ChLimck'(background)=white, ChLimck(foreground)=black); Set(BSumDef(enabled)=false, BSumDef(background)=wheat); Set('TFIntegDefVal' = ""); Set('IntegDefValck' = "", 'IntegDefValck'(background)=white, IntegDefValck(foreground)=black); Set('reply' = "", reply(background)=white, reply(foreground)=black); Set('MMLHINTSub' = MathML[Export](Integx='A'*Int(f(u),u))); Set(LHINTSubU(caption)=cat("So pick u=g(", var, ") so that ")); Set(LHINTSubdU(caption)=cat("Be sure to multiply by ", dvar, " in your formula for du.")); Set(TFSYNTAX=cat("sin(",var,")^n")); Set(MMLSYNTAX(value)=MathML[Export](sin(var)^'n')); #????? Set(Budush(enabled)=true, Buduck(enabled)=true); Set(Budush(background)=turquoise, Buduck(background)=turquoise); Set(BIntegush(enabled)=true, BIntegupr(enabled)=true, BInteguck(enabled)=true); Set(BIntegush(background)=turquoise, BIntegupr(background)=turquoise, BInteguck(background)=turquoise); Set(BIntegValush(enabled)=true, BIntegValupr(enabled)=true, BIntegValuck(enabled)=true); Set(BIntegValush(background)=turquoise, BIntegValupr(background)=turquoise, BIntegValuck(background)=turquoise); Set(BShIntegValx(enabled)=true, BPreIntegValx(enabled)=true, BCkIntegValx(enabled)=true); Set(BShIntegValx(background)=turquoise, BPreIntegValx(background)=turquoise, BCkIntegValx(background)=turquoise); Set(BShChLim(enabled)=true, BCkChLim(enabled)=true); Set(BShChLim(background)=turquoise, BCkChLim(background)=turquoise); end proc: Check_udu:= proc() global var, dvar, usub, dusub, case; local user_usub, user_dusub; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_usub:= Get('TFu'::algebraic, corrections=true, update=true); user_dusub:= Get('TFdu'::algebraic, corrections=true, update=true); if simplify(normal(usub[case] - user_usub)) = 0 and simplify(normal(dusub[case]*dvar - user_dusub)) = 0 then Set('uduck' = " correct ", 'uduck'(background)=green, uduck(foreground)=black); Set('reply' = great[randgreat()], reply(background)=green, reply(foreground)=black); elif simplify(normal(usub[case] - user_usub)) = 0 and simplify(normal(dusub[case] - user_dusub)) = 0 then Set('uduck' = " warning ", 'uduck'(background)=yellow, uduck(foreground)=black); Set('reply' = cat("In your formula for du you forgot to multiply by ", dvar, "."), reply(background)=yellow, reply(foreground)=black); elif simplify(normal(usub[case] - user_usub)) = 0 then Set('uduck' = "incorrect", 'uduck'(background)=red, uduck(foreground)=white); Set('reply' = "There is an error in your formula for du. ", reply(background)=red, reply(foreground)=white); elif simplify(normal(diff(user_usub,var)*dvar - user_dusub)) = 0 then Set('uduck' = " warning ", 'uduck'(background)=yellow, uduck(foreground)=black); Set('reply' = "You did not pick u the way I expected but you did compute its differential correctly. Try taking u as a different trig function.", reply(background)=yellow, reply(foreground)=black); elif simplify(normal(diff(user_usub,var) - user_dusub)) = 0 then Set('uduck' = " warning ", 'uduck'(background)=yellow, uduck(foreground)=black); Set('reply' = cat("You did not pick u the way I expected but you did compute its differential correctly except that you forgot the ", dvar, ". Try taking u as a different trig function."), reply(background)=yellow, reply(foreground)=black); else Set('uduck' = " warning ", 'uduck'(background)=yellow, uduck(foreground)=black); Set('reply' = "You did not pick u the way I expected. Try taking u as the whole inner function.", reply(background)=yellow, reply(foreground)=black); end if; end proc: Show_udu:= proc() global dvar, usub, dusub, case; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFu' = usub[case]); Set('TFdu' = dusub[case] * dvar); Set('uduck' = " ", 'uduck'(background)=white, uduck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Check_Integu:= proc() global Integu, InteguWrong; local user_Integu; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_Integu:= Get('TFIntegu'::anything, corrections=true, update=true); if simplify(normal(Integu - user_Integu)) = 0 then Set('Integuck' = " correct ", 'Integuck'(background)=green, Integuck(foreground)=black); Set('reply' = great[randgreat()], reply(background)=green, reply(foreground)=black); elif simplify(normal(InteguWrong - user_Integu)) = 0 then Set('Integuck' = "incorrect", 'Integuck'(background)=red, Integuck(foreground)=white); Set('reply' = cat("You seem to have made a mistake in substituting for the differential. ", tryagain[randtry()]), reply(background)=red, reply(foreground)=white); else Set('Integuck' = "incorrect", 'Integuck'(background)=red, Integuck(foreground)=white); Set('reply' = cat(sorry[randsorry()], tryagain[randtry()]), reply(background)=red, reply(foreground)=white); end if; end proc: Show_Integu:= proc() global Integu; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFIntegu' = Integu); Set('Integuck' = " ", 'Integuck'(background)=white, Integuck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Check_IntegValu:= proc() global IntegValu, LimsOK, IndefOK; local user_IntegValu; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_IntegValu:= Get('TFIntegValu'::anything, corrections=true, update=true); if simplify(normal(IntegValu - user_IntegValu)) = 0 then Set('IntegValuck' = " correct ", 'IntegValuck'(background)=green, IntegValuck(foreground)=black); Set('reply' = great[randgreat()], reply(background)=green, reply(foreground)=black); IndefOK:=true: if LimsOK then Set(BSumDef(enabled)=true, BSumDef(background)=turquoise); end if; elif simplify(normal(IntegValu - user_IntegValu-C)) = 0 then Set('IntegValuck' = " warning ", 'IntegValuck'(background)=yellow, IntegValuck(foreground)=black); Set('reply' = cat("You forgot to add C to the indefinite integral."), reply(background)=yellow, reply(foreground)=black); else Set('IntegValuck' = "incorrect", 'IntegValuck'(background)=red, IntegValuck(foreground)=white); Set('reply' = cat(sorry[randsorry()], tryagain[randtry()]), reply(background)=red, reply(foreground)=white); end if; end proc: Show_IntegValu:= proc() global IntegValu; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFIntegValu' = IntegValu); Set('IntegValuck' = " ", 'IntegValuck'(background)=white, IntegValuck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Check_ChLim:= proc() global var, A, B, uA, uB, LimsOK, IndefOK; local user_uA, user_uB; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_uA:= Get('TFuA'::realcons, corrections=true, update=true); user_uB:= Get('TFuB'::realcons, corrections=true, update=true); if simplify(normal(uA - user_uA)) = 0 and simplify(normal(uB - user_uB)) = 0 then Set('ChLimck' = " correct ", 'ChLimck'(background)=green, ChLimck(foreground)=black); Set('reply' = great[randgreat()], reply(background)=green, reply(foreground)=black); LimsOK:=true: if IndefOK then Set(BSumDef(enabled)=true, BSumDef(background)=turquoise); end if; elif simplify(normal(uA - user_uA)) = 0 then Set('ChLimck' = "incorrect", 'ChLimck'(background)=red, ChLimck(foreground)=white); Set('reply' = "There is an error in the value of u at the upper limit.", reply(background)=red, reply(foreground)=white); elif simplify(normal(uB - user_uB)) = 0 then Set('ChLimck' = "incorrect", 'ChLimck'(background)=red, ChLimck(foreground)=white); Set('reply' = "There is an error in the value of u at the lower limit.", reply(background)=red, reply(foreground)=white); else Set('ChLimck' = "incorrect", 'ChLimck'(background)=red, ChLimck(foreground)=white); Set('reply' = "There are errors in the values of u at both limits.", reply(background)=red, reply(foreground)=white); end if; end proc: Show_ChLim:= proc() global uA, uB; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFuA' = uA); Set('TFuB' = uB); Set('ChLimck' = " ", 'ChLimck'(background)=white, ChLimck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Check_IntegValx:= proc() global IntegValx, Def; local user_IntegValx; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_IntegValx:= Get('TFIntegValx'::anything, corrections=true, update=true); if simplify(normal(IntegValx - user_IntegValx)) = 0 then Set('IntegValxck' = " correct ", 'IntegValxck'(background)=green, IntegValxck(foreground)=black); if Def then Set(BSumDef(enabled)=true, BSumDef(background)=turquoise); Set('reply' = great[randgreat()], reply(background)=green, reply(foreground)=black); else Set('reply' = cat(great[randgreat()], nextquest[randnext()]), reply(background)=green, reply(foreground)=black); end if; elif simplify(normal(IntegValx - user_IntegValx-C)) = 0 then Set('IntegValxck' = " warning ", 'IntegValxck'(background)=yellow, IntegValxck(foreground)=black); Set('reply' = "You forgot to add C to the indefinite integral.", reply(background)=yellow, reply(foreground)=black); else Set('IntegValxck' = "incorrect", 'IntegValxck'(background)=red, IntegValxck(foreground)=white); Set('reply' = cat(sorry[randsorry()], tryagain[randtry()]), reply(background)=red, reply(foreground)=white); end if; end proc: Show_IntegValx:= proc() global IntegValx; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFIntegValx' = IntegValx); Set('IntegValxck' = " ", 'IntegValxck'(background)=white, IntegValxck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Check_IntegDefVal:= proc() global IntegDefVal; local user_IntegDefVal; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; user_IntegDefVal:= Get('TFIntegDefVal'::anything, corrections=true, update=true); if simplify(normal(IntegDefVal - user_IntegDefVal)) = 0 then Set('IntegDefValck' = " correct ", 'IntegDefValck'(background)=green, IntegDefValck(foreground)=black); Set('reply' = cat(great[randgreat()], nextquest[randnext()]), reply(background)=green, reply(foreground)=black); elif simplify(normal(IntegDefVal+C - user_IntegDefVal)) = 0 then Set('IntegDefValck' = " warning ", 'IntegDefValck'(background)=yellow, IntegDefValck(foreground)=black); Set('reply' = "You should not have a +C in a definite integral.", reply(background)=yellow, reply(foreground)=black); elif simplify(normal(IntegDefVal + user_IntegDefVal)) = 0 then Set('IntegDefValck' = "incorrect", 'IntegDefValck'(background)=red, IntegDefValck(foreground)=white); Set('reply' = "Recall, a definite integral is computed by evaluating the antiderivative at the upper limit minus the lower limit. You got them backwards.", reply(background)=red, reply(foreground)=white); else Set('IntegDefValck' = "incorrect", 'IntegDefValck'(background)=red, IntegDefValck(foreground)=white); Set('reply' = cat(sorry[randsorry()], tryagain[randtry()]), reply(background)=red, reply(foreground)=white); end if; end proc: Show_IntegDefVal:= proc() global IntegDefVal; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; Set('TFIntegDefVal' = IntegDefVal, 'TFIntegDefVal'(background)=turquoise); Set('IntegDefValck' = " ", 'IntegDefValck'(background)=white, IntegDefValck(foreground)=black); Set('reply' = showit[randshow()], 'reply'(background)=lightorange, reply(foreground)=black); end proc: Preview:=proc(TFname) local expr; global CurrentTFname; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; CurrentTFname := TFname; if Get(TFname)="" then Set('reply'="You must enter an expression to be previewed.", 'reply'(background)=lightorange, reply(foreground)=black); else expr:=Get(TFname::anything, corrections=true, update=true); Set('TFPreview' = expr); Set('MMLPreview' = MathML[Export](expr)); Set('ARunPreview'(run)=true); end if; end proc: Update_Preview:=proc() local expr; global CurrentTFname; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; expr:=Get(TFPreview::anything, corrections=true, update=true); Set('MMLPreview' = MathML[Export](expr)); Set(CurrentTFname = expr); end proc: ChLimSubBk:=proc() global ChLim; options `Copyright 2005, Philip B. Yasskin, Texas A&M Univ.`; ChLim:=Get(RBChLim); if ChLim then Set(LIntegValx(visible)=false); Set(TFIntegValx(visible)=false); Set(BPreIntegValx(visible)=false); Set(BCkIntegValx(visible)=false); Set(IntegValxck(visible)=false); Set(BShIntegValx(visible)=false); Set(LChLim(visible)=true); Set(Lxb(visible)=true); Set(TFxb(visible)=true); Set(LuB(visible)=true); Set(TFuB(visible)=true); Set(Lxa(visible)=true); Set(TFxa(visible)=true); Set(LuA(visible)=true); Set(TFuA(visible)=true); Set(BCkChLim(visible)=true); Set(ChLimck(visible)=true); Set(BShChLim(visible)=true); Set(LSumDef(caption)="Changing Limits"); Set('MMLsumdef1' = MathML[Export](" J" = IntegDefx)); Set('MMLsumdef2' = MathML[Export](" " = IntegDefu)); Set('MMLsumdef3' = MathML[Export](" " = Eval(IntegValu-C, u=uA..uB))); else Set(LIntegValx(visible)=true); Set(TFIntegValx(visible)=true); Set(BPreIntegValx(visible)=true); Set(BCkIntegValx(visible)=true); Set(IntegValxck(visible)=true); Set(BShIntegValx(visible)=true); Set(LChLim(visible)=false); Set(Lxb(visible)=false); Set(TFxb(visible)=false); Set(LuB(visible)=false); Set(TFuB(visible)=false); Set(Lxa(visible)=false); Set(TFxa(visible)=false); Set(LuA(visible)=false); Set(TFuA(visible)=false); Set(BCkChLim(visible)=false); Set(ChLimck(visible)=false); Set(BShChLim(visible)=false); Set(LSumDef(caption)="Substituting Back"); Set('MMLsumdef1' = MathML[Export](" J" = IntegDefx)); Set('MMLsumdef2' = MathML[Export](" " = IntegDefux)); Set('MMLsumdef3' = MathML[Export](" " = Eval(IntegValx-C, var=A..B))); end if; end proc: TrigIntegrals := Maplet(onstartup = RunWindow(MAIN), Font[helv10]("helvetica",10), Window[MAIN]( 'title'="Trigonometric Integrals", 'defaultbutton'='Hint', [ halign=none, background=wheat, [ background=wheat, [ background=wheat, Button("Indefinite Integral", Evaluate('function' = "Show_Integral(false)"), background=turquoise), Button(" Definite Integral ", Evaluate('function' = "Show_Integral(true)"), background=turquoise) ], [ background=wheat, VerticalGlue(), "Use a substitution ", " to compute the integral:", VerticalGlue() ], MathMLViewer[MMLint]('value'=MathML[Export](" I" = Int(F(x),x)), 'width'=300, 'height'=100), HorizontalGlue(), [ background=wheat, Button("Quit", Shutdown(), background=pink), Button['Hint']("Hint", RunWindow(HINTSub), background=turquoise), Button("Syntax", RunWindow(SYNTAX), background=turquoise) ] ], BoxColumn('background'=wheat, 'inset'=0, 'spacing'=0, 'border'=true, 'caption'="Step 1 - Define the substitution:", [ background=wheat, "u =", TextField['TFu']("g(x)", 'width'=20, 'background'=turquoise), " du =", TextField['TFdu']("g ' (x) * dx", 'width'=20, 'background'=turquoise), HorizontalGlue(), Button[Buduck]("Check", Evaluate('function' = "Check_udu"), background=wheat, enabled=false), TextField['uduck']('width'=6, editable=false, background=white), Button[Budush]("Show", Evaluate('function' = "Show_udu"), background=wheat, enabled=false) ] ), BoxColumn('background'=wheat, 'inset'=0, 'spacing'=0, 'border'=true, 'caption'="Step 2 - Rewrite and evaluate the indefinite integral after applying the proper trigonometric identities.", [ background=wheat, "Substitute u into the indefinite integral: I =", TextField['TFIntegu']('width'=30, 'background'=turquoise), HorizontalGlue(), Button[BIntegupr]("Preview", onclick=APreSub, background=wheat, enabled=false), Button[BInteguck]("Check", Evaluate('function' = "Check_Integu"), background=wheat, enabled=false), TextField['Integuck']('width'=6, editable=false, background=white), Button[BIntegush]("Show", Evaluate('function' = "Show_Integu"), background=wheat, enabled=false) ], [ background=wheat, "Compute the indefinite u-integral: I =", TextField['TFIntegValu']('width'=30, 'background'=turquoise), HorizontalGlue(), Button[BIntegValupr]("Preview", onclick=APreIndef, background=wheat, enabled=false), Button[BIntegValuck]("Check", Evaluate('function' = "Check_IntegValu"), background=wheat, enabled=false), TextField['IntegValuck']('width'=6, editable=false, background=white), background=wheat, Button[BIntegValush]("Show", Evaluate('function' = "Show_IntegValu"), background=wheat, enabled=false) ] ), BoxColumn('background'=wheat, 'inset'=0, 'spacing'=0, 'border'=true, 'caption'="Step 3 - Rewrite the integral in terms of the original variable (or find new limits if appropriate).", [ background=wheat, Label[LCLvsSB]("Select: ", enabled =false), RadioButton['RBChLim']("Change Limits", 'value'=false, 'group'='BG1', enabled =false), RadioButton['RBSubBk']("Substitute Back", 'value'=true, 'group'='BG1', enabled =false), HorizontalGlue() ], [ background=wheat, Label[LChLim]("Compute the u-limits", visible=false), [ background=wheat, [ background=wheat, Label[Lxb](" x =", visible=false), TextField['TFxb']("b", 'width'=10, editable=false, visible=false), Label[LuB](" @ u =", visible=false), TextField['TFuB']("g(b)", 'width'=20, 'background'=turquoise, visible=false) ], [ background=wheat, Label[Lxa](" x =", visible=false), TextField['TFxa']("a", 'width'=10, editable=false, visible=false), Label[LuA](" @ u =", visible=false), TextField['TFuA']("g(a)", 'width'=20, 'background'=turquoise, visible=false) ] ], HorizontalGlue(), Button[BCkChLim]("Check", Evaluate('function' = "Check_ChLim"), background=wheat, visible=false, enabled =false), TextField['ChLimck']('width'=6, editable=false, background=white, visible=false), Button[BShChLim]("Show", Evaluate('function' = "Show_ChLim"), background=wheat, visible=false, enabled =false) ], [ background=wheat, Label[LIntegValx]("Substitute back: I =", visible=true), TextField['TFIntegValx']('width'=40, 'background'=turquoise, visible=true), HorizontalGlue(), Button[BPreIntegValx]("Preview", onclick=APreIntegValx, background=wheat, visible=true, enabled =false), Button[BCkIntegValx]("Check", Evaluate('function' = "Check_IntegValx"), background=wheat, visible=true, enabled =false), TextField['IntegValxck']('width'=6, editable=false, background=white, visible=true), Button[BShIntegValx]("Show", Evaluate('function' = "Show_IntegValx"), background=wheat, visible=true, enabled =false) ] ), BoxColumn('background'=wheat, 'inset'=0, 'spacing'=0, 'border'=true, 'caption'="Step 4 - Final evaluation of the definite integral (if appropriate)", [ background=wheat, HorizontalGlue(), Button[BSumDef]("Summarize the Definite Integral Computations", RunWindow(SUMDEF), background=wheat, enabled=false), HorizontalGlue() ], [ background=wheat, Label[LIntegDefVal]("Evaluate at the limits: J =", enabled =false), TextField['TFIntegDefVal']('width'=40, 'background'=wheat, enabled =false), HorizontalGlue(), Button[BPreIntegDefVal]("Preview", onclick=APreIntegDefVal, background=wheat, enabled =false), Button[BCkIntegDefVal]("Check", Evaluate('function' = "Check_IntegDefVal"), background=wheat, enabled =false), TextField['IntegDefValck']('width'=6, editable=false, background=white, enabled =false), Button[BShIntegDefVal]("Show", Evaluate('function' = "Show_IntegDefVal"), background=wheat, enabled =false) ] ), TextBox['reply']('width'=70, 'height'=2, 'editable'='false', background=white ), BoxRow('background'="#DDFFFF", 'inset'=0, 'spacing'=0, Label("Programmers: Matt Pertzborn / Daniel Lin", 'font'=helv10), HorizontalGlue(), Label("Copyright 2006, D.B. Meade and P.B. Yasskin", 'font'=helv10), HorizontalGlue(), Label("v. 1.2 May 2006", 'font'=helv10) ) ]), Window[DEFintro]( 'title'="Definite Integration", 'defaultbutton'='CloseDef', [ halign=none, background=wheat, [ background=wheat, "Your goal is to compute the definite integral: ", MathMLViewer[MMLintdef]('value'=MathML[Export](" J" = Int(F(x),x=a..b)), 'width'=300, 'height'=100) ], [ background=wheat, "But first compute the corresponding indefinite integral:", MathMLViewer[MMLintindef]('value'=MathML[Export](" I" = Int(F(x),x)), 'width'=300, 'height'=100) ], [ background=wheat, "You will get to choose whether you want to Change Limits or Substitute Back.", HorizontalGlue() ], [ background=wheat, HorizontalGlue(), CheckBox[CBDef]("Do not show this window again.", 'value'=false), Button['CloseDef']("Close", CloseWindow(DEFintro), background=pink) ] ]), Window[HINTSub]( 'title'="Integration by Substitution -- Hints", 'defaultbutton'='CloseHint', [ halign=none, background=wheat, [ background=wheat, HorizontalGlue(), Button['CloseHint']("Close", CloseWindow(HINTSub), background=pink) ], [ background=wheat, "The Change of Variables Theorem states:", MathMLViewer('value'=MathML[Export](Int(f(g(x))*Diff(g,x),x) = Int(f(u),u)), 'width'=350, 'height'=100) ], [ background=wheat, Label[LHINTSubU]("So pick u=g(x) so that "), MathMLViewer[MMLHINTSub]('value'=MathML[Export](Int(F(x),x) = 'A'*Int(f(u),u)), 'width'=350, 'height'=100) ], [ background=wheat, "for some functions f and g and some constant A.", HorizontalGlue()], [ background=wheat, Label[LHINTSubdU]("Be sure to multiply by dx in your formula for du."), HorizontalGlue()] ]), Window[SYNTAX]( 'title'="Syntax for Integrals", 'defaultbutton'='CloseInt', [ halign=none, background=wheat, [ background=wheat, HorizontalGlue(), Button['CloseInt']("Close", CloseWindow(SYNTAX), background=pink) ], [ background=wheat, "Type ", TextField("Int(f(u),u)", width=12), " for ", MathMLViewer('value'=MathML[Export](Int(f(u),u)), 'width'=100, 'height'=50) ], [ background=wheat, "Type ", TextField[TFSYNTAX](cat("sin(x)^n"), width=12), " for ", MathMLViewer[MMLSYNTAX]('value'=MathML[Export](sin(x)^'n'), 'width'=100, 'height'=50) ] ]), Window[PREVIEW]( 'title'="Preview", 'defaultbutton'='UpdatePreview', [ halign=none, background=wheat, [ background=wheat, TextField['TFPreview']('width'=50, background=turquoise), Button['UpdatePreview']("Update", Evaluate('function' = "Update_Preview()"), background=turquoise), Button['ClosePreview']("Close", CloseWindow(PREVIEW), background=pink) ], [ background=wheat, MathMLViewer[MMLPreview]('value'=MathML[Export](Int(f(x),x)), 'width'=500, 'height'=100) ] ]), Window[SUMDEF]( 'title'="Summary of Definite Integral Computations", 'defaultbutton'='Closesumdef', [ halign=none, background=wheat, [ background=wheat, HorizontalGlue(), Label[LSumDef]("Substituting Back"), HorizontalGlue(), Button['Closesumdef']("Close", CloseWindow(SUMDEF), background=pink) ], [ background=wheat, MathMLViewer[MMLsumdef1]('value'=MathML[Export](J = IntegDefx), 'width'=500, 'height'=100) ], [ background=wheat, MathMLViewer[MMLsumdef2]('value'=MathML[Export](" " = IntegDefux), 'width'=500, 'height'=100) ], [ background=wheat, MathMLViewer[MMLsumdef3]('value'=MathML[Export](" " = IntegDefEvalx), 'width'=500, 'height'=100) ] ]), Action[ADEFintro](RunWindow(DEFintro)), Action[ARunPreview](RunWindow(PREVIEW)), Action[APreSub](Evaluate('function' = "Preview(TFIntegu)")), Action[APreIndef](Evaluate('function' = "Preview(TFIntegValu)")), Action[APreIntegValx](Evaluate('function' = "Preview(TFIntegValx)")), Action[APreIntegDefVal](Evaluate('function' = "Preview(TFIntegDefVal)")), ButtonGroup['BG1'](onchange = Evaluate('function' = "ChLimSubBk")) ): Maplets[Display]( TrigIntegrals );