       Re: Incoherent value for partial derivative

• To: mathgroup at smc.vnet.net
• Subject: [mg91075] Re: Incoherent value for partial derivative
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Tue, 5 Aug 2008 04:03:44 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <g76auv\$dks\$1@smc.vnet.net>

```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.

This is true only for the *special* form g'. If you use D[g,x],
you get similar result and behavior as for D[f[1,2],x].

The operator D always evaluates its arguments in the same and consistent
way, regardless of the name and number of variables.

However, the ' (prime) form is a special form that does *not* evaluate
its argument as the operator D does. (And prime works only for a
function of one variable.)

In other words, the ' (prime) form and the operator D form are *not*
equivalent and they are not interchangeable without care.

In:= g[x_] := 3 x^2 + 5 x;
g' // Trace
D[g, x] // Trace

Out=
2                    2
{{g', {g[#1], 3 #1  + 5 #1, 5 #1 + 3 #1 }, 5 + 6 #1 & },

(5 + 6 #1 & ), 5 + 6 2, {6 2, 12}, 5 + 12, 17}

Out=
2           2
{{g, 3 2  + 5 2, {{2 , 4}, 3 4, 12}, {5 2, 10}, 12 + 10, 22},

D[22, x], 0}

As we can see above, the ' (prime) form first the function into an pure
function and takes its first derivative, then applies the resulting pure
function to the numeric value (2) passed as argument of the original
function.

On the other hand, the operator D first evaluates its argument, which
yields a numeric value, i.e. a constant, and since the derivative of a
constant with respect to whatever variable is zero, the result is zero.

> But for
> partial derivative Mathematica works different way (not correspondig
> to FullForm

FullForm is irrelevant here: what matters is when the arguments are
evaluated and how they are transformed before before applying numeric
value. Trace is more appropriate to visualize what is going on. You can
see the the reasoning (and behavior) is similar to what we did above.

In:= f[x_, y_] := x^2 + x y^2;
FullForm[D [f[x, y], x]]
D[f[1, 2], x] // Trace

Out//FullForm= Plus[Times[2, x], Power[y, 2]]

Out=
2      2    2         2
{{f[1, 2], 1  + 1 2 , {1 , 1}, {{2 , 4}, 1 4, 4}, 1 + 4, 5},
D[5, x], 0}

> 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
>
> I dont understand the reason.

Hope this helps,
-- Jean-Marc

```

• Prev by Date: Re: Workaround for an unexpected behavior of Sum
• Next by Date: RE: Denoting a Cartesian Product
• Previous by thread: Re: Incoherent value for partial derivative
• Next by thread: Re: Incoherent value for partial derivative