Plotting a function and its derivative
- To: mathgroup at smc.vnet.net
- Subject: [mg49478] Plotting a function and its derivative
- From: adrian sky <skaai at earthlink.net>
- Date: Wed, 21 Jul 2004 06:40:27 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
first of all, thanks for reading this message, i would imagine this is
a beginner level question, and sorry if this was answered previously,
im still getting the hang of proper searches in a mathematical forum.
anyways, what i'm trying to do is illustrate the simplest of
derivatives in the form of a graph but i am getting errors.
the function i'm trying to derive is x^2
its derivative i'm trying to illustrate is 2x
i would like to set up a graph which allows me to determine the
argument (be it x^2 or x^4+1), calculate its derivative, and graph them
so as to illustrate their relationship.
i know that the derivative can be graphed at any x value, and as far as
this is concerned, the value can be anything, probably a small value to
keep the graph manageable.
anyways, i'm inputting this:
f[x_] := x^2; d[x_] := ¶_x f[x]
which supposedly should assign the f(x) a value of ^2 and d(x) a value
of the derivative of f(x)
i can even type f(x) and get back the value x^2 and d(x) gives me 2x,
so it seems the system understands and assigns the requested values
but when I try to plot this with the command:
Plot[{f[x], d[x]}, {x, -5, 5}]
i get numerous errors and only get the graph of x^2
the errors are:
General::ivar: -5. is not a valid variable.
Plot::plnr: d[x] is not a machine-size real number at x =
-4.9999995833333335`
Plot::plnr: d[x] is not a machine-size real number at x =
-4.594330084270842`
and a few more similar plot errors
anyways, to simplify my question, how to i plot a function (like x^2)
and its derivative (like 2x) and apply its derivative to any part of
the function (like x=3) so as to show the tangent line which should
touch the function? i thought my way should have worked, but it seems
the d(x) is the troublesome function, since without it, i get a graph
of the function (albeit without the derivative).....
many thanks for looking this question over!
adrian sky
For a man to attain to an eminent degree in learning costs him time,
watching, hunger, nakedness, dizziness in the head, weakness in the
stomach, and other inconveniences. - Miguel De Cervantes