MathGroup Archive 1997

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

Search the Archive

Re: Q. How to work with derivative?

  • To: mathgroup at
  • Subject: [mg6674] Re: [mg6615] Q. How to work with derivative?
  • From: jpk at
  • Date: Wed, 9 Apr 1997 09:15:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

> If any one has any experience with the following, could you please
> help?
> Suppose I have a function f[x], say f[x]=x^3. Then I want to calculate
> the derivative of say Log[f[x]] and evaluate it at some point, say x=3.
> I try:
> --------------------------------------
> Clear[f,s];
> f[x_]:=x^3;
> s[x_]:=D[Log[f[x]],x];
> s[3]
> General::"ivar": "\!\(3\) is not a valid variable."
> Out[47]=
> \!\(\[PartialD]\_3 Log[27]\)
--- schnip snapp schnip snap ----
> and get the result, but I need a _function_ (which I can later
> plot for instanse). What is the possible way to do it along the lines
> of my first approach?
> Thank you for all suggestions,
> Yaroslaw.

Hi Yaroslaw,

here is what You want:

         D[f[xx],xx] /. xx->x
This reflects the usual mathematical notation

d f     |
--- (x) |
d x     | x=3

because when You build the derivative the variable x is not assigned
to a value. As a pure function the

fun=Block[{x},Evaluate[D[f[x],x]] /. x->#] &

version works.

In general it is more serious to pass f[x] as a parameter instead of
use a global variable.

Hope that helps


  • Prev by Date: Re: Mathematica Functions
  • Next by Date: Suggestions on graphics references?
  • Previous by thread: Re: Q. How to work with derivative?
  • Next by thread: Re: Q. How to work with derivative?