The budget was a worst case
Worth reading first: How many primes the answer needs · An answer with no error in it.
How many primes the answer needs set up a modular determinant with a fixed plan. Work modulo a word-sized prime and no intermediate can exceed twenty-six bits, whatever the matrix does. Reassemble the answer from several primes by the Chinese remainder theorem. And decide how many primes beforehand, “by a theorem about how large a determinant can be, not by trying more until it settles”. Hadamard’s bound is the theorem. A fraction recovered from one remainder closed its own route with the same note: nothing in the algorithm adapts, and every quantity deciding how much work happens is computed before any work happens.
The plan is clean, and it is not what anybody writing a production exact solver actually does. Reconstruct after every prime, watch the value, and stop when it stops changing. The difference is worth measuring in both directions, because a theorem about a worst case may be far from the case in hand, and because a value that has stopped changing is not automatically a value that is right.
Both directions are measurable exactly here. Fraction-free elimination returns the true determinant in integers, on every matrix below, so each stop can be scored with no margin at all.
What the bound budgets against what the matrix needs
Six families are used, at orders 8, 16 and 32. Three of them are built so their determinants are large or their rows are long: random entries below 9, random entries below 999, and Hadamard matrices, whose rows are exactly orthogonal. Two have a determinant of one: Pascal matrices and unit triangular ones. And scaled Hilbert matrices have a determinant that is large in itself but far below the size of the entries. For each, Hadamard’s product of row norms is taken, and a prime supplies about twenty-six bits.
At order 32 the bound is doing very different amounts of work. On a Hadamard matrix it is exact: four primes budgeted, four needed. That family is the case of equality in the bound, by construction. On random entries it is nearly exact too, seven budgeted against six needed below 9 and fifteen against fourteen below 999. A random matrix has nearly orthogonal rows, so its determinant comes within a factor that is modest in the logarithm of the product of its row norms, and a logarithm is what primes are counted in.
The three other families are nothing like that. The scaled Hilbert matrix is budgeted 107 primes and needs 34. The unit triangular matrix is budgeted three and needs one. And the Pascal matrix, whose rows hold binomial coefficients of up to fifty-nine bits, is budgeted forty-six primes for a determinant of exactly one.
Across the orders this picture is very regular. On the random family the two curves run together, 137 bits against 161 at order 32. On the Hilbert family they run parallel at a factor of about three, on a logarithmic axis, so the gap grows with the order: 881 bits of determinant against a bound of 2,782. And on Pascal the determinant stays at one bit while the bound goes through 1,192. So the size of the gap is a property of the family and not of the order. A matrix whose rows are far from orthogonal has a determinant far below the product of their lengths, and nothing about that is an accident, since that is exactly what the bound’s equality condition says.
The Hadamard ratio that the number that decides nothing proposed as a scale-free measure of how far the columns are from orthogonal is the same quantity seen from the other side. Written in bits it is exactly the size of the over-budget, so the first thing an exact solver could read about a matrix before running anything is how badly its budget will overpay, given a cheap estimate of the determinant’s size. Such an estimate is generally not to be had, and that is why the plan exists at all.
The stop that tries more until it settles
The alternative costs almost nothing to state. After each prime, update the running value by Garner’s incremental form of the remainder theorem, centre it in the symmetric range, and compare it with the last one. If the value is the same for primes in a row, return it.
The arithmetic behind it is simple. A true determinant of bits has a unique symmetric residue once the product of the primes passes , so from that prime on the value does not move, whatever else happens. The stop therefore returns no later than the number of primes the determinant needs, plus . That part is a theorem as well. It gives the stop an upper limit that depends on the determinant and not on the rows.
On all eighteen cases, at each of , 2 and 3, the value the stop returned equals the determinant from exact elimination. The count of primes is exactly the need plus every time. The Pascal matrix of order 32 returns after two primes, or 4 per cent of the budget, and the scaled Hilbert matrix after 35, or a third of it.
The figure also shows who loses. On Hadamard matrices at order 32, the stop with one repeat uses five primes where the plan uses four, and at three repeats it uses seven. That is 75 per cent more than the plan. On the two random families a stop with one repeat breaks even and three repeats pay about a fifth more. The bound was already tight on these, so any confirmation primes are simply extra. The stop saves work where the bound is loose, and it costs a constant where the bound is tight. Since the constant is a few primes and the saving is potentially most of them, that trade favours the stop on any collection that is not made up purely of matrices with nearly orthogonal rows. The plan, however, has a different virtue, which is what the next section is about.
A value can settle and be wrong
The stop’s failure is simple to arrange. Suppose modulo every prime the stop has seen, with . Then the value stays at and the stop returns it. So all that is needed is a true determinant that differs from a small number by a multiple of the first few primes in the list. And an integer matrix can be built with any chosen determinant: a diagonal matrix with that number in one corner, multiplied on each side by a few random unimodular matrices.
That is the result here. An order-8 matrix built on the first six primes of the list has a determinant with 156 bits, and every stop asking for fewer than six repeats reads a value of seven and returns it: after two primes at one repeat, three at two repeats, four at three repeats. The answer has the right sign and looks very plausible. It is wrong by something a hundred and fifty bits long. Only when the stop asks for as many repeats as the determinant has built-in primes does the value finally move, and after six repeats it stops at thirteen primes with the right number. A stop cannot know what repeat count would be enough without knowing the answer. Hadamard’s bound is true of this matrix too. Its entries run to 160 bits, a consequence of how it was built, so the bound budgets 1,138 bits or 44 primes, and the plan returns the right answer without any question arising.
A prime that divides the answer already showed the small case of this: a modular elimination reports a singular matrix, truthfully, because the prime divides the determinant, and the residue itself gives no warning. This is that same phenomenon lengthened. A stop that takes each prime’s word for what it says inherits the same blindness once per prime.
So the plan’s virtue is real, and that is what the original essay meant. A count derived from a theorem cannot be fooled by the matrix. A count derived from what the computation has seen so far can. This matrix was built for the purpose, and its 160-bit entries show it, but nothing in the failure needs them: any determinant is a multiple of its own factors, and it is only an adversary, or extreme bad luck, that places several of those at the front of one particular list.
Randomness instead of a budget
That last observation points at the repair. The stop has no defence against a list that is known in advance. It does have a defence against bad luck, because the list can be chosen after the matrix.
Draw the primes in random order from the same pool of forty. A stop with one repeat on a matrix with six bad primes in the pool is fooled when both of its first two primes are bad, with a probability of about 1.9 per cent. Over 2,000 draws it is measured at 2.6 per cent, and it stays close to the calculated rate at each of the five settings in the figure, from 9.2 per cent measured against 8.5 calculated down to 0.7 against 0.54. Each extra repeat multiplies the probability by a small ratio.
Forty primes is a small pool, chosen so that the measurement could see the failures. The primes below number about four million. If a determinant is bounded by bits, it can have at most of them as factors, however it was built. So with the pool that large, the probability that a stop’s next prime is bad, once the value is wrong, is at most about in four million. For the largest budget on this page, of 2,782, that bound is one in 37,000, and each further repeat multiplies by another factor of that size. This is a proved inequality rather than a measurement, and it holds against any matrix chosen without knowledge of the random draw.
So the choice is not really between a theorem and a guess. It is between a deterministic count, which costs the budget, and a probabilistic stop, which costs the need plus a few, with a failure probability that one prime buys down by four or five decades. Most exact libraries take the second, and it is why they can handle matrices whose budget is unaffordable.
What the saving is worth in eliminations
Each prime costs one elimination modulo that prime, about word multiplications. At order 32 that is 10,923, and the counts above turn directly into totals. The scaled Hilbert matrix pays 1.17 million under the plan and 382,000 under a stop with one repeat. The Pascal matrix pays 502,000 and 22,000. The Hadamard matrix pays 44,000 and 55,000, the one place in this table where the plan is cheaper, and by the price of the confirming prime.
Those are small numbers next to what the same determinant would cost by the route this field began with. The answer is longer than the question measures fraction-free elimination’s intermediates, which on these matrices reach the size of the bound, so that every multiplication is a multi-word one. That is the true reason a budget matters. A modular determinant at a budget of 107 primes does 107 eliminations in machine words, and it remains far cheaper than a single elimination with 2,800-bit numbers. The saving on offer here comes on top of a route that has already won, and an exact answer to a measured problem would add that for many matrices none of this matters, because entries measured to six digits do not deserve a determinant correct to eight hundred bits.
The budget’s size also has a practical side that the table at order 32 understates. The pool of primes below runs out of bits nowhere near any of these budgets, but a matrix of order a thousand with entries of a hundred bits has a budget of about bits, or four thousand eliminations of a cubic cost. A plan that spends that whenever its row norms say so, on a matrix that might well have a small determinant, is not something a code can simply accept, and that is the pressure which pushes exact libraries towards adapting.
What a determinant cannot check and a solution can
There is a further distinction, which the fraction essay’s own closing step already contains. Its route ends with a verification: form in integers and confirm that it is zero. That one exact product turns an answer into a certificate. So a rational solver can use the early stop with no risk at all, however the primes came. It reconstructs when the value settles, multiplies, and either has a proof or has learned to try more. An adaptive solve that ends with that check is exact, and that is a stronger statement than either the plan or the stop makes on its own.
A determinant has no such check. Nothing cheaper than computing it confirms that a number is the determinant of a matrix; that is exactly why this family of failures is possible. The closest thing is a further random prime, which is what a repeat is. This is where a plan’s ability to say that it is right still has a real advantage, and the budget is therefore not wasted in the case where a guarantee is the point. The normal forms essay uses a determinant’s bound as a modulus, where a wrong value would silently corrupt everything else, and there the argument for the plan is at its strongest. The rank is in between: the field decides it usually measures how often a single prime gets a rank right, and a rank from a prime is at worst an underestimate, so it fails in one known direction, which a determinant’s residue does not.
What this leaves out
The cost of a prime here is one elimination, word operations, and the cost of the reconstruction is ignored. Garner’s incremental form costs on the order of limb operations over primes, which is small beside elimination at every size on this page. A real code would also not reconstruct after every prime, but in doubling batches, which makes the stop a bit later and the arithmetic cheaper.
The families were chosen to show the range rather than to represent what a person will meet. Six families cannot say how often a real matrix sits near each end, and a matrix from an integer programming model or a graph has its own distribution, about which nothing here is known. The pool used for the random draw is small, by design, and its first primes were the ones built into the fooling matrix, so these measurements test the failure when it is available to happen and not how a pool of millions would fare. And since here is a determinant, nothing in this measures early stopping on a matrix’s rank or on a solution.
Still open: a cheap estimate of the bits, and a stop that is also a solve
An estimate from floating point. A logarithm of a determinant is available from a floating-point LU at the cost of one factorisation, and its error is small even when the digits of the value are all gone. The prediction with a sign is that the floating-point value of is within ten bits of the truth on every family at every order here except the Hilbert matrices above order 16, so that a code could set a tight budget in advance for the cost of one prime. If it holds, the case for the stop shrinks to the matrices floating point cannot handle.
Doubling the batches. Reconstructing after 1, 2, 4, 8 primes rather than after each costs less arithmetic and may overshoot. The prediction is that with doubling the total of primes used is at most twice the need on every case here, that the reconstruction work falls below one elimination’s on all of them at order 32, and that the fooling matrix built on six primes still fools the stop unless the first batch exceeds six, so that a batching schedule hides the same failure at a different count.
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.
- A graph is alternating modulo two — both name determinant, exact arithmetic, modular arithmetic, unlucky prime
- Each column divides by the prime — both name determinant, exact arithmetic, modular arithmetic, unlucky prime
- A bound on every intermediate at once — both name determinant, exact arithmetic, hadamard bound
- Every intermediate is a minor — both name determinant, exact arithmetic, hadamard bound
- The pivot is in every product — both name determinant, exact arithmetic, hadamard bound
- The rank depends on the ring — both name exact arithmetic, modular arithmetic, unlucky prime
Named objects
A flat tag is an object no other essay names yet.
Chinese remainder theoremDeterminantExact arithmeticHadamard boundModular arithmeticUnlucky prime