Expand description
§use-polynomial
Small polynomial primitives and operations for RustUse.
Concrete coefficient-based polynomials with evaluation, derivatives, arithmetic, and simple real root helpers for low-degree cases.
§Install
[dependencies]
use-polynomial = "0.0.5"§What belongs here
use-polynomial owns concrete polynomial representation and direct polynomial
operations over f64 coefficients. It provides construction, degree handling,
evaluation, derivatives, integrals, arithmetic, and small real-root helpers for
degree 1 and 2 workflows.
Coefficient ordering is explicit: coefficients[i] is the coefficient for
x^i, so 3 + 2x + x^2 is stored as vec![3.0, 2.0, 1.0].
The zero polynomial is represented as an empty coefficient vector. That keeps
degree() and leading_coefficient() explicit by returning None for the zero
polynomial.
§Neighboring crates
| Crate | Responsibility |
|---|---|
use-polynomial | Polynomial representation and direct polynomial operations |
use-equation | Equation-solving workflows built on polynomial expressions |
use-numerical | Iterative numerical methods and higher-degree root finding |
use-calculus | Calculus concepts and function-based derivative workflows |
use-complex | Complex numbers and complex roots |
use-algebra | Algebraic structures and law checking |
use-real | Real-number wrappers and real-specific policy |
use-optimization | Optimization routines that may consume polynomial models |
use-polynomial intentionally does not define symbolic algebra,
interpolation frameworks, arbitrary-precision arithmetic, or complex roots in
v1.
§Examples
§Construct, inspect, and evaluate
use use_polynomial::Polynomial;
let p = Polynomial::new(vec![3.0, 2.0, 1.0]);
assert_eq!(p.degree(), Some(2));
assert_eq!(p.evaluate(2.0), 11.0);§Differentiate a polynomial
use use_polynomial::Polynomial;
let p = Polynomial::new(vec![3.0, 2.0, 1.0]);
let derivative = p.derivative();
assert_eq!(derivative.coefficients(), &[2.0, 2.0]);§Solve a quadratic with real roots
use use_polynomial::quadratic_roots;
let roots = quadratic_roots(1.0, -3.0, 2.0);
assert_eq!(roots, vec![1.0, 2.0]);§Status
use-polynomial is a concrete pre-1.0 crate in the RustUse math workspace.
The API stays small and explicit so adjacent equation, numerical, calculus,
algebra, complex, geometry, real-number, and optimization crates can build on a
single focused polynomial surface.
Small polynomial primitives and operations for RustUse.
Modules§
- polynomial
- Polynomial primitives and direct operations.
- roots
- Small real-root helpers for low-degree polynomials.
Structs§
- Polynomial
- A polynomial whose coefficients are stored in ascending power order.
Functions§
- linear_
root - Returns the real root of
ax + b = 0. - quadratic_
roots - Returns the real roots of
ax^2 + bx + c = 0.