bundles / scipy 1.17.1 / scipy / interpolate / _fitpack_py / sproot
function
scipy.interpolate._fitpack_py:sproot
Signature
def sproot ( tck , mest = 10 ) Summary
Find the roots of a cubic B-spline.
Extended Summary
Given the knots (>=8) and coefficients of a cubic B-spline return the roots of the spline.
Parameters
tck: tuple or a BSpline objectIf a tuple, then it should be a sequence of length 3, containing the vector of knots, the B-spline coefficients, and the degree of the spline. The number of knots must be >= 8, and the degree must be 3. The knots must be a montonically increasing sequence.
mest: int, optionalAn estimate of the number of zeros (Default is 10).
Returns
zeros: ndarrayAn array giving the roots of the spline.
Notes
Manipulating the tck-tuples directly is not recommended. In new code, prefer using the BSpline objects.
Array API Standard Support
sproot is not in-scope for support of Python Array API Standard compatible backends other than NumPy.
See dev-arrayapi for more information.
Examples
For some data, this method may miss a root. This happens when one of the spline knots (which FITPACK places automatically) happens to coincide with the true root. A workaround is to convert to `PPoly`, which uses a different root-finding algorithm. For example,x = [1.96, 1.97, 1.98, 1.99, 2.00, 2.01, 2.02, 2.03, 2.04, 2.05] y = [-6.365470e-03, -4.790580e-03, -3.204320e-03, -1.607270e-03, 4.440892e-16, 1.616930e-03, 3.243000e-03, 4.877670e-03, 6.520430e-03, 8.170770e-03] from scipy.interpolate import splrep, sproot, PPoly tck = splrep(x, y, s=0) sproot(tck)✓
ppoly = PPoly.from_spline(tck) ppoly.roots(extrapolate=False)✓
See also
Aliases
-
scipy.interpolate.sproot