scipy.interpolate.BPoly.from_derivatives¶

classmethod
BPoly.
from_derivatives
(xi, yi, orders=None, extrapolate=None)[source]¶ Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints.
Parameters:  xi : array_like
sorted 1D array of xcoordinates
 yi : array_like or list of array_likes
yi[i][j]
is thej
th derivative known atxi[i]
 orders : None or int or array_like of ints. Default: None.
Specifies the degree of local polynomials. If not None, some derivatives are ignored.
 extrapolate : bool or ‘periodic’, optional
If bool, determines whether to extrapolate to outofbounds points based on first and last intervals, or to return NaNs. If ‘periodic’, periodic extrapolation is used. Default is True.
Notes
If
k
derivatives are specified at a breakpointx
, the constructed polynomial is exactlyk
times continuously differentiable atx
, unless theorder
is provided explicitly. In the latter case, the smoothness of the polynomial at the breakpoint is controlled by theorder
.Deduces the number of derivatives to match at each end from
order
and the number of derivatives available. If possible it uses the same number of derivatives from each end; if the number is odd it tries to take the extra one from y2. In any case if not enough derivatives are available at one end or another it draws enough to make up the total from the other end.If the order is too high and not enough derivatives are available, an exception is raised.
Examples
>>> from scipy.interpolate import BPoly >>> BPoly.from_derivatives([0, 1], [[1, 2], [3, 4]])
Creates a polynomial f(x) of degree 3, defined on [0, 1] such that f(0) = 1, df/dx(0) = 2, f(1) = 3, df/dx(1) = 4
>>> BPoly.from_derivatives([0, 1, 2], [[0, 1], [0], [2]])
Creates a piecewise polynomial f(x), such that f(0) = f(1) = 0, f(2) = 2, and df/dx(0) = 1. Based on the number of derivatives provided, the order of the local polynomials is 2 on [0, 1] and 1 on [1, 2]. Notice that no restriction is imposed on the derivatives at x = 1 and x = 2.
Indeed, the explicit form of the polynomial is:
f(x) =  x * (1  x), 0 <= x < 1  2 * (x  1), 1 <= x <= 2
So that f’(10) = 1 and f’(1+0) = 2