numdifftools.core.fornberg_weights

numdifftools.core.fornberg_weights(x, x0, m=1)[source][source]

Return weights for finite difference approximation of the m’th derivative U^m(x0), evaluated at x0, based on n values of U at x[0], x[1],... x[n-1]:

U^m(x0) = sum weights[i] * U(x[i])
Parameters:

x : vector

abscissas used for the evaluation for the derivative at x0.

x0 : scalar

location where approximations are to be accurate

m : integer

order of derivative. Note for m=0 this can be used to evaluate the interpolating polynomial itself.

Notes

The x values can be arbitrarily spaced but must be distinct and len(x) > m.

The Fornberg algorithm is much more stable numerically than regular vandermonde systems for large values of n.