Expand description
§use-equation
Small equation-solving primitives for RustUse.
Focused helpers for explicit linear equations, quadratic equations, small 2x2 systems, and reusable root-solving traits.
§Install
[dependencies]
use-equation = "0.0.6"Optional low-degree polynomial bridging:
[dependencies]
use-equation = { version = "0.0.6", features = ["polynomial"] }§What belongs here
use-equation owns small, explicit equation-solving primitives over f64.
It provides direct helpers for:
- linear equations of the form
ax + b = 0 - quadratic equations of the form
ax^2 + bx + c = 0 - small
2x2linear systems - reusable solving traits and equation wrapper structs
The crate stays intentionally small. It does not add symbolic algebra, arbitrary-precision arithmetic, iterative numerical methods, complex roots, or large linear system solvers in v1.
§Neighboring crates
| Crate | Responsibility |
|---|---|
use-equation | Direct equation-solving helpers, result enums, and solving traits |
use-polynomial | Polynomial representation and direct polynomial operations |
use-linear | Higher-level linear algebra workflows and typed matrix-driven solves |
use-matrix | Matrix primitives |
use-vector | Vector primitives |
use-calculus | Calculus workflows and derivative or integral helpers |
use-optimization | Optimization routines that may consume equation models |
use-complex | Complex numbers and complex roots |
use-numerical | Iterative numerical root-finding methods |
§Examples
§Solve a linear equation
use use_equation::{Roots, solve_linear};
assert_eq!(solve_linear(2.0, -4.0), Roots::One(2.0));§Solve a quadratic equation
use use_equation::{Roots, solve_quadratic};
assert_eq!(solve_quadratic(1.0, -3.0, 2.0), Roots::Two(1.0, 2.0));§Solve a 2x2 system
use use_equation::solve_2x2;
let solution = solve_2x2(
2.0, 1.0, 5.0,
1.0, -1.0, 1.0,
);
assert_eq!(solution, Some((2.0, 1.0)));§Use the RootSolver trait
use use_equation::{LinearEquation, RootSolver, Roots};
let equation = LinearEquation::new(2.0, -4.0);
assert_eq!(equation.solve(), Roots::One(2.0));§Status
use-equation is a concrete pre-1.0 crate in the RustUse math workspace. It
keeps equation solving explicit and reusable so neighboring polynomial,
numerical, linear algebra, simulation, optimization, and physics crates can
build on a small shared surface.
Small equation-solving primitives for RustUse.
Modules§
- linear
- Linear equation helpers for equations of the form
ax + b = 0. - polynomial
- Low-degree polynomial bridge helpers.
- quadratic
- Quadratic equation helpers for equations of the form
ax^2 + bx + c = 0. - root
- Root result values and shared solving traits.
- system
- Small
2x2linear-system helpers.
Structs§
- Linear
Equation - A linear equation of the form
ax + b = 0. - Linear
System2 - A
2x2linear system of the form: - Quadratic
Equation - A quadratic equation of the form
ax^2 + bx + c = 0.
Enums§
- Roots
- Real-root outcomes for the small equation helpers in this crate.
Traits§
- Root
Solver - Shared trait for equation types that can solve themselves.
Functions§
- solve_
2x2 - Solves a
2x2linear system with Cramer’s rule. - solve_
linear - Solves the linear equation
ax + b = 0. - solve_
polynomial_ degree_ 1_ or_ 2 - Solves a polynomial when its degree is 0, 1, or 2.
- solve_
quadratic - Solves the quadratic equation
ax^2 + bx + c = 0over the real numbers.