Single- and multi-variable calculus, automatic differentiation, nonlinear least squares, and
Lie groups in pure safe no_std Rust: the same code from a 64-bit server down to a bare-metal
microcontroller.
combined_demo_reel.mp4
A reel of the live showcase demos: the 3D and 2D arm IK solvers, then the Newton fractal and the gradient-driven marbles; every number on screen is measured live.
- Runs the same math from a server to a microcontroller. Every commit is built and tested on six targets:
the
x86_64andaarch64Linux hosts and on four bare-metal ABIs (thumbv7emsoft-float,thumbv7emhardware-FPU,thumbv6m, andriscv32imc), running the real math under QEMU.no_std, no-alloc, and no-panic rules hold on every one. - Every module checked against reference libraries. Each module's results are verified against established libraries like
numpyandscipyfixtures within ~1 ulp, thus validating the rust implementation. - Fast, and measured (i7-12650H): a third derivative in 26.7 ns, a 10×10 LU solve in 239 ns, a full Levenberg-Marquardt fit in 2 µs. In the live demos: ~4 million Newton solves/sec on one core, and a 1 kHz arm IK at ~6 µs/solve. See the benchmarks.
- Exact derivatives, not estimates. Differentiation, Jacobians, Hessians, Newton steps, and Levenberg-Marquardt fits use forward-mode automatic differentiation, so derivatives are exact to machine precision; finite differences remain available for black-box functions.
- Pure safe and panic-free.
#![forbid(unsafe_code)], no C dependencies, andunwrap/panicdenied on library paths; every fallible call returns a typed error. - One dependency.
no_std, no heap by default, with transcendentals fromlibm.
- Automatic differentiation:
Dual,HyperDual, andJetscalars for exact first, second, and nth-order derivatives. - Differentiation: derivatives of any order (total and partial), plus Jacobian and Hessian matrices; autodiff by default, finite differences for black-box functions.
- Integration: iterative Newton-Cotes rules (Boole, Simpson, Trapezoidal) and Gaussian quadrature (Legendre, Hermite, Laguerre) over finite, semi-infinite, and infinite limits.
- Linear algebra: fixed-size, stack-allocated
MatrixandVectorwith LU, Cholesky, column-pivoted QR, and SVD: solves, determinant, inverse, pseudo-inverse, and condition number. - Least-squares optimization:
LevenbergMarquardtandGaussNewtonsolvers for nonlinear curve fitting. - Root finding: bracketed bisection and Newton solvers for scalar equations and square systems, with an optional damped line search.
- Vector calculus: curl, divergence, and line and flux integrals.
- Approximation: linear and quadratic Taylor models with goodness-of-fit metrics.
- ODE integrators: fixed-step
Rk4and adaptiveRk45(Dormand-Prince 5(4)) with PI step control and dense output. - Discretization: zero-order hold, Van Loan, and discrete white-noise models for continuous-time linear systems.
- Spatial math:
Quaternionand theSO2/SE2/SO3/SE3Lie groups for 2D and 3D rotations and rigid-body transforms. - Kinematics: differential-drive and unicycle maps between wheel and body motion, with exact SE(2) odometry.
- Estimation: linear and extended
KalmanFilters with Joseph-form covariance updates, optional control input, and innovation access for measurement gating.ExtendedKalmanFiltertakes nonlinear models as functions and differentiates them for the Jacobians — no hand-derived Jacobians.
cargo add multicalcThe guide is a comprehesive tutorial for each module. It shows the full imports, expected outputs in comments, error-path notes, and pointers to runnable demos. Start there when you need the complete picture of a feature.
- Guide: A worked section for every module: imports, a runnable snippet, error paths, and a demo pointer.
- Crate README / API docs: the
crates.io page and full API reference, with notes on
no_std, error handling, and heap allocation. - Examples: Self-contained, self-checking programs for each module in the
demos/crate. Run one withcargo run -p multicalc-demos --example <name>. - Benchmarks: Per-module accuracy tables and latency measurements, generated from the QA fixtures and checked in CI.
- Live showcases: Five animated Rerun demos: a 1 kHz IK on a 3-link arm, an 8-link SE(3) arm tracking a moving 3D pose, a Newton fractal, Fourier epicycles drawing Ferris, and gradient-driven marbles, each streaming live-measured speed and accuracy.
- QA crate:
multicalc-qaholds the CI-enforced accuracy fixtures and generates the benchmarks tables from them.
The published library crate lives in crates/multicalc; the repository
root is a Cargo workspace. Runnable demos live in the dev-only demos/ crate (basics and
live Rerun showcases), and tools/embedded-smoke runs multicalc on the
four bare-metal targets (three Cortex-M targets + riscv32imc) under QEMU every PR.
Contributions are welcome. See CONTRIBUTING.md.
The least-squares solvers and QR factorization port the public-domain MINPACK routines (Moré, Garbow, Hillstrom; netlib); the full citation is in the crate README.
Licensed under the MIT License.