Exact arithmetic, and what it costs instead

Each column divides by the prime

Square random 0/1 matrices are almost always invertible over the rationals and invertible modulo a small prime only at that field's uniform law — so at twenty rows, 72% of the rationally invertible ones are singular modulo two. A few extra columns were predicted to remove most of that field-dependence modulo three and five. They remove it modulo every prime, at the rate the law for uniformly random matrices states: each extra column divides the share that falls short by about the prime. Four columns take the loss modulo two from 72% to 6.5% and modulo three from 45% to under 1%. The leading square block, meanwhile, keeps its square-matrix odds exactly — a rectangular matrix's rank is decided by all its maximal minors together, and only their greatest common divisor has to be prime to p.

Worth reading first: How many primes the answer needs · A matrix with no numbers in it · The number that decides nothing.

The field decides it, usually counted how often a matrix’s rank depends on the field it is read over. Random 0/1 matrices showed it at almost every size: at twenty rows 99.8% are invertible over the rationals, 29% modulo two and 56% modulo three, and modulo two they obey, corank by corank, the law for uniformly random matrices over that field — invertible with probability ∏k=1n(1−q−k)\prod_{k=1}^{n}(1 - q^{-k}), which for q=2q = 2 never rises above 0.289.

Its last section turned to rectangular matrices. An n×(n+k)n \times (n+k) matrix over a field with qq elements has full row rank with probability ∏i=k+1n+k(1−q−i)\prod_{i=k+1}^{n+k}(1 - q^{-i}), which is much nearer one, and “the prediction is that a few extra columns remove most of the field-dependence of full rank modulo three and five, and none of the field-dependence of the determinant’s divisibility, which is a square-matrix question.” It added a second prediction, with a sign: that the square matrices’ gap to the law “closes geometrically in nn, at a rate set by how far the entry distribution is from uniform modulo the prime”.

The first half of the first prediction holds, and more generally than stated. The second half holds and turns out to be the explanation. The second prediction was looking at the wrong field.

Six columns to spare

The matrices are 0/1 with each entry a fair coin, 3,000 of them at each of eight, twelve, sixteen and twenty rows, each drawn with six columns more than rows. Every prefix is read — the square matrix, then one column more, then two — so the comparison across column counts is on the same matrices. Each prefix is ranked modulo 2, 3, 5 and 7 by elimination in small integers, and over the rationals as the larger of its ranks modulo two primes near 2312^{31}, which equals the rational rank unless both primes divide every maximal minor; the earlier essay checked that construction against exact rational elimination.

Of 3,000 random 0/1 matrices with twenty rows, the share that are full rank over the rationals but not modulo 2, 3, 5 or 7, against the number of columns beyond twenty, beside the uniform law's chance of falling shortmodulo 2: 71.8%, 43.1%, 24.1%, 11.9%, 6.5%, 3.3%, 1.6%; modulo 3: 44.6%, 16.2%, 5.6%, 1.9%, 0.7%, 0.1%, 0.0%; modulo 5: 24.0%, 4.9%, 1.0%, 0.0%, 0.0%, 0.0%, 0.0%; modulo 7: 15.4%, 2.5%, 0.5%, 0.1%, 0.0%, 0.0%, 0.0% with 0 to 6 extra columns; floored at 0.01%. The dashed lines are the uniform law: one minus the product, over i from k + 1 to n + k, of one minus q to the power −i.012345610⁻⁴10⁻³10⁻²10⁻¹1extra columnsshare losing rank modulo qmodulo 2modulo 3modulo 5modulo 7twenty rows · dashed: the uniform law · floored at 10⁻⁴each column divides by q
Fig. 1 Twenty-row matrices: the share that are full rank over the rationals but not modulo 2, 3, 5 or 7, against the columns beyond twenty, on a logarithmic axis. The dashed lines are the uniform law’s chance of falling short.

The figure at the top of the page is the field-dependence the prediction was about: of the matrices the rationals call full rank, the share some prime does not. Square, it is 71.8% modulo two, 44.6% modulo three, 24.0% modulo five and 15.4% modulo seven. One extra column takes those to 43.1, 16.2, 4.9 and 2.5 per cent; two to 24.1, 5.6, 1.0 and 0.5; four to 6.5, 0.7, under 0.1 and under 0.1. Every line is straight on the logarithmic axis, and every line sits on its dashed law.

The prediction said three and five. It holds for every prime, two included, and the rate is the same rule for each: each column divides the shortfall by about qq. Modulo two the ratios from one column count to the next are 1.7, 1.8 and 2.0; modulo three 2.8, 2.9 and 2.9. With kk extra columns the law’s shortfall is dominated by its first factor, 1−(1−q−(k+1))=q−(k+1)1 - (1 - q^{-(k+1)}) = q^{-(k+1)}, so the chance of falling short is about q−(k+1)q^{-(k+1)} divided by 1−1/q1 - 1/q, and each extra column removes one power of qq.

Why a column is worth a power of the prime

Over a field, an n×(n+k)n \times (n+k) matrix falls short of full row rank exactly when its rows are dependent, and a fixed nonzero combination of the rows vanishes on each new column with probability 1/q1/q when the column is uniform. Adding a column is one more independent chance to break every dependence the first n+k−1n + k - 1 columns allowed; the chance that the smallest one survives is divided by qq.

Over the integers the same statement reads differently, and the difference is the essay’s second half. A rectangular integer matrix has full rank modulo pp unless pp divides every one of its maximal minors — every n×nn \times n determinant that a choice of nn columns makes. A square matrix has one maximal minor, its determinant; an n×(n+k)n \times (n+k) matrix has (n+kn)\binom{n+k}{n} of them. The rank modulo pp is full when pp fails to divide the greatest common divisor of all of them, which is a much weaker demand than that pp fail to divide any particular one. The prediction’s phrase, “the determinant’s divisibility, which is a square-matrix question”, is exactly right, and it is the mechanism: the leading square block’s determinant goes on being divisible by pp at the square rate, and the rank stops caring.

Twenty-row random 0/1 matrices with four extra columns: the share whose leading square block is nonsingular modulo each prime, against the share whose whole matrix has full rankmodulo 2: leading block 28.1%, whole matrix 93.5%; modulo 3: leading block 55.2%, whole matrix 99.3%; modulo 5: leading block 75.7%, whole matrix 100.0%; modulo 7: leading block 84.3%, whole matrix 100.0%.0%25%50%75%100%modulo 228.1%93.5%modulo 355.2%99.3%modulo 575.7%100.0%modulo 784.3%100.0%the leading 20 × 20 blockthe whole 20 × 24 matrix3,000 matricesone minor against all of them
Fig. 2 Twenty-row matrices with four extra columns: the share whose leading 20 × 20 block is nonsingular modulo each prime, against the share whose whole matrix has full rank.

The figure shows it on the same matrices. The leading block is nonsingular modulo two on 28.1% of them, the square law’s 28.9% within sampling error; the whole matrix of which it is the first twenty columns is full rank modulo two on 93.5%. Modulo three, 55.2% against 99.3%; modulo five and seven, 75.7% and 84.3% against all of them. Adding columns did not make any minor less divisible by the prime. It added minors, and the rank needs only one of them not to be.

A prime that divides the answer met the same distinction in a modular solve: a prime that divides the determinant is unlucky for the solve, whatever the other primes say. The rank of a rectangular matrix has more chances than a solve with a square one, and a prime has to be unlucky for all of them at once.

The invariant factor that has to be prime to p

The same fact has a cleaner statement in the language the rank depends on the ring opened the subject with. Every integer matrix has a Smith normal form: unimodular row and column operations — the ones that can be undone over the integers — reduce it to a diagonal of invariant factors d1∣d2∣⋯∣dnd_1 \mid d_2 \mid \cdots \mid d_n, each dividing the next. For an n×(n+k)n \times (n+k) matrix of full rational rank there are nn of them, and their product is the greatest common divisor of all the maximal minors. Unimodular operations survive reduction modulo any prime, so the rank modulo pp is nn minus the number of invariant factors pp divides — and since they divide each other in order, it is full exactly when pp does not divide the last one, dnd_n.

For a square matrix, dnd_n carries most of the determinant: what a determinant does not determine and the swell was one-sided both found random square integer matrices to have Smith forms of all ones and then the determinant, so a prime that divides the determinant divides dnd_n, and the rank modulo pp drops. A rectangular matrix’s dnd_n is a common divisor of many determinants, and a common divisor of many random-looking integers is almost always one. Each extra column multiplies the number of maximal minors and leaves fewer integers for which a given prime divides all of them. The law’s factor of 1/q1/q per column is that dilution, counted.

Nothing in this requires the field at all, which is the point of reading it this way. The rank over Fp\mathbb{F}_p is a question about one prime and the matrix’s last invariant factor, and the integers decide it before any reduction is made. Every entry under the determinant worked modulo the determinant because the determinant bounds everything the lattice can say; here the last invariant factor is the smaller number that bounds what every field can say about the rank.

The law holds from sixteen rows

The share of 3,000 random 0/1 matrices with 16 rows that have full row rank, over the rationals and modulo 2, 3, 5 and 7, against the number of extra columns, with the uniform law for each primeover ℚ: 0.972, 0.997, 0.999, 0.999, 0.999, 1.000, 1.000; modulo 2: 0.297, 0.609, 0.787, 0.885, 0.941, 0.966, 0.983; modulo 3: 0.552, 0.826, 0.941, 0.983, 0.992, 0.998, 1.000; modulo 5: 0.751, 0.952, 0.992, 0.998, 0.999, 1.000, 1.000; modulo 7: 0.839, 0.976, 0.996, 0.999, 0.999, 1.000, 1.000. The law modulo 2: 0.289, 0.578, 0.770, 0.880, 0.939, 0.969, 0.984.01234560.20.40.60.81extra columnsshare with full row rankover ℚmodulo 2modulo 3modulo 5modulo 716 rowsover ℚ, square0.97modulo 2, square0.3modulo 2, four extra0.94dots: measured · dashed: the uniform lawthe law, from sixteen rows on
Fig. 3 The share with full row rank over the rationals and modulo each prime, against the extra columns, with each prime’s uniform law dashed. The dial sets the number of rows.

At sixteen and twenty rows every prime’s measured share sits on its law at every column count, within four standard errors on all fifty-six comparisons — four primes, seven column counts, two row counts. The rationals sit at the top, above 0.97 square and above 0.999 with two columns to spare. The law was derived for matrices whose entries are uniform over the field, and 0/1 matrices are uniform only modulo two; modulo three, five and seven their entries never take most of the field’s values. At these sizes it does not matter. Twenty rows of coin flips have forgotten, modulo every small prime, that they were coin flips.

Turn the dial to eight rows and that stops being true for every prime but two. Modulo two the eight-row matrices are still on the law — 0.292 square against 0.290 — because their entries are uniform modulo two at every size. Modulo three, five and seven they fall below their laws, and the dial at twelve rows shows the shortfall shrinking.

Why a law derived for uniform entries should hold for coin flips modulo seven is worth a sentence. A determinant is a sum of n!n! signed products, and its residue modulo a small prime is a sum of so many nearly independent terms that the entries’ own distribution is washed out — the same reason a sum of many dice is close to uniform modulo a small number whatever the die. The washing-out needs enough terms, and at eight rows it is incomplete for every odd prime; at sixteen it is complete to within sampling error. An answer with no error in it began this field with exact arithmetic as a guarantee; this is exact arithmetic as a census, and the census says that small primes treat integer matrices of moderate size as random over their field, whatever the integers’ own distribution.

At eight rows the rationals set the ceiling

Eight-row random 0/1 matrices: the share at full row rank over the rationals and modulo 2, 3, 5 and 7, against the extra columns, with the uniform lawsover ℚ: 0.558, 0.833, 0.930, 0.969, 0.987, 0.993, 0.996; modulo 2: 0.292, 0.583, 0.784, 0.879, 0.941, 0.973, 0.986; modulo 3: 0.465, 0.767, 0.902, 0.958, 0.982, 0.992, 0.996; modulo 5: 0.542, 0.825, 0.928, 0.968, 0.987, 0.993, 0.996; modulo 7: 0.555, 0.833, 0.929, 0.969, 0.987, 0.993, 0.996. The square laws are 0.290, 0.560, 0.760, 0.837 for q = 2, 3, 5, 7.01234560.20.40.60.81extra columnsshare with full row rankover ℚmodulo 2modulo 3modulo 5modulo 7eight rows · dashed: the uniform lawsthe rationals set the ceiling
Fig. 4 Eight-row matrices: the share at full row rank over the rationals and modulo each prime, against the extra columns, with the uniform laws dashed. Modulo five and seven the measured shares lie on the rational curve, not on their own laws.

The shortfall is not modulo the prime at all. A matrix that is rank deficient over the rationals is rank deficient over every field, because a rational dependence among its rows clears denominators into an integer dependence that survives reduction modulo anything. At eight rows, 44% of square 0/1 matrices are singular over the rationals — two equal rows, a zero row, a row that is the sum of two others are all common when there are only 282^8 possible rows — and every one of them is singular modulo every prime, which the measurement checks matrix by matrix.

So the eight-row share modulo five and seven is the rational share — 0.542 and 0.555 against the rationals’ 0.558 — and the uniform laws, 0.760 and 0.837, are not reachable. Modulo three, 0.465, the field’s own shortfall adds a little to the rationals’. The same holds with columns to spare: the rational share climbs to 0.996 with six extra columns and every odd prime climbs with it, step for step.

This is where the second prediction went wrong. It expected the square matrices’ gap to the law to close “at a rate set by how far the entry distribution is from uniform modulo the prime”, and it read the gap as a property of the field — slower modulo five than modulo three, because 0/1 entries cover two-fifths of the field rather than two-thirds. At these sizes the gap is the rationals’ singularity probability, which is the same for every prime and falls with nn at its own rate: 44% at eight rows, 17% at twelve, 3% at sixteen, 0.4% at twenty. Modulo five the gap to the law is 0.22 at eight rows and 0.06 at twelve; modulo seven 0.28 and 0.08; modulo three, whose law is lowest and so least constrained by the rational ceiling, 0.10 and 0.02. Five does close more slowly than three, as predicted — but because its law sits higher under the same ceiling, not because its entries are further from uniform.

A column or two, prime by prime

How many columns beyond twenty a random 0/1 matrix with twenty rows needs before it has full row rank modulo 2, 3, 5 and 7, over 3,000 matrices, with each prime's meanmodulo 2: 28.1%, 28.8%, 19.0%, 12.2%, 5.4%, 3.2%, 1.7% at 0 to 6; mean 1.51 against the law's 1.61; modulo 3: 55.2%, 28.6%, 10.6%, 3.8%, 1.2%, 0.5%, 0.1% at 0 to 6; mean 0.69 against the law's 0.68; modulo 5: 75.7%, 19.3%, 3.9%, 1.0%, 0.0%, 0.0%, 0.0% at 0 to 6; mean 0.30 against the law's 0.30; modulo 7: 84.3%, 13.1%, 2.1%, 0.5%, 0.1%, 0.0%, 0.0% at 0 to 6; mean 0.19 against the law's 0.19.modulo 228%29%19%12%5%3%2%mean 1.51modulo 355%29%11%4%1%1%mean 0.69modulo 576%19%4%1%mean 0.30modulo 784%13%2%mean 0.190123456extra columns needed before full ranktwenty rows, 3,000 matricesa column or two, a prime at a time
Fig. 5 How many columns beyond twenty each twenty-row matrix needs before it has full rank modulo each prime, over 3,000 matrices, with each prime’s mean.

Read the other way, the law says how many columns a matrix needs before a prime stops mattering. Modulo two, 28% of twenty-row matrices need none, 29% need one, 19% two, and 1.7% still fall short with six; the mean, counted to six, is 1.51 columns. Modulo three the mean is 0.69 against the law’s 0.68; modulo five 0.30 against 0.30; modulo seven 0.19. A matrix that will be read modulo many primes — as how many primes the answer needs reads every exact solve — is limited by the smallest, and modulo two it takes about seven extra columns before fewer than one matrix in a hundred falls short.

The practical version is the one exact-rank algorithms use: to decide the rank of an integer matrix modulo a prime with high confidence, it is not the matrix that should be random but the reduction. Multiply by a random matrix with a few extra columns, or project to a few extra random combinations, and a prime that divided every maximal minor of the original would have to divide every minor of the projection. Rank is a decision made the floating-point version of that point; here the decision is exact and only the field is chosen, and choosing a large one is the same remedy as adding columns, since the shortfall is about 1/q1/q either way.

The two remedies — more columns, or a larger field — price differently, and the measurement says by how much. Each extra column costs one more column of elimination, a fraction 1/n1/n of the work, and buys a factor of qq. A larger prime buys the same factor all at once: modulo a prime near 2312^{31} the shortfall of a square matrix is about 2−312^{-31}, and the arithmetic still fits in a machine word with room to multiply. For deciding a rank, the large prime is the better trade by far, which is why the rational ranks here are computed that way. The small primes are where the trade becomes visible, and they are also where it matters in practice, because a computation over F2\mathbb{F}_2 is not chosen for convenience — codes, graphs and parity problems live there — and in that field the only remedy is more columns or more equations, at one bit of confidence per column. Seven columns for a one-in-a-hundred chance of falling short, ten for one in a thousand: a rule of thumb that is exact enough to plan with, since the measured shares sit on the law to sampling error from sixteen rows up.

What the coin flips do not settle

The entries here are fair coins. Sparse 0/1 matrices — the earlier essay measured density a quarter — are not uniform modulo two, and the law should then be approached from below at small sizes for every prime, two included; whether a column still divides the shortfall by two there is not measured. The rational rank is the larger of two large-prime ranks, which is exact unless both primes divide every maximal minor; on 0/1 matrices of these sizes that would need minors with two specific ten-digit prime factors, and it was not ruled out by an independent rational elimination on the rectangular ones. And the mean extra columns are counted to six; modulo two the 1.7% that need more pull the measured mean below the law’s 1.61.

Still open: symmetric matrices, and the rational ceiling’s own law

Adjacency matrices. The earlier essay’s second question stands. A random graph’s adjacency matrix is symmetric, and symmetric matrices over a field follow a different law — modulo two, a symmetric matrix’s corank distribution differs from a general one’s at every size. The prediction with a sign is that random graphs on twenty vertices with edge probability one half are nonsingular modulo two at the symmetric law’s rate, about 0.42, not the general law’s 0.29, and that modulo three they approach the symmetric law from below as these approached the general one.

The rationals’ own shortfall. At eight rows 44% of 0/1 matrices are singular over the rationals, then 17%, 2.8% and 0.4% at twelve, sixteen and twenty. Two equal rows or two equal columns account for about 2(n2)2−n2\binom{n}{2}2^{-n} of it, which is 0.04% at twenty rows against the 0.4% measured. The prediction with a sign is that the shortfall keeps falling by a factor of about seven every four rows, to about 0.06% at twenty-four, and that dependences among three or more rows carry at least nine-tenths of it at every size from sixteen up — so that the rational ceiling is not a matter of repeated rows at any size measured.

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.

DeterminantExact arithmeticExact ground truthInvariant factorsModular arithmeticRank is a decisionUnlucky prime