SCBPolynomial#

class SCBPolynomial(coefficients: ndarray, domain: tuple = None)#

Bases: object

Lightweight 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.Polynomial without 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:
  • coefficients (array-like) – Polynomial coefficients [a0, a1, …, an] in ascending degree order.

  • domain (tuple of float, optional) – (t0, tf) bounding the valid evaluation range. Evaluation outside this range raises ValueError.

See also

numpy.polynomial.Polynomial

Standard 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:
deg

Degree \(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.

derivative()

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:
  • t_array (np.ndarray) – Independent variable (time).

  • y_array (np.ndarray) – Dependent variable (e.g., mass values).

  • deg (int) – Degree of the polynomial to fit.

  • domain (tuple, optional) – Domain [t0, tf] for the polynomial.

Returns:

Fitted polynomial instance.

Return type:

SCBPolynomial

classmethod from_fit(t_array: ndarray, y_array: ndarray, deg: int, domain: tuple = None)#

Alias for fit().

Parameters:
  • t_array (np.ndarray) – Independent variable (time).

  • y_array (np.ndarray) – Dependent variable values to fit.

  • deg (int) – Degree of the polynomial to fit.

  • domain (tuple, optional) – Domain [t0, tf] for the polynomial.

Returns:

Fitted polynomial instance.

Return type:

SCBPolynomial

convert(domain: tuple)#

Return a copy of this polynomial with a new validity domain.

Parameters:

domain (tuple of float) – New (t0, tf) interval to enforce.

Returns:

poly – A shallow copy sharing the same coefficients but with domain replacing the original.

Return type:

SCBPolynomial

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:

SCBPolynomial

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:
  • a (float) – Lower bound of integration.

  • b (float) – Upper bound of integration.

Returns:

integral – Value of \(\int_a^b p(t)\,\mathrm{d}t\).

Return type:

float

property deg: int#

Degree \(n\) of the polynomial (number of coefficients minus one).