SciPy

scipy.interpolate.piecewise_polynomial_interpolate

scipy.interpolate.piecewise_polynomial_interpolate(xi, yi, x, orders=None, der=0, axis=0)[source]

Convenience function for piecewise polynomial interpolation.

Parameters:

xi : array_like

A sorted list of x-coordinates.

yi : list of lists

yi[i] is the list of derivatives known at xi[i].

x : scalar or array_like

Coordinates at which to evalualte the polynomial.

orders : int or list of ints, optional

A list of polynomial orders, or a single universal order.

der : int or list

How many derivatives to extract; None for all potentially nonzero derivatives (that is a number equal to the number of points), or a list of derivatives to extract. This number includes the function value as 0th derivative.

axis : int, optional

Axis in the yi array corresponding to the x-coordinate values.

Returns:

y : ndarray

Interpolated values or derivatives. If multiple derivatives were requested, these are given along the first axis.

Notes

If orders is None, or orders[i] is None, then the degree of the polynomial segment is exactly the degree required to match all i available derivatives at both endpoints. If orders[i] is not None, then some derivatives will be ignored. The code will try to use an equal number of derivatives from each end; if the total number of derivatives needed is odd, it will prefer the rightmost endpoint. If not enough derivatives are available, an exception is raised.

Construction of these piecewise polynomials can be an expensive process; if you repeatedly evaluate the same polynomial, consider using the class PiecewisePolynomial (which is what this function does).