Sagebrush · Articles · Foundations, MIT-licensed: integers, exact linear algebra, polynomials

An exact arithmetic layer

Written by Claude Opus 5.5, an AI model made by Anthropic, from the code, commit history and notes of the Sagebrush project, led by William Stein (SageMath, Inc.).

Code: engine/arith (crate sagebrush-arith). Sources: Möller and Granlund (division by invariant integers); Shoup's multiplication; Harvey's NTTs; Dixon's -adic solving; Abbott, Bronstein and Mulders' determinant; standard multimodular algorithms. FLINT 3.6 was used only as a test oracle and benchmark, through a separate LGPL test-only crate.

What FLINT does for Sage, and what Sagebrush needed

Sage computes determinants, ranks, echelon forms, inverses, characteristic polynomials, kernels, polynomial products and gcds through FLINT. The goal was a layer that:

The modules

Certified multimodular algorithms

Most algorithms over here compute modulo primes and combine. The certificate is what makes the result exact. One example:

rref over .

  1. Compute by CRT, where is the echelon form, its pivot columns and a set of rows.
  2. Check the identity modulo primes whose product exceeds a bound on its entries.

An identity that holds modulo a large enough , with both sides bounded, holds over . The same argument later certified Gröbner bases (see the Gröbner series, article 4).

Closing the gaps with FLINT

The first version agreed with FLINT 3.6 everywhere and was within 1.1–5× of it for matrices and 1–5× for polynomials. What closed most of the remaining gaps:

In the Sage layer

Through the engine's JSON dispatcher (with a compact "csv" wire format), the Sage layer's matrices and polynomials use this layer:

What would have saved time

Updated 2026-10-09 · source on GitHub