MathGroup Archive 2005

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

Search the Archive

Re: assigning functions

Hi juergen,
see below:

juejung wrote:
> dear all,
> i would like to do the following.
> assign a function:
> f[x_] := x^2;
> take its derivate:
> D[f[x], x]
> and assign the result of this to a new function, like fprime[x]:
> fprime[x_] := D[f[x], x]

":=" tells Mathematica to delay evaluation of the derivative. If you later use 
e.g. fprime[2], Mathematica replace x by 2 in your expression giving: D[f[2], 2] 
what is wrong.
What you want is to evaluate the derivative at define-time, d.h.:
fprime[x_] = D[f[x], x]

Sincerely, Daniel
> unfortunately that doesn't work.
> when i try to evaluate fprime[2] i get an error message.
> can somebody please help, this haunts me for a while now.
> thanks and all the best
> juergen

  • Prev by Date: Re: assigning functions
  • Next by Date: Re: match 1, replace 2
  • Previous by thread: Re: assigning functions
  • Next by thread: Re: assigning functions