Re: Simple question
- To: mathgroup@smc.vnet.net
- Subject: [mg11270] Re: Simple question
- From: dwcp <dwcp@mail.nerc-essc.ac.uk>
- Date: Wed, 4 Mar 1998 01:39:26 -0500
- Organization: ESSC
- References: <6dg8ro$2vh@smc.vnet.net>
G'day, Here's an answer and some examples. The key thing is that the dummy variable f_ (or whatever) can be a function as well as something simple like a number. -David. In[12]:= cleverfunc[f_, x_, n_, p_] := D[f,{x,n}] /. x -> p In[13]:= cleverfunc[g[z], z, n, p] (n) Out[13]= g [p] In[14]:= cleverfunc[Sin[x^5]/Exp[x y], x, 2, p] 3 5 4 5 8 5 2 5 20 p Cos[p ] 10 p y Cos[p ] 25 p Sin[p ] y Sin[p ] Out[14]= ------------- - --------------- - ------------- + ---------- p y p y p y p y E E E E In[15]:= cleverfunc[Sin[x^5]/Exp[x y], x, 2, 1] 2 20 Cos[1] 10 y Cos[1] 25 Sin[1] y Sin[1] Out[15]= --------- - ----------- - --------- + --------- y y y y E E E E Anderson Brasil da Silva wrote: > I am a new user of Mathematica and I am having troubles trying to > create a function FUNC[f,n,p] that returns the value of the n-th > derivative of f in the point p. -- David Pearson, Phone: +44 (0)118 9318741 ESSC, Fax: +44 (0)118 9316413 University of Reading, Reading RG6 6AL, Email: dwcp@mail.nerc-essc.ac.uk UK.