Skip to main content

Crate use_equation

Crate use_equation 

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

Rust 1.95.0+ Edition 2024 Equation solving License MIT or Apache-2.0

§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 2x2 linear 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

CrateResponsibility
use-equationDirect equation-solving helpers, result enums, and solving traits
use-polynomialPolynomial representation and direct polynomial operations
use-linearHigher-level linear algebra workflows and typed matrix-driven solves
use-matrixMatrix primitives
use-vectorVector primitives
use-calculusCalculus workflows and derivative or integral helpers
use-optimizationOptimization routines that may consume equation models
use-complexComplex numbers and complex roots
use-numericalIterative 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 2x2 linear-system helpers.

Structs§

LinearEquation
A linear equation of the form ax + b = 0.
LinearSystem2
A 2x2 linear system of the form:
QuadraticEquation
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§

RootSolver
Shared trait for equation types that can solve themselves.

Functions§

solve_2x2
Solves a 2x2 linear 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 = 0 over the real numbers.