scipy.misc.derivative

scipy.misc.derivative(func, x0, dx=1.0, n=1, args=(), order=3)[source]

Find the n-th derivative of a function at point x0.

Given a function, use a central difference formula with spacing dx to compute the n-th derivative at x0.

Parameters :

func : function

Input function.

x0 : float

The point at which nth derivative is found.

dx : int, optional

Spacing.

n : int, optional

Order of the derivative. Default is 1.

args : tuple, optional

Arguments

order : int, optional

Number of points to use, must be odd.

Notes

Decreasing the step size too small can result in round-off error.

Examples

>>> def x2(x):
...     return x*x
...
>>> derivative(x2, 2)
4.0

Previous topic

scipy.misc.comb

Next topic

scipy.misc.factorial