Re: How to use "Apply" to do differentiation ?
- To: mathgroup at smc.vnet.net
- Subject: [mg114510] Re: How to use "Apply" to do differentiation ?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sun, 5 Dec 2010 21:59:05 -0500 (EST)
- References: <firstname.lastname@example.org>
Hi, > 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. I think your expectation of what Apply does is fooling you. Apply is doing what it is supposed: it replaces the Head Power in Power[x,5] with Function[D[#,x]], and since # is #1 will evaluate D[x,x], not even looking at the second argument. > Finally I have to take a detour and use: > Nest[D[#, x] &, x^5, 1] You could also just have done: (D[#, x] &)[x^5] > I have been using Mathematica for several years and > never found that. I myself is wordless, but can anyone > explain that? hth, albert