restart: with(Maplets): with(Maplets[Elements]):with(Maplets[Tools]): StartEngine(); randomize(): Logdiff:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN]('title'="Logarithmic differentiation", [ halign=none, [ Button("New Function", Evaluate('function' = "ask")), HorizontalGlue(), Button("Quit", Shutdown()) ], [ "Use logarithmic differentiation to find the derivative of", HorizontalGlue() ], [ HorizontalGlue(), "f(x) =", MathMLViewer[Fn]('value' = MathML[Export](((x-a)^m*(x-b)^n)/((x-c)^p*(x-d)^q)), height=75, width=200), HorizontalGlue() ], [ "Take the log of both sides.", HorizontalGlue() ], [ "ln f(x) =", TextField['lnFn']('width'=30), HorizontalGlue() ], [ HorizontalGlue(), Button("Check", Evaluate('function' = "check1")), TextField['reply1']('width'=8, background=white), Button("Show", Evaluate('function' = "show1")), HorizontalGlue() ], [ "Find the derivative of both sides. Type df/dx for the derivative of f(x).", HorizontalGlue() ], [ TextField['LHS']('width'=8), "=", TextField['RHS']('width'=25), HorizontalGlue() ], [ HorizontalGlue(), Button("Check", Evaluate('function' = "check2")), TextField['reply2left']('width'=11), TextField['reply2right']('width'=12), Button("Show", Evaluate('function'="show2")), HorizontalGlue() ], [ "Solve for the derivative of f(x).", HorizontalGlue() ], [ "df/dx = ", TextField['dFn']('width' =45), HorizontalGlue() ], [ HorizontalGlue(), Button("Check", Evaluate('function' = "check4")), TextField['reply4']('width'=8), Button("Show", Evaluate('function' = "show4")), HorizontalGlue() ], [ "Programmers: Greisser & Schepp Copyright P. Yasskin 2005" ] ] ) ): randnum:=rand(-9...9): randpow:=rand(2..6): ask := proc() global a,m,b,n,c,p,d,q,g, randnum, randpow; a:=randnum(); b:=randnum(); n:=randpow(); m:=randpow(); c:=randnum(); d:=randnum(); p:=randpow(); q:=randpow(); g:=(x-a)^m*(x-b)^n/(x-c)^p/(x-d)^q; Set(Fn=MathML[Export](g)); Set(lnFn=""): Set(reply1="", 'reply1'(background)=white, 'reply1'(foreground) = black): Set(LHS=""): Set(RHS=""): Set('reply2left'="", 'reply2left'(background)=white, 'reply2left'(foreground)=black): Set('reply2right'="", 'reply2right'(background)=white, 'reply2right'(foreground)=black): Set(dFn=""): Set('reply4'="", 'reply4'(background)=white, 'reply4'(foreground)=black): end proc: check1 := proc() local user_lnf, lnf; global a,b,m,n,c,d,p,q; user_lnf := Get(lnFn::algebraic, corrections=true, update=true): lnf:=m*ln(x-a)+n*ln(x-b)-p*ln(x-c)-q*ln(x-d); if simplify(normal(user_lnf - lnf))<> 0 then Set('reply1'="incorrect", 'reply1'(background)=red, 'reply1'(foreground)=white): else Set('reply1'=" correct ", 'reply1'(background)=green, 'reply1'(foreground)=black): end if; end proc: show1 := proc() local lnf; global a,m; lnf:=m*ln(x-a)+n*ln(x-b)-p*ln(x-c)-q*ln(x-d); Set(lnFn = lnf): Set('reply1'="", 'reply1'(background)=white, 'reply1'(foreground)=black): end proc: check2 := proc() global a,b,m,n,c,d,p,q; local user_lhs,lhs,user_rhs,rhs; user_lhs := Get(LHS::algebraic, corrections=true, update=true): lhs:=1/f*df/dx; user_rhs := Get(RHS::algebraic, corrections=true, update=true): rhs:=m/(x-a)+n/(x-b)-p/(x-c)-q/(x-d); if simplify(normal(user_lhs - lhs))= 0 then Set('reply2left'="left side correct", 'reply2left'(background)=green, 'reply2left'(foreground)=black): else Set('reply2left'="left side incorrect", 'reply2left'(background)=red, 'reply2left'(foreground)=white): end if; if simplify(normal(user_rhs - rhs))= 0 then Set('reply2right'="right side correct", 'reply2right'(background)=green, 'reply2right'(foreground)=black): else Set('reply2right'="right side incorrect", 'reply2right'(background)=red, 'reply2right'(foreground)=white): end if; end proc: show2 := proc() global a,b,m,n,c,d,p,q; local lhs, rhs; lhs:=1/f*df/dx; rhs:=m/(x-a)+n/(x-b)-p/(x-c)-q/(x-d); Set(LHS = lhs): Set(RHS = rhs): Set('reply2left'="", 'reply2left'(background)=white, 'reply2left'(foreground)=black): Set('reply2right'="", 'reply2right'(background)=white, 'reply2right'(foreground)=black): end proc: check4 := proc() global a,b,m,n,c,d,p,q,g; local user_fnl,fnl; user_fnl := Get(dFn::algebraic, corrections=true, update=true): fnl:=(m/(x-a)+n/(x-b)-p/(x-c)-q/(x-d))*g; if simplify(normal(user_fnl - fnl))<> 0 then Set('reply4'="incorrect", 'reply4'(background)=red, 'reply4'(foreground)=white): else Set('reply4'=" correct ", 'reply4'(background)=green, 'reply4'(foreground)=black): end if; end proc: show4 := proc() global a,b,m,n,c,d,p,q,g; local fnl; fnl:=(m/(x-a)+n/(x-b)-p/(x-c)-q/(x-d))*g; Set(dFn = fnl): Set('reply4'="", 'reply4'(background)=white, 'reply4'(foreground)=black): end proc: Display(Logdiff);