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: [mg114506] Re: How to use "Apply" to do differentiation ?
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 5 Dec 2010 21:58:21 -0500 (EST)
  • References: <idd7ts$nja$1@smc.vnet.net>

On Dec 4, 3:16 am, Mayasky <alix.zh... at gmail.com> 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?

Apply[f, g] replaces the head of g by f.

In[1]:= Apply[ D[#, x] &, x^5 ]
Out[1]= 1

That replaced Power by Function[D[#1,x]], giving

In[2]:= Function[ D[#1, x] ][ x, 5 ]
Out[2]= 1

You need to wrap x^5 in something to give it a
head that can be replaced by Function[D[#1,x]].

In[3]:= Apply[ D[#, x] &, {x^5} ]
Out[3]= 5*x^4

In[4]:= Apply[ D[#, x] &, h[x^5] ]
Out[4]= 5*x^4


  • Prev by Date: Re: FileName Widget
  • 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 ?