Overview
rssn is a scientific computing library for Rust built around one idea: every symbolic operation is an identity transformation. Differentiating, integrating, solving and simplifying are all requests — diff(f, x), solve(eq, x) — rewritten by rule sets on a hash-consed e-graph until an equal closed form, or a number, is found.
That engine carries the rest of the crate. Calculus, algebra, differential equations, analysis and physics rule sets all lower to the same representation, and every scalar term carries an inferred dimension, so an answer reports its units as well as its value.
The same closed forms can then be compiled: to an SSA tape with reverse gradients and interval enclosures, or through Cranelift to machine code, or across rows on a CPU pool or a wgpu device. Symbolic and numeric paths share the operator registry rather than living in separate worlds.
Capabilities
what it doesE-graph algebra
Every operation is an identity transformation on a hash-consed DAG: differentiate, integrate, solve and simplify rewrite to an equal closed form.
Dimensions in the terms
Each scalar carries an inferred dimension, and operators declare how dimensions combine — SI and affine units, symbolic exponents, strict or advisory.
Calculus and algebra
Definite and improper integrals, Meijer G, Gröbner bases (Buchberger, F4, F5), CAD quantifier elimination, and ODE/PDE solution families.
Numeric kernels
Adaptive quadrature, stiff ODE solvers, Krylov methods, Chebyshev and AAA approximation, FFT, sparse linear algebra and statistics.
Compiled expressions
Closed forms compile to an SSA tape with reverse gradients and interval enclosures, or to Cranelift machine code with the jit feature.
Physics and simulation
Rule sets for classical mechanics through QFT, plus FDM, FEM, FVM, BEM, CFD, molecular dynamics and spectral solvers.
How it works
design notesRule scheduling
Rewriting runs in tiers — reduce, normalise, explore — so cheap identities settle before expensive searches start, and the fixpoint terminates without unbounded exploration.
Extraction by target
The engine keeps every equivalent form and picks one at the end: the most compact closed form for symbolic work, or the numerically stable variant for a requested tolerance.
Kernel manifest
Every operator has a deterministic, self-describing manifest entry — signature, unit, constants — which is what plugins, the C ABI and the bincode-next wire format are built on.
Compilation backends
Closed forms lower to an SSA tape (gradients, Hessian-vector products, interval enclosures) or to Cranelift machine code with caching and tiered compilation.
Host callbacks
Checked callback signatures for quadrature, Brent, non-linear least squares and four ODE integrators, including dimensions and error propagation across the ABI.
Simulation layer
Time-stepping and discretised fields live outside the identity engine: FDM, FEM, FVM, BEM, CFD, molecular dynamics, SPH, spectral and multigrid solvers with ready-made scenarios.
Coverage at a glance
from docs/MATH_COVERAGE.md| Domain | Representative capability | Notes |
|---|---|---|
| Calculus | derivatives, definite and improper integrals, limits, series | Hermite reduction for algebraic integrands |
| Algebra | factorisation, Gröbner bases, CAD quantifier elimination | Buchberger, F4 and F5 |
| Differential equations | ODE classification and solution, PDE on boxes and shells | Dirichlet, Neumann, Robin, periodic |
| Numerics | quadrature, stiff ODE solvers, Krylov, FFT, statistics | Dormand–Prince, Radau IIA, BDF |
| Physics | classical, EM, relativity, QM, QFT, solid state | plus FDM, FEM, FVM, BEM, CFD, MD, SPH |
| Output | text, LaTeX, Typst, Unicode, plots, .npy | round-trippable |
Install
cargo# the library
cargo add rssn
# optional: JIT compilation of closed forms
cargo add rssn --features jitA C and C++ interface is generated with cbindgen (rssn.h, rssn.hpp) and built with scripts/build_ffi.sh. GPU execution is available behind the gpu-wgpu feature.