scipy.interpolate.approximate_taylor_polynomial(f, x, degree, scale, order=None)

Estimate the Taylor polynomial of f at x by polynomial fitting

A polynomial Parameters ———- f : callable

The function whose Taylor polynomial is sought. Should accept a vector of x values.
x : scalar
The point at which the polynomial is to be evaluated.
degree : integer
The degree of the Taylor polynomial
scale : scalar
The width of the interval to use to evaluate the Taylor polynomial. Function values spread over a range this wide are used to fit the polynomial. Must be chosen carefully.
order : integer or None
The order of the polynomial to be used in the fitting; f will be evaluated order+1 times. If None, use degree.

p : poly1d

the Taylor polynomial (translated to the origin, so that for example p(0)=f(x)).


The appropriate choice of “scale” is a tradeoff - too large and the function differs from its Taylor polynomial too much to get a good answer, too small and roundoff errors overwhelm the higher-order terms. The algorithm used becomes numerically unstable around order 30 even under ideal circumstances.

Choosing order somewhat larger than degree may improve the higher-order terms.

Previous topic


Next topic

Input and output (

This Page

Quick search