Inspiration

A numerical routine can pass an ordinary allclose test and still be numerically unstable. Classical Gram-Schmidt QR, least squares through the normal equations, and solving with an explicit inverse all return plausible numbers on easy matrices. They lose accuracy on hard ones. AI assistants write this kind of code often, and a quick test rarely shows the difference.

What it does

NumProof-LA audits QR, least-squares and linear-solve code on adversarial matrices and tells you whether a failure is the algorithm's fault or the problem's.

  • It generates matrices with a prescribed condition number and rank: ill-conditioned, rank-deficient, near-singular, badly scaled, Hilbert, Vandermonde, Kahan, graded, duplicated columns, and non-finite input.
  • It computes a high-precision reference with mpmath at adaptive precision.
  • It measures backward error, orthogonality loss and forward error, with tolerances that scale with the condition number.
  • It reports one verdict per case: OK, ALGORITHM_UNSTABLE, ILL_CONDITIONED_EXPECTED or INVALID_OUTPUT.

Two demo results from the repository's own run:

  • Classical Gram-Schmidt passes an ordinary allclose check on 20 of 20 cases. The audit fails it. On a case with condition number 1e8, orthogonality loss is 9.34e-03 against a tolerance of 7.11e-14.
  • Least squares via the normal equations also passes 20 of 20 ordinary checks. The audit fails it, with backward error 1.88e-10 against a tolerance of 7.99e-14.

How we measured the tool itself

We ran NumProof-LA on candidates whose behaviour we knew in advance. All counts come from results/benchmark.json and can be reproduced with scripts/reproduce.sh.

  • Planted faults: 17 of 19 detected (Wilson 95% interval 68.6% to 97.1%). 348 of 554 fault cases failed the audit.
  • Good candidates: 0 of 8 flagged (interval 0% to 32.4%). 0 of 228 good cases flagged.
  • Two misses, both documented: a Householder routine with a bad sign choice, and solving with an explicit inverse. Neither failed on the generated matrices.
  • We also wrote 8 candidates in the style of typical AI-generated code. Results were mixed: one good candidate (pinv least squares) was flagged on 13 of 42 cases, and one expected fault passed. These candidates were written by Claude to imitate typical code. They were not sampled from any model.

How we built it

Python, NumPy, SciPy and mpmath. Matrices come from SVD-based generators. Candidate code runs in a separate subprocess with a timeout and memory limit, and passes data through npz and json files, not pickle. This is isolation for robustness, not a security sandbox. The tolerances were calibrated on the good candidates: the worst backward error was 0.641 u·m·n against a limit of 10 u·m·n, and the worst forward error was 0.075 κ·u·m·n against a limit of 100 κ·u·m·n. There are 50 unit tests.

The project page is a 3D scrollytelling site built with Three.js, with a 2D fallback when WebGL is unavailable.

Challenges

  • Separating a bad algorithm from a hard problem. Backward error is what an algorithm controls, so tolerances scale with the condition number.
  • Getting a trustworthy reference. The oracle raises its working precision until the answer stabilizes.
  • Keeping the benchmark honest: the planted-fault set is small, so we report intervals and the cases we missed.

Limits

  • ILL_CONDITIONED_EXPECTED is not counted as a failure, but it can hide real errors on badly scaled input, because the plain condition number overstates difficulty there.
  • The benchmark is small (19 planted faults, 8 good candidates) and covers only QR, least squares and linear solve.
  • The tolerances were calibrated on the same good candidates we report on.

Related work

NumGuard (github.com/bhaskargurram-ai/numguard) is a related project on numerical checking. NumProof-LA narrows the scope to condition-aware linear algebra and benchmarks itself. We also cite arXiv:2611.21570.

What's next

More routines (SVD, eigenvalue problems), a larger and independently sourced set of candidates, and a refined scaling-aware condition measure.

AI-use disclosure

This project was developed with AI assistance (Claude by Anthropic). The AI wrote and reviewed much of the code, the project page and the demo voice-over (Kokoro open-source TTS). The author directed the work and is responsible for the submission. No pre-existing project work is included.

Source code

https://github.com/jinnat55/numproof (MIT license).

Share this project:

Updates

Submission history