MathGroup Archive 2011

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

Search the Archive

Re: How to plot derivative directly?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118097] Re: How to plot derivative directly?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 12 Apr 2011 05:57:45 -0400 (EDT)

On 4/11/11 at 7:05 AM, Serych at panska.cz wrote:

>it seems to me, that response to my question shall be very simple,
>but I cannot find it. :-(

>I want to plot the derivative of the function. I would like to do it
>directly, something like:

>Plot[D[x^3 - 6 (x + 1)^2 + x - 7, x],{x,-3,8}]

>It returns: General::ivar: "-2.99978 is not a valid variable."

>I can understand that it is because local variable x from Plot
>command interferes with the x variable from the D[].

More specifically, Plot substitutes a numerical value for x
every where it appears in the expression then evaluates the
expression. The way to plot the derivative is to force
evaluation of the derivative before Plot substitutes a numerical
value for x. That is you want to do:

Plot[Evaluate[D[x^3 - 6 (x + 1)^2 + x - 7, x]], {x, -3, 8}]

And even if you could somehow get

Plot[D[x^3 - 6 (x + 1)^2 + x - 7, x],{x,-3,8}]

to work, you really wouldn't want to do that since it would mean
re-evaluating the derivative for each numerical value of x. That
would require a lot of unneeded computation.



  • Prev by Date: Re: How to plot derivative directly?
  • Next by Date: Re: How to plot derivative directly?
  • Previous by thread: Re: How to plot derivative directly?
  • Next by thread: Re: How to plot derivative directly?