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:
- coefficientsarray-like
Polynomial coefficients
[a0, a1, …, an]in ascending degree order.- domaintuple of float, optional
(t0, tf)bounding the valid evaluation range. Evaluation outside this range raisesValueError.
- 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]\).
See also
numpy.polynomial.PolynomialStandard NumPy polynomial (autograd-incompatible).
References
[1]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.
- classmethod fit(t_array: ndarray, y_array: ndarray, deg: int, domain: tuple = None)#
Fit a polynomial of degree deg to the given data.
- Parameters:
- t_arraynp.ndarray
Independent variable (time).
- y_arraynp.ndarray
Dependent variable (e.g., mass values).
- degint
Degree of the polynomial to fit.
- domaintuple, optional
Domain [t0, tf] for the polynomial.
- Returns:
- SCBPolynomial
Fitted polynomial instance.
- classmethod from_fit(t_array: ndarray, y_array: ndarray, deg: int, domain: tuple = None)#
Alias for
fit().- Parameters:
- t_arraynp.ndarray
Independent variable (time).
- y_arraynp.ndarray
Dependent variable values to fit.
- degint
Degree of the polynomial to fit.
- domaintuple, optional
Domain
[t0, tf]for the polynomial.
- Returns:
- SCBPolynomial
Fitted polynomial instance.
- convert(domain: tuple)#
Return a copy of this polynomial with a new validity domain.
- Parameters:
- domaintuple of float
New
(t0, tf)interval to enforce.
- Returns:
- polySCBPolynomial
A shallow copy sharing the same coefficients but with domain replacing the original.
- 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:
- dpolySCBPolynomial
Degree-\((n-1)\) polynomial representing \(p'(t)\), inheriting the same domain.
- integrate(a: float, b: float) float#
Compute the definite integral of \(p(t)\) over \([a, b]\).
Constructs the antiderivative
\[P(t) = \sum_{k=0}^{n} \frac{a_k}{k+1}\,t^{k+1}\]and returns \(P(b) - P(a)\).
- Parameters:
- afloat
Lower bound of integration.
- bfloat
Upper bound of integration.
- Returns:
- integralfloat
Value of \(\int_a^b p(t)\,\mathrm{d}t\).