MathGroup Archive 1998

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

Search the Archive

Re: Simple question



Anderson Brasil da Silva wrote:
> ... 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. My main problem is that I have no idea
> about how to create a function that takes other functions as
> parameters. Besides this problem, when I use Dt[f,{x,n}] I can get the
> derivative, but I can't get the value of this in any specific point (if
> I try something like (Dt[f,{x,n}])[0] it doesn't work).
>    Can somebody help me, please?

Anderson,
Some of the difficulty arises from having to distinguish between
functions and formulas. I hope that the following examples will help

1) with formulas:
You will need to retain the information as to which variable the
differention is with respect to:

In[1]:=
func1[expr_,{x_,n_},p_]:= D[expr,{x,n}]/.x->p

In[2]:=
func1[Sin[x+y],{x,3}, r]

Out[2]=
-Cos[r+y]

2) with functions

In[3]:=
func2[f_,n_, p_] = Derivative[n][f][p];

There are several ways to get a function from a formula:

2.1) 

In[4]:=
func2[Sin[#+y]&,3][p]

Out[4]=
-Cos[p+y]

2.2) Here the choice of the function (dummy) variable x echos the choice
of the D-variable in 1)

In[5]:=
func2[Function[x,Sin[x+y]],3][p]

Out[5]=
-Cos[p+y]

2.3) An external definition (again the function variable must be
specified)

In[6]:=
f[x_] := Sin[x+y]

In[7]:=
func2[f,3][p]

Out[7]=
-Cos[p+y]

-- 
Allan Hayes
Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642




  • Prev by Date: ListContourPlot: actual x and y values marked on the axes?
  • Next by Date: RE: Re: algebraic solutions
  • Prev by thread: RE: Simple question
  • Next by thread: are nested patterns impossible?