Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg114470] Re: How to use "Apply" to do differentiation ?
  • From: Chenguang Zhang <alix.zhang at gmail.com>
  • Date: Sun, 5 Dec 2010 21:51:43 -0500 (EST)

I tried different forms, the following three work:
Apply[D[#, x] &, FullForm[x^1000]]
Apply[D[#, x] &, HoldForm[x^1000]]
Apply[D[#, x] &, Hold[x^1000]]

Even the reason is clear, it is still a little unnatural to me
because Apply[D[#, x] &, x^1000] is closer to mathematical language. Anyway,
people generally use D[f[x], x] instead of the Apply command, and I tried
that command because I wanted to use Nest command to do recursive
differentiation to a function (Nest did work even Apply got me confused for
a while)

Cheers.

On Sat, Dec 4, 2010 at 9:02 AM, Achilleas Lazarides <
achilleas.lazarides at gmx.com> wrote:

> Trace does show you what happened: Apply replaces the head of its second
> argument by the first. In this case, it replaces Power in Power[x,5] by
>
> D[#, x] &
>
> (the second step in the trace). So if instead of D[#,x]& you had eg
> Print[#1,#2]&, it would have printed
> x5
> because that is what Print[x,5] does.
>
> The point is that it does not give you a message to the effect that your
> anonymous function has too many arguments in the second step in the trace;
> it just silently drops the second argument. This is what anonymous functions
> in Mathematica seem to do: silently drop extra arguments (I have no idea if
> this is good, bad, neutral, accidental etc).
>
> So basically you are evaluating
> (D[#1, x] & )[x, 5]
> which drops the second argument and differentiates x.
>
> On Dec4, 2010, at 1:16 PM, 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: Changing Graph style
  • Next by Date: Re: Cyclical Decimal Expansion
  • Previous by thread: Re: How to use "Apply" to do differentiation ?
  • Next by thread: Re: How to use "Apply" to do differentiation ?