[Date Index] [Thread Index] [Author Index]
Re: Incoherent value for partial derivative
On 8/4/08 at 3:26 AM, misvrne at gmail.com (Miguel) wrote: >Let >In: g[x_]:=3x^2+5x; FullForm[g'[x]] >Out: Plus[5,Times[6,x]] >In: g' Out: 17 >Mathematica works fine and the result is correct. First, it executes >the derivation and then the delayed substitution/assignation. Unless I had either tested this or found something specific in the documentation to say things would work this way, I would not have relied on this particular sequence of execution. Without checking, I would have expected Mathematica to substitute a particular value for x then take the derivative getting 0 since f evaluates as a constant. >But for partial derivative Mathematica works different way (not >correspondig to FullForm This really isn't a correct conclusion. FullForm[expr] gives the form corresponding to the evaluation of expr. >In: f[x_,y_]:=x^2+x y^2; FullForm[\!\( >\*SubscriptBox[\(\[PartialD]\), \(x\)]\ \(f[x, y]\)\)] >Out: Plus[Times[2,x],Power[y,2]] >In: \!\( \*SubscriptBox[\(\[PartialD]\), \(x\)]\ \(f[1, 2]\)\) >Out: 0 Here, the sequence of evaluation is more along the lines of what I would expect. That is values for x and y are substituted resulting in a real value then the derivative is computed. You can verify this works as I've described by using Trace.