[SciPy-user] Derivative() usage?
Robert Kern
rkern at ucsd.edu
Thu Oct 21 12:15:03 CDT 2004
Francesc Alted wrote:
> Hi,
>
> I'm trying to figure out how to compute the derivatives of a function with
> scipy, but the documentation is a bit terse for me:
>
> def derivative(func,x0,dx=1.0,n=1,args=(),order=3):
> """Given a function, use an N-point central differenece
> formula with spacing dx to compute the nth derivative at
> x0, where N is the value of order and must be odd.
>
> Warning: Decreasing the step size too small can result in
> round-off error.
> """
>
> I would like to compute a derivative of an arbitrary order, but by reading
> the docs, I'm not sure what the n and order parameters exactly means.
>
> Someone smarter than me can help me?
'n' as in d^n/dx^n .
Somewhat confusingly, 'N' is being used in the docstring as a synonym
for 'order' and is the number of discrete points used to evaluate the
numerical derivative. I'm going to fix that.
For example, when n=2, and order=3, one is computing the second central
derivative using 3 points [x0-dx, x0, x0+dx].
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the SciPy-user
mailing list