Exact arithmetic, and what it costs instead

How many primes the answer needs

Work modulo a word-sized prime and no intermediate can exceed twenty-six bits, whatever the matrix does. The catch is that the answer must be reassembled from several such computations, and the number of them has to be fixed before the first one runs — by a theorem about how large a determinant can be, not by trying more until it settles.

Worth reading first: The number that decides nothing · An answer with no error in it · Elimination is a sequence of choices.

The first three essays in this field all had the same shape of problem: exact arithmetic on integers that grow, with the argument being about how much they grow and whose fault it is. There is a way to remove the growth entirely, and it is not a cleverer elimination.

Work in a ring where the numbers cannot grow. Choose a prime p below 2²⁶, reduce every entry of the matrix modulo p, and eliminate. Every quantity that appears is a residue in [0, p), a product of two of them fits exactly in a double, and there is no bit-length curve to draw because the bit length is 26 from the first step to the last, whatever the matrix was.

8 × 8: three exact determinants agree to the digit, and the float one does notdet A = 3458508270104059228258152 on a wide matrix of order 8, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 4 word-sized primes put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 3.45850827·10²⁴, a relative error of 3.105·10⁻¹⁶, which is what a determinant of 82 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 87 bits are needed and 4 primes supply them.Bareiss82 bitsrationals77 bitsmodular26 bitsthe answer82 bitsHadamard87 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 4 primes0floating-point LU3.1·10⁻¹⁶det A = 3458508270104059228258152three routes, one integerand no tolerance anywhere in the comparison
Fig. 1 The three exact routes on a matrix with three-digit entries. The modular route’s widest number is 26 bits while the determinant it computes has 82 — because the 82 bits are assembled at the end rather than carried through the middle.

The answer is then wrong, in a specific and recoverable way: what has been computed is the determinant of A over the field with p elements, which is det A reduced modulo p. One residue is not the determinant. Several of them are.

That is a completely different bargain from the two the field has already made. Fraction-free elimination keeps the intermediates near the answer’s own length and pays for it with a long division per entry; reduced-rational elimination keeps them there and pays with a greatest common divisor. Both are still doing arithmetic on numbers whose length is decided by the matrix. This one fixes the length at twenty-six bits and moves the entire cost into how many times the elimination is run.

Putting it back together

The Chinese remainder theorem says that residues modulo pairwise coprime moduli determine a unique value modulo their product. So computing det A mod p₁, det A mod p₂, … and combining them recovers det A modulo p₁p₂…, and once that product exceeds the range det A can lie in, the value is det A.

Two details in that sentence carry all the weight.

The range is signed. A determinant can be negative and the residues cannot, so the reconstruction has to be read in the symmetric range [−M/2, M/2) rather than in [0, M). Reading it in the wrong one reports a determinant of −6 as a twenty-digit integer, which is not a small error and is not detectable from inside: the arithmetic is right, the interpretation is not.

“Once the product exceeds the range” has to be decided in advance. There is no way to look at a partial reconstruction and tell whether it has settled. Adding a prime always changes the value — that is what a larger modulus does — and a value that stops changing has not converged, it has coincided. The number of primes is not something the computation can discover about itself.

That second point is the interesting one, and it is the opposite of how almost every other computation on this site terminates. An iterative solver stops when its residual is small enough; the essay on what a method reports is about the gap between that number and the real one, and the essay on stopping tests is about two quantities racing to decide it. Every one of those is a routine watching itself and deciding when to stop. A modular reconstruction cannot watch itself at all. It has to be told, before it starts, how much work it is going to do.

The bound, which is a theorem

Hadamard’s inequality supplies the missing number: for any real matrix,

|det A|  ≤  Π ‖row i‖₂

the product of the row two-norms. That is computable from the entries in n² operations, before any elimination, and it says how many bits det A can occupy. Divide by 26 and round up and that is how many word-sized primes are needed.

The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 11 the random family needs 47 bits, which is 2 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.34567891011110¹10²nbitsthe budget and what it buysrandom, bound47random, actual33primes needed2Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 2 The bound in bits against the determinant’s actual length, on four families. The solid lines are the budget; the dotted ones are what the budget was for.

On the random family with one-digit entries the bound at n = 12 is 52 bits and the determinant occupies 40, so three primes are budgeted where two would have done. On the wide family with three-digit entries the bound at n = 12 is 133 bits and the answer 121: six primes budgeted, five needed. The waste is small and it is systematic — the bound is a product of row norms and the determinant is a signed sum with cancellation in it, so the bound exceeds the answer by whatever the cancellation was.

Why a loose bound would still be the right thing to use

There is an obvious objection: a bound that is not tight is a bound that makes the routine do more work than it needs to. It is worth answering carefully, because the answer is not “the waste is small”.

The alternative to budgeting is checking, and checking is not available. A routine that computed residues until the reconstruction stopped changing would be reading a coincidence as a convergence. A routine that computed one extra prime and compared would detect a disagreement rather than a sufficiency — which is a genuinely useful thing to do, and it is what the next essay is about, but it tests for a different failure.

So the budget is not a conservative choice among several. It is the only mechanism available, and its being an over-estimate by a few per cent is the price of the whole route working at all.

It is worth putting that beside the site’s usual complaint about bounds. The growth factor in Gaussian elimination has a bound of 2ⁿ⁻¹ that no matrix anybody has ever assembled comes near, and the finding there is that the bound is useless for deciding anything. The a-priori bound in model reduction is the other extreme: attained exactly, at every order, to four decimals. Hadamard’s sits between them and is used differently from either — not to predict what will happen, and not to reassure, but as an input to the algorithm. A routine that budgets against a bound is a routine whose correctness depends on the bound being true rather than on its being tight.

And the bound is attained

A bound that could never be reached would be a different objection, and this one can be.

Hadamard’s inequality holds with equality exactly when the rows are mutually orthogonal. A Hadamard matrix — entries ±1, rows orthogonal — attains it: at order eight, every row has norm √8, the product of the norms is 8⁴ = 4096, and the determinant is 4096. Twenty-five bits budgeted, twenty-five bits used, nothing wasted.

That is the refusal this essay carries. A claim that the bound is loose by more than a byte on every matrix is fed the Sylvester construction at order eight and has to reject it — and the assertion is run rather than described, so the claim in the paragraph above is one the build would catch if it stopped being true.

The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 8 the random family needs 32 bits, which is 2 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.345678110¹10²nbitsthe budget and what it buysrandom, bound32random, actual24primes needed2Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 3 The same measurement at smaller sizes, where the four families have not yet separated and the bound is within a few bits of the answer on all of them.

The families where it is enormously slack are equally instructive. The unit triangular family has a determinant of exactly 1 and rows of growing length, so the bound climbs linearly while the answer stays at one bit. The Pascal family is worse: entries reaching twenty bits, a bound of 149 bits at n = 12, and a determinant of 1. Both are correct behaviours of the inequality — orthogonal rows are what make it tight, and neither family has any — and both are the standing reminder that the size of an answer is not predicted by the size of the entries.

What this buys, measured against the alternatives

The modular route’s advantage is not speed at these sizes. It is that the cost is a known number of word-sized eliminations rather than one elimination on operands of unknown length.

Fraction-free elimination performs n³/3 operations on integers that grow to about the determinant’s length — so the real cost is n³/3 multiplied by the cost of arithmetic at that length, which is quadratic in it for schoolbook multiplication. The modular route performs k·n³/3 operations on machine words, where k is the number of primes, and k is itself about the determinant’s length over 26. So the two are the same order and the constants are entirely different, and the second’s inner loop is a loop over doubles.

The comparison is worth making precisely, because the two routes are the same order and it is easy to conclude from that that they are the same. Fraction-free elimination performs its n³/3 operations on operands that reach the determinant’s length L, at a cost quadratic in L for schoolbook arithmetic, so the total is about n³L²/3. The modular route performs k = L/26 eliminations of n³/3 word operations each, so the total is about n³L/78. The ratio is L, and L is the determinant’s own bit length — which is the field’s usual answer to everything: the length of the numbers is the cost, and a route that never lets them get long never pays it.

There is a second advantage that matters more in practice and is invisible in an operation count: the k eliminations are completely independent. Nothing in the modulo-p₁ computation is needed by the modulo-p₂ one. The essays about what a machine actually costs spend their time on data movement and dependence, and here there is none of either — which is a different kind of statement from a flop count and is the reason this route is the one that scales.

12 × 12: three exact determinants agree to the digit, and the float one does notdet A = 647452350646 on a random matrix of order 12, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 3 word-sized primes put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 6.47452351·10¹¹, a relative error of 3.394·10⁻¹⁵, which is what a determinant of 40 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 53 bits are needed and 3 primes supply them.Bareiss40 bitsrationals39 bitsmodular26 bitsthe answer40 bitsHadamard53 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 3 primes0floating-point LU3.4·10⁻¹⁵det A = 647452350646three routes, one integerand no tolerance anywhere in the comparison
Fig. 4 Three primes, on a matrix whose determinant needs forty bits. Each of the three eliminations is an ordinary one on machine words, and none of them knows about the others.

Where the residues are actually wrong

One thing has been assumed throughout and it is not always true: that the elimination modulo p succeeds. It can fail, and it fails in a way that looks exactly like a correct answer.

If p divides det A then the matrix is singular over the field with p elements. The elimination reaches a column of zeros, reports a determinant of zero, and is right: that determinant genuinely is zero. What it is not is a residue of the determinant that was wanted — or rather it is, and it is the uninformative one, and there is no way to tell from inside a single residue whether the answer is zero because the matrix is singular or because the prime was unfortunate.

The same substitution reaches the rank. Rank over the field with p elements is a perfectly good quantity, computed by the same elimination with no threshold anywhere, and it is not the rank over the rationals — a second and quite separate way for an exact answer to answer a question nobody asked. Rank as a threshold decision is the floating-point version of the same trouble reached from the opposite direction, and the two have nothing in common but the symptom.

That is the whole cost of having no growth, and it is the next essay. It is a failure mode with no analogue in floating point: nothing in the arithmetic is inaccurate, no quantity is small enough to be mistaken for zero, and the essay about deciding that a zero has arrived is about a judgement that here is not being made. The zero is exact. It is the question that was substituted.

det A = 30030, and its residue at 25 primes — 5 of which divide itEach dot is det A mod p, drawn as a fraction of p so the primes are comparable. A dot on the floor is a prime at which the elimination reports a singular matrix — and the matrix is not singular: its determinant is 30030. 5 of 25 primes here are unlucky, a rate of 20 per cent, which is what it looks like when the primes are small. At the 26-bit primes a modular determinant actually uses, a prime divides a 15-bit determinant with probability of order 2.24·10⁻⁷ — but the consequence is unchanged, and there is no way to see it from one residue. What sees it is the budget: computing more residues than Hadamard's bound requires, and refusing to reconstruct when the extra ones disagree.det mod p, as a fraction of p3713a prime that divides the answerdet A3·10⁴primes swept25unlucky5rate0.2det, in bits15singular mod p is not singularand one residue cannot tell them apart
Fig. 5 A matrix whose determinant is 30030 = 2·3·5·7·11·13, and its residue at twenty-five small primes. The five dots on the floor are correct computations of the wrong thing.

Choosing the primes, which is not arbitrary

Three properties are wanted of the moduli and only one of them is obvious.

They must be pairwise coprime, which for distinct primes is free. Using a composite modulus is the failure this reaches for: the modular inverse of a nonzero entry may not exist, the elimination reports a singular matrix, and the report is about the modulus rather than about the matrix. A list of primes typed by hand is a place for a composite to hide, so the list here is generated by trial division rather than written down.

They must be small enough that a product of two residues is exact in the arithmetic doing the work. A double holds integers exactly to 2⁵³, so a modulus below 2²⁶·⁵ keeps every product inside it. That is the whole reason for the twenty-six: it is not a word size, it is half a significand. The same routine written for 64-bit integers would use 31-bit primes and the same argument.

And they must be large enough that not many are needed, which is the counter-pressure. Every prime is a full elimination, so halving the modulus doubles the work. Twenty-six bits is where those two meet on a machine whose fast arithmetic is floating point — which is a slightly startling place for an exact algorithm to end up, and it is the same observation the low-precision essays make from the other direction: the fastest arithmetic on a modern machine is the one with the shortest operands, and an algorithm that wants speed goes to meet it.

What is left over

Two things about this route are not settled by the budget and both get their own essay.

The first is the unlucky prime: a modulus dividing the determinant, at which the elimination is correct and uninformative. The defence is to compute more residues than the bound requires and check that the extra ones agree — which is a genuinely different test from the sufficiency the budget provides, and which turns an undetectable wrong answer into a detected one.

The second is that everything above is about a determinant, which is a single integer. A solution is a vector of fractions, and the Chinese remainder theorem reconstructs integers. Getting a fraction back out of a residue is a separate mechanism with a separate bound, and the bound is about a lattice rather than about a product of primes.

Recovering 355/113 from its residue: nothing below 2^18, everything aboveThe fraction 355/113 is reduced modulo a prime just above 2^e and then reconstructed from that one residue by the extended Euclidean algorithm. Below e = 18 the reconstruction returns a different fraction or refuses; at and above it, it returns 355/113 exactly, at every e tried. The crossover is not a property of the algorithm: a residue determines a rational uniquely once the modulus exceeds twice the square of the LARGER of the two parts, which here is 2^17.94, and below that there are two fractions with the same residue and both parts small enough. The measured first success is 2^18. There is no band in which the answer is is nearly right — the value returned below the cliff is a perfectly good fraction that is not this one.2^18modulus, as a power of twoa lattice with one short vectornumerator355denominator1132·max(n, d)², bits18first recovered at18moduli tried42below the bound there are two answersand the algorithm cannot prefer one
Fig. 6 The other bound: below a modulus twice the square of the fraction’s longer part, a residue does not determine the fraction at all, and the failure is a cliff rather than a slope.

At other settings

The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 13 the random family needs 56 bits, which is 3 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.345678910111213110¹10²nbitsthe budget and what it buysrandom, bound56random, actual44primes needed3Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 7 Out to n = 13, where the wide family needs six primes and the unit triangular family’s bound has passed a hundred bits for an answer of one.
The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 5 the random family needs 18 bits, which is 1 word-sized prime at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.345110¹10²nbitsthe budget and what it buysrandom, bound18random, actual15primes needed1Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 8 And at the smallest sizes, where one prime does for every family.
12 × 12: three exact determinants agree to the digit, and the float one does notdet A = 1 on a pascal matrix of order 12, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 6 word-sized primes put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 1.00000034, a relative error of 3.372·10⁻⁷, which is what a determinant of 1 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 150 bits are needed and 6 primes supply them.Bareiss20 bitsrationals20 bitsmodular26 bitsthe answer1 bitsHadamard150 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 6 primes0floating-point LU3.4·10⁻⁷det A = 1three routes, one integerand no tolerance anywhere in the comparison
Fig. 9 A determinant of 1, budgeted at 149 bits, which is the slackest the bound gets on this site.
8 × 8: three exact determinants agree to the digit, and the float one does notdet A = 4096 on a hadamard matrix of order 8, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 1 word-sized prime put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 4096, a relative error of 0, which is what a determinant of 13 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 14 bits are needed and 1 prime supplies them.Bareiss13 bitsrationals4 bitsmodular26 bitsthe answer13 bitsHadamard14 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 1 prime0floating-point LU0det A = 4096three routes, one integerand no tolerance anywhere in the comparison
Fig. 10 The case where the bound is attained: rows orthogonal, twenty-five bits budgeted and twenty-five used.
6 × 6: three exact determinants agree to the digit, and the float one does notdet A = 2435091120 on a hilbert matrix of order 6, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 4 word-sized primes put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 2.43509112·10⁹, a relative error of 1.329·10⁻¹¹, which is what a determinant of 32 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 85 bits are needed and 4 primes supply them.Bareiss40 bitsrationals15 bitsmodular26 bitsthe answer32 bitsHadamard85 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 4 primes0floating-point LU1.3·10⁻¹¹det A = 2435091120three routes, one integerand no tolerance anywhere in the comparison
Fig. 11 The integer Hilbert matrix, where the float route has already lost the answer and the modular one has not noticed the conditioning at all.
Three exact eliminations of the same wide matrix, and the widest number each one formsEvery route here returns the same determinant exactly, so there is no error to plot and the y-axis is the length of the intermediates in bits. At n = 11 the answer itself is 112 bits and Hadamard's bound allows 121. Fraction-free elimination never forms a number wider than 112 bits, because each of its intermediates is a minor of the original matrix. Rational elimination that reduces every fraction to lowest terms reaches 112 bits and pays a gcd on every arithmetic operation to stay there. Rational elimination that does not reduce reaches 2969950 bits — 26500 times the width of the fraction-free route and 26500 times the width of the answer. All three are correct.34567891011110¹10²10³10⁴10⁵10⁶nwidest intermediate, in bitsrationals, not reducedfraction-free · rationals reduced · the answerone answer, three widthsn11answer112Hadamard bound121fraction-free112reduced rationals112unreduced3·10⁶the error is zero on every curvethe cost is the length of the numbers
Fig. 12 The growth this route removes, on the same family.
Three exact eliminations of the same random matrix, and the widest number each one formsEvery route here returns the same determinant exactly, so there is no error to plot and the y-axis is the length of the intermediates in bits. At n = 12 the answer itself is 40 bits and Hadamard's bound allows 52. Fraction-free elimination never forms a number wider than 40 bits, because each of its intermediates is a minor of the original matrix. Rational elimination that reduces every fraction to lowest terms reaches 39 bits and pays a gcd on every arithmetic operation to stay there. Rational elimination that does not reduce reaches 1422165 bits — 35600 times the width of the fraction-free route and 35600 times the width of the answer. All three are correct.3456789101112110¹10²10³10⁴10⁵10⁶nwidest intermediate, in bitsrationals, not reducedfraction-free · rationals reduced · the answerone answer, three widthsn12answer40Hadamard bound52fraction-free40reduced rationals39unreduced1.4·10⁶the error is zero on every curvethe cost is the length of the numbers
Fig. 13 And on one-digit entries, where the unreduced route reaches 1.4 million bits and the modular one stays at twenty-six.
det A = 30030, and its residue at 44 primes — 5 of which divide itEach dot is det A mod p, drawn as a fraction of p so the primes are comparable. A dot on the floor is a prime at which the elimination reports a singular matrix — and the matrix is not singular: its determinant is 30030. 5 of 44 primes here are unlucky, a rate of 11.4 per cent, which is what it looks like when the primes are small. At the 26-bit primes a modular determinant actually uses, a prime divides a 15-bit determinant with probability of order 2.24·10⁻⁷ — but the consequence is unchanged, and there is no way to see it from one residue. What sees it is the budget: computing more residues than Hadamard's bound requires, and refusing to reconstruct when the extra ones disagree.det mod p, as a fraction of p311a prime that divides the answerdet A3·10⁴primes swept44unlucky5rate0.11det, in bits15singular mod p is not singularand one residue cannot tell them apart
Fig. 14 The same failure swept further out, where the floor fills slowly and never empties.
The exact solution of a wide system is longer than the systemAx = b with A a wide integer matrix and b chosen so the answer is a genuine vector of fractions. At n = 10 the question occupies 1000 bits — 10² entries of 10 bits each — and the answer occupies 2058, a ratio of 2.06. Every entry is a ratio of two determinants by Cramer's rule, checked here by multiplying each one back by det A and comparing it with the determinant of the column-replaced matrix as an integer — so every denominator divides det A and none of them is longer than its 103 bits, while a numerator can be, at 105 here. The answer IS that long, whatever route produced it. That is a floor no exact solver can get under, and it is why the modular route reconstructs the answer rather than eliminating its way to it.34567891010²10³nbitsthe answerthe question · det Abits in, bits outn10question1000answer2058det A103widest part105the answer is the floorand no route writes it down more cheaply
Fig. 15 The answer’s own length, which is what the budget is a bound on.
Every boxed entry is a 3 × 3 minor of the matrix beside itA 5 × 5 wide matrix and its state after 2 steps of fraction-free elimination. Each of the 9 boxed entries was formed as (pivot × entry − column × row) divided by the previous pivot, and every one of those 25 divisions came out exact. The reason is that the entry at (i, j) is exactly the 3 × 3 minor of the ORIGINAL matrix on rows 0…1 and i, columns 0…1 and j — checked here against a cofactor expansion of A rather than against a second elimination. The widest number anywhere in the picture is 30 bits.-257325-86896-994-523-996278116-612-894131-704-870-29973890972-390570-7246836-574A, the matrix as given-257325-86896-9940195418-469898-150509-52397400-3.542·10⁸-4.333·10⁸-5.814·10⁸005.441·10⁸4.641·10⁷3.383·10⁸00-2.442·10⁸4.23·10⁷-5.447·10⁸after 2 fraction-free steps3 × 3 minors25 divisions, all exactthe intermediates are minorswhich is why the divisions come out whole
Fig. 16 The route that carries the length through the middle instead of assembling it at the end.
log₁₀|det H_n| by three routes, to n = 26The exact rational determinant of the Hilbert matrix falls to 10^-387 at n = 26. The accumulated logarithm of the pivots follows it to n = 13 and then departs, reaching 10^-289 — wrong by 98 orders of magnitude and still an ordinary-looking number. The product of the pivots is a separate curve that ends at n = 26, where it underflows to exactly zero.261014182226-400-300-200-1000nlog₁₀|det H_n|exact rationalΣ log|u_ii|Π u_iithree routes, one theoremexact at the largest n-387accumulated logarithm-289decades of disagreement98smallest pivot at that n3.1·10⁻¹⁸every pivot is a normal numberat every size on this axis
Fig. 17 The float determinant, whose error this route does not have and whose speed it does not match.
Growth factor under partial pivoting to n = 40: the bound, the worst case, and realityGrowth factor against matrix size on a logarithmic vertical axis. The two-to-the-n bound rises as a straight line; Wilkinson's matrix sits exactly on it; random matrices stay near one.0816243240110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴matrix size ngrowth factor max|u| / max|a|the 2ⁿ⁻¹ boundworst of 30 randommedian randomWilkinson's matrix sits on the bound30 Gaussian matrices per sizeat n = 40: bound 5.5·10¹¹, worst 4.8
Fig. 18 The elimination field’s bound that is never attained, beside one that is.
The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 8 the random family needs 32 bits, which is 2 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.345678110¹10²nbitsthe budget and what it buysrandom, bound32random, actual24primes needed2Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 19 Eight by eight, where the random family needs two primes and the wide one four.
The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 10 the random family needs 42 bits, which is 2 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.345678910110¹10²nbitsthe budget and what it buysrandom, bound42random, actual37primes needed2Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 20 Ten, where the unit triangular bound has passed eighty bits for an answer of one.
10 × 10: three exact determinants agree to the digit, and the float one does notdet A = 1 on a unitriangular matrix of order 10, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 1 word-sized prime put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 1, a relative error of 0, which is what a determinant of 1 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 13 bits are needed and 1 prime supplies them.Bareiss1 bitsrationals1 bitsmodular26 bitsthe answer1 bitsHadamard13 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 1 prime0floating-point LU0det A = 1three routes, one integerand no tolerance anywhere in the comparison
Fig. 21 A determinant of 1 with a budget of eighty bits, which is what a bound costs.
6 × 6: three exact determinants agree to the digit, and the float one does notdet A = -40098 on a random matrix of order 6, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 1 word-sized prime put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns -4.0098·10⁴, a relative error of 3.629·10⁻¹⁶, which is what a determinant of 16 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 23 bits are needed and 1 prime supplies them.Bareiss16 bitsrationals13 bitsmodular26 bitsthe answer16 bitsHadamard23 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 1 prime0floating-point LU3.6·10⁻¹⁶det A = -40098three routes, one integerand no tolerance anywhere in the comparison
Fig. 22 One prime, on a matrix whose determinant fits inside a single modulus.
Three exact eliminations of the same hilbert matrix, and the widest number each one formsEvery route here returns the same determinant exactly, so there is no error to plot and the y-axis is the length of the intermediates in bits. At n = 8 the answer itself is 40 bits and Hadamard's bound allows 140. Fraction-free elimination never forms a number wider than 60 bits, because each of its intermediates is a minor of the original matrix. Rational elimination that reduces every fraction to lowest terms reaches 19 bits and pays a gcd on every arithmetic operation to stay there. Rational elimination that does not reduce reaches 94136 bits — 1570 times the width of the fraction-free route and 2350 times the width of the answer. All three are correct.345678110¹10²10³10⁴10⁵nwidest intermediate, in bitsrationals, not reducedfraction-free · rationals reduced · the answerone answer, three widthsn8answer40Hadamard bound140fraction-free60reduced rationals19unreduced9.4·10⁴the error is zero on every curvethe cost is the length of the numbers
Fig. 23 The growth the modular route removes, on the ill-conditioned family.
Every boxed entry is a 4 × 4 minor of the matrix beside itA 5 × 5 random matrix and its state after 3 steps of fraction-free elimination. Each of the 4 boxed entries was formed as (pivot × entry − column × row) divided by the previous pivot, and every one of those 29 divisions came out exact. The reason is that the entry at (i, j) is exactly the 4 × 4 minor of the ORIGINAL matrix on rows 0…2 and i, columns 0…2 and j — checked here against a cofactor expansion of A rather than against a second elimination. The widest number anywhere in the picture is 12 bits.1-2-6-7-474-26-12-5-8-524-394151435A, the matrix as given1-2-6-7-401840552700112217207000-2877-3467000-1582-1026after 3 fraction-free steps4 × 4 minors29 divisions, all exactthe intermediates are minorswhich is why the divisions come out whole
Fig. 24 The route that carries the length rather than assembling it.
5 × 5: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a unitriangular matrix of order 5 is the diagonal [1, 1, 1, 1, 1], reached by unimodular row and column operations, with each entry dividing the next — a property the elimination does not give and which has to be enforced and asserted. The same numbers computed from the definition — the gcd of all k × k minors, over the gcd of all (k−1) × (k−1) minors — are [1, 1, 1, 1, 1], and the two agree entry for entry. Their product is 1, which is |det A| = 1. The Hermite form of the same matrix reaches 1 bits against the Smith form's 1, and its transform has determinant 1, so the lattice the rows generate is unchanged.s10 bitss20 bitss30 bitss40 bitss50 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A1Π invariants1SNF widest1HNF widest1det of the transform1an algorithm and a definitionagreeing as integers
Fig. 25 A map with every invariant factor 1, so no prime is unlucky for it.
The exact solution of a random system is longer than the systemAx = b with A a random integer matrix and b chosen so the answer is a genuine vector of fractions. At n = 12 the question occupies 576 bits — 12² entries of 4 bits each — and the answer occupies 944, a ratio of 1.64. Every entry is a ratio of two determinants by Cramer's rule, checked here by multiplying each one back by det A and comparing it with the determinant of the column-replaced matrix as an integer — so every denominator divides det A and none of them is longer than its 40 bits, while a numerator can be, at 41 here. The answer IS that long, whatever route produced it. That is a floor no exact solver can get under, and it is why the modular route reconstructs the answer rather than eliminating its way to it.345678910111210²10³nbitsthe answerthe question · det Abits in, bits outn12question576answer944det A40widest part41the answer is the floorand no route writes it down more cheaply
Fig. 26 The answer this budget is ultimately a bound on.
One 6 × 6 integer matrix, 3 different ranksThe same matrix of integers, its rank computed exactly with no rounding and no threshold anywhere, over the rationals and over the fields with 2, 3, 5, 7, 11, 13, 101, 65537 elements. Over ℚ the rank is 6; over 𝔽2 and 𝔽3 it is 4 and 5. Nothing has been approximated and nothing has been decided by a tolerance — the eliminations are exact in every case, and there is no small number anywhere for a threshold to be compared against. The rank is not a property of the array of numbers; it is a property of the array together with the ring the entries are read in, and a modular algorithm that reports a rank has reported the second one.6𝔽24𝔽35𝔽56𝔽76𝔽116𝔽136𝔽1016𝔽655376rank, by the ring the entries are read inthe rank of one matrixover ℚ6over 𝔽24over 𝔽35over 𝔽56over 𝔽76nothing is rounded hereand the answer still is not a property of the matrix
Fig. 27 The rank, where a prime dividing an invariant factor costs one.
An exact solve of a measured 8 × 8 system, against the error the measurement put thereThe rising curve is the distance from the exact solution of a perturbed system to the exact solution of the unperturbed one, as the perturbation grows from a relative 10⁻¹⁶ to 1. Every point on it was computed with no rounding anywhere: the elimination is over the rationals, the residual of each solve is the zero vector, and the error is entirely the data's. At a measurement accurate to 10^-6 the answer is wrong by 1.342, which is 1.3·10⁶ times the data's own error — the matrix's condition number, doing the only job left for it to do. The straight line of slope one is the whole finding: removing the arithmetic error changes nothing about this quantity, because this quantity was never about the arithmetic.10⁻¹⁶10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²110⁻⁷10⁻⁵10⁻³10⁻¹10¹relative error in the datarelative error in the answerthe answer's errorthe data's errornothing here is the arithmetic'sdata error10⁻⁶answer error1.3amplification1.3·10⁶rounding committed0residual0the residual is exactly zeroand the answer is wrong anyway
Fig. 28 And whether the exact answer the budget buys is the answer that was wanted.
The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 6 the random family needs 22 bits, which is 1 word-sized prime at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.3456110¹10²nbitsthe budget and what it buysrandom, bound22random, actual16primes needed1Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 29 Six by six, where every family fits inside one prime.
The determinant's length, and the bound that decides how many primes to use before any of them is chosenSolid: Hadamard's bound on |det A|, the product of the row 2-norms, in bits. Dotted: the determinant's actual length. The bound is what a modular determinant budgets against — at n = 11 the random family needs 47 bits, which is 2 word-sized primes at 26 bits each, and that count is fixed before the first residue is computed. On a Sylvester Hadamard matrix of order 8 the bound is 13 bits and the determinant has 13, so the bound is attained rather than merely satisfied. On the unit triangular family the determinant is 1 at every size while the bound grows, which is the gap the budget pays for: a matrix can have a determinant of one and rows that are long.34567891011110¹10²nbitsthe budget and what it buysrandom, bound47random, actual33primes needed2Hadamard n = 8, bound13Hadamard n = 8, actual13the count is decided by a theorembefore any arithmetic happens
Fig. 30 Eleven, where the wide family needs five.
8 × 8: three exact determinants agree to the digit, and the float one does notdet A = 4096 on a hadamard matrix of order 8, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 1 word-sized prime put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 4096, a relative error of 0, which is what a determinant of 13 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 14 bits are needed and 1 prime supplies them.Bareiss13 bitsrationals4 bitsmodular26 bitsthe answer13 bitsHadamard14 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 1 prime0floating-point LU0det A = 4096three routes, one integerand no tolerance anywhere in the comparison
Fig. 31 The attained case, twenty-five bits budgeted and twenty-five used.
12 × 12: three exact determinants agree to the digit, and the float one does notdet A = 1 on a unitriangular matrix of order 12, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 1 word-sized prime put back together by the Chinese remainder theorem. The three differ by exactly zero — as integers, not to a tolerance. The floating-point LU of the same matrix returns 1, a relative error of 0, which is what a determinant of 1 bits does to a significand of 53. The modular route's entries never exceed 26 bits, which is why the number of primes has to be decided in advance: Hadamard's bound says 17 bits are needed and 1 prime supplies them.Bareiss1 bitsrationals1 bitsmodular26 bitsthe answer1 bitsHadamard17 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 1 prime0floating-point LU0det A = 1three routes, one integerand no tolerance anywhere in the comparison
Fig. 32 And the slackest, a determinant of one under an eighty-bit budget.
Every boxed entry is a 2 × 2 minor of the matrix beside itA 4 × 4 wide matrix and its state after 1 step of fraction-free elimination. Each of the 9 boxed entries was formed as (pivot × entry − column × row) divided by the previous pivot, and every one of those 9 divisions came out exact. The reason is that the entry at (i, j) is exactly the 2 × 2 minor of the ORIGINAL matrix on rows 0…0 and i, columns 0…0 and j — checked here against a cofactor expansion of A rather than against a second elimination. The widest number anywhere in the picture is 20 bits.-257325-86896-994-523-996278116-612-894131-704-870-299A, the matrix as given-257325-868960457461-837349794900-257937835192154782013835333729864267after 1 fraction-free step2 × 2 minors9 divisions, all exactthe intermediates are minorswhich is why the divisions come out whole
Fig. 33 The route that carries the length instead of budgeting for it.
Three exact eliminations of the same pascal matrix, and the widest number each one formsEvery route here returns the same determinant exactly, so there is no error to plot and the y-axis is the length of the intermediates in bits. At n = 10 the answer itself is 1 bits and Hadamard's bound allows 100. Fraction-free elimination never forms a number wider than 16 bits, because each of its intermediates is a minor of the original matrix. Rational elimination that reduces every fraction to lowest terms reaches 16 bits and pays a gcd on every arithmetic operation to stay there. Rational elimination that does not reduce reaches 16 bits — 1 times the width of the fraction-free route and 16 times the width of the answer. All three are correct.345678910110¹nwidest intermediate, in bitsrationals, not reducedfraction-free · rationals reduced · the answerone answer, three widthsn10answer1Hadamard bound100fraction-free16reduced rationals16unreduced16the error is zero on every curvethe cost is the length of the numbers
Fig. 34 A family whose entries are long and whose answer is one.
5 × 5: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a random matrix of order 5 is the diagonal [1, 1, 1, 1, 22616], reached by unimodular row and column operations, with each entry dividing the next — a property the elimination does not give and which has to be enforced and asserted. The same numbers computed from the definition — the gcd of all k × k minors, over the gcd of all (k−1) × (k−1) minors — are [1, 1, 1, 1, 22616], and the two agree entry for entry. Their product is 22616, which is |det A| = 22616. The Hermite form of the same matrix reaches 24 bits against the Smith form's 15, and its transform has determinant -1, so the lattice the rows generate is unchanged.s10 bitss20 bitss30 bitss40 bitss514 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A-2.3·10⁴Π invariants2.3·10⁴SNF widest15HNF widest24det of the transform-1an algorithm and a definitionagreeing as integers
Fig. 35 The invariant factors, which say which primes must be avoided.
One lattice, two bases: an orthogonality defect of 12.04 reduced to 1The dots are the lattice generated by (1, 0) and (12, 1) — every one of them, out to ±4 in each coefficient. The long pair of arrows is that basis; the short pair is what LLL returns after 1 steps, in exact rational arithmetic with δ = 3/4. The two bases generate the same set of points, which is checked rather than drawn: the lattice determinant is 1 before and 1 after, and every step of the reduction is a unimodular operation, which is what makes that so. What the reduction changes is the orthogonality defect — the product of the basis vectors' lengths over the determinant — from 12.042 to 1. One is the floor, and it is attained only by an orthogonal basis.the same lattice, twicewhat the reduction may not changedet, before1det, after1defect, before12defect, after1LLL steps1the determinant is the invariantand the defect is what is being reduced
Fig. 36 The lattice the second stage of the modular route reduces.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Bit lengthChinese remainder theoremDeterminantExact arithmeticFraction-free eliminationHadamard boundModular arithmetic