Two errors, and whose fault they are

Balanced is not symmetric

The Sylvester–Kac matrix is made of small integers, so a double holds it exactly, and its eigenvalues are the integers from −(n − 1) to n − 1 in steps of two. Every digit an eigensolver loses on it is therefore the solver's own, and it loses them at exactly the rate first-order perturbation theory predicts: the median error is half the prediction across 1,568 eigenvalues. Balancing, the preprocessing libraries apply for this kind of matrix, divides every condition number by about sixty and leaves their growth untouched, and at order 112 the unbalanced solver returns eighteen complex eigenvalues for a spectrum of integers.

Worth reading first: An answer that is known · The eigenvalues that are not there · The algorithm the libraries actually run.

An answer that is known measured a linear solve against the Hilbert matrix’s integer inverse and ended by ranking the evidence an error claim can rest on: an answer known exactly, then an answer constructed backwards, then a backward error that certifies the algorithm and says nothing about the answer. The top level was available because the Hilbert matrix’s inverse is a closed form. It had a flaw the essay’s own later measurements exposed. The matrix a program holds is not the Hilbert matrix — every entry 1/(i+j−1)1/(i+j-1) is rounded on the way into a double — and the exact answer to a nearby problem found that storing it accounts for between a fifth and all of what the solve gets wrong. The closed form is the answer to a matrix nobody stored.

An eigenvalue problem can be put at the top level without that flaw. The Sylvester–Kac matrix of order nn has zeros on its diagonal, 1,2,…,n−11, 2, \dots, n-1 above it and n−1,…,2,1n-1, \dots, 2, 1 below it. Every entry is a small integer, so the double a program holds is the matrix, with nothing rounded. And its eigenvalues are the integers −(n−1),−(n−3),…,n−3,n−1-(n-1), -(n-3), \dots, n-3, n-1 — Sylvester stated it in 1854, and Kac met the same matrix again in 1947 as the Ehrenfest urn model of diffusion, where its eigenvalues are the rates at which a disturbed urn relaxes. The answer is known, the question is stored exactly, and every digit a solver loses is the solver’s.

Two exact routes to the integers

The integers are not taken on trust. The characteristic polynomial of a tridiagonal matrix with zero diagonal obeys a three-term recurrence — each principal minor is −λ-\lambda times the one before, minus the product of the new off-diagonal pair times the one before that — and in exact integer arithmetic that recurrence is evaluated at every integer from −(n−1)-(n-1) to n−1n-1. At orders 8, 17, 40 and 120 it is exactly zero at the nn integers of the stated spectrum and nonzero at every integer between them. No tolerance enters: the spectrum is those integers and nothing else.

Three routes to the spectrum, and how far each gets

The largest error in the computed eigenvalues of the Sylvester–Kac matrix, whose eigenvalues are integers, against its orderThe Kac matrix of order n has zeros on its diagonal, 1 to n − 1 above it and n − 1 to 1 below, and eigenvalues exactly the integers from minus n − 1 to n − 1 in steps of two. as given: largest error 1.6e-14 at order 8, 1.0e-6 at 64, 2.1e+0 at 120, with complex pairs from order 112; balanced: largest error 1.8e-14 at order 8, 1.5e-8 at 64, 1.8e+0 at 120, with complex pairs from order 120; symmetrised: largest error 2.0e-14 at order 8, 7.5e-13 at 64, 3.4e-12 at 120.largest eigenvalue erroras given, order 960.043balanced, order 964.4·10⁻⁴symmetrised, order 962.2·10⁻¹²016324864809611210⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴10⁻¹order nlargest |computed − exact| eigenvaluean error of one: the integers are no longer told apartas givenbalancedsymmetrisedopen dots: complex pairs returned for a real spectrumevery entry is an integer, stored exactly
Fig. 1 The largest eigenvalue error against the order, for the Kac matrix as given, the same after balancing, and the symmetric matrix it is similar to. Open dots: orders at which the computed spectrum contained complex eigenvalues.

The first route hands the matrix to the algorithm every library runs on a nonsymmetric matrix — reduction to Hessenberg form, then the Francis double-shift QR iteration, applied implicitly as two shifts that are never formed describes, after the reduction that makes it affordable. At order 8 the largest error is 1.6⋅10−141.6\cdot 10^{-14}, which is rounding. At 64 it is 1.0⋅10−61.0\cdot 10^{-6}; at 96, 4.3⋅10−24.3\cdot 10^{-2}; at 104, 0.38, by which point neighbouring integers two apart are barely told apart. At 112 the solver returns eighteen of its 112 eigenvalues as complex numbers, the largest imaginary part 3.7, and at 120 twenty-six, with imaginary parts up to 6.4. The exact spectrum is 120 real integers.

Read as the urn model, the damage has a meaning. The eigenvalues are relaxation rates, evenly spaced by two, and at order 104 an error of 0.38 is a fifth of the spacing: the computed rates are still in the right order, but the gaps between neighbouring modes — which set how long an intermediate state of the urn persists — are wrong by up to thirty-five per cent. At 112 some modes no longer relax at all in the computed answer; they oscillate, because a complex eigenvalue is an oscillation, and the process has none. A user who read the answer’s structure rather than its digits would conclude something false about the physics, and no warning would say so.

The third route symmetrises first. A tridiagonal matrix whose off-diagonal pairs have positive products is similar, by a diagonal matrix, to the symmetric tridiagonal with off-diagonals k(n−k)\sqrt{k(n-k)}, and a symmetric eigensolver on that matrix returns the integers to 2.0⋅10−142.0\cdot 10^{-14} at order 8, 7.5⋅10−137.5\cdot 10^{-13} at 64 and 3.4⋅10−123.4\cdot 10^{-12} at 120 — within about twice nn units of roundoff of the norm at every order. The square roots are rounded where the Kac matrix’s entries were not; it makes no difference, because a symmetric eigenvalue moves by no more than the perturbation, which symmetry is worth more than precision is about.

Between them sits the route the libraries take by default: balance first.

The prediction, tested against integers

The explanation for the first route’s collapse is the standard one, and it can be checked here more directly than anywhere else. The condition number of an eigenvalue, κ(λ)=∥x∥ ∥y∥/∣yTx∣\kappa(\lambda) = \|x\|\,\|y\|/|y^{\mathsf T}x| for its right and left eigenvectors, is the factor by which a perturbation of the matrix moves it. A condition number for one eigenvalue introduced it on a four-by-four; on the Kac matrix it can be computed for every eigenvalue at every order, because the eigenvectors are the symmetrised matrix’s eigenvectors scaled by the symmetrising diagonal and its inverse. A backward stable eigensolver perturbs the matrix by a few units of roundoff times its norm, so the prediction for each eigenvalue’s error is κ(λ) u ∥A∥\kappa(\lambda)\,u\,\|A\|.

Every eigenvalue's error for the Kac matrix of order 48, as given and balanced, beside its first-order predictionDots: the computed eigenvalue's distance from the exact integer. Lines: the condition number of that eigenvalue times the unit roundoff times the matrix norm. as given: worst condition number 6.6e+5, at eigenvalue -1; largest error 3.0e-9, at eigenvalue -3; balanced: worst condition number 1.3e+4, at eigenvalue -11; largest error 4.7e-11, at eigenvalue -19.order 48as given, worst κ(λ)6.6·10⁵balanced, worst κ(λ)1.3·10⁴-48-40-32-24-16-808162432404810⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴10⁻¹exact eigenvalueerror, and κ(λ) u ‖A‖as givenbalancedlines: condition number × unit roundoff × normthe prediction, tested against integers
Fig. 2 Every eigenvalue’s error, as dots, and its condition number times the unit roundoff times the norm, as lines, for the Kac matrix as given and balanced. The dial sets the order.

At order 48 the prediction is an arch — condition numbers of 2 at the two ends of the spectrum and 6.6⋅1056.6\cdot 10^5 at ±1\pm 1 — and the errors of the unbalanced route sit on it, the largest 3.0⋅10−93.0\cdot 10^{-9} at −3-3. Turn the dial and the arch rises by fifteen or so every eight orders; at 96 its top is 6.6⋅10126.6\cdot 10^{12}, and the largest error is 4.3⋅10−24.3\cdot 10^{-2} against a prediction of 7⋅10−27\cdot 10^{-2}. The extreme eigenvalues stay at rounding level at every order, because they stay well conditioned. What collapses is the middle.

Every computed eigenvalue's error, in units of roundoff times the norm, against its condition number1568 eigenvalues of Kac matrices of orders 8 to 112, as given and balanced, wherever the computed spectrum was still real. First-order perturbation theory puts each on the diagonal, error equal to condition number times unit roundoff times norm. The ratio of error to that prediction has median 0.51, a tenth of them below 8.0e-2, and the largest is 135.1568 eigenvaluesmedian error ÷ prediction0.51largest135110³10⁶10⁹10¹²10¹⁵10⁻²10¹10⁴10⁷10¹⁰10¹³10¹⁶eigenvalue condition number κ(λ)error ÷ (unit roundoff × ‖A‖)as givenbalancederror = κ u ‖A‖dashed diagonal: the first-order predictionthe theory, checked against integers
Fig. 3 Every eigenvalue of every order below the collapse, both nonsymmetric routes: its error in units of roundoff times the norm, against its condition number. First-order theory puts every point on the diagonal.

Pooled over every order up to the collapse and both nonsymmetric routes, 1,568 eigenvalues lie along the diagonal over sixteen decades of condition number. The ratio of error to prediction has a median of 0.51; a tenth of the eigenvalues come out more than twelve times better than predicted, which is the prediction being a worst case over perturbations the solver did not happen to make; and the largest ratio is 135, at order 72 — the error a backward perturbation of about twice nn units of roundoff would produce, which is within what a Hessenberg reduction and a few hundred Francis steps are entitled to.

That is a stronger statement than the usual one, and it is available only because the answer is integers. The usual check of perturbation theory compares a computed eigenvalue with the same eigenvalue computed more carefully, which is the circularity the Hilbert essay opened with. Here the theory is checked against an answer that cannot be wrong in the same direction, over sixteen orders of magnitude, and it holds to within a factor that stays near one.

Balancing buys a constant and keeps the rate

Balancing is the answer a library gives to a matrix like this one. Before the Hessenberg reduction, Parlett and Reinsch’s algorithm scales row ii down and column ii up by a power of two, repeatedly, until every row’s off-diagonal sum matches its column’s to within a factor of two. It is a diagonal similarity, so it changes no eigenvalue, and because the scalings are powers of two it rounds nothing. Its purpose is to shrink the norm the solver’s backward error is measured against, and with it the error. On the Kac matrix, which is a diagonal similarity away from symmetric, it is natural to expect it to find that similarity.

The largest eigenvalue condition number of the Kac matrix against its order, as given and after balancingThe condition number of the worst-conditioned eigenvalue, from the eigenvectors of the similar symmetric matrix and the diagonal that symmetrises. As given it runs from 2.5 at order 8 to 2.3e+16 at 120; balanced, from 1.4 to 3.7e+14. Balancing divides it by 7.5 at order 24 and by 62 at 120, and both grow by a factor of about 15 every eight orders.what balancing buysbalancing divides κ by, at 4044and at 120620163248648096112110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10¹⁶order nlargest eigenvalue condition numberas givenbalancedthe symmetrised matrix: one at every ordera constant bought, the rate kept
Fig. 4 The largest eigenvalue condition number against the order, for the Kac matrix as given and after balancing. The symmetrised matrix’s is one at every order.

It does not. Balancing divides the worst condition number by 7.5 at orders 24 and 32, by 44 at 40, and by between 49 and 62 from 48 to 120 — a real gain, worth one and a half to two digits, and the hero figure shows it as a parallel shift of the error curve. What it does not change is the slope. As given, the worst condition number grows by a factor of about fifteen every eight orders, from 2.5 at order 8 to 2.3⋅10162.3\cdot 10^{16} at 120. Balanced, it grows at the same rate to within a quarter, from 1.4 to 3.7⋅10143.7\cdot 10^{14}. The balanced solver reaches the unbalanced one’s errors about twelve orders later — sixty is fifteen to the power one and a half — and then collapses the same way: at 112 its largest error is 0.24, and at 120 it returns fourteen complex eigenvalues.

The symmetrised matrix’s condition numbers are all exactly one, at every order. So the diagonal similarity that would remove the whole of the growth exists, is cheap, and is what balancing is looking for. Balancing does not find it.

Fifteen every eight orders is a binomial coefficient

The rate itself has a closed form, and it is worth deriving because it says what any diagonal scaling is up against. Symmetrising the Kac matrix means choosing dk+1/dkd_{k+1}/d_k so that the pair at position kk becomes equal, and the pair there is k+1k+1 above and n−1−kn-1-k below, so the diagonal needs dk+12/dk2=(n−1−k)/(k+1)d_{k+1}^2/d_k^2 = (n-1-k)/(k+1). Multiplying those ratios from the top gives dk2=(n−1k)d_k^2 = \binom{n-1}{k}: the symmetrising diagonal is the square roots of a row of Pascal’s triangle. Its entries run from one at the ends to the square root of the central binomial coefficient in the middle, which is about 2(n−1)/22^{(n-1)/2}, and an eigenvector of the symmetric matrix that spreads across the whole diagonal is stretched by that much on one side and shrunk by that much on the other.

Measured, the worst condition number is that square root divided by n\sqrt{n}, times a constant: the constant is 1.20 at order 8, 1.14 at 32, and 1.131 from 64 to 104, which is within three parts in a thousand of 2/π2/\sqrt{\pi} — a limit the measurement suggests and does not prove. Either way the growth is 2n/22^{n/2} less a power of nn, which is sixteen every eight orders with the power’s share taken off, and that is the fifteen the figure shows.

The derivation also says what balancing would have to do to remove it. The ideal scaling spans a factor of about 2n/22^{n/2} from the ends of the diagonal to its middle — 101710^{17} at order 120 — and balancing’s scalings span a factor of 64, at order 64 and at order 120 alike, because matching each row’s sum to its column’s is satisfied long before the pairs match. A diagonal that is allowed to span 101710^{17} is exactly what the symmetrising route uses, in square roots rather than powers of two, and it is the only one of the three routes whose condition numbers do not grow.

Sums matched, pairs not

The two entries of each off-diagonal pair of the order-64 Kac matrix, as a ratio, before and after balancingFor each k the entry above the diagonal divided by the entry below it; a symmetric matrix has every ratio equal to one. As given the ratio runs from 1/63 to 63. Balancing, which makes each row's off-diagonal sum match its column's to within a factor of two, leaves pairs unequal by up to 15.0 times.order 64as given, worst pair63balanced, worst pair15081624324048566410⁻²10⁻¹110¹10²position k along the diagonalabove ÷ belowas givenbalancedsymmetricbalancing equalises sums, not pairsthe symmetrising diagonal makes every ratio one
Fig. 5 Each off-diagonal pair of the order-64 Kac matrix, as the entry above the diagonal divided by the entry below it, before and after balancing. A symmetric matrix has every ratio equal to one.

The reason is in what balancing equalises. A symmetric tridiagonal matrix has, for each kk, the entry above the diagonal equal to the entry below it — n−1n-1 conditions on the pairs. Balancing imposes a different set: row ii’s off-diagonal sum equal to column ii’s, which for a tridiagonal matrix is ∣ai,i−1∣+∣ai,i+1∣=∣ai−1,i∣+∣ai+1,i∣|a_{i,i-1}| + |a_{i,i+1}| = |a_{i-1,i}| + |a_{i+1,i}|. A matrix can meet every one of those and have no equal pair at all. As given, the order-64 Kac matrix’s pairs run from 1/631/63 to 6363. Balanced, they run within a factor of fifteen of one, and the worst balanced pair grows with the order — three at order 8, nineteen at 80, twenty-nine at 120 — because matching sums leaves a drift from one end of the diagonal to the other that the rounding to powers of two cannot remove.

The condition numbers follow the pairs rather than the sums. An eigenvalue condition number of a diagonally symmetrisable matrix is set by how unequal the scaled eigenvector’s two sides are, and that is the product of the pair ratios along the diagonal: an imbalance of fifteen at each of many positions compounds to the 101410^{14} the balanced matrix still has at order 120. Balancing pulls each ratio in by a factor of about four at the ends of the diagonal and leaves the compounding in place.

This is the sense in which balanced is not symmetric. The two are different fixed points of different conditions, and a matrix can be at the first and as far from the second as the Kac matrix is. The ratio of the worst balanced pair to one is visible in a single pass over the matrix, which makes it a cheap warning: a balanced tridiagonal whose off-diagonal pairs are still unequal by ten or more has condition numbers balancing did not reach.

Where the spectrum goes when it collapses

The computed eigenvalues of the order-120 Kac matrix in the complex plane, against the integers they should beEvery exact eigenvalue is a real integer, marked on the real axis. as given: 26 of 120 eigenvalues returned complex, the largest imaginary part 6.40; balanced: 14 of 120 eigenvalues returned complex, the largest imaginary part 1.01. The symmetrised matrix returns all 120 real, within 3.4e-12 of the integers.order 120, of 120 real eigenvaluesas given, complex26balanced, complex14-120-100-80-60-40-20020406080100120-7-5-3-11357real partimaginary partas givenbalancedthe integersticks: the exact spectrumpairs of integers merged and left the axis
Fig. 6 The computed eigenvalues of the order-120 Kac matrix in the complex plane, as given and balanced, with the exact integers marked on the real axis.

At order 120 the computed spectrum is not noisy integers. The outer eigenvalues, which are well conditioned, are on their integers to many digits. The middle ones — twenty-six of them unbalanced — have left the real axis and sit on a closed curve around the origin, a flattened oval reaching 6.4 above and below it; balanced, fourteen have left, on a curve reaching only 1.0. A backward stable solver has returned the exact eigenvalues of a matrix within u∥A∥u\|A\| of the Kac matrix, and the Kac matrix is so far from normal that matrices that close to it have eigenvalues anywhere inside that curve.

That is the pseudospectrum drawn by the solver’s own rounding, and it is the same non-normality that makes a spectral radius that grows first climb before it decays. The eigenvalues that are not there drew the same region from the resolvent norm; here it appears as the set of answers a correct algorithm is entitled to return, and the exact integers make it possible to say that every point off the axis is wrong rather than merely different.

What an exact answer adds

Three things were measured here that no comparison between two floating-point computations could have established. That the symmetrised route is right, rather than merely more consistent: it agrees with integers to 3.4⋅10−123.4\cdot 10^{-12} at order 120. That first-order perturbation theory predicts each eigenvalue’s error to within a median factor of two, not merely bounds it. And that the complex pairs at order 112 are an error of the whole method on this matrix, since the exact spectrum was verified integral before any of it was computed.

The Hilbert matrix could not give the first of these cleanly, because its question was already rounded before the solver saw it. The Kac matrix can, and the difference is worth stating as a rule for choosing test problems: a ground truth is only as good as the match between the problem it answers and the problem the program holds. An integer matrix with a known spectrum meets that rule; a matrix of fractions with a known inverse meets it only after the fractions are cleared, as a count that comes out of a determinant does with a Laplacian.

What the Kac matrix does not show

It is one family, and a peculiar one: tridiagonal, zero diagonal, diagonally symmetrisable, with a spectrum of evenly spaced integers. Balancing’s failure here is a failure on the family it is least suited to — a matrix whose imbalance is spread thinly along a long diagonal — and on a dense matrix with a few badly scaled rows it does what it was designed for. The eigensolver is a direct implementation of the Francis iteration rather than a library’s, with the deflation test and shift strategy of the algorithm the libraries actually run, though the Hessenberg reduction and double shift are the textbook ones and the first-order ratio of 0.51 says it is behaving as a backward stable solver should. And the symmetrising route requires knowing that a symmetrising diagonal exists, which for a general nonsymmetric tridiagonal matrix is the sign condition on the pair products and for a dense matrix is almost never true.

Still open: the alternation, a balancing that matches pairs, and the eigenvectors

Neighbours that differ tenfold. At order 40 the unbalanced errors alternate: 1.4⋅10−101.4\cdot 10^{-10} at −9-9, 8.4⋅10−128.4\cdot 10^{-12} at −7-7, 1.6⋅10−101.6\cdot 10^{-10} at −5-5, while the condition numbers change by a fifth from one to the next. Every eigenvalue and its negative have identical errors. The symmetry is the matrix’s — the diagonal of alternating signs is an exact similarity from the Kac matrix to its own negative, which is why the spectrum is symmetric about zero — and the prediction with a sign is that the alternation is the Francis iteration deflating the spectrum in pairs from the ends, so that eigenvalues found in the same deflation share their backward error. Recording which step deflated each eigenvalue would settle it.

A balancing that matches pairs. For a tridiagonal matrix the symmetrising diagonal is a single pass, one square root a position. For a general matrix no diagonal symmetrises, but a scaling that minimises the largest pair ratio, rather than equalising sums, is a small linear programme in the logarithms of the scalings. Whether it beats Parlett–Reinsch on dense nonsymmetric matrices with graded structure, or only on the Kac family, is the measurement.

The eigenvectors. The Kac matrix’s eigenvectors are known too — Krawtchouk polynomials, with integer entries — so the angle between a computed and an exact eigenvector can be measured the same way. The prediction is that the eigenvectors of the middle eigenvalues are lost before the eigenvalues are, since an eigenvector’s sensitivity carries the gap to the neighbouring eigenvalue as well as the non-normality, and the gap here is only two.

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.

Eigenvalue condition numberExact ground truthFrancis's double shiftNon-normalityPerturbation theoryPseudospectrumSimilarity transformationSymmetric eigenproblemTridiagonal