A cheap logarithm, and what vouches for it
Worth reading first: How many primes the answer needs · The number that decides nothing · Orthogonal is a number.
The budget was a worst case priced the primes a modular determinant is given by Hadamard’s bound against the primes the determinant actually needs, on six families of integer matrix, and found the bound exact on Hadamard matrices, within a prime on random entries, three times too large on scaled Hilbert matrices and forty-six times too large on a Pascal matrix of order 32, whose determinant is one. It then measured the alternative every practical library uses, stopping when the reconstructed value has repeated, found it right on all eighteen matrices tried, and built a determinant that fooled it.
Its first open question was cheaper than either. A logarithm of a determinant is available from a floating-point LU at the cost of one factorisation, as the sum of the logarithms of the pivots’ magnitudes, and the sum cannot overflow where the determinant itself would. Its error is often small even when every digit of the determinant is gone, because the digits and the size are different quantities. The prediction it signed was that this estimate falls within ten bits of the truth on every family at every order, except the Hilbert matrices above order 16, so that a code could set a tight budget for the cost of one prime.
The estimate against the exact length
The families are the same six: random entries below 9 and below 999, Hadamard matrices, Pascal matrices, unit triangular matrices and scaled Hilbert matrices. The orders run from 8 to 48. The exact determinant comes from fraction-free elimination, which returns it in integers because every intermediate is a minor, and its length in bits is the reference. Hadamard matrices exist only at powers of two, so that family contributes four orders rather than seven, and the six families give thirty-nine distinct matrices. The estimate is one LU with partial pivoting in binary64, on the integers rounded to binary64, with read off the diagonal of .
On a Pascal matrix the exact line lies on the axis, since the determinant is one at every order. The estimate lies on it too as far as order 16, then rises: 1.5 bits at order 20, 42 at 24, 223 at 32 and 1,041 at 48. Hadamard’s bound, at 2,753 bits at order 48, stays above it throughout. On the scaled Hilbert matrices the estimate leaves the exact line earlier and climbs faster: 22 bits high at order 16, 235 at 24, 685 at 32 and 2,337 at 48, where it reads 4,051 bits against a true 1,713. On random entries, below 9 or below 999, the dial shows the estimate on the exact line at every order, and the bound a little above both.
So the prediction fails twice, in two different ways. On the family it exempted, Hilbert, it fails at order 16, the first order where it was supposed to start holding. And it fails on Pascal matrices, which it did not exempt at all and where the earlier essay found the bound’s worst overpayment. The estimate is wrong in exactly the two families where a budget better than Hadamard’s would have been worth most.
Four families where it is perfect
On the other four families the error is not small but nil, in any practical sense. Random entries below 9 and below 999, Hadamard matrices and unit triangular matrices give an estimate within a twentieth of a bit of the exact length at every order from 8 to 48, and on most of them the logarithms agree to more places than any count of primes could use. Those four are the families where the bound itself was within a prime, apart from unit triangular matrices at the larger orders, so the estimate’s success is real but its value is small: it matches the determinant where Hadamard’s bound already did.
Two of the four are exact for a reason that has nothing to do with stability. A unit triangular matrix is already its own , with ones on the diagonal, and the logarithms sum to zero with no rounding at all. A Hadamard matrix of entries eliminates through small integers and halves, every one of which binary64 holds exactly, so its pivots are the exact pivots and their logarithms sum to , 192 bits at order 64, to the last place. Only the two random families are exact in the ordinary sense, of rounding that happened and did not matter: their pivots carry relative errors of order , and a logarithm summed over 48 of them moves by less than bits.
That is less disappointing than it looks, because the question was never whether a floating-point LU knows the size of a well-behaved determinant. Floating-point elimination with partial pivoting is backward stable, and the number that decides nothing has already drawn what that means for a determinant: the computed value is the exact determinant of a matrix close to the input, and on a matrix whose determinant does not move much when the entries move, close enough. The cases that matter are the ones where it moves a great deal.
What the condition number knows
The two failing families are the two whose condition numbers are large, and the connection can be made quantitative with nothing a code does not already have.
Against the condition number, in bits, as a binary64 singular value decomposition reports it, the Pascal errors fall in a clean sequence. At 24, 40 and 55 bits of condition the estimate is exact. At 68 bits it is 1.5 bits out, at 77 bits 42, at 92 bits 223 and at 123 bits 1,041. The Hilbert matrices behave the same way with a twist: their computed condition stops climbing near 64 bits, because a binary64 decomposition cannot resolve a smallest singular value much below the largest times the roundoff, and so their errors pile up in a column there, 22 bits to 2,337 at a computed condition of 60 to 64. That saturation is itself informative. A computed condition number near the precision’s limit means the true one is at least that large and may be far larger.
Across all thirty-nine distinct matrices one rule holds without exception. Wherever the computed condition is below 50 bits, the estimate is within a twentieth of a bit of the exact length, and every miss of a bit or more has a computed condition above 55. A condition number tells how many digits of a solution survive; here it tells how many bits of a determinant’s size do, and it has the same threshold, the significand’s 53 bits.
The mechanism is the same as for a solve. On a matrix with condition , a backward error of order in the entries moves the smallest singular values by up to relative to themselves, and the determinant is their product. Once reaches one, the smallest singular values the LU has implicitly found are not the matrix’s at all, and their logarithms are whatever rounding left. On a Pascal matrix, rounding leaves pivots much larger than the true ones, which is why the estimate runs high; nothing in the arithmetic requires that direction in general. The sign is the last digit to go found the same threshold from the other end, for the sign of a determinant near singularity: the sign survives until the relative error of the value reaches one, and the logarithm here is the measure of that relative error, read on a scale of bits.
Never low, except where it matters
On the six families the estimate was never low. Its smallest error over all thirty-nine matrices is within a twentieth of a bit of zero, and every real miss is an overestimate. A budget set from it with ten bits of margin is therefore safe on every case measured: it lies between the primes the determinant needs and Hadamard’s budget, every time.
At order 32, even where it is wrong, the estimate’s budget is far tighter than the bound’s. The Pascal matrix, needing one prime, is budgeted nine by the estimate and forty-six by Hadamard. The scaled Hilbert matrix, needing 34, is budgeted 61 and 108. On the three well-behaved families shown the estimate matches the need exactly, 6, 14 and 4, where the bound asks one more. The unit triangular matrix needs one prime by every route at this order. So a wrong estimate still saves most of what an exact one would, on these two families, and a right one saves the last prime the bound wastes on the others.
But “never low” is an observation about six families, and the earlier essay had already built a seventh. Its fooling matrices have as determinant the product of the first primes of the list plus seven, made from an integer matrix of small determinant by integer row operations, which leaves entries far larger than the determinant they produce.
Built on two primes, the determinant has 52 bits and the estimate reads 80, an overestimate of 28 bits at a computed condition of 62 bits, in line with everything above. Built on four, six or eight primes, the determinant has 104, 156 and 208 bits, its entries run to 111, 163 and 215 bits, and the binary64 LU meets an exactly zero pivot. The estimate is : the factorisation says the matrix is singular. A budget set from that number is one prime, which returns the determinant modulo one prime, which is wrong.
This is the one way the cheap logarithm can underestimate, and it is the way that matters. The entries do not fit in binary64, so rounding them alone changes the matrix by far more than its determinant, and the rounded matrix genuinely is singular to working precision. A floating-point zero pivot is a statement about the rounded matrix, and here the rounded matrix is not the one asked about. It happens on exactly the matrices built to fool the repeated-value stop, which is not a coincidence: both constructions put a large determinant behind entries that hide it.
What the estimate costs, and what it is for
A floating-point LU of order costs about multiplications and additions, and so does one elimination modulo a word-sized prime. Counted that way, the estimate costs about one prime, and the question is whether it saves more than one. Over the thirty-nine matrices, the rule that trusts it below 50 bits of condition saves twenty-four primes against Hadamard’s bound in total. Four of those are on the unit triangular matrix of order 48, four on the Hilbert matrix of order 8, seven on the two smallest Pascal matrices, and the rest are one prime at a time on random entries, where the bound was already within one. Thirty-nine estimates for twenty-four primes is a loss, on this count. The estimate is trustworthy exactly where a budget barely needed improving, and the condition test sends every matrix where the bound wastes most back to the bound.
So the estimate is not much use as a budget. It is better used as a witness. The repeated-value stop already uses within one prime of the need on every ordinary matrix, Pascal and Hilbert included, and its one weakness is the built determinant, whose congruences are arranged to settle on the wrong value. A stop that also required the settled value’s length to match the floating-point estimate, whenever the condition allows the estimate to be believed, would be fooled only by a matrix that defeats both the congruences and a backward-stable factorisation at once. On the built determinants the condition does not allow it, and the stop would fall back to running out the bound, which is the correct answer to a matrix whose entries hide its determinant. A congruence and a magnitude are independent measurements, in the way a prime that divides the answer found that a single residue is not, and two independent measurements that agree are what a certificate is made of.
What a code can do with this
Put together, the measurements suggest a simple rule rather than a better bound. Factor the matrix once in floating point, and compute or estimate its condition number at the same time; an estimate that can be fooled and two columns see what one walk cannot describe the estimators codes use, which cost a few solves with the factors already in hand. If the condition is below 50 bits and no pivot is zero, budget the estimate plus a margin. Otherwise fall back to Hadamard’s bound, or to the repeated-value stop with its known risk. On the thirty-nine matrices here that rule gives the exact need on every well-conditioned case and Hadamard’s budget on every ill-conditioned one, which is never worse than the bound and never fooled by the built determinants, since every one of them has a computed condition above 60 bits.
The rule is conservative in two places. It sends the Pascal matrix of order 16 and the Hilbert matrix of order 12 to Hadamard’s bound although the estimate was exact on both, because their computed conditions, 55 and 54 bits, sit just above the threshold. And it gives up the saving on the large ill-conditioned matrices, where an overestimate would still have been five times tighter than the bound. A threshold set at the significand is the honest one; one set higher would trade a little safety for those primes.
None of this removes the case for the stop. How many primes the answer needs counted the primes against a determinant’s length, and the repeated-value stop gets within one of that on every ordinary matrix without knowing the length at all. What the floating-point estimate offers is independence: it is a measurement of size that does not go through the congruences, so a matrix built to make the congruences lie does not also make the estimate lie. It makes it fail loudly instead, and a loud failure is a better property in a budget than a silent one.
What this leaves out
The six families are the ones the exact field already used, chosen for what is known about each rather than for being typical. The fooling construction is one recipe; an adversary with the estimate in mind could aim for an overestimate small enough to pass the condition test and a determinant just past the budget it sets, and whether the condition test can be passed that way was not measured. The condition numbers come from a binary64 singular value decomposition, which is more than a code would compute; a cheap estimator can be several bits out, which moves the threshold rather than the rule. And the margin of ten bits was not needed on any well-conditioned case here, where the estimate was within a twentieth of a bit, so it is a choice of how much to trust a backward error analysis rather than a measured requirement.
What stands is that the cheap logarithm is exact where the condition number is moderate and arbitrary where it is not, that the condition number computed beside it tells which, and that the one case where it runs low is a matrix whose entries binary64 could not hold.
Still open: a sharper threshold, and the doubling schedule
A threshold read from the estimator a code has. The rule above uses a binary64 singular value decomposition. The prediction with a sign is that a one-norm condition estimate of the kind LAPACK computes from the LU factors, with a threshold of 48 bits, classifies all thirty-nine matrices the same way as the decomposition at 50, and that on a hundred random integer matrices of order 24 with entries below 999 multiplied by a random unimodular matrix of growing entry size, every case the estimator passes is within a bit of the exact length.
Doubling the batches. The earlier essay’s second question stands, sharpened by the estimate. Reconstructing after 1, 2, 4 and 8 primes rather than after each costs less arithmetic and may overshoot. The prediction is that with doubling the primes used are at most twice the need on every case here, that a schedule starting at the estimate’s budget where the condition allows it needs no second batch on any well-conditioned case, and that the matrix built on six primes still fools the stop unless the first batch exceeds six, so that doubling hides the same failure at a different count while the condition test does not.
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 bound on every intermediate at once — both name determinant, fraction-free elimination, hadamard bound
- A rule that is correct and unusable — both name condition number, determinant, lu factorisation
- An answer with no error in it — both name condition number, fraction-free elimination, hadamard bound
- The answer is longer than the question — both name determinant, fraction-free elimination, hadamard bound
- The pivot is in every product — both name determinant, fraction-free elimination, hadamard bound
- Three orders and one last entry — both name determinant, fraction-free elimination, hadamard bound
Named objects
A flat tag is an object no other essay names yet.
Chinese remainder theoremCondition numberDeterminantFraction-free eliminationHadamard boundLU factorisationModular arithmetic