2. Incommensurability — √2 and Integer Powers
Box arithmetic has no fractions, so quantities like √2 — numbers whose square is a natural number but which are not themselves natural numbers — require a different treatment than you might expect.
The exact statement
√2 is the positive solution to . Checking natural numbers:
const xSquared = new Polynumber(1n, [2]);
xSquared.evaluate([1n]); // 1n — below 2
xSquared.evaluate([2n]); // 4n — above 2
There is no natural number n where xSquared.evaluate([n]) === 2n. Box arithmetic does not pretend otherwise — the polynomial is the exact object. What does not exist is a natural number equal to √2.
Stuffing the root behind an integer power
The practical pattern is: never compute √2 as a value — square both sides and work with the relation in proportion form.
Instead of asserting (which requires a non-integer), assert , i.e., the proportion:
This is a natural number equality — both sides are box arithmetic objects, and it can be checked without any approximation:
const a2 = new Polynumber(1n, [2, 0]); // a²
const b2 = new Polynumber(2n, [0, 2]); // 2b²
// Is 3² = 2 × 2²? → 9 vs 8 — close, not exact
a2.evaluate([3n, 2n]) === b2.evaluate([3n, 2n]); // 9n !== 8n
// Is 7² = 2 × 5²? → 49 vs 50 — one off
a2.evaluate([7n, 5n]) === b2.evaluate([7n, 5n]); // 49n !== 50n
// Is 17² = 2 × 12²? → 289 vs 288 — one off, tighter
a2.evaluate([17n, 12n]) === b2.evaluate([17n, 12n]); // 289n !== 288n
Each pair is a Pell equation candidate. The gap shrinks but never closes — that is the precise meaning of , expressed entirely in natural number arithmetic. The same proportion check (10n * tax !== amount style from §6) applies here: no division, no float, no approximation — just two products that must match.
In practice
This pattern carries through to the FIA (see Box Math & Primes), bonding curves, and any invariant involving a square root: square the invariant and enforce the squared relation. The integer domain is preserved throughout, and the Pell-equation structure of the near-misses is an explicit, auditable residual rather than hidden rounding error.
When you genuinely need an integer approximation of √n — e.g. for a Uniswap-style liquidity computation — the Babylonian method (used by Uniswap v2) finds in pure integer arithmetic. That pattern is covered in the §8 Degree Truncation.