MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: More on functions & derivatives

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3492] Re: More on functions & derivatives
  • From: j-guyer at nwu.edu (Jon Guyer)
  • Date: Mon, 18 Mar 1996 00:56:31 -0500
  • Organization: Northwestern University, Evanston, IL
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4ibau1$fbt at ralph.vnet.net>, rich_klopp at qm.sri.com (Richard W.
Klopp) wrote:

> The following must be related to the recent thread [mg3384] substitution
> of functions in derivatives. Can someone help me understand what is going
> on?

> I try to plot its first derivative, but get errors instead.
> 
> Plot[D[f[x],x],{x,-2,2}]
> 
> General::ivar: -2. is not a valid variable.
> General::ivar: -2. is not a valid variable.
> Plot::plnr: 
>    CompiledFunction[{x}, <<1>>, -C<<9>>de-][x]
>      is not a machine-size real number at x = -2.....
> 
> I try to plot its first derivative another way, and it works as expected.
> 
> Plot[f'[x],{x,-2,2}]

There's nothing wrong with either form of the derivative. The problem is
the way substitutions are done in the plot statement. The value of "x"
that is being iterated over gets substituted

Plot[D[f[x],x],{x,-2,2}]
         ^  ^
here_____|  |
and here____|

yielding for the first iteration:

Plot[D[f[-2],-2],{x,-2,2}]
              ^
It is this____| 
which is giving you the 
"General::ivar: -2. is not a valid variable." error.

Try instead:

Plot[Evaluate[D[f[x],x]],{x,-2,2}]


There's nothing ambiguous about which "x" you mean in f'[x], so the
Evaluate[] isn't needed.

__________________________________________________________________
Jonathan E. Guyer
Dept. of Materials Science                         Zairyoo Kagakka
Northwestern University                        Noosuesutan Daigaku

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Re: Re-evaluation of Conditional expressions, wrong explanation
  • Next by Date: Re: Re-evaluation of Conditional expressions
  • Previous by thread: Re: More on functions & derivatives
  • Next by thread: Re: More on functions & derivatives