Expand description
§use-numerical
Small approximate numerical helpers for RustUse.
Focused helpers for floating-point comparison, finite differences, numerical integration, and iterative root finding.
§Install
[dependencies]
use-numerical = "0.0.6"Optional bounded-interval bridge support:
[dependencies]
use-numerical = { version = "0.0.6", features = ["interval"] }§What belongs here
use-numerical owns small, explicit helpers for approximate numerical work
over f64. It provides:
- tolerance-based floating-point comparison
- first-derivative finite difference helpers
- deterministic numerical integration rules
- iterative root-finding helpers and error types
This crate is intentionally about approximation-oriented methods only. It does not add exact algebraic solvers, symbolic differentiation, symbolic integration, polynomial-specific APIs, matrix solving, or optimization workflows.
§Neighboring crates
| Crate | Responsibility |
|---|---|
use-numerical | Approximate numerical methods, tolerances, and iterative solvers |
use-equation | Exact small equation helpers such as linear and quadratic formulas |
use-polynomial | Polynomial structs, evaluation, derivatives, and direct operations |
use-calculus | Calculus concepts and higher-level derivative or integral workflows |
use-optimization | Optimization algorithms and optimization workflows |
use-real | Real-number abstractions and validation policy |
use-linear | Matrix and vector driven linear-system solving |
§Examples
§Compare floating-point values with an epsilon
use use_numerical::approx_eq;
assert!(approx_eq(0.1 + 0.2, 0.3, 1e-12));§Approximate a derivative with a central difference
use use_numerical::central_difference;
let derivative = central_difference(|x| x * x, 3.0, 1e-6);
assert!((derivative - 6.0).abs() < 1e-5);§Integrate numerically with the trapezoidal rule
use use_numerical::trapezoidal_rule;
let area = trapezoidal_rule(|x| x * x, 0.0, 1.0, 1_000).unwrap();
assert!((area - 1.0 / 3.0).abs() < 1e-3);§Find a root with bisection
use use_numerical::{RootOptions, bisection};
let root = bisection(
|x| x * x - 2.0,
1.0,
2.0,
RootOptions::default(),
)
.unwrap();
assert!((root - 2.0_f64.sqrt()).abs() < 1e-8);§Find a root with Newton-Raphson
use use_numerical::{RootOptions, newton_raphson};
let root = newton_raphson(
|x| x * x - 2.0,
|x| 2.0 * x,
1.0,
RootOptions::default(),
)
.unwrap();
assert!((root - 2.0_f64.sqrt()).abs() < 1e-8);§Status
use-numerical is a concrete pre-1.0 crate in the RustUse math workspace.
It keeps approximation helpers explicit and reusable so neighboring calculus,
equation, polynomial, simulation, control, signal, optimization, and physics
crates can build on one small numerical surface.
Small approximate numerical helpers for RustUse.
Modules§
- approx
- Floating-point comparison helpers for approximate numerical work.
- difference
- Finite-difference helpers for first-derivative approximation.
- integration
- Deterministic numerical integration rules over
f64intervals. - root
- Iterative approximate root-finding helpers.
Structs§
- Root
Options - Configuration for iterative approximate root finders.
Enums§
- Root
Error - Failure modes for approximate iterative root finders.
Functions§
- approx_
eq - Returns
truewhenaandbare within an absolute epsilon. - backward_
difference - Approximates the first derivative with a backward difference.
- bisection
- Finds a root with the bisection method on a bracketing interval.
- bisection_
interval - Finds a root with the bisection method over a bounded
use-intervalinterval. - central_
difference - Approximates the first derivative with a central difference.
- clamp_
epsilon - Normalizes an epsilon to a non-negative finite value.
- forward_
difference - Approximates the first derivative with a forward difference.
- midpoint_
rule - Approximates an integral with the midpoint rule.
- newton_
raphson - Finds a root with Newton-Raphson iteration.
- rectangle_
rule - Approximates an integral with the left-rectangle rule.
- relative_
eq - Returns
truewhenaandbare within a relative epsilon. - simpsons_
rule - Approximates an integral with Simpson’s rule.
- trapezoidal_
rule - Approximates an integral with the trapezoidal rule.