MathGroup Archive 2010

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

Search the Archive

Re: How to use "Apply" to do differentiation ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114475] Re: How to use "Apply" to do differentiation ?
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Sun, 5 Dec 2010 21:52:38 -0500 (EST)

Hi,

> I have been using Mathematica for several years and
> never found that.

and you never questioned what Apply really does?
It "replaces the head of an expression". So lets look on your expression

In[8]:= FullForm[x^5]
Out[8]//FullForm= Power[x,5]

The head is Power. So what do we expect from Apply[D[#, x] &, x^5]? We
expect that it evaluates to

D[#, x] &[x,5]

Since the # in your function is short for #1 this reduces to

D[x,x]

which is 1 (no matter what the exponent is).

To investigate in this behavior, you could have replaced the normal
D[..] function with something that doesn't do anything and you would
have seen what happened earlier:

In[15]:= Apply[d[#,x]&,x^5]
Out[15]= d[x,x]

Hope this helps.

Cheers
Patrick




On Sat, 2010-12-04 at 06:16 -0500, Mayasky wrote:
> Something simple yet unbelievable occurred when I use:
> 
> Apply[D[#, x] &, x^5]
> 
> The output is invariably 1 whether I use x^5 or x^100.
> Also I suggest you to try "Trace" command to see
> the weirdness -- the output is messy if pasted as
> text here.
> 
> Finally I have to take a detour and use:
> Nest[D[#, x] &, x^5, 1]
> 
> I have been using Mathematica for several years and
> never found that. I myself is wordless, but can anyone
> explain that?
> 



  • Prev by Date: Re: How to use "Apply" to do differentiation ?
  • Next by Date: Re: How to use "Apply" to do differentiation ?
  • Previous by thread: Re: How to use "Apply" to do differentiation ?
  • Next by thread: Re: How to use "Apply" to do differentiation ?