Structure, and the solver that cannot see it

The correction lost to its own two-by-two solve

Solving a band matrix through a circulant and a small correction was measured losing the answer to 10⁻⁴ where elimination kept it to 10⁻¹⁴, and a wrap that landed one sample on a zero was measured costing four orders more than one that landed a pair. Both measurements solved the two-by-two correction system by Cramer's rule. Solved with a row interchange, the corrected solve on the same matrix loses 2.9·10⁻¹⁰ — the cancellation, and nothing multiplied onto it — and the single landing costs what the pair costs. The loss was in the determinant.

Worth reading first: The matrix that is one row · A correction cheaper than the problem · The answer is longer than the question.

The circulant the problem did not contain took a band matrix that differs from a circulant only in its corners, solved it through the circulant by a fast transform — the closed-form spectrum the matrix that is one row established — and repaired the corners with a rank-two Sherman–Morrison–Woodbury correction. Its cost claim was exact. Its accuracy claim was measured and found wanting: on tridiag(−1, 2 + σ, −1), whose condition number stops at 1,712, the corrected solve was wrong by 1.2·10⁻⁴ at σ = 10⁻⁸ while elimination was right to 1.1·10⁻¹⁴. The essay explained the loss as two amplifications multiplied — the cancellation in the correction’s last line, and the condition number of the two-by-two capacitance matrix S — and it recorded, as a remark about its own method, that a code which solved S by elimination with pivoting instead of by Cramer’s rule “would change the constant of a tenth and not the slope, since S is two by two and the factorisation is the same arithmetic either way”.

Two near-zeros cost less than one built on that. A wrap whose samples land a conjugate pair on the symbol’s zeros left S perfectly conditioned; one that landed a single sample made S nearly singular and cost four orders of magnitude more in the answer, at the same condition number of the wrap. It ended by asking what happens when the correction has rank four and the symbol four zeros: whether the capacitance matrix is well conditioned exactly when the number of landed samples equals the correction’s rank.

Building the rank-four correction answered that question and, in passing, the first essay’s remark. It is not the same arithmetic.

The same correction, solved two ways

A rank-four correction needs a four-by-four capacitance system, and nobody solves a four-by-four system by Cramer’s rule; the natural code is elimination with partial pivoting. The first single landing solved that way was harmless — its error was the cancellation’s, not four orders more. Setting the band’s outer coefficient to zero turns the rank-four correction back into the rank-two one on the same tridiagonal matrix, and the error stayed harmless. The only difference left between the two codes was how the small system was solved.

The same correction, its two-by-two system solved two ways, on tridiag(−1, 2 + σ, −1)The forward error of solving tridiag(−1, 2 + σ, −1) of size 64 through its periodic circulant and a rank-two correction, median of five answers, against σ on a logarithmic axis, with the correction's two-by-two capacitance system solved by Cramer's rule and by elimination with a row interchange; beside elimination on the matrix itself, and the size of the intermediate over the answer times the unit roundoff. At σ = 10⁻⁸ the errors are 1.2·10⁻⁴, 2.9·10⁻¹⁰ and 1.1·10⁻¹⁴, and the cancellation times u is 1.7·10⁻¹⁰.at σ = 10⁻⁸Cramer's rule1.2·10⁻⁴pivoted2.9·10⁻¹⁰elimination on T1.1·10⁻¹⁴cancellation × u1.7·10⁻¹⁰-10-9-8-7-6-5-4-3-210⁻¹⁶10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²1σ, as a power of tenforward errorCramer's rulepivotedcancellation × uelimination on Tleft: σ small, the wrap nearly singularthe pivoted solve follows the cancellation
Fig. 1 The corrected solve of tridiag(−1, 2 + σ, −1), size 64, against σ: its two-by-two system solved by Cramer’s rule and by pivoted elimination, beside elimination on the band matrix and the cancellation in the correction’s last line times u.

On the first essay’s own family the difference is not a constant. At σ = 10⁻⁴ the two solves give 3.1·10⁻¹³ and 4.2·10⁻¹⁴; at 10⁻⁶, 1.1·10⁻⁸ and 2.2·10⁻¹²; at 10⁻⁸, 1.2·10⁻⁴ and 2.9·10⁻¹⁰; at 10⁻¹⁰, 1.3 and 2.8·10⁻⁸. Cramer’s rule loses a hundred times the accuracy for every decade of σ; the pivoted solve loses ten. The pivoted curve lies on the cancellation times u at every σ — within a factor of two down to 10⁻⁹, and 8.5 at 10⁻¹⁰ — and that is the whole of its error. The slope is not the same slope.

So the first essay’s product law is a law about Cramer’s rule. The correction does lose accuracy against elimination, and the reason it gave for that is the right one: the intermediate y=A1by = A^{-1}b is larger than the answer by the wrap’s near-singularity, and subtracting to get the answer loses the ratio in relative accuracy. At σ = 10⁻⁸ that is 1.7·10⁻¹⁰ of the answer, twenty thousand times elimination’s error. What is not real is the second factor. The capacitance matrix’s condition number, 6.2·10⁶ there, is not multiplied onto anything when the two-by-two system is solved stably.

Where Cramer’s rule loses it

A rule that is correct and unusable measured Cramer’s rule on its own: on two-by-two systems whose rows are nearly parallel it returns an answer with a backward error of 458 units of roundoff where elimination returns 1.3. The capacitance matrix of a nearly singular wrap is such a system, and its entries are large.

Cramer’s rule divides by detS=s00s11s01s10\det S = s_{00}s_{11} - s_{01}s_{10}. When S is nearly singular that difference is much smaller than either product, and each product carries a rounding error of u relative to itself, so the computed determinant is wrong by u times the ratio of product to difference. Elimination never forms the difference: it divides the second row by the first row’s pivot and subtracts, which is a backward-stable operation whatever the rows’ near-parallelism.

How much of Cramer's determinant cancels, against the capacitance matrix's condition numberFor each setting of the three families, the larger of the two products whose difference is the capacitance matrix's determinant, divided by that determinant — the factor by which the products' rounding is magnified — against κ(S), on logarithmic axes. The Laplacian's periodic wrap and the single landing lie along a line, the ratio about a quarter of κ(S): from 2268 to 2.3·10⁸ for the single as κ(S) goes from 9070 to 9.1·10⁸. The pair sits at κ(S) = 1 with a ratio of 1.00 at every distance.the determinant's cancellationsingle, nearest: ratio2.3·10⁸single, nearest: κ(S)9.1·10⁸pair: ratio, every distance1110²10⁴10⁶10⁸110²10⁴10⁶10⁸κ(S), the capacitance matrix's condition numberproduct ÷ determinantthe Laplacian's wrapa single landinga paired landingdashed: ratio equal to κ(S)the pair never cancels
Fig. 2 For the Laplacian’s periodic wrap and for the single and paired landings at every distance, the larger product in the capacitance matrix’s determinant divided by the determinant, against κ(S).

The ratio is the loss, and it is readable directly. On the Laplacian’s wrap and on the single landing it rises with κ(S) along a line a little under the diagonal — 2.3·10³ at κ(S) = 9.1·10³, up to 2.3·10⁸ at κ(S) = 9.1·10⁸ — so every digit of κ(S) is a digit Cramer’s rule throws away in the determinant, and it throws it away in both components of the solution at once. On the paired landing the ratio is 1.0 at every distance: the two products in the determinant are not close to each other, because a pair leaves S near the identity and s01s10s_{01}s_{10} near zero. That is why the paired landing looked safe and the single did not. It was never the landing that was safe. It was the determinant.

The landings, again

The second essay’s comparison is worth redrawing with both solves, because it was the comparison that made the conditioning of S look like the mechanism.

A wrap landing a single sample on the symbol's zeros, its correction solved two waysA simple-zero symbol at n = 64 whose wrap lands one zero at 0.3 of a turn, with the twist moved the distance across off the landing, on logarithmic axes; the correction's forward error, median of five answers, with the capacitance system solved by Cramer's rule and with pivoting, and the cancellation times u. At the nearest distance the capacitance matrix has κ 9.1·10⁸, the wrap 3.8·10¹⁰, and the errors are 4.2 and 5·10⁻⁸ against a cancellation times u of 2.9·10⁻⁹.10⁻⁹ of a turn from landingκ of the capacitance matrix9.1·10⁸Cramer's rule4.2pivoted5·10⁻⁸cancellation × u2.9·10⁻⁹-9-8-7-6-5-410⁻¹³10⁻¹¹10⁻⁹10⁻⁷10⁻⁵10⁻³10⁻¹10¹distance of the twist from landing, turns, as a power of tenforward errorCramer's rulepivotedcancellation × uleft: the twist nearly on the landingthe pivoted solve follows the cancellation
Fig. 3 A simple-zero symbol at n = 64 whose wrap lands one sample on a zero at 0.3 of a turn, with the twist moved off the landing by the distance across: the correction’s error under each solve, and the cancellation times u. The dial moves the landing; at 0 it lands a conjugate pair.

At 0.3 of a turn a single sample is landed on. Ten to the minus nine of a turn from the landing, κ(S) is 9.1·10⁸, Cramer’s rule returns an answer wrong by 4.2 — worse than no answer — and the pivoted solve returns one wrong by 5.0·10⁻⁸, against a cancellation times u of 2.9·10⁻⁹. At 10⁻⁵ of a turn the figures are 3.0·10⁻⁸ and 2.8·10⁻¹².

Turn the dial to 0, where a real wrap lands both zeros of the pair, and the two solves coincide at every distance — 9.8·10⁻⁸ at the nearest, against a cancellation times u of 2.7·10⁻⁸. The pair’s error and the single’s pivoted error differ by a factor of two at matched distances. The four orders the second essay measured between them are the difference between S’s determinant cancelling and not cancelling, and when S is solved without forming its determinant there is nothing between them to measure.

What survives of that essay is real and worth keeping. The twist decides which samples of the symbol the wrap takes, and so how nearly singular the wrap is; that sets the cancellation, which is the correction’s genuine loss, and reading the twist off the symbol’s zeros is the right way to keep it small. The claim that a single landing is uniquely expensive does not survive.

Refinement, and what it was paying for

The first essay found that refinement against the band matrix repaired the corrected solve, pass by pass, and measured the passes it took. That measurement too was a measurement of Cramer’s rule.

Refinement against the band matrix, pass by pass, with the capacitance system solved two waystridiag(−1, 2 + 10⁻⁸, −1) of size 64 solved through its periodic wrap and then refined: each pass computes the residual against the band matrix and solves for the update by the same correction. With Cramer's rule the forward error goes 5.1·10⁻⁵, 5.3·10⁻⁹, 4.2·10⁻¹², 1.9·10⁻¹⁴, 6.2·10⁻¹⁵; with pivoting it goes 7.8·10⁻¹¹, 6.5·10⁻¹⁵, 1.5·10⁻¹⁴, 1.7·10⁻¹⁴, 9.7·10⁻¹⁵. Elimination on the band matrix reaches 1.2·10⁻¹⁵.σ = 10⁻⁸Cramer, after one pass5.3·10⁻⁹pivoted, after one pass6.5·10⁻¹⁵elimination on T1.2·10⁻¹⁵0123410⁻¹⁵10⁻¹³10⁻¹¹10⁻⁹10⁻⁷10⁻⁵refinement passesforward errorCramer's rulepivotedelimination on Teach pass reuses the correctionone pass is enough when the small system is solved stably
Fig. 4 tridiag(−1, 2 + 10⁻⁸, −1) solved through its periodic wrap and refined against itself, pass by pass, with the correction’s two-by-two system solved each way; elimination on the band matrix as a reference.

With Cramer’s rule the error goes 5.1·10⁻⁵, 5.3·10⁻⁹, 4.2·10⁻¹², 1.9·10⁻¹⁴ — three passes to reach elimination’s accuracy, each one clearing about four digits. With pivoting it goes 7.8·10⁻¹¹ and then 6.5·10⁻¹⁵: one pass. That is what refinement should do for a solver whose error is a fixed relative loss — here the cancellation — against a residual computed accurately; each pass multiplies the error by that loss, and a loss of 10⁻¹⁰ is cleared in one. Under Cramer’s rule the loss per pass was the cancellation times the determinant’s cancellation, and three passes were the price of the second factor. The corrected solve with a stable two-by-two system and one refinement step is as accurate as elimination on the band matrix and keeps the transform’s cost.

The gap refinement can close measured the general version of this: a solver that is not backward stable, refined at the working precision against an accurately computed residual, is repaired — and how quickly depends on how large the solver’s own relative error is, which is exactly the quantity the two solves here differ in. Cramer’s rule made the corrected solve’s relative error the cancellation times the determinant’s cancellation, two factors each growing with the wrap’s near-singularity, and the refinement had to clear both; the pivoted solve leaves only the first, and one pass clears it. The refinement count the first essay reported is therefore a reading of the small system’s solver, not of the correction.

A correction of rank four

The question the second essay asked can now be answered on its own terms. The pentadiagonal band with symbol (d12cosθ)(d22cosθ)(d_1 - 2\cos\theta)(d_2 - 2\cos\theta) has four zeros, and its corners differ from the wrap’s in a two-by-two block at each end, so the correction back to the band is rank four. A twist lands the wrap’s samples on the zeros in any of six arrangements: none; one conjugate pair; both pairs; one sample; two samples on the same side of zero; and one sample beside the mirror image of the other zero.

A pentadiagonal band through its wrap: the rank-four capacitance matrix at six landingsA symbol with four zeros — the product of two tridiagonal symbols — at n = 64, and a wrap whose twist is 10⁻⁷ of a turn from landing its samples on the zeros in six ways: none, κ(S) 15; one pair, κ(S) 2.4·10⁷; both pairs, κ(S) 1; one sample, κ(S) 1.7·10⁸; same side, κ(S) 1.8·10⁷; crossed, κ(S) 3.9·10⁷. The capacitance matrix is perfectly conditioned only when all four zeros are landed on.κ of the 4 × 4 capacitance matrixboth pairs landed1one pair landed2.4·10⁷one sample landed1.7·10⁸110²10⁴10⁶10⁸κ(S)none0 landedone pair2 landedboth pairs4 landedone sample1 landedsame side2 landedcrossed2 landedfour zeros, a correction of rank fourκ(S) = 1 only when the landings fill the rank
Fig. 5 The pentadiagonal band’s wrap, 10⁻⁷ of a turn from each of six landings: the condition number of the four-by-four capacitance matrix.

The capacitance matrix is perfectly conditioned in exactly one arrangement: both pairs landed, four near-null samples for a correction of rank four, κ(S) = 1.00. With one pair landed — the arrangement that was perfect at rank two — κ(S) is 2.4·10⁷. With one sample landed it is 1.7·10⁸; with two samples on one side, 1.8·10⁷; with two crossed, 3.9·10⁷; with nothing landed, 15. So the second essay’s conjecture holds in its sharp form: the capacitance matrix is well conditioned when the number of near-null directions the wrap brings in equals the rank of the correction that has to remove them. At rank two a pair fills the rank; at rank four a pair leaves two columns of the correction with nothing to cancel, and S is as badly conditioned as it is for a single landing.

The same six landings: the rank-four correction's error, the cancellation, and eliminationFor the six landings of the pentadiagonal band's wrap, the pivoted correction's forward error (median of five answers), the size of the intermediate over the answer times u, and elimination on the band matrix. The error is 82.7, 2.3, 3.5, 28.9, 3.5, 4.4 times the cancellation's, whatever κ(S) is — 15, 2.4·10⁷, 1, 1.7·10⁸, 1.8·10⁷, 3.9·10⁷.rank four, solved with pivotinglanded, largest error ÷ cancellation × u29at κ(S)1.7·10⁸both pairs: error ÷ cancellation × u3.510⁻¹⁵10⁻¹³10⁻¹¹10⁻⁹forward errornoneone pairboth pairsone samplesame sidecrossedthe correctioncancellation × uelimination on Tdots: the corrected solve, pivotedbars: the cancellation and elimination
Fig. 6 The same six landings: the pivoted correction’s error, the cancellation times u, and elimination on the band matrix.

And it does not matter. Solved with pivoting, the rank-four correction’s error is 2.3, 3.5, 28.9, 3.5 and 4.4 times the cancellation times u across the five arrangements that land anything, and the arrangement with κ(S) = 1 is not the most accurate of them — one pair landed, at κ(S) = 2.4·10⁷, is. The single landing is the worst at 29 times, a factor of ten over the others for a condition number ten times higher, which is the only trace of κ(S) in the errors: nothing like its eight orders. The arrangement with nothing landed has an error of 1.7·10⁻¹⁴, eighty times a cancellation that is itself negligible there, so its error is the base solve’s rounding rather than anything the correction does.

The conjecture is true and it is bookkeeping. Whether the capacitance matrix is well conditioned says how the correction divides the work between the transform solve and the small system; it does not say what the answer costs, because a stably solved small system does not multiply its condition number onto the answer.

The same lesson, a fourth time

The same failure has appeared before, three times, each time in a formula that is exact algebra and a bad computation.

A correction cheaper than the problem measured Sherman and Morrison’s formula — the rank-one case of the correction here — returning a forward error of 2.5·10⁻⁴ on a system whose updated matrix was the identity, because the formula passes through the inverse of the matrix before the update, and that matrix was nearly singular. The inverse that is never formed measured the general case: x=A1bx = A^{-1}b is how a solution is written and not how it is computed, because the route through an explicit inverse is not backward stable and the route through a factorisation is. The number that decides nothing measured the determinant itself as a quantity, and found it wrong on matrices of modest size and uninformative about conditioning on matrices where it was right.

The corrected circulant is all three at once. It is a low-rank update formula; the capacitance system inside it is small enough that writing its solution with an explicit inverse — which is what Cramer’s rule is, for a two-by-two — looks harmless; and the determinant it divides by is exactly the quantity that loses its digits. The difference from the three earlier cases is that here the cost of the bad route was not visible as a bad route. The two-by-two system is so small that “solve it by the formula” and “solve it properly” sound like the same instruction, the earlier essay said so in as many words, and the measurement that would have separated them was never made, because the loss it produced had an explanation ready: the correction was losing accuracy, and it was nearly singular, and the numbers fitted a product law.

The measurement that separates them costs one line: solve the small system with a row interchange and see whether anything changes. It changed the slope.

Why an ill-conditioned S costs nothing

That last statement needs a reason, since a nearly singular system normally does amplify errors. The reason is where S’s size comes from. As the wrap nears singularity, A1A^{-1} applied to anything has one enormous component — along the near-null vector of the sample that is nearly landed — and S=I+VHA1US = I + V^{\mathsf H}A^{-1}U inherits that component as one large, nearly rank-one term. The right-hand side r=VHA1br = V^{\mathsf H}A^{-1}b inherits the same component in the same proportion, because it is computed through the same A1A^{-1}. The small system’s near-singularity is along the direction in which S and r are large together, and a backward-stable solve of that system returns the w that makes the correction’s last line, yZwy - Zw, cancel the large component of y against the large component of Zw. What is left is the answer, with the rounding of the cancellation and no more — which is what every measurement above shows.

Cramer’s rule breaks this by computing the determinant first. The determinant is small exactly because the large term is rank one, and computing it as a difference of two large products throws away the information that the large term was rank one. Every later step divides by that damaged number.

What this does not settle

Every rank-two measurement is on the families the two earlier essays used — the tridiagonal Laplacian and the simple-zero symbols at n = 64 — with five seeded right-hand sides. The rank-four band is one symbol family, one size, one distance from landing; the rank-four errors are medians of five, and the factor-of-ten spread between arrangements is within what five draws can resolve only roughly.

The explanation of why an ill-conditioned S is harmless is an argument about where S’s large entries come from, checked only through its consequence — the error equalling the cancellation — and not by measuring the alignment of the rounding in S and r directly. A correction whose U and V did not see the near-null vector symmetrically might break it, and none is measured here.

The earlier essays’ figures still draw what they drew: the corrected solve with Cramer’s rule. Their numbers are right about that computation. What they attributed to the correction belongs to the rule.

Still open: the cancellation as the only cost, and bands with more zeros than the correction has columns

Removing the cancellation. With the capacitance system solved stably, the corrected solve’s only loss is that the intermediate y is larger than the answer. A twist chosen to keep the wrap’s samples off the zeros keeps y small, and the earlier essays found where to put it; whether some twist makes y no larger than the answer for every symbol — so that the corrected solve is as accurate as elimination with no refinement at all — is the question the cost claim now rests on.

More near-null directions than columns. At rank four the symbol has at most four zeros, so the landings can never outnumber the correction’s columns. A banded matrix whose symbol has a zero of high order — the square of the Laplacian, whose symbol vanishes to fourth order at the origin — brings several nearly null samples in at once from a single zero, and a correction of fixed rank then has fewer columns than near-null directions. Whether a stable small solve is still enough there, or whether the cancellation itself grows faster than the wrap’s condition number, is the measurement the rank-four band cannot make.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

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.

Backward errorCapacitance matrixCirculant matrixCondition numberCramers ruleDeterminantIterative refinementLow-rank updateSherman morrison woodburySymbol