Re: How to plot derivative directly?
- To: mathgroup at smc.vnet.net
- Subject: [mg118081] Re: How to plot derivative directly?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Tue, 12 Apr 2011 05:54:51 -0400 (EDT)
The trouble, as you probably realize, is that when Plot feeds in a value
of x to its first argument, you are now trying to take the derivative of
a constant with respect to a constant.
Another way to do it is:
f[x_]:= x^3 - 6 (x + 1)^2 + x - 7
Plot[f'[x],{x,-3,8}]
Or, perhaps a bit better f the function is much more complicated:
Plot[Evaluate[f'[x],{x,-3,8}]
On 4/11/2011 7:05 AM, =8Aer=FDch Jakub wrote:
> Dear mathgroup,
>
> 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[].
>
> Yes I can bypass the problem by:
> deriv = D[x^3 - 6 (x + 1)^2 + x - 7, x]
> Plot[deriv, {x, -3, 8}]
>
> which is fully functional, but as far as I know Mathematica, there must
> be some simple solution how to do it directly inside the Plot[].
>
> Thanks in advance for kick-off
>
> Jakub
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305