A scalar multi-variate polynomial, modeled after the msspoly in spotless.
Polynomial represents a list of additive Monomials, each one of which is a product of a constant coefficient (of T, which by default is double) and any number of distinct Terms (variables raised to positive integer powers).
Variables are identified by integer indices rather than symbolic names, but an automatic facility is provided to covert variable names up to four characters into unique integers, provided those variables are named using only lowercase letters and the “#_.” characters followed by a number. For example, valid names include “dx4” and “m_x”.
Monomials which have the same variables and powers may be constructed but will be automatically combined: (3 * a * b * a) + (1.5 * b * a**2) will be reduced to (4.5 * b * a**2) internally after construction.
Polynomials can be added, subtracted, and multiplied. They may only be divided by scalars (of T) because Polynomials are not closed under division.
- __init__(self: pydrake.polynomial.Polynomial) -> None
Construct the vacuous polynomial, “0”.
- __init__(self: pydrake.polynomial.Polynomial, arg0: float) -> None
Construct a Polynomial of a single constant. e.g. “5”.
- __init__(self: pydrake.polynomial.Polynomial, arg0: numpy.ndarray[float64[m, 1]]) -> None
A legacy constructor for univariate polynomials: Takes a vector of coefficients for the constant, x, x**2, x**3… Monomials.
CoefficientsAlmostEqual(self: pydrake.polynomial.Polynomial, other: pydrake.polynomial.Polynomial, tol: float = 0.0, tol_type: pydrake.common._module_py.ToleranceType = ToleranceType.absolute) → bool¶
Checks if a Polynomial is approximately equal to this one.
Checks that every coefficient of
tolof the corresponding coefficient of this Polynomial.
tol_typeis kRelative, if any monomials appear in
otherbut not both, then the method returns false (since the comparison is relative to a missing zero coefficient). Use kAbsolute if you want to ignore non-matching monomials with coefficients less than
Derivative(self: pydrake.polynomial.Polynomial, derivative_order: int = 1) → pydrake.polynomial.Polynomial¶
Takes the derivative of this (univariate) Polynomial.
Returns a new Polynomial that is the derivative of this one in its sole variable.
Raises: RuntimeError if this Polynomial is not univariate.
If derivative_order is given, takes the nth derivative of this Polynomial.
GetCoefficients(self: pydrake.polynomial.Polynomial) → numpy.ndarray[float64[m, 1]]¶
GetDegree(self: pydrake.polynomial.Polynomial) → int¶
Returns the highest degree of any Monomial in this Polynomial.
The degree of a multivariate Monomial is the product of the degrees of each of its terms.
GetNumberOfCoefficients(self: pydrake.polynomial.Polynomial) → int¶
Returns the number of unique Monomials (and thus the number of coefficients) in this Polynomial.
Integral(self: pydrake.polynomial.Polynomial, integration_constant: float = 0.0) → pydrake.polynomial.Polynomial¶
Takes the integral of this (univariate, non-constant) Polynomial.
Returns a new Polynomial that is the indefinite integral of this one in its sole variable.
- RuntimeError if this Polynomial is not univariate, or if it has no
If integration_constant is given, adds that constant as the constant term (zeroth-order coefficient) of the resulting Polynomial.
IsAffine(self: pydrake.polynomial.Polynomial) → bool¶
Returns true iff this is a sum of terms of degree 1, plus a constant.
IsApprox(self: pydrake.polynomial.Polynomial, other: pydrake.polynomial.Polynomial, tol: float) → bool¶