Skip to main content

Crate use_polynomial

Crate use_polynomial 

Source
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.

Rust 1.95.0+ Edition 2024 Polynomial primitives License MIT or Apache-2.0

§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

CrateResponsibility
use-polynomialPolynomial representation and direct polynomial operations
use-equationEquation-solving workflows built on polynomial expressions
use-numericalIterative numerical methods and higher-degree root finding
use-calculusCalculus concepts and function-based derivative workflows
use-complexComplex numbers and complex roots
use-algebraAlgebraic structures and law checking
use-realReal-number wrappers and real-specific policy
use-optimizationOptimization 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.