RE: How do I see justification of solution?

*To*: mathgroup at smc.vnet.net*Subject*: [mg28390] RE: [mg28377] How do I see justification of solution?*From*: "David Park" <djmp at earthlink.net>*Date*: Sun, 15 Apr 2001 00:13:41 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

David, You can't always get Mathematica to show all the steps it used in a command because many of the steps are buried in C code. Still, many students and teachers would like to do and show steps which Mathematica does automatically. One solution to this problem is a package called Algebra`ExpressionManipulation which is available at my web site below. The package was developed by Ted Ersek and myself to handle just this type of problem. (I believe that Ted also has some overlapping packages available at MathSource.) This is how we would apply it to your example to show all the steps, complete with annotation. Needs["Algebra`ExpressionManipulation`"] HoldForm[D[Sin[x^2 + 5*x], x]] Print["Use of chain rule."] %% /. HoldPattern[D[(f_)[e_], x]] :> Derivative[1][f][e]*D[e, x] Print["Function derivative."] EvaluateAtPattern[Derivative[1][Sin][_]][%%] Print["Use of sum rule."] %% /. HoldPattern[D[a_ + b_, x]] :> D[a, x] + D[b, x] Print["Use of constant rule"] %% /. HoldPattern[D[(a_)?(FreeQ[#1, x] & )*b_, x]] :> a*D[b, x] Print["Evaluating derivatives."] EvaluateAtPattern[_D][%%] ReleaseHold[%] The output, which looks much better in standard form (for instance the HoldForm is invisible), is: HoldForm[D[Sin[x^2 + 5*x], x]] Use of chain rule. HoldForm[Derivative[1][Sin][x^2 + 5*x]*D[x^2 + 5*x, x]] Function derivative. HoldForm[Cos[5*x + x^2]*D[x^2 + 5*x, x]] Use of sum rule. HoldForm[Cos[5*x + x^2]*(D[x^2, x] + D[5*x, x])] Use of constant rule HoldForm[Cos[5*x + x^2]*(D[x^2, x] + 5*D[x, x])] Evaluating derivatives. HoldForm[Cos[5*x + x^2]*(2*x + 5*1)] (5 + 2*x)*Cos[5*x + x^2] The ExpressionManipulation package has routines for the controlled evaluation of expressions. It also has a PositionsPalette which allows one to highlight a subexpression and obtain its position. There is another routine called ColorPositions which will color and label explicit positions or positions which match a pattern. It also has a feature of "extended positions". An extended position is a subset of level parts in an expression. An example would be a + c in f[1+a+b+c+d]. Extended positions can also be manipulated. There is also an EvaluationTutorial that illustrate the routines and show techniques for controlled expression manipulation. There are examples from simple fraction problems to integration by parts. I like your example so much, I might just add it to the tutorial. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > -----Original Message----- > > I want to see how Mathematica solves the problem I give it; Not > just the sub-expressions that Trace puts out. > > Ex. If I give it Find the derivative of D[sin(x^2 + 5x),x] > I'd like to see: > Chain Rule (...) > sum Rule (x^2 + 5x) > power rule (x^2) > . > .. > .. > > Isn't there some way to get the thing to show the steps it took to solve > a problem? > >