Elimination, and the swap

The other side was small too

An inverse formed by columns, from AX = I, leaves AX̂ − I at a tenth of a unit of roundoff, and that tenth turns out to be the constant in the law that put the inverse route's backward error at about u/ρ. Formed the mirror way, from the transpose, the two sides swap: X̂A − I goes to a tenth and AX̂ − I to almost seven units, so the backward error on a random right-hand side rises forty-fold, as predicted, and the forward error on b = Ax falls from fourteen times LU's to 1.7. LAPACK's way, U⁻¹ then W L = U⁻¹, was the form the prediction was about, and it does not trade at all: both sides stay under half a unit at every condition number, so it has the forward error of the one and nearly the backward error of the other. Partial pivoting keeps L at a condition number near two hundred whatever A is, and that is the only factor this form solves against on the side it did not ask for.

Worth reading first: A correction cheaper than the problem · The exact answer to a nearby problem · The same arithmetic at a different price.

The test that made the answer small moved the blame for an unstable inverse from the inverse to the right-hand side. Solving Ax=bAx = b as x^=X^b\hat x = \hat X b, with X^\hat X a computed inverse, has a backward error of about u/ρu/\rho, where ρ=∥x∥σmin⁡/∥b∥\rho = \|x\|\sigma_{\min}/\|b\| is the answer’s size over the largest it could be. The test every earlier measurement used, b=Axb = Ax for a random xx, makes ρ\rho about as small as it gets, and so found the inverse route twelve decades worse than LU at a condition number of 101410^{14}. A random right-hand side has ρ\rho near a quarter and no gap at all.

That inverse was formed the obvious way, one column at a time, by solving Ax^j=ejA\hat x_j = e_j with the LU factors. Each column is then the exact solution of a nearby system, so the residual AX^−IA\hat X - I is small. Nothing in that construction says anything about the other residual, X^A−I\hat XA - I, and the earlier essay predicted, with a sign, what would happen if the sides were swapped. LAPACK’s inversion routine does not solve AX=IAX = I. It inverts UU, then solves WL=U−1WL = U^{-1} for WW row by row, and undoes the permutation, so X^=WP\hat X = WP satisfies X^A≈I\hat XA \approx I in the sense that the column form satisfies AX^≈IA\hat X \approx I. The prediction was that this form’s backward error on random right-hand sides would be at least ten times the column form’s at κ=1014\kappa = 10^{14}, while its forward error on b=Axb = Ax would fall to within twice LU’s, against the column form’s fifteen times.

The forward error half holds. The backward error half fails, and the reason it fails is the more useful finding: the form the prediction was about does not have a large residual on its other side at all. A third form, which really is the column form turned around, does, and behaves exactly as predicted.

Three inverses of one matrix

The matrices are the earlier essay’s: order 30, singular values spaced geometrically from one down to 1/κ1/\kappa, singular vectors drawn at random and kept, so that the exact solution of any system is available to rounding and ρ\rho can be read off. Three inverses are formed from the same partially pivoted factorisation PA=LUPA = LU:

  • the columns of AX=IAX = I, each column by a forward and a back substitution;
  • the transpose’s columns, the same thing done to ATA^{\mathsf T} and transposed back, so that each row of X^\hat X solves a system and X^A−I\hat XA - I is the residual made small;
  • WL=U−1WL = U^{-1}, LAPACK’s order: U−1U^{-1} by columns, then WW by rows against LL, then X^=WP\hat X = WP.

The second is the clean mirror of the first and the third is what a library does. The prediction had the third in mind and assumed it behaves like the second.

The two residuals of three computed inverses of one matrix of order 30 at κ = 10¹⁴, in units of rounding, each scaled by ‖A‖‖X̂‖columns of AX = I: ‖AX̂ − I‖ 0.13 and ‖X̂A − I‖ 5.67 units of rounding; the transpose's columns: ‖AX̂ − I‖ 6.72 and ‖X̂A − I‖ 0.12 units of rounding; W L = U⁻¹: ‖AX̂ − I‖ 0.38 and ‖X̂A − I‖ 0.17 units of rounding.0.1110columns of AX = I‖AX̂ − I‖0.13‖X̂A − I‖5.67the transpose's columns‖AX̂ − I‖6.72‖X̂A − I‖0.12W L = U⁻¹‖AX̂ − I‖0.38‖X̂A − I‖0.17residual over ‖A‖‖X̂‖, in units u = 2⁻⁵³order 30 · geometric singular valuesthe sides are not what the equation fixes
Fig. 1 Both residuals of the three inverses, scaled by ‖A‖‖X̂‖, in units of roundoff. The dial sets the condition number.

At κ=1014\kappa = 10^{14} the column form’s own side, AX^−IA\hat X - I, is 0.13 units of roundoff, scaled by ∥A∥∥X^∥\|A\|\|\hat X\|, and its other side is 5.7. The transpose’s form is the exact mirror: 0.12 on its own side, X^A−I\hat XA - I, and 6.7 on AX^−IA\hat X - I. The third form is 0.17 on its own side and 0.38 on the other. Turning the dial down to 10610^{6} shrinks the mirrored pair’s other sides to just over one unit and leaves the third form at half a unit or less on both. Every number on this figure is a few units of roundoff or less. That alone says the prediction’s picture, of an inverse whose other residual is not controlled, was too strong: what the other side does is grow, slowly, from about one unit to about six across twelve decades of condition number, and only for two forms of the three.

The other side, as the condition number grows

The residual each computed inverse leaves on the side it did not solve along, scaled by ‖A‖‖X̂‖, against the condition number, with the column form's own side for comparisoncolumns: X̂A − I: 9.1e-17 at 10², 1.9e-16 at 10⁴, 1.3e-16 at 10⁶, 1.2e-16 at 10⁸, 3.8e-16 at 10¹⁰, 4.5e-16 at 10¹², 6.3e-16 at 10¹⁴; transpose: AX̂ − I: 8.7e-17 at 10², 1.3e-16 at 10⁴, 1.2e-16 at 10⁶, 1.3e-16 at 10⁸, 2.1e-16 at 10¹⁰, 2.7e-16 at 10¹², 7.5e-16 at 10¹⁴; W L = U⁻¹: AX̂ − I: 1.0e-16 at 10², 6.7e-17 at 10⁴, 5.4e-17 at 10⁶, 5.0e-17 at 10⁸, 4.8e-17 at 10¹⁰, 3.4e-17 at 10¹², 4.2e-17 at 10¹⁴; every form, its own side: 3.3e-17 at 10², 2.3e-17 at 10⁴, 2.0e-17 at 10⁶, 1.4e-17 at 10⁸, 1.3e-17 at 10¹⁰, 1.5e-17 at 10¹², 1.4e-17 at 10¹⁴.246810121410⁻¹⁷10⁻¹⁶10⁻¹⁵log₁₀ κresidual over ‖A‖‖X̂‖columns: X̂A − Itranspose: AX̂ − IW L = U⁻¹: AX̂ − Ievery form, its own sideu = 1.1 × 10⁻¹⁶a few units, not κ units
Fig. 2 The residual each inverse leaves on the side it did not solve along, against the condition number, with the column form’s own side for comparison.

The two mirrored forms track each other closely: 9⋅10−179 \cdot 10^{-17} at κ=102\kappa = 10^2, rising to 66 to 8⋅10−168 \cdot 10^{-16} at 101410^{14}, a factor of about eight over twelve decades. A bound that would let the other side grow with κ\kappa, which is what the algebra X^A−I=X^(AX^−I)X^−1\hat XA - I = \hat X(A\hat X - I)\hat X^{-1} allows, is nowhere near attained. The third form’s other side does not grow at all: it drifts from 1.0⋅10−161.0 \cdot 10^{-16} down to 4⋅10−174 \cdot 10^{-17}. Three other matrices of the same construction at κ=1014\kappa = 10^{14} give the same split, the column form’s other side between 1.3 and 2.3 units and the third form’s between 0.25 and 0.42, so the matrix drawn here is the column form’s worst of four and not a typical one.

So the side on which an inverse’s residual is small is not settled by which equation the inverse was computed from. The third form computes X^\hat X from WL=U−1WL = U^{-1} and is small on both sides; the first two compute it from AX=IAX = I and XA=IXA = I respectively and are small on one. Something about the order of the work matters.

What the backward error was reading

The size of the residual on each side would be a curiosity if it did not show up in the solve. It does, and it shows up in the constant of the earlier essay’s law. The residual of x^=X^b\hat x = \hat Xb is

b−AX^b=−(AX^−I) b+(the rounding of the product),b - A\hat Xb = -(A\hat X - I)\,b + (\text{the rounding of the product}),

so the backward error, which divides by ∥A∥∥x^∥+∥b∥\|A\|\|\hat x\| + \|b\|, is about ∥AX^−I∥⋅∥X^∥∥b∥/(∥A∥∥X^∥∥x∥)\|A\hat X - I\| \cdot \|\hat X\|\|b\|/(\|A\|\|\hat X\|\|x\|), which is the scaled residual on the AX^−IA\hat X - I side times 1/ρ1/\rho. The earlier essay found its backward error equal to “about a tenth of a unit of roundoff over ρ\rho”, and the constant was a fitted range from 0.006 to 0.34. The tenth was the column form’s own residual, 0.13 units. That law was a law about one inverse, and the constant in it belongs to the form.

The median backward error of x̂ = X̂b on twelve random right-hand sides, for three computed inverses and for LU, against the condition numberLU: 3.2e-17 at 10², 2.6e-17 at 10⁴, 2.4e-17 at 10⁶, 2.2e-17 at 10⁸, 2.1e-17 at 10¹⁰, 1.6e-17 at 10¹², 1.7e-17 at 10¹⁴; columns of AX = I: 4.1e-17 at 10², 3.2e-17 at 10⁴, 2.8e-17 at 10⁶, 2.4e-17 at 10⁸, 2.2e-17 at 10¹⁰, 2.4e-17 at 10¹², 2.5e-17 at 10¹⁴; the transpose's columns: 7.4e-17 at 10², 1.2e-16 at 10⁴, 1.1e-16 at 10⁶, 1.4e-16 at 10⁸, 1.9e-16 at 10¹⁰, 2.9e-16 at 10¹², 9.9e-16 at 10¹⁴; W L = U⁻¹: 6.5e-17 at 10², 6.9e-17 at 10⁴, 5.5e-17 at 10⁶, 5.4e-17 at 10⁸, 5.6e-17 at 10¹⁰, 3.9e-17 at 10¹², 4.3e-17 at 10¹⁴.246810121410⁻¹⁷10⁻¹⁶10⁻¹⁵log₁₀ κbackward error, random bLUcolumns of AX = Ithe transpose's columnsW L = U⁻¹median of twelve drawsone form trades a digit
Fig. 3 The median backward error of x̂ = X̂b on twelve random right-hand sides, for the three inverses and for LU, against the condition number.

The mirror form, with 6.7 units on that side, should then lose about fifty times as much on any right-hand side, and on random right-hand sides that is what the figure shows: 9.9⋅10−169.9 \cdot 10^{-16} at κ=1014\kappa = 10^{14}, against 2.5⋅10−172.5 \cdot 10^{-17} for the column form and 1.7⋅10−171.7 \cdot 10^{-17} for LU. That is forty times the column form’s and fifty-eight times LU’s, which satisfies the letter of the prediction, a factor of ten or more, and “breaks the agreement with LU” by a digit and a half. It does not break it by anything like the twelve decades that b=Axb = Ax costs, because the random right-hand side’s ρ\rho is still near a quarter: the loss is the residual’s growth, from 0.13 units to 6.7, and nothing else.

The third form, the one the prediction was about, sits at 4.3⋅10−174.3 \cdot 10^{-17}, between the column form and twice it, at every condition number. On a random right-hand side LAPACK’s inverse is as good as the column form’s to within a factor of two. The prediction misidentified the form, and its claimed mechanism, a residual on the far side that is not controlled, belongs to a form no library uses.

What b = Ax was reading

The forward error is a different expression. With b=Axb = Ax, up to the rounding in forming bb,

x^−x=X^Ax−x+(rounding)=(X^A−I) x+(rounding),\hat x - x = \hat X A x - x + (\text{rounding}) = (\hat XA - I)\,x + (\text{rounding}),

so it reads the other residual, X^A−I\hat XA - I. That is the column form’s bad side.

The median forward error of x̂ = X̂b over LU's on twelve right-hand sides b = Ax with x random, for three computed inverses, against the condition numbercolumns of AX = I: 2.17 at 10², 3.58 at 10⁴, 5.13 at 10⁶, 3.45 at 10⁸, 5.79 at 10¹⁰, 12.98 at 10¹², 13.81 at 10¹⁴; the transpose's columns: 1.56 at 10², 1.55 at 10⁴, 1.87 at 10⁶, 1.08 at 10⁸, 0.98 at 10¹⁰, 1.22 at 10¹², 1.73 at 10¹⁴; W L = U⁻¹: 1.48 at 10², 1.17 at 10⁴, 1.49 at 10⁶, 1.27 at 10⁸, 0.98 at 10¹⁰, 1.28 at 10¹², 1.47 at 10¹⁴.24681012140246810121416log₁₀ κforward error over LU's, b = Axcolumns of AX = Ithe transpose's columnsW L = U⁻¹median of twelve drawsX̂A − I is what b = Ax reads
Fig. 4 The median forward error of x̂ = X̂b over LU’s, on right-hand sides b = Ax with x random, for the three inverses, against the condition number.

The column form’s forward error on these right-hand sides climbs from 2.2 times LU’s at κ=102\kappa = 10^2 to 13 and 14 times at 101210^{12} and 101410^{14}, which is where the earlier essay’s “fifteen times” came from. Both forms that keep X^A−I\hat XA - I small stay within twice LU’s throughout: the mirror at 1.7 and the third form at 1.46 at 101410^{14}, and neither above 1.6 anywhere on the range. This half of the prediction holds, and it holds for both of the forms that might have been meant.

Put the two halves side by side and the column form and its mirror simply trade. The column form is nearly LU on backward error and fourteen times worse on the forward error of an arranged test; the mirror is nearly LU on that forward error and fifty times worse on backward error everywhere. Neither has both. The third form has both: under twice LU’s forward error on b=Axb = Ax, and under three times its backward error on a random bb.

Four kinds of right-hand side at the worst condition number

The median backward error of x̂ = X̂b for three computed inverses and of LU, on four kinds of right-hand side, at κ = 10¹⁴b = Ax, x random: LU 2.5e-17, columns of AX = I 4.7e-5, the transpose's columns 2.6e-5, W L = U⁻¹ 2.0e-5; b random: LU 1.7e-17, columns of AX = I 2.5e-17, the transpose's columns 9.9e-16, W L = U⁻¹ 4.3e-17; b on the top left singular vector: LU 3.8e-17, columns of AX = I 3.7e-5, the transpose's columns 5.0e-5, W L = U⁻¹ 5.7e-5; b on the bottom one: LU 1.7e-17, columns of AX = I 2.9e-17, the transpose's columns 6.5e-16, W L = U⁻¹ 5.2e-17.10⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴b = Ax, x random, ρ ≈ 8.5e-14LUcolumns of AX = Ithe transpose's columnsW L = U⁻¹b random, ρ ≈ 2.3e-1LUcolumns of AX = Ithe transpose's columnsW L = U⁻¹b on the top left singular vector, ρ ≈ 3.0e-14LUcolumns of AX = Ithe transpose's columnsW L = U⁻¹b on the bottom one, ρ ≈ 3.3e-1LUcolumns of AX = Ithe transpose's columnsW L = U⁻¹backward error, median of twelveorder 30 · κ = 10¹⁴ρ decides it, not the side
Fig. 5 The median backward error of x̂ = X̂b for the three inverses and LU, on four kinds of right-hand side, at κ = 10¹⁴.

On the two kinds of right-hand side with small ρ\rho, b=Axb = Ax and bb along the top left singular vector, all three inverses are equally bad: backward errors between 2⋅10−52 \cdot 10^{-5} and 6⋅10−56 \cdot 10^{-5}, eleven to twelve decades above LU’s. That is the earlier essay’s u/ρu/\rho at its worst, and the form does not rescue it, since every form’s residual is at most a few units and 1/ρ1/\rho is 101310^{13}. On the two kinds with ρ\rho near a quarter or a third, the random bb and bb along the bottom singular vector, the forms separate by exactly the factor of their AX^−IA\hat X - I residuals, and the mirror sits a digit and a half above the others. So the right-hand side decides whether there is a loss at all, and the form decides its size only where the loss is small.

Their forward errors along the top singular vector tell the same story from the other side: the column form’s is 5.5⋅10−25.5 \cdot 10^{-2}, the other two 3.33.3 and 3.9⋅10−33.9 \cdot 10^{-3}, LU’s 1.9⋅10−31.9 \cdot 10^{-3}. The column form loses a digit to the others wherever xx is small, which is wherever X^A−I\hat XA - I is being read.

Where the conditioning sits

Why should the third form keep both sides? It computes three things in turn: U−1U^{-1} by columns, which leaves UU−1−IUU^{-1} - I small; WW by rows against LL, which leaves WL−U−1WL - U^{-1} small; and a permutation, which is exact. On the side it did not aim for, AX^−IA\hat X - I, the error of the second step is carried through L−1L^{-1}, and the error of the first through LL and L−1L^{-1} on either side. The mirrored column forms instead carry their wrong-side error through the triangular factor that holds the conditioning.

The condition numbers in the infinity norm of the two factors partial pivoting produces, L and U, against the condition number of the matrixκ = 10²: κ(L) 221, κ(U) 3.1e+2; κ = 10⁴: κ(L) 180, κ(U) 1.7e+4; κ = 10⁶: κ(L) 211, κ(U) 1.1e+6; κ = 10⁸: κ(L) 159, κ(U) 9.1e+7; κ = 10¹⁰: κ(L) 255, κ(U) 5.7e+9; κ = 10¹²: κ(L) 245, κ(U) 7.2e+11; κ = 10¹⁴: κ(L) 190, κ(U) 6.0e+13.246810121410¹10³10⁵10⁷10⁹10¹¹10¹³10¹⁵log₁₀ κ(A)κ∞ of the factorκ(U)κ(L)order 30 · partial pivotingall the conditioning is in U
Fig. 6 The condition numbers in the infinity norm of the factors L and U, against the condition number of the matrix.

Partial pivoting bounds every multiplier in LL by one, and on these matrices that leaves κ∞(L)\kappa_\infty(L) between 160 and 250 at every condition number from 10210^2 to 101410^{14}. All the conditioning goes into UU, whose condition number tracks the matrix’s, 6.0⋅10136.0 \cdot 10^{13} at κ=1014\kappa = 10^{14}. So a form whose wrong-side solve is against LL is amplifying its rounding by a fixed and modest factor, and that is consistent with what the third form does. The argument is suggestive rather than proved: the worst-case amplification, a factor of κ(L)\kappa(L) or κ(U)\kappa(U), is nowhere near attained by either form, since the mirrored forms’ other side reaches seven units where κ(U)\kappa(U) would allow 101310^{13}, and this measurement does not separate the factor’s conditioning from the alignment of the errors with it. What it does show is that the conditioning is all in one factor, and that the one form whose wrong-side work avoids that factor is the one that keeps both residuals.

How a program ends up holding the mirror

The mirror form would be a curiosity if nobody computed it, and nobody sets out to. It arrives by a route that involves no decision at all. A program that stores its matrices by rows and hands one to a routine that works by columns has handed over the transpose, since the same block of memory read the other way is ATA^{\mathsf T}. If the routine inverts by solving for the columns of the identity, the most direct way to write an inverse with a solver, then it has solved ATY=IA^{\mathsf T}Y = I by columns, and the block of memory that comes back, read by rows again, is YTY^{\mathsf T}: the transpose’s columns, transposed. That is exactly the second form here, produced by a program whose source contains the words “solve” and “identity” and nothing about sides. The same happens when an inverse of ATA^{\mathsf T} is wanted for its own sake, in a least squares or adjoint computation, and is obtained by transposing an inverse already in hand.

None of this changes a single entry by more than a few units of roundoff, and the forward error of such a program on its own tests would look better than the column form’s, not worse, because the tests are usually built as b=Axb = Ax. That is the arrangement under which the mirror shines. Its cost shows only on the right-hand sides a test is not built from, a digit and a half of backward error that every solve then carries. A program that checks its inverse by multiplying it back, X^A\hat XA, will find it at a tenth of a unit and report a good inverse, a check that passes on the measure the program did not need, which is the shape of a backward stable answer to a problem nobody asked in miniature. The column form would have reported 5.7 units on the same check and been the better inverse for the solves.

The constant in a law belongs to an algorithm

There is a general point under the particular one. The earlier essay’s law, backward error about a tenth of the roundoff over ρ\rho, was a good law: fourteen decades of ρ\rho, a hundred right-hand sides, the constant inside a factor of ten either way. It read as a law about multiplying by an inverse. It was a law about multiplying by one inverse. The 1/ρ1/\rho belongs to the problem, since it measures how much the answer’s size lets a fixed residual matter, and every form shares it. The tenth belongs to the arithmetic that built X^\hat X, and two forms of three have a different one.

This is the same separation three errors and one number draws between what a problem contributes to an error and what each decision about the computation does, and it is why a fitted constant should be reported with the algorithm that produced it. A constant fitted on one route is a measurement; carried to another route it is an assumption, and here the assumption would be off by a factor of fifty in one direction, on a measure that the most natural check reports as better.

What a person holding an inverse should take from this

The inverse that is never formed gave the usual advice and the usual reason: solve, do not invert, because one route is backward stable and the other is not. The gap refinement can close found that one step of refinement repairs the inverse route’s backward error, and the earlier essay narrowed the instability to the right-hand sides that make ρ\rho small. This adds one more condition, about the inverse itself. An inverse that has to exist, because it is the quantity a program reports or because it is applied to vectors that arrive one at a time, should be formed LAPACK’s way: its backward error on a forgiving right-hand side matches the column form’s within a factor of two, and its forward error on an unforgiving one matches LU’s within a factor of two. The mirrored column form, which is what a program gets by forming the inverse of a transpose and transposing it back, is the worst of the three on the measure that matters on forgiving right-hand sides, and a check of its residual X^A−I\hat XA - I would pass it.

That last point is the one to keep. A small residual is not a small error, and for an inverse a small residual is not even a statement about the inverse, until it says which side. A library that reports ∥X^A−I∥\|\hat XA - I\| as its inverse’s accuracy has told the user about the forward error on arranged tests and nothing about the backward error of the solves that will be done with it; one that reports ∥AX^−I∥\|A\hat X - I\| has told the opposite. The exact answer to a nearby problem is the standard of backward stability, and for x^=X^b\hat x = \hat Xb the nearby problem’s distance is the AX^−IA\hat X - I side divided by ρ\rho, whichever side the inverse was built along.

What order thirty does not settle

One family of matrices, one order, one factorisation with partial pivoting. The factor LL stayed near a condition number of two hundred here because these matrices have random singular vectors; matrices for which partial pivoting produces a badly conditioned LL exist, the bound that is never attained describes their growth, and on them the third form’s argument above would predict a larger far-side residual. Matrices with graded rows or columns, tried in passing at grading up to 10−1210^{-12}, did not separate the forms on either measure, since normwise measures are dominated by the scaling; componentwise measures would see more and were not computed. Larger orders let the column forms’ far side grow further, and how fast is not measured.

Still open: an L that is badly conditioned, and the componentwise sides

A matrix that conditions L. The argument from where the conditioning sits predicts that the third form keeps its far side small only while LL is well conditioned. The prediction with a sign is that on a matrix whose partially pivoted LL has κ∞(L)\kappa_\infty(L) above 10610^{6}, such as a Wilkinson-type matrix with small perturbations or a matrix built as L0U0L_0U_0 with an L0L_0 of graded columns, the third form’s AX^−IA\hat X - I rises to within a factor of ten of the column forms’ far side, and its backward error on random right-hand sides with it. If it does not rise, the order of the work, not the conditioning of LL, is what keeps it small.

Componentwise. On graded matrices the normwise measures hide everything. The prediction is that the componentwise residuals ∣AX^−I∣|A\hat X - I| against ∣A∣∣X^∣|A||\hat X| separate the three forms by more than the normwise ones do here, by at least a factor of a hundred at a grading of 10−810^{-8}, with the third form again the only one small on both sides.

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 errorCondition numberForward errorLU factorisationMatrix inversePartial pivotingResidual