Re: assigning functions
- To: mathgroup at smc.vnet.net
- Subject: [mg56223] Re: [mg56204] assigning functions
- From: yehuda ben-shimol <bsyehuda at gmail.com>
- Date: Wed, 20 Apr 2005 05:29:53 -0400 (EDT)
- References: <200504190855.EAA02540@smc.vnet.net>
- Reply-to: yehuda ben-shimol <bsyehuda at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
All you need is to assign the value of x AFTER applying the function,
so do as follows
fprime[x]/.x->2
Or define the function differently
such as
fprime1[f_,x_]:=Module[{y},D[f[y],y]/.y->x]
and then call it with
fprime1[f,2] and get the desired results.
Please note that I modified fprime1 a little bit so it would be more
general and can be applied for other functions and not only on the
globally defined f[x_]:=x^2 as you did
good luck
yehuda
On 4/19/05, juejung <juejung at indiana.edu> 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]
>
> 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
>
>
- References:
- assigning functions
- From: juejung <juejung@indiana.edu>
- assigning functions