Dr. T. L. Marchioro II wrote:
>
> Robert Knapp wrote:
> > Mark James wrote:
> > >
> > > Does anyone know of a function that calculates the derivative of
> > > a function (that can't be differentiated symbolically) at a given
> > > point by numerical means? I can't find it as a built-in or in the
> > > standard packages. Thanks.
> >
> > The function ND in the package NumericalMath`NLimit does this.
> >
> > I mention in passing that numerical derivatives will be computed
> > automatically in the next release of Mathematica.
>
> Really? By what method? Where will they be well defined? That is, if
> you have a discrete data stream will be the derivatives be accurate at
> the same points you know the data, or at the midpoints between the data,
> or somewhere else? To what order will be the derivatives be accurately
> calculable?
>
> Inquiring minds and all that :)
>
Heres an example(from Mathematica 3.0 beta 2)
In[1]:= f[x_?NumberQ,t_?NumberQ] :=NDSolve[{y'[s] == x y[s],y[0] ==
1},y,{s,0,t}][[1,1,2]][t]
In[2]:= Derivative[1,0][f][x,t]
(1,0)
Out[2]= f [x, t]
In[3]:= Derivative[1,0][f][1,1]
(1,0)
Out[3]= f [1, 1]
not done since it is exact
In[4]:= Derivative[1,0][f][1.,1.]
Out[4]= 2.71828
This is calculated to machine precision. If your function was defined
such that it could be calculated to higher precision, the derivative
routine would attempt to calculate to the precision of the arguments.
It works using high order finite differences. There is not a limit to
the order derivative it uses since the wieghts are generated on
calculation, however, high order derivatives can take excessively
long.
Also, mixed partials are not computed since error detection is much
more difficult.
Rob
--
Rob Knapp
Wolfram Research, Inc.
http://www.wri.com/~rknapp
==== [MESSAGE SEPARATOR] ====