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

• To: mathgroup at smc.vnet.net
• Subject: [mg114500] Re: How to use "Apply" to do differentiation ?
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sun, 5 Dec 2010 21:57:16 -0500 (EST)

```On 4 Dec 2010, at 12:16, 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?
>

I don't see anything very strange in this. Note that the full form of x^5 is Power[x,5]. Observe that in general

Apply[f[#] &, p[x, y]]

f(x)

So not Apply[D[#,x]&,Power[x,5]] will give D[x,x] which is 1.

What I do not understand is what you actually intended to achieve. If you wanted simply to differentiate x^5 the way to do it is

D[#, x] &@(x^5)

or (if you really must):

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

5 x^4

Andrzej Kozlowski

```

• Prev by Date: Re: How to use "Apply" to do differentiation ?
• Next by Date: Counting number of numbers in a large list between two valus
• Previous by thread: Re: How to use "Apply" to do differentiation ?
• Next by thread: Re: How to use "Apply" to do differentiation ?