> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apich.org/llms.txt
> Use this file to discover all available pages before exploring further.

# rssn

> Open-source scientific computing library for Rust: e-graph computer algebra, dimensional typing, numerical kernels, JIT/GPU backends, and physics simulations.

**rssn** unifies symbolic computer algebra, arbitrary-precision numerical kernels, and multi-physics simulations behind one Rust API — built around the idea that **every symbolic operation is an identity transformation**.

> [!NOTE]
>
> For the full operator catalog, numerical coverage caveats, and C/C++/Python/Julia/R binding guides, see [docs.rs/rssn](https://docs.rs/rssn), [ARCHITECTURE.md](https://github.com/Apich-Organization/rssn/blob/v0.3/ARCHITECTURE.md), and [docs/NUMERICS.md](https://github.com/Apich-Organization/rssn/blob/v0.3/docs/NUMERICS.md).

> [card] [Full API Reference](https://docs.rs/rssn)
>
> Generated rustdoc for `rssn::api`, `graph`, `rules`, `kernels`, `backend`, and `sim`.

> [card] [Project Homepage](https://apich.org/projects/rssn/)
>
> Design notes, math coverage summary, and Open Collective budget on apich.org.

> [card] [GitHub Repository](https://github.com/Apich-Organization/rssn)
>
> Source code, Bazel build targets, FFI headers, and language bindings.

> [card] [Figshare DOI](https://doi.org/10.6084/m9.figshare.31044715)
>
> Persistent citation (`10.6084/m9.figshare.31044715`) for academic use.

## Architecture: E-Graph Core, Kernels & Simulation

Requests such as `diff(f, x)` or `solve(eq, x)` enter `Session::compute(term, &config)` and are rewritten in tiers (`Reduce` → `Normalize` → `Explore`) on a hash-consed e-graph DAG until an extractor selects either a symbolic closed form (`Target::Symbolic`) or a numeric witness (`Target::Numeric`).

```mermaid theme={null}
flowchart TB
    Callers["Rust (api) · C/C++ (ffi: rssn.h/hpp) · Hosts/Plugins (kernel ABI)"] --> Graph["graph: hash-consed DAG + e-classes + tiered scheduler + graph::dim"]
    Graph --> Rules["rules/<domain>: calculus, algebra, ODE/PDE, physics, units"]
    Rules --> Kernels["kernels/<area>: quadrature, ODE/SDE, Krylov, FFT, convex/MILP, mp"]
    Graph --> Backend["backend: Interpreter · SSA Tape (autodiff) · Cranelift JIT · wgpu"]
    Sim["sim: FDM · FEM · FVM · BEM · CFD · MD · SPH · spectral · multigrid"] --> Kernels
```

## Module Map

| Module | Role |
| - | - |
| `src/graph/` | Domain-free e-graph engine, union-find e-classes, open operator registry, assumptions, and `graph::dim` |
| `src/rules/` | Modular domain rule sets (`arith`, `calculus`, `poly`, `solve`, `ode`, `pde`, `holonomic`, `lie`, `physics`, `numeric`) |
| `src/kernels/` | Plain numeric algorithms on `f64`/`ndarray` plus arbitrary-precision `kernels::mp` (up to \~9,800 decimal digits) |
| `src/backend/` | SSA tape IR (reverse autodiff + intervals), Cranelift JIT (`jit`), LIR, and `wgpu` (`f32` + double-single `f64`) |
| `src/sim/` | Time-stepping & field solvers outside the identity engine, exposed uniformly via `sim::scenario::run` |
| `src/io/` & `src/dim/` | Text, LaTeX, Typst, plots, `.npy`, `DataFrame`, Parquet, HDF5, NetCDF; CODATA & SI/Planck unit systems |
| `src/kernel/` & `src/ffi/` | Deterministic `KernelManifest`, dynamic `Value` ABI, `plugin-cdylib`, and `cbindgen` headers (`rssn.h`, `rssn.hpp`) |

## Cargo Features

Default features enable `jit`, `npy`, and `gpu-wgpu`. Use `--no-default-features` for a minimal Rust build.

| Feature | Enables |
| - | - |
| `jit` | Cranelift JIT compilation (`rssn::backend::jit`) |
| `gpu-wgpu` | `wgpu` GPU execution (`f32` and double-single `f64`) |
| `npy` | NumPy `.npy` import/export in `rssn::io` |
| `plugin-cdylib` | Dynamic shared-library plugins loaded into the host process |
| `full` | Enables `jit`, `npy`, `gpu-wgpu`, and `plugin-cdylib` |

## Quick Example

```rust theme={null}
use rssn::api::*;

fn main() -> Result<(), ComputeError> {
    let s = Session::new();
    let x = s.sym("x");

    // Symbolic phase: closed-form derivative
    let d = s.compute(diff(sin(x) * cos(x), x), &Config::new())?;
    assert_eq!(d.term.to_string(), "cos(2*x)");

    // Numeric phase: evaluated at x = 0.0
    let n = s.compute(
        diff(sin(x) * cos(x), x),
        &Config::new().numeric(1e-12).bind("x", 0.0),
    )?;
    assert_eq!(n.value, Some(1.0));
    Ok(())
}
```


## Related topics

- [Stack Architecture & Project Map](https://docs.apich.org/guides/architecture.md)
- [aevia](https://docs.apich.org/projects/aevia.md)
- [Apich Organization Documentation](https://docs.apich.org/index.md)
- [Quickstart](https://docs.apich.org/quickstart.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.