SCBPolynomial#
- class SCBPolynomial(coefficients: ndarray, domain: tuple = None)#
Bases:
objectLightweight polynomial wrapper for time-varying scalar profiles.
Stores coefficients in ascending order (lowest to highest degree) and optionally enforces a validity domain \([t_0, t_f]\). Designed as a drop-in replacement for
numpy.polynomial.Polynomialwithout its autograd incompatibilities.Given coefficients \([a_0, a_1, \ldots, a_n]\), the polynomial is
\[p(t) = a_0 + a_1\,t + a_2\,t^2 + \cdots + a_n\,t^n = \sum_{k=0}^{n} a_k\,t^k\]- Parameters:
See also
numpy.polynomial.PolynomialStandard NumPy polynomial (autograd-incompatible).
References
Press, W. H.; Teukolsky, S. A.; Vetterling, W. T.; Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press. ISBN 978-0521880688.
- Attributes:
degDegree \(n\) of the polynomial (number of coefficients minus one).
Methods
__call__(t)Evaluate \(p(t) = \sum_{k=0}^{n} a_k\,t^k\).
convert(domain)Return a copy of this polynomial with a new validity domain.
Return the first derivative \(p'(t)\) as a new polynomial.
fit(t_array, y_array, deg[, domain])Fit a polynomial of degree deg to the given data.
from_fit(t_array, y_array, deg[, domain])Alias for
fit().integrate(a, b)Compute the definite integral of \(p(t)\) over \([a, b]\).
- classmethod fit(t_array: ndarray, y_array: ndarray, deg: int, domain: tuple = None)#
Fit a polynomial of degree deg to the given data.
- Parameters:
- Returns:
Fitted polynomial instance.
- Return type:
- classmethod from_fit(t_array: ndarray, y_array: ndarray, deg: int, domain: tuple = None)#
Alias for
fit().- Parameters:
- Returns:
Fitted polynomial instance.
- Return type:
- convert(domain: tuple)#
Return a copy of this polynomial with a new validity domain.
- Parameters:
- Returns:
poly – A shallow copy sharing the same coefficients but with domain replacing the original.
- Return type:
- derivative()#
Return the first derivative \(p'(t)\) as a new polynomial.
Applies the power rule coefficient-wise:
\[p'(t) = a_1 + 2\,a_2\,t + \cdots + n\,a_n\,t^{n-1} = \sum_{k=1}^{n} k\,a_k\,t^{k-1}\]- Returns:
dpoly – Degree-\((n-1)\) polynomial representing \(p'(t)\), inheriting the same domain.
- Return type: