MathGroup Archive 2005

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

Search the Archive

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
> 
>


  • Prev by Date: Re: match 1, replace 2
  • Next by Date: Re: (x-y) DiracDelta[x-y] does not simplify to 0
  • Previous by thread: Re: assigning functions
  • Next by thread: Re: Integrate is driving me crazy, please help!