Re: Numerical Differentiation
- To: mathgroup at smc.vnet.net
- Subject: [mg4347] Re: Numerical Differentiation
- From: rdieter at mathlab44.unl.edu (Rex Dieter)
- Date: Thu, 11 Jul 1996 01:00:22 -0400
- Organization: University of Nebraska--Lincoln
- Sender: owner-wri-mathgroup at wolfram.com
In article <4qirpi$3cq at dragonfly.wolfram.com> sfpse at u.washington.edu (Russell
Brunelle) writes:
> I have needed to perform numerical differentiation as well. The following
> function, which finds the derivative with respect to f[t] at point t0 is
> the best I could do.
>
> ND[f_, t_, t0_, prec_:$MachinePrecision] :=
> With[{h=1/(2 10^(prec-6)), t0p=SetPrecision[t0,prec]},
> N[((f /. t->(t0p+h)) - (f /. t->(t0p=h)))/(2 h), prec]]
No need to write your own, it already exists in stock Mathematica in the
NLimit package:
In[1]:= Needs["NumericalMath`NLimit`"]
In[2]:= ?ND
ND[expr, x, x0] gives a numerical approximation to the derivative of expr
with respect to x at the point x0. ND[expr, {x, n}, x0] gives a
numerical approximation to the n-th derivative of expr with respect to x
at the point x0. ND attempts to evaluate expr at x0. If this fails, ND
fails.
--
Rex Dieter
Computer System Manager
Department of Mathematics and Statistics
University of Nebraska Lincoln
==== [MESSAGE SEPARATOR] ====