From: Peter Breitfeld on

Plot[f[x],{x,0,5}] has the Attribute HoldAll. This means here, that to
generate the plot Mathematica first chooses numbers for x e.g. x=0,
x=0.5,... and calculates f[0], f[0.5],...

In your case it tries to calculate the D[0^2,0] which is nonsense, so
you get warnings and not plot drawn. To force the calculation of the
derivative you should use Evaluate:

Plot[D[myFunction[x],x]//Evaluate,{x,0,5}]

which will work. It is stated in the documentation of Plot "More Information".

Andrew DeYoung wrote:

> Hi,
>
> It seems like Mathematica has difficulty plotting calls to other
> functions. Is this true? For example, can you help me understand why
> the following does not plot?
>
> If I write
>
> myFunction[x_] := x^2;
> Plot[D[myFunction[x], x], {x, 0, 5}]
>
> nothing plots.
>
> If I write
>
> myFunction[x_] := x^2;
> Plot[D[myFunction[x][x], x], {x, 0, 5}]
>
> again, nothing plots.
>
> However, if I compute the derivative of the function outside of the
> Plot command,
>
> myFunction[x_] := x^2;
> myDerivative = D[myFunction[x], x]
> Plot[myDerivative, {x, 0, 5}]
>
> the derivative of x^2 (i.e., 2x) plots correctly.
>
> Can anyone please help me understand why my first two tries do not
> work, but my third try does?
>
> Many thanks in advance.
>
> Andrew DeYoung
> Carnegie Mellon University
> adeyoung(a)andrew.cmu.edu
>

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

From: Andrew DeYoung on
Hi, all,

Thank you so very much to all for all your help, and your generosity
with your time! All these posts help me very much to understand the
concepts. Many thanks to all.

Andrew DeYoung
Carnegie Mellon University
adeyoung(a)andrew.cmu.edu

First  |  Prev  | 
Pages: 1 2
Prev: Exporting into PowerPoint
Next: StringForm v.s Row