A computer algebra system written in Rust. Exact arithmetic, not floating-point approximation. LaTeX in, LaTeX out. Works as a CLI tool for humans and as an MCP server for AI agents.
Arithma exists because mathematics tools should be correct. Not approximately correct, not usually correct, but correct in the way that exact rational arithmetic and well-chosen algorithms make possible.
Single binary, no dependencies. The MCP server is a 3.3 MB binary. No Python runtime, no Java, no Wolfram kernel, no network calls. Copy it anywhere and it works.
Exact arithmetic. Every computation uses rational numbers (BigRational),
not floating-point. 0.9999999999999998. Results are deterministic and reproducible.
Silence over lies. If Arithma cannot compute something, it says so. It never guesses, approximates heuristically, or returns an unverified result. An agent that gets "I can't do this" can try a different approach. An agent that gets a wrong answer propagates it through its entire reasoning chain.
Proves what's impossible. The Risch algorithm doesn't just integrate — it
can prove when no elementary antiderivative exists. Ask for
Every answer declares its evidence. Each MCP response carries a
result_status: exact (decision procedure), verified (numeric agreement
at n points — evidence, never proof), approximate (floating-point result
with a first-order propagated error bound and a significant_digits count),
heuristic, unable_to_compute, or provably_impossible (with
certificate). An agent can tell an algebraic identity from "agreed at 12
test points" — because those are different things. Every caveat carries a
machine-readable code from a fixed registry (the prose message carries no
contract), every refusal states its reason as a code, and bounded numeric
outcomes publish the error_bound they were judged against. Verdict-shaped
tools additionally carry a machine-readable verdict
(pass/fail/inconclusive) — no consumer ever parses prose to learn an
outcome. result_status is emitted both as a top-level field and inside
structuredContent, so typed SDK clients that drop unknown siblings still
see it. See docs/result-status.md.
Verifies whole derivations, not just answers. The verify_chain tool
takes an ordered list of reasoning steps — each declaring its relation to
the previous one (equals, derivative_of, integral_of, substitution,
implies, solution_of, factored_form_of) — and checks every step by
the mechanism appropriate to its relation. The chain's status is the
minimum evidence across steps: one numeric step makes the whole chain
verified, never exact. A failing step carries the specific
counterexample that refutes it. The counterexample is the diagnosis.
1813 tests, zero failures. Every algorithm is verified against known results.
The simplifier has a verified idempotency contract:
simplify(simplify(e)) = simplify(e).
| Feature | Example |
|---|---|
| Polynomial factoring (Berlekamp-Zassenhaus) | |
| Radical simplification |
|
| Like-radical collection | |
| Radical products |
|
| Fraction cancellation | |
| Trig identities |
|
| Exact trig values |
|
| Symbolic trig |
|
| Inverse trig values | |
| Hyperbolic values |
|
| Log rules |
|
| Exp/log folding |
|
| Partial fractions | Full decomposition via factoring |
| Common denominator | |
| Assumption-aware |
|
| Repeating decimals | |
| Factorial & binomial |
|
| GCD / LCM |
Simplification rewrites are identities in the standard CAS sense — equality
in the field of rational functions / at generic points — so
| Feature | Example |
|---|---|
| Differentiation (chain rule) | |
| All 24 trig/hyperbolic functions | sin, cos, ..., arccoth — derivatives and integrals |
| 8 integration methods | polynomial, parts, u-sub, trig, partial fractions, ... |
| Risch algorithm | proves non-elementarity with certificate |
| Special function recognition |
|
| Multi-extension towers | |
| Parametric integration | |
| Exact definite integrals | |
| Taylor series | exact rational coefficients, symbolic center |
| Limits | L'Hôpital, series expansion, one-sided, at infinity |
| Feature | Example |
|---|---|
| Degree 1–4 exact | Cardano, Ferrari |
| Exact radical roots | |
| Parametric | |
| Systems | exact Gaussian elimination, polynomial substitution |
| Inequalities | |
| Rational equations |
| Feature | Example |
|---|---|
| Faulhaber's formulas | |
| Geometric series | |
| Telescoping | |
| Product notation | |
| Symbolic products |
| Feature | Example |
|---|---|
| Separable | |
| First-order linear | integrating factor |
| Second-order constant-coefficient | |
| Power series solutions | Hermite, Legendre, arbitrary order |
| Formal power series | lazy eval, composition, Lagrange inversion |
| Feature | Example |
|---|---|
| Determinant, inverse | exact over |
| Eigenvalues | symbolic ( |
| Systems |
|
| Algebraic number fields | exact arithmetic in |
| Feature | Description |
|---|---|
| Reasoning-chain verification | verify_chain: per-step relations (equals, derivative_of, integral_of, substitution, implies, solution_of, factored_form_of), per-step verdict + mechanism, chain status = minimum evidence across steps |
| Numeric cross-check | 12 test points, assumption-aware, counterexample on FAIL |
| Exact refutation | inside the polynomial/rational fragment, disagreements are established in exact rational arithmetic — no floating-point tolerance; x = x + 10^{-15} is refuted, not tolerated |
| Expression equivalence | simplify-and-compare, then assumption-aware sampling |
| Non-elementarity proofs | Risch algorithm certificates; recognized special-function antiderivatives (erf, Ei, li) named alongside the certificate, guarded by a differentiation round-trip |
| Result status | evidence taxonomy on every response — exact / verified / approximate / heuristic / unable_to_compute / provably_impossible |
| Error propagation | float paths carry a first-order propagated error bound; significant_digits gates what may be claimed, zero digits is a refusal, and cancellation is attributed (rewritable) vs ill-conditioning (not) |
| Coded caveats | every caveat is {code, message} from a fixed registry; every refusal carries its reason as a code — agents route on codes, never prose |
| Machine-readable verdicts | pass / fail / inconclusive on verify, equivalent, verify_chain — outcomes are fields, not prose; a bounded comparison that can neither confirm nor refute says inconclusive with the bound published |
| Self-checking | transcendental simplifications and integration round-trips are independently verified before being blessed |
The arithma-mcp binary speaks MCP over
stdio. 17 tools with LaTeX I/O:
| Tool | Purpose |
|---|---|
format |
Parse and normalize LaTeX without simplifying |
simplify |
Reduce an expression to canonical form |
differentiate |
Symbolic derivative |
integrate |
Indefinite/definite; proves non-elementary when applicable, naming the special-function antiderivative (erf, Ei, li) when recognized |
substitute |
Replace a variable with an expression |
solve |
Equations or inequalities |
solve_system |
Systems of linear/polynomial equations |
factor |
Irreducible factoring over |
partial_fractions |
Decompose |
limit |
Symbolic limits |
taylor_series |
Series expansion with exact coefficients |
evaluate |
Numerical evaluation — exact when possible; float results carry approximate status with propagated error bound and significant-digit count, and refuse rather than return digit-free noise |
matrix |
Determinant, inverse, eigenvalues, rank, RREF, |
equivalent |
Check if two expressions are equal |
verify |
Numerically cross-check at multiple test points |
verify_chain |
Verify a multi-step derivation, step by step, with per-step verdicts and evidence |
solve_ode |
First-order, constant-coeff, and power series |
verify_chain takes an ordered list of steps, each declaring its relation
to the previous one:
{
"steps": [
{ "label": "f", "expr": "x^3 - x" },
{ "label": "factored", "expr": "x(x-1)(x+1)", "relation": "factored_form_of" },
{ "label": "f'", "expr": "3x^2 - 1", "relation": "derivative_of", "variable": "x" }
]
}Each step reports verdict (pass/fail/inconclusive), the mechanism
that actually ran (canonical_form_Q, differentiation_roundtrip, …), and
its evidence class. A wrong step comes back with the counterexample that
refutes it. For incremental use, send a two-step chain of the previous and
new step.
All tools accept an optional assumptions parameter:
{
"expr": "\\sqrt{x^2}",
"assumptions": {"x": ["positive"]}
}Valid assumptions: positive, nonnegative, negative, nonzero, real,
integer.
Claude Code — add to .claude/settings.json:
{
"mcpServers": {
"arithma": {
"command": "/path/to/arithma-mcp"
}
}
}Claude Desktop — add to your config file
(~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"arithma": {
"command": "/path/to/arithma-mcp"
}
}
}The frontend/ directory contains a browser-based calculator built with
React and MathLive. Arithma compiles to
WebAssembly and runs entirely client-side — same exact-arithmetic engine,
no server, no network calls.
wasm-pack build --target web --out-dir frontend/public/pkg
cd frontend && npm install && npm run devThen open http://localhost:5173.
Interactive REPL or one-shot subcommands. Output is human-readable Unicode
when attached to a terminal; pipe the output (or pass --latex) to get raw
LaTeX instead.
$ arithma simplify "x^2 + 2x + 1"
x² + 2x + 1
$ arithma diff "x^3 + \sin(x)" x
3x² + cos(x)
$ arithma integrate "3x^2" x
x³ + C
$ arithma solve "x^2 - 2 = 0"
x = √2
x = -√2
$ arithma simplify "\sum_{k=1}^{n} k^2"
n · (n + 1) · (2n + 1)/6
$ arithma solve "x^2 - 4 > 0"
(-∞, -2) ∪ (2, ∞)
$ arithma integrate "\exp(-x^2)" x
[provably impossible] This integral has no formula using elementary
functions (polynomials, exponentials, logarithms, trigonometric). This is a
theorem, not a limitation of the tool. — antiderivative in special
functions: √π/2 · erf(x)
All 13 subcommands: format, simplify, differentiate (diff), integrate,
solve, factor, prime-factorize (factorint), partial-fractions (pf),
evaluate (eval), limit, taylor, substitute (sub), ode.
The CLI and MCP surfaces differ deliberately: the verification tools
(verify, equivalent, verify_chain), matrix, and solve_system are
MCP-only — they exist for agents consuming structured results — while
prime-factorize is CLI-only. Neither list is a subset of the other.
Cargo workspace: math engine library (root) + CLI (crates/cli/) + MCP server (crates/mcp/).
cargo build --release --workspace # all crates
cargo build --release -p arithma-cli # CLI only
cargo build --release -p arithma-mcp-server # MCP server only
cargo test --workspace # run all 1813 tests
- Correct first. Exact arithmetic everywhere. Verified idempotency.
- Well-chosen algorithms. Berlekamp-Zassenhaus, Cardano, Ferrari, Risch. The algorithm matters more than the implementation speed.
- No hardcoded answers. The system computes results; it does not look them up.
- LaTeX is the interface. Agents speak LaTeX. We parse it and produce it.
- Deterministic. Same input, same output. No randomness.
- Small footprint. Under 5 MB, zero dependencies, compiles to WASM.
See CONTRIBUTING.md for development conventions, CI discipline, and PR workflow.
MIT. See LICENSE.