pub struct Polynomial { /* private fields */ }Expand description
A real polynomial a[0] + a[1] x + ... + a[n] x^n with finite
coefficients.
Implementations§
Source§impl Polynomial
impl Polynomial
Sourcepub fn new(coefficients: &[f64]) -> NumericResult<Self>
pub fn new(coefficients: &[f64]) -> NumericResult<Self>
A polynomial from coefficients in ascending order of power. Trailing zero coefficients are dropped.
§Errors
Refuses a non-finite coefficient.
Sourcepub fn from_roots(roots: &[f64]) -> NumericResult<Self>
pub fn from_roots(roots: &[f64]) -> NumericResult<Self>
(x - r_0)(x - r_1)..., expanded. A convenience for building test
and reference polynomials.
§Errors
Refuses a non-finite root or an expansion that overflows.
Sourcepub fn coefficients(&self) -> &[f64]
pub fn coefficients(&self) -> &[f64]
Coefficients in ascending order of power, without trailing zeros.
Sourcepub fn evaluate_with_bound(&self, x: f64) -> (f64, f64)
pub fn evaluate_with_bound(&self, x: f64) -> (f64, f64)
p(x) and a rigorous bound on the rounding error of that value.
The bound is gamma(2n + 1) * sum |a_i| |x|^i plus an underflow
allowance, where gamma(k) = k u / (1 - k u).
Sourcepub fn derivative(&self) -> Polynomial
pub fn derivative(&self) -> Polynomial
The derivative.
Sourcepub fn real_roots(
&self,
lower: f64,
upper: f64,
) -> NumericResult<Vec<PolynomialRoot>>
pub fn real_roots( &self, lower: f64, upper: f64, ) -> NumericResult<Vec<PolynomialRoot>>
Every real root in [lower, upper], in increasing order.
Each entry is either one certified RootKind::Simple root with an
enclosure, or an RootKind::Unresolved region with the most
roots it can hold. No root of the polynomial in the interval is left
out: a root not reported as simple lies in an unresolved region.
§Errors
Refuses non-finite bounds, lower > upper, and the zero polynomial
(NumericError::ZeroPolynomial).