Exact arithmetic, and what it costs instead

The rank depends on the ring

A floating-point rank is a decision about a threshold. Remove the arithmetic error entirely and the threshold goes away — and the answer still is not a property of the array of numbers, because one integer matrix has rank six over the rationals, five modulo three and four modulo two, with nothing rounded and nothing decided.

Worth reading first: Rank is a decision · An answer with no error in it · Elimination is a sequence of choices.

Rank is a decision is one of this site’s oldest arguments and it has a specific shape. A floating-point matrix does not have a rank; it has singular values, and somewhere in them is a gap, and the rank is where somebody draws a line. The essay’s whole content is the line: it is a threshold, it is a choice, and the choice is where the answer comes from.

A reader is entitled to conclude that the trouble is the arithmetic, and that exact arithmetic would settle it. It does settle that. It does not settle the question.

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. 1 One six by six matrix of integers. Its rank is computed exactly, by elimination, with no threshold anywhere and no small number to be careful about. Three different answers.

The site has said several times that a computed quantity often belongs to the algorithm rather than to the matrix. This is the sharper version: a quantity that belongs to neither, because the question was underspecified and the arithmetic supplied the missing argument silently.

Three ranks, none of them a judgement

The matrix in the figure has rank six over the rationals, five over the field with three elements, and four over the field with two. Every one of those computations is an exact elimination: the entries are integers, the pivots are exact, an entry is zero or it is not, and there is nothing anywhere for a tolerance to compare against.

So the rank of a matrix is not a function of its entries. It is a function of the entries together with the ring they are read in, and dropping the second argument is what makes the question look ill-posed. A routine that reports “the rank” has silently chosen one, and a modular routine has chosen a finite field.

It is worth pausing on how unlike the site’s usual findings that is. Almost everything here is about an implementation failing to deliver what the algebra promised — orthogonality that is not orthogonal, a residual that is small while the error is not, an eigenvalue moved by the eighth root of a perturbation. In every one of those the algebra is unambiguous and the arithmetic falls short. Here the arithmetic is perfect and the algebra is ambiguous: the question has a parameter nobody supplied.

Where the different answers come from

The construction says exactly why, and it is built rather than found.

Take the diagonal matrix diag(1, 1, 1, 1, 2, 6) and conjugate it by two unimodular matrices — integer matrices with determinant ±1, so their inverses are integral too. The result is an ordinary looking integer matrix with no visible structure, and its invariant factors are unchanged by the conjugation: still 1, 1, 1, 1, 2, 6.

Over the rationals every one of those is invertible, so the rank is six. Modulo 3 the last one vanishes, so the rank is five. Modulo 2 both the fifth and the sixth vanish, so the rank is four. And modulo 5, 7, 11, 13, 101 or 65537 nothing vanishes, so the rank is six again.

That is the whole mechanism, and it makes the phenomenon completely predictable: the rank over 𝔽ₚ is six minus the number of invariant factors p divides. Not a probability, not a tendency — a count. The figure asserts each of the three values before drawing them, so a change to the construction that broke the correspondence would fail rather than merely make the picture duller.

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. 2 The invariant factors of an ordinary random integer matrix: five entries, four of them 1 and one carrying the entire determinant. The primes dividing that last factor are the only ones at which its rank drops.

Why this is a different failure from the threshold one

It is worth separating the two carefully, because they are easy to blur into rank is difficult.

The threshold version is about a continuum. A singular value of 10⁻¹² sits between zero and one, the matrix is near a rank-deficient one and is not one, and the decision is genuinely a decision: different thresholds give different answers and all of them are defensible. The cheap rank-revealing route is about how well a greedy pivot rule locates that gap, and it has a matrix on which the rule has nothing to choose between.

The ring version is about a discontinuity, and there is nothing to decide. Over 𝔽₃ the rank is five, exactly and provably; over ℚ it is six, exactly and provably; and there is no threshold whose adjustment would reconcile them, because both are right. What is wrong is only the assumption that they were answering one question.

That makes the ring version closer to a partition decided in the last digit than to anything in the rank literature: a correct computation whose subject is not the one that was asked about. And it is the same substitution as the unlucky prime one essay back — which is not a coincidence, since a prime that is unlucky for the determinant is a prime dividing the last invariant factor, and the determinant is the product of them all.

What the elimination looks like when it happens

The mechanism deserves one concrete pass, because “an invariant factor is divisible by p” is a statement about a normal form and the thing that actually happens is a pivot.

Eliminate the matrix over ℚ and the pivots are nonzero all the way down: six of them, product ±12, rank six. Eliminate the same matrix modulo 3 and five of the six pivots are nonzero units of 𝔽₃; the sixth is 0, because the entry that would have been a multiple of 3 is a multiple of 3, and in 𝔽₃ that is zero. Nothing was small. Nothing was rounded. An integer that happened to be divisible by the modulus became the additive identity, which is what reduction modulo p is for.

Modulo 2 it happens twice, because two invariant factors are even, and the elimination runs out of pivots two rows early.

The reason this cannot be defended against by care is that the entry which vanishes is not identifiable in advance without knowing the invariant factors — and computing those is strictly harder than the rank was. There is no cheap test. What there is instead is the observation that it happens at a computable, finite set of primes, so a second prime almost certainly disagrees with a first that was unlucky.

What a modular rank is good for anyway

The natural reaction is that modular rank is unusable, and it is not. It is a lower bound, and a lower bound on rank is often exactly what is wanted.

The rank over 𝔽ₚ is never larger than the rank over ℚ, because a linear dependence over the rationals can be cleared of denominators and reduced modulo p, while a dependence modulo p need not lift. So one modular elimination on machine words certifies that the true rank is at least what it found — and certifying a large rank is the hard direction, since it needs a nonvanishing minor and a single modular elimination has produced one.

The direction it cannot certify is deficiency. A matrix with modular rank four might have rank four, five or six over ℚ, and no number of primes settles it — although agreement across several primes is strong evidence, and disagreement between two primes is proof that at least one of them is unlucky.

That asymmetry is the same one the determinant had: nonsingularity is cheap to prove and singularity is not, and it is the shape of certificate the interval field spends a whole essay on: a verdict of yes that is cheap and a verdict of no that is not, with nothing can be said as the honest third outcome. It comes from the same place. A nonzero object stays nonzero at almost every prime, and a zero object is zero at all of them, so the primes can witness presence and never absence.

One 8 × 8 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 8; over 𝔽2 and 𝔽3 it is 6 and 7. 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.8𝔽26𝔽37𝔽58𝔽78𝔽118𝔽138𝔽1018𝔽655378rank, by the ring the entries are read inthe rank of one matrixover ℚ8over 𝔽26over 𝔽37over 𝔽58over 𝔽78nothing is rounded hereand the answer still is not a property of the matrix
Fig. 3 The same construction at order eight, where the ranks over 𝔽₂ and 𝔽₃ are six and seven and every larger prime returns eight.

The rank over ℤ, which is a third thing again

There is a further question the field has to name, because it is the one an application usually wanted and it is not the rank at all.

An integer matrix defines a map from ℤⁿ to ℤᵐ. The image of that map is a subgroup, and describing it takes more than a dimension: it is generated by vectors, and the quotient by it can have torsion — elements of finite order — which no rank records. The matrix in the hero has rank six over ℚ, so its image spans the whole space over the rationals; over the integers its image is an index-12 subgroup, and the 12 is the product of its invariant factors — which is the determinant, and is why an integer matrix’s determinant measures a volume in a sense that survives having no real entries at all.

So there are three separate quantities and the word “rank” is used for the first two:

  • the rank over ℚ, which is how many rows are independent when division is allowed;
  • the rank over 𝔽ₚ, which is that count when arithmetic is done modulo p;
  • and the full invariant-factor list, which is what the map over ℤ actually is, and of which both ranks are shadows.

The third is the subject of the next essay, and once it is in hand the first two stop being separate facts: the rank over ℚ is the number of nonzero invariant factors, and the rank over 𝔽ₚ is the number of them p does not divide.

What a numerical analyst should take from it

There is a practical reading of all this that does not require caring about finite fields, and it is the one worth carrying out of the essay.

A rank returned by any routine is a rank with respect to something, and the something is rarely printed. In floating point it is a threshold, usually a multiple of the largest singular value and the machine epsilon, and the essays on that argue it should be printed beside the answer. In exact modular arithmetic it is a prime. In exact rational arithmetic it is the rationals, which is the only case where the parameter is the one almost everybody meant — and it is also the most expensive case, which is why library routines are rarely doing it.

So a rank is three things at once: a number, a ring, and in the floating-point case a tolerance. Two of the three are usually thrown away before the number reaches the caller, and both of the discarded ones can change the answer.

And the two failure modes do not overlap, so neither defends against the other. Exact arithmetic removes the threshold and leaves the ring; a well-separated gap removes the ambiguity in the threshold and says nothing about the ring; and a matrix can be badly conditioned over ℝ and perfectly well behaved over 𝔽ₚ, or the reverse. There is no single computation that settles rank once, and the useful question is always which of the three quantities the application actually depends on.

The cost, which is why anybody does this modulo p

The reason a modular rank is computed at all is the reason the whole modular route exists: no growth.

An exact rank over ℚ by fraction-free elimination forms intermediates of the determinant’s own length, so on a matrix with three-digit entries at n = 12 it is doing arithmetic on 121-bit integers. The same elimination modulo a 26-bit prime is doing arithmetic on machine words throughout, and it is the same n³/3 operations. The ratio is the length, exactly as it was for the determinant.

So the working method is the one the asymmetry suggests: compute the rank modulo a couple of primes, take the largest answer, and — if the application needs certainty rather than a lower bound — pay for one exact elimination to confirm it. The modular passes are nearly free and they say what the answer probably is, which is what makes the expensive confirmation short.

That is the same two-stage shape as almost every expensive computation on this site: a cheap estimate that is usually right, and an expensive verification that is run once. What is different here is that the cheap stage’s failure is not an inaccuracy — it is an integer that is too small by one, arrived at exactly, and the only thing that reveals it is a second cheap stage disagreeing.

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. 4 The length the exact route carries and the modular route does not, on the family where the difference is largest.

The construction, and why it had to be built

The first attempt at this figure did what would occur to anybody: take a random integer matrix, make two of its rows dependent so the rank over ℚ drops, and hope that a small prime drops it further.

It does not. A matrix built by adding rows has rank deficiency over every ring at once, because the dependency it carries has integer coefficients and reduces modulo anything. The measurement came back with the same rank at every prime, and the figure had nothing to show — which is the correct outcome for that construction and would have been read as evidence for the claim the essay exists to refuse.

What is needed is a dependency that exists modulo p and not over ℚ, and there is exactly one way to arrange one: an invariant factor divisible by p. So the construction starts from the invariant factors and works outwards — diag(1, 1, 1, 1, 2, 6), then two unimodular conjugations to hide it — and the ranks at 2, 3 and every other prime are known before anything is computed.

That is the general rule this field keeps rediscovering. A counterexample found by looking is evidence that one exists; a counterexample built from the property is evidence about the property, and it can carry an assertion. Here the assertion is three exact equalities — rank n−2 modulo two, n−1 modulo three, n at every other prime tried — and a build in which the construction stopped having that structure would fail rather than produce a less interesting picture.

4 × 4: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a random matrix of order 4 is the diagonal [1, 1, 1, 4386], 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, 4386], and the two agree entry for entry. Their product is 4386, which is |det A| = 4386. The Hermite form of the same matrix reaches 13 bits against the Smith form's 13, and its transform has determinant -1, so the lattice the rows generate is unchanged.s10 bitss20 bitss30 bitss412 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A-4386Π invariants4386SNF widest13HNF widest13det of the transform-1an algorithm and a definitionagreeing as integers
Fig. 5 The invariant factors computed two ways at the smallest size the definition is affordable at: by unimodular elimination, and by the gcds of every minor of each order.

At other settings

One 4 × 4 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 4; over 𝔽2 and 𝔽3 it is 2 and 3. 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.4𝔽22𝔽33𝔽54𝔽74𝔽114𝔽134𝔽1014𝔽655374rank, by the ring the entries are read inthe rank of one matrixover ℚ4over 𝔽22over 𝔽33over 𝔽54over 𝔽74nothing is rounded hereand the answer still is not a property of the matrix
Fig. 6 The smallest size the construction exists at, where the ranks are four, three and two.
One 9 × 9 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 9; over 𝔽2 and 𝔽3 it is 7 and 8. 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.9𝔽27𝔽38𝔽59𝔽79𝔽119𝔽139𝔽1019𝔽655379rank, by the ring the entries are read inthe rank of one matrixover ℚ9over 𝔽27over 𝔽38over 𝔽59over 𝔽79nothing is rounded hereand the answer still is not a property of the matrix
Fig. 7 Order nine, where the two small primes still lose one and two and nothing else changes.
One 7 × 7 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 7; over 𝔽2 and 𝔽3 it is 5 and 6. 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.7𝔽25𝔽36𝔽57𝔽77𝔽117𝔽137𝔽1017𝔽655377rank, by the ring the entries are read inthe rank of one matrixover ℚ7over 𝔽25over 𝔽36over 𝔽57over 𝔽77nothing is rounded hereand the answer still is not a property of the matrix
Fig. 8 Order seven, with the same invariant factors placed in a larger matrix.
6 × 6: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a random matrix of order 6 is the diagonal [1, 1, 1, 1, 1, 40098], 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, 40098], and the two agree entry for entry. Their product is 40098, which is |det A| = 40098. The Hermite form of the same matrix reaches 27 bits against the Smith form's 16, and its transform has determinant -1, so the lattice the rows generate is unchanged.s10 bitss20 bitss30 bitss40 bitss50 bitss615 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A-4·10⁴Π invariants4·10⁴SNF widest16HNF widest27det of the transform-1an algorithm and a definitionagreeing as integers
Fig. 9 Six invariant factors, computed by an algorithm and by the gcds of the minors.
5 × 5: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a pascal 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 7 bits against the Smith form's 7, 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 widest7HNF widest7det of the transform1an algorithm and a definitionagreeing as integers
Fig. 10 Pascal, whose determinant is 1, so every invariant factor is and no prime is unlucky for it at all.
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. 11 The determinant version of the same substitution, at the primes dividing the last invariant factor.
Singular values of a rank-4 matrix with noise of relative size 10⁻⁸Ten singular values on a logarithmic axis. The first four sit near one; the rest sit at the noise level, and the vertical distance between the two groups is the evidence for the rank.1234567891010⁻¹⁸10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³1indexsingular valuecutoff, σ₁ · 10⁻¹⁰numerical rank 10gap 8.2·10⁶an opiniontrue rank 410×10, built with 4 nonzero valuesrank is a decision
Fig. 12 The threshold version, which is the failure this one is not.
A randomised rank-k solve, 4 seeds a rankRelative error against the rank kept, on a logarithmic vertical axis, with a vertical bar at each rank spanning the seeds. The band is 1.68 wide at rank 8, where the method is at its worst, and 1.004 wide at rank 20, where it is at its best. The same computation on the same data returns a different answer each time.0481216202428321rank keptrelative errormedianthe answer movesspread at rank 81.7spread at rank 201best median error0.15widest where the method is worstand the bound does not say so
Fig. 13 A rank as a band of plausible values, which an exact rank never is.
How far |r_nn| sits above σ_min on Kahan's matrix, against the size and the parameter3 curves of |r_nn| ÷ σ_min against n, one per Kahan parameter. Every curve rises without turning over, reaching 4·10⁶ at n = 40, c = 0.5. Column pivoting makes no interchange at any point on any of them, so the failure is not a poor choice — there is nothing to choose.815222936110¹10²10³10⁴10⁵10⁶10⁷10⁸size of the matrix|r_nn| ÷ σ_minthe two agreec = 0.2c = 0.35c = 0.5no ceilingratio at n = 1021ratio at n = 404·10⁶interchanges, anywhere0the greedy rule never had a choiceand the gap grows with every row
Fig. 14 What a greedy pivot rule can see of a gap, in the field that measured it.
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. 15 The growth an exact rank carries and a modular one does not.
10 × 10: three exact determinants agree to the digit, and the float one does notdet A = -77985307738 on a random matrix of order 10, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 2 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 -7.79853077·10¹⁰, a relative error of 3.913·10⁻¹⁶, which is what a determinant of 37 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 43 bits are needed and 2 primes supply them.Bareiss37 bitsrationals36 bitsmodular26 bitsthe answer37 bitsHadamard43 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 2 primes0floating-point LU3.9·10⁻¹⁶det A = -77985307738three routes, one integerand no tolerance anywhere in the comparison
Fig. 16 The determinant, which is the product of the invariant factors this essay is about.
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 = 10 the question occupies 400 bits — 10² entries of 4 bits each — and the answer occupies 721, a ratio of 1.8. 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 37 bits, while a numerator can be, at 38 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 outn10question400answer721det A37widest part38the answer is the floorand no route writes it down more cheaply
Fig. 17 The answer’s own length, on a system this elimination would be the first step of.
One 5 × 5 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 5; over 𝔽2 and 𝔽3 it is 3 and 4. 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.5𝔽23𝔽34𝔽55𝔽75𝔽115𝔽135𝔽1015𝔽655375rank, by the ring the entries are read inthe rank of one matrixover ℚ5over 𝔽23over 𝔽34over 𝔽55over 𝔽75nothing is rounded hereand the answer still is not a property of the matrix
Fig. 18 Order five, where the ranks are five, four and three.
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. 19 The construction at its drawn size, with three distinct answers.
5 × 5: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a wide matrix of order 5 is the diagonal [1, 1, 1, 1, 2580458337283640], 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, 2580458337283640], and the two agree entry for entry. Their product is 2580458337283640, which is |det A| = 2580458337283640. The Hermite form of the same matrix reaches 106 bits against the Smith form's 52, and its transform has determinant -1, so the lattice the rows generate is unchanged.s10 bitss20 bitss30 bitss40 bitss551 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A-2.6·10¹⁵Π invariants2.6·10¹⁵SNF widest52HNF widest106det of the transform-1an algorithm and a definitionagreeing as integers
Fig. 20 Invariant factors on wide entries, where only the last is not 1.
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. 21 A unimodular map, whose rank is the same over every ring.
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. 22 The determinant version of the same substitution.
8 × 8: three exact determinants agree to the digit, and the float one does notdet A = -8650618 on a random matrix of order 8, computed three ways with no rounding anywhere: fraction-free elimination, elimination over the rationals, and elimination modulo 2 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 -8.650618·10⁶, a relative error of 2.153·10⁻¹⁶, which is what a determinant of 24 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 33 bits are needed and 2 primes supply them.Bareiss24 bitsrationals23 bitsmodular26 bitsthe answer24 bitsHadamard33 bitswidest number formedrelative error against the exact answerfraction-free (Bareiss)0rational elimination0modular, 2 primes0floating-point LU2.2·10⁻¹⁶det A = -8650618three routes, one integerand no tolerance anywhere in the comparison
Fig. 23 The determinant, which is the product of the invariant factors.
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. 24 What an exact rank over the rationals costs in length.
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. 25 The budget a modular rank does not have and does not need.
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 = 9 the question occupies 324 bits — 9² entries of 4 bits each — and the answer occupies 454, a ratio of 1.4. 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 25 bits, while a numerator can be, at 28 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.345678910²nbitsthe answerthe question · det Abits in, bits outn9question324answer454det A25widest part28the answer is the floorand no route writes it down more cheaply
Fig. 26 The answer a full-rank system of this kind produces.
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. 27 The lattice whose quotient the invariant factors describe.
One 9 × 9 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 9; over 𝔽2 and 𝔽3 it is 7 and 8. 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.9𝔽27𝔽38𝔽59𝔽79𝔽119𝔽139𝔽1019𝔽655379rank, by the ring the entries are read inthe rank of one matrixover ℚ9over 𝔽27over 𝔽38over 𝔽59over 𝔽79nothing is rounded hereand the answer still is not a property of the matrix
Fig. 28 The largest size drawn, where the two small primes still cost one and two.
3 × 3: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a random matrix of order 3 is the diagonal [1, 1, 330], 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, 330], and the two agree entry for entry. Their product is 330, which is |det A| = 330. The Hermite form of the same matrix reaches 6 bits against the Smith form's 6, and its transform has determinant -1, so the lattice the rows generate is unchanged.s10 bitss20 bitss38 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A-330Π invariants330SNF widest6HNF widest6det of the transform-1an algorithm and a definitionagreeing as integers
Fig. 29 The smallest size the definition by minors runs at.
4 × 4: the invariant factors, computed twice by routes with no algorithm in commonThe Smith normal form of a hilbert matrix of order 4 is the diagonal [1, 7, 7, 105], 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, 7, 7, 105], and the two agree entry for entry. Their product is 5145, which is |det A| = 5145. The Hermite form of the same matrix reaches 9 bits against the Smith form's 9, and its transform has determinant 1, so the lattice the rows generate is unchanged.s10 bitss23 bitss33 bitss47 bitsinvariant factors, in bitstwo routes, and a conserved quantitydet A5145Π invariants5145SNF widest9HNF widest9det of the transform1an algorithm and a definitionagreeing as integers
Fig. 30 An ill-conditioned integer matrix’s invariant factors.
det A = 30030, and its residue at 36 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 36 primes here are unlucky, a rate of 13.9 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 swept36unlucky5rate0.14det, in bits15singular mod p is not singularand one residue cannot tell them apart
Fig. 31 The determinant version, at order eight.
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. 32 The product of the invariant factors, three ways.
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. 33 The length an exact rank over the rationals carries.
Every boxed entry is a 3 × 3 minor of the matrix beside itA 5 × 5 random 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 9 bits.1-2-6-7-474-26-12-5-8-524-394151435A, the matrix as given1-2-6-7-401840552700112217207003943011710017279153after 2 fraction-free steps3 × 3 minors25 divisions, all exactthe intermediates are minorswhich is why the divisions come out whole
Fig. 34 The elimination whose zero pivot is a rank statement.
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 = 9 the question occupies 810 bits — 9² entries of 10 bits each — and the answer occupies 1626, a ratio of 2.01. 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 91 bits, while a numerator can be, at 92 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.345678910²10³nbitsthe answerthe question · det Abits in, bits outn9question810answer1626det A91widest part92the answer is the floorand no route writes it down more cheaply
Fig. 35 A full-rank system’s answer, in bits.

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.

Exact arithmeticInvariant factorsModular arithmeticRank is a decisionSmith normal formUnimodularUnlucky prime