What is excyst?
excyst checks the maths in Python code. It holds a library of 1,038 formulas, from probability and statistics to deep learning, signal processing and physics. Each one comes with code that computes it correctly and a worked example whose answer was computed separately, so the two check each other.
You point excyst at a function that you, or an AI coding agent, wrote. It runs your function next to its own on the same inputs and tells you whether they agree. When they don't, it tells you what the mistake is.
Think of a spell-checker, but for formulas. It doesn't write your code. It tells you where your code computes something other than what the formula says.
Why would I need it?
Because maths code rarely crashes when it is wrong. It returns a believable number, and nothing tells you it is off.
Take the bug in the demo film. Asked for a KL divergence (a standard measure of how different two probability distributions are), an AI agent wrote np.log2 where the formula uses the natural log. On the textbook example its function returns 0.737 instead of 0.511. The code runs and the number looks reasonable. A test written by the same agent would most likely expect 0.737 too, because the test would share the mistake.
Bugs like this end up in results, dashboards and papers. excyst catches them in a few milliseconds.
How does it check?
- 01
It works out which formula you meant
From your function's name (
kl_divergence,softmax), from its docstring, or because you tell it. - 02
It tries the textbook example
Your function and excyst's reference both get the formula's worked example, whose answer was computed separately from the reference.
- 03
Then 24 random inputs
Inputs of the right kind, such as probabilities that add up to 1, so code that only gets the example right still fails. They are random but repeatable, so any failure can be reproduced. If everything agrees, one last test with very large numbers catches code that overflows.
- 04
It gives a verdict
PASS if every answer agrees. FAIL if any doesn't, with what is different, the likely cause and an input where it goes wrong.
Does it fix my code?
No, on purpose: excyst never changes your files. It tells you what is wrong precisely enough that the fix is usually one line, then checks the fix. Here is what it says about that KL divergence:
excyst prove metrics.py:kl_divergence
prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example p=[0.5, 0.5] q=[0.9, 0.1] (worked example) yours 0.736966 reference 0.510826 (also computed independently: 0.510826) 1 ms
The why line is the diagnosis. Every one of your answers is the right answer divided by , which is exactly what using log base 2 instead of the natural log does. So the fix is to change np.log2 to np.log. Make the change, run the same command again, and it passes:
excyst prove metrics.py:kl_divergence
prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name PASS agrees with the reference on all 25 inputs (the worked example ✓ and 24 random, seed 0) 1 ms
Who makes the change? You, or your AI agent. Once excyst is connected to a coding agent such as Claude Code or Cursor (step 6), the agent can run this loop itself: check its code, read the diagnosis, fix it, check again. The rule in step 6 tells it to do that whenever it writes maths.
Sometimes the difference is a choice, not a mistake. Bits or nats, dividing by or by : both appear in textbooks. excyst labels these convention instead of likely bug. If your version is the one you meant, your code is fine and you can leave it.
What does “numpy only” mean?
It is about what excyst needs on your computer, and the list is short. excyst is a Python program. Apart from Python itself (version 3.11 or newer), it needs exactly one other package: numpy, the standard library for working with numbers in Python, which most data and machine-learning projects already use. The install command installs numpy along with excyst, and if you use uv it fetches a suitable Python too.
It also says what excyst does not need: no account, no API key, no subscription and nothing online once it is installed. It runs entirely on your computer and never sends your code anywhere. It is free, under the MIT licence.
How to use it, step by step
You type excyst's commands in a terminal: the Terminal app on a Mac, or any terminal on Linux. Each step is one command.
1 · Install it
Paste this line into the terminal and press enter:
curl -LsSf https://excyst.com/install.sh | sh
Check it worked: excyst --version should print excyst 0.2.1. If the command isn't found, open a new terminal window. On Windows, or to install with pip, see other ways to install.
2 · Watch it catch real bugs
excyst tour
This writes a small file, metrics.py, of the kind an AI agent produces when asked for “the usual evaluation helpers”, and checks every function in it. It works in a temporary folder, so nothing is added to yours, and there is nothing to set up. Five of the six functions are wrong, and the tour says why for each one.
See the whole tour
excyst tour
tour an agent was asked for “the usual evaluation helpers” and wrote metrics.py. Every function runs. Every number looks plausible. excyst matches each function to a verified formula and proves it. prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example p=[0.5, 0.5] q=[0.9, 0.1] (worked example) yours 0.736966 reference 0.510826 (also computed independently: 0.510826) 10 ms prove softmax ← metrics.py:softmax formula softmax(z)ₖ = exp(zₖ) / Σⱼ exp(zⱼ) chosen the function name matches the formula id softmax inputs z passed by name FAIL right on all 25 inputs, but not on large ones overflow with z at magnitude 1000 the answer is finite and this code gives nan: an overflow (subtract the max before exp, or work in log-space) 1 ms prove standard_error ← metrics.py:standard_error formula SE = σ / √n chosen the function name matches the formula id standard_error inputs s, n passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × √(n/(n−1)): n−1 where this formula has n, inside a square root (n is the input n) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example s=2 n=100 (worked example) yours 0.201008 reference 0.2 (also computed independently: 0.2) 1 ms prove cosine_similarity ← metrics.py:cosine_similarity formula cos θ = x·y / (‖x‖‖y‖) chosen the function name matches the formula id cosine_similarity inputs x, y passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is 1 − the formula's: the complement (distance vs similarity, p vs 1 − p) [likely bug] example x=[1, 0] y=[1, 1] (worked example) yours 0.292893 reference 0.707107 (also computed independently: 0.707107) 1 ms prove kl_gaussians ← metrics.py:kl_gaussians formula KL = ln(σ₂/σ₁) + (σ₁² + (μ₁−μ₂)²) / (2σ₂²) − ½ chosen the function name matches the formula id kl_gaussians inputs m1, s1, m2, s2 passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is the formula's + ½ on every input: a constant term is added or dropped [likely bug] example m1=0 s1=1 m2=1 s2=2 (worked example) yours 0.943147 reference 0.443147 (also computed independently: 0.443147) 1 ms prove entropy ← metrics.py:entropy formula H(X) = −Σₓ p(x) log p(x) chosen the function name matches the formula id entropy inputs p passed by name PASS agrees with the reference on all 25 inputs (the worked example ✓ and 24 random, seed 0) 1 ms metrics.py 1 of 6 proved 5 of 6 functions are wrong, and nothing crashed. In your own project: excyst prove metrics.py every function whose name matches a formula excyst prove metrics.py:kl kl_divergence one function, one formula excyst connect let Claude Code, Cursor or Codex call it themselves
Typing excyst on its own opens excyst's own screen instead. There you type the same commands without the word excyst, and / shows a menu of them.
3 · Check your own code
In the terminal, go to your project's folder (cd my-project) and point excyst at a file:
excyst prove metrics.py # every function whose name matches a formula
excyst prove metrics.py:kl_divergence # just this one function
excyst recognises a function by its name or its docstring. If yours has a name it won't recognise, look up the formula's id and give it after the function:
excyst find kl divergence # search the formulas for its id
excyst prove metrics.py:my_kl kl_divergence
Functions that match no formula are listed as unmatched. They are never counted as passed.
4 · Read the result
Each line of a result has one job. In the FAIL above:
formulaandchosen: the formula your code was compared with, and why excyst picked it.inputs: how your function's arguments were matched to the formula's inputs.FAILorPASS: how many of the 25 inputs agreed, and whether the worked example did.why: what separates your answers from the right ones, the likely cause, and whether it may be a deliberateconventionor is alikely bug.example,yoursandreference: one input where the two disagree, with your answer and the right one, so you can reproduce it.
Some failures also have a blame line: the inputs that break agreement when changed on their own. That tells you where to look in your code.
5 · Fix it, then check again
Change the code (here, np.log2 becomes np.log), run the same command again and look for PASS. In excyst's screen the up arrow brings the last command back, so checking again takes two keys.
6 · Let your AI agent do it
excyst connect --write
This adds excyst to the coding agents it finds on your computer: Claude Code, Cursor, Codex and Windsurf, and VS Code for the folder you are in. Restart the agent afterwards. Without --write it only shows what it would change.
From then on the agent can look up the exact formula before it writes one, and check its code afterwards. To make sure it does, paste the short rule that excyst connect --rules prints into your project's AGENTS.md or CLAUDE.md. It tells the agent to check every formula it writes and to treat a FAIL like a failing test.
7 · Look up any formula
excyst entropy # anything that isn't a command searches the formulas
excyst formulas kl_divergence # one formula: its definition, notes and worked example
excyst copy kl_divergence # its LaTeX, copied to your clipboard
Or browse them all on the formulas page.
What it can't do
- It reads Python only. Code in other languages can't be checked.
- It checks the formulas it knows. There are 1,038 of them. If your function computes something that isn't in the library, excyst says so instead of guessing. Missing one you need? Tell us.
- A PASS is strong evidence, not a mathematical proof. It means your code agreed with the reference on 25 inputs and the large-number test. A bug that only shows up on other inputs can still slip through.
- It can't know what you intended. If you meant bits and wrote bits, it still points out the difference, labelled as a convention. Which one you wanted is your call.
- It runs your code. That is how it checks, so only point it at code you would be happy to run.
Other questions
Is it free?
Yes. No account, no plan, no trial. It is released under the MIT licence.
Does my code get sent anywhere?
No. excyst runs entirely on your computer and never connects to the internet. If an AI agent is calling it, the agent talks to its own provider as it always does; excyst adds nothing to that.
Which AI agents does it work with?
Any agent that supports MCP, the common standard for giving agents tools. excyst connect sets up Claude Code, Cursor, Codex, Windsurf and VS Code for you, and the docs show how to add it to others by hand.
Does it work on Windows?
The commands do. excyst's full-screen view needs macOS or Linux, so on Windows results are printed as plain text. Install it there with pip or uv: see other ways to install.
Do I need to know the maths?
No. excyst knows the formula. You only need to know what your function is meant to compute, and its name usually tells excyst that.
What else can it do?
excyst check tests whether a trained classifier can be trusted: whether its confidence is honest (calibration), its accuracy, its coverage, how it copes with noisy inputs and whether it is reproducible. Each gets a pass or a fail and what to try next. See check a model.