Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1622
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to plot derivative directly? |
| Date | 2011-04-12 09:56 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <io17jo$i8r$1@smc.vnet.net> (permalink) |
On 4/11/11 at 7:05 AM, Serych@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.
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How to plot derivative directly? Bill Rowe <readnews@sbcglobal.net> - 2011-04-12 09:56 +0000
csiph-web