MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: RE:? D[f,{x,n}]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25570] Re: [mg25559] RE:[mg25495] ? D[f,{x,n}]
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sun, 8 Oct 2000 00:41:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

on 10/7/00 4:36 PM, Ersek, Ted R at ErsekTR at navair.navy.mil wrote:

> seems to prove that D[f, {x, n}]  evaluates
> Nest[ D[#, x]&, f, n ]
> or something equivalent.
> -----------------------------

I think the point is (as already has been pointed out by Carl Woll)  that:

In[22]:=
MatchQ[Unevaluated[D[f, {x, n}]], Unevaluated[D[f_, y_]]]
Out[22]=
True

We can see what happens in your case simply by looking at Trace:

In[28]:=
Trace[D[(x + 2)^4, {x, 2}]]

Out[28]=
{{{HoldForm[x + 2], HoldForm[2 + x]}, HoldForm[(2 + x)^4]}, HoldForm[D[(2 +
x)^4, {x, 2}]], {HoldForm[flag], HoldForm[True]}, HoldForm[Block[{flag},
D[Expand[(2 + x)^4], {x, 2}]]], {{HoldForm[Expand[(2 + x)^4]], HoldForm[16 +
32*x + 24*x^2 + 8*x^3 + x^4]}, HoldForm[D[16 + 32*x + 24*x^2 + 8*x^3 + x^4,
{x, 2}]], HoldForm[48 + 48*x + 12*x^2]}, HoldForm[48 + 48*x + 12*x^2]}

As you can see,  D[(2 + x) , {x, 2}] was found to match the rule for
D[f_,x_]/;flag and the rule was simply applied. There was need to use Nest,
and so on. This is just a case of pattern matching doing its job.

A similar approach can be used to show that when Mathematica evaluates
Derivative[n][f] it does not do actually do this by nesting Derivative[1]'s.

Here is a rule for Derivative that is, essentially, equivalent to the above
one for D (note that there is no need to use Unprotect as Derivative does
not have the Protected Attribute!):

In[1]:=
Derivative[1][Function[p_]] /; flag :=
  Block[{flag}, Derivative[1][Function @@ {Expand[p] }]]

In[2]:=
flag = True;

This works just as above:


In[3]:=
(# + 2)^3 &'[x]

Out[3]=
               2
12 + 12 x + 3 x

But:

In[4]:=
((# + 2)^3 &)''[x]

Out[4]=
6 (2 + x)

While on the other hand

In[5]:=
((# + 2)^3 &')'[x]

Out[5]=
12 + 6 x


Of course what one should do is use a  more general pattern:

In[6]:=
Derivative[n_][Function[p_]] /; flag :=
Block[{flag}, Derivative[n][Function @@ {Expand[p] }]]


so that:

In[7]:=
((# + 2)^5 &)'''[x]

Out[7]=
                  2
240 + 240 x + 60 x


-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/



  • Prev by Date: RE: Complex Function Plot
  • Next by Date: Re: Complex Function Plot
  • Previous by thread: Re: RE:? D[f,{x,n}]
  • Next by thread: Re: RE:? D[f,{x,n}]