Elimination, and the swap

The test that made the answer small

Solving by a computed inverse was measured twelve orders of magnitude less backward stable than solving by LU at a condition number of 10¹⁴, on a right-hand side built as b = Ax from a random x. That construction is how a known answer is arranged, and it makes the answer about as small as it can be. On a random right-hand side the inverse route's backward error is 2·10⁻¹⁷, the same as LU's, at every condition number measured. The backward error is about a tenth of the roundoff over ρ, the answer's size over its largest possible, and across 200 random right-hand sides ρ never falls below 0.016. The instability is real, and it belongs to right-hand sides whose answers are small, which is a class that includes most tests and many applications.

Worth reading first: A correction cheaper than the problem · The exact answer to a nearby problem · Orthogonal is a number.

The inverse that is never formed gave the real reason to avoid writing x=A−1bx = A^{-1}b as an instruction. The cost is the small objection, three times the arithmetic. The large one is that the route through a computed inverse is not backward stable and the route through LU is, and at κ=1014\kappa = 10^{14} they differ by twelve orders of magnitude in the number that says whose fault a wrong answer is. Its sequel, the gap refinement can close, left that finding standing and studied its repair.

Both essays, like most measurements of a linear solver, built their right-hand side the same way. A vector xx is drawn at random, and bb is set to AxAx, since then the true answer is known and a forward error can be computed. That is a sensible habit with a side effect nobody remarked on: it fixes a property of the problem that turns out to decide the result.

The bound has the answer’s size in it

The residual of x^=X^b\hat x = \hat X b is b−AX^bb - A\hat Xb. Whatever the right-hand side, it is about u∥A∥∥X^∥∥b∥u\|A\|\|\hat X\|\|b\|, because X^\hat X is an inverse with a rounding-level error relative to its size, and the multiplication by AA brings that back. The normwise backward error divides the residual by ∥A∥∥x^∥+∥b∥\|A\|\|\hat x\| + \|b\|. So it is approximately

u κ(A) ∥b∥∥A∥ ∥x∥,u\,\kappa(A)\,\frac{\|b\|}{\|A\|\,\|x\|},

and everything hangs on the size of xx. Write ρ=∥x∥σmin⁡/∥b∥\rho = \|x\|\sigma_{\min}/\|b\|, which is the answer’s size over the largest it could possibly be, ∥b∥/σmin⁡\|b\|/\sigma_{\min}. The backward error is then about u/ρu/\rho. At the top of its range, ρ=1\rho = 1, the inverse is as stable as anything. At the bottom, ρ=1/κ\rho = 1/\kappa, it has lost all the digits it can.

Druinsky and Toledo made this observation in 2012, in a paper whose title is the question the first essay here assumed it had answered. The measurement that follows puts numbers on it for the same kind of matrix: order 30, singular values spaced geometrically from one down to 1/κ1/\kappa, with singular vectors drawn at random, and known, so that ρ\rho can be read directly.

The backward error of solving by a computed inverse and by LU against rho, the size of the answer over its largest possible size, at a condition number of 1e+14 and order 30At a condition number of 1e+14 the inverse route's backward error falls from 1.6e-4 at rho 1.4e-14 to 1.8e-17 at rho 1.00, a fitted slope of -0.98. LU's stays between 1.2e-17 and 6.9e-17.10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²110⁻¹⁸10⁻¹⁶10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²ρ, the answer's size over its largest possiblebackward errorby the computed inverseby LUorder 30 · κ = 10¹⁴the size of x decides, not the inverse
Fig. 1 The backward error of solving by a computed inverse (red) and by LU (blue) against ρ\rho, for right-hand sides mixing the top and bottom singular vectors. The dial sets the condition number.

At κ=1014\kappa = 10^{14} the inverse route’s backward error starts at 1.6⋅10−41.6 \cdot 10^{-4} where ρ\rho is 1.4⋅10−141.4 \cdot 10^{-14}, and falls in a straight line to 1.8⋅10−171.8 \cdot 10^{-17} where ρ\rho is one. The fitted slope is −0.98-0.98. LU’s, on the same right-hand sides, wanders between 1.2⋅10−171.2 \cdot 10^{-17} and 6.9⋅10−176.9 \cdot 10^{-17} the whole way across. So the two lines start twelve decades apart and end at the same place. Turning the dial to a lower condition number shortens the line from the left, since the least possible ρ\rho is 1/κ1/\kappa, and leaves the right-hand end exactly where it was.

The backward error of the computed inverse route, times rho, in units of the roundoff, across the mixed right-hand sides at three condition numbers: the least, a central value and the greatestκ = 10⁶: from 0.021 to 0.336; κ = 10¹⁰: from 0.006 to 0.303; κ = 10¹⁴: from 0.015 to 0.269.10⁻³10⁻²10⁻¹1κ = 10⁶κ = 10¹⁰κ = 10¹⁴backward error × ρ / udot: the geometric centre · bar: the rangethe one number that predicts it
Fig. 2 The backward error of the inverse route times ρ\rho, in units of the roundoff, across these mixed right-hand sides at three condition numbers: the range, and a central value.

As a law it is good. The backward error times ρ\rho over uu lies between 0.006 and 0.34 across all three condition numbers, around a hundred right-hand sides spanning fourteen decades of ρ\rho. So the backward error is about a tenth of a unit of roundoff over ρ\rho, within a factor of ten either way, which is an extremely tight description of a quantity that varies by twelve orders of magnitude. Only one number is doing that work.

The construction that picks the bad end

Now the question is where the usual test sits on that line.

Median backward error of the two routes at a condition number of ten to the fourteen and order 30, for four kinds of right-hand side, with rho for eachb = Ax, x random: rho 9e-14, inverse 5e-5, LU 2e-17; b random: rho 2e-1, inverse 2e-17, LU 2e-17; b on the top left singular vector: rho 3e-14, inverse 4e-5, LU 4e-17; b on the bottom one: rho 3e-1, inverse 3e-17, LU 2e-17.10⁻¹⁸10⁻¹⁴10⁻¹⁰10⁻⁶b = Ax, x random, ρ = 9e-14by the computed inverseby LUb random, ρ = 2e-1by the computed inverseby LUb on the top left singular vector, ρ = 3e-14by the computed inverseby LUb on the bottom one, ρ = 3e-1by the computed inverseby LUbackward error, median of twelveκ = 10¹⁴ · order 30a dozen decades, or none
Fig. 3 The median backward error of the two routes at a condition number of 101410^{14}, for four kinds of right-hand side, with ρ\rho for each.

With b=Axb = Ax for a random xx, ρ\rho is 9⋅10−149 \cdot 10^{-14}, a few times its minimum. The reason is that a random xx has components of comparable size along all of the right singular vectors, and AA multiplies the largest by one and the smallest by 10−1410^{-14}, so that bb lies very nearly along the top left singular vectors and has a norm of about one per ∥x∥\|x\|. So the test chooses a problem where ∥x∥≈∥b∥/∥A∥\|x\| \approx \|b\|/\|A\|, the smallest an answer can be. The inverse route’s backward error on it is 5⋅10−55 \cdot 10^{-5}. LU’s is 2⋅10−172 \cdot 10^{-17}. Those are the twelve orders the earlier essay reported. Set bb exactly on a top singular vector and it is almost the same, 4⋅10−54 \cdot 10^{-5}.

With a random bb the answer is as different as it could be. The solution now picks up the bottom singular vector’s 1/σmin⁡1/\sigma_{\min} directly, so ∥x∥\|x\| is about as large as it can be, ρ\rho is about 0.2, and the inverse route’s median backward error is 2⋅10−172 \cdot 10^{-17}, the same as LU’s. With bb on a bottom singular vector, ρ\rho is about 0.3 and the two routes come to 3⋅10−173 \cdot 10^{-17} and 2⋅10−172 \cdot 10^{-17}. On those right-hand sides nothing separates them.

Median backward error against the condition number at order 30: the computed inverse on a right-hand side arranged as b = Ax and on a random one, and LUBy the inverse with b = Ax: 3e-16, 1e-14, 7e-13, 5e-11, 3e-9, 4e-7, 5e-5. By the inverse with b random: 4e-17, 3e-17, 3e-17, 2e-17, 2e-17, 2e-17, 2e-17. By LU with b = Ax: 5e-17, 4e-17, 3e-17, 3e-17, 2e-17, 2e-17, 2e-17.10²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁸10⁻¹⁶10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²condition numberbackward error, median of twelveinverse, b = Axinverse, b randomLU, b = Axorder 30 · matrices with known singular valuesthe earlier sweep is the red line only
Fig. 4 Median backward error against the condition number: the computed inverse on b=Axb = Ax (red) and on a random bb (green), and LU (blue).

Against κ\kappa the picture is the earlier one with a second line added. On b=Axb = Ax the inverse route climbs from 3⋅10−163 \cdot 10^{-16} at κ=102\kappa = 10^2 to 5⋅10−55 \cdot 10^{-5} at 101410^{14}, a slope of about one. On a random bb it stays between 2⋅10−172 \cdot 10^{-17} and 4⋅10−174 \cdot 10^{-17} across all twelve decades, overlapping LU’s line so closely that the two are barely distinguishable. The statement that the backward error of the inverse route grows like κ\kappa, which the first essay stated and measured, is true of this right-hand side and not of the route.

A claim’s most tempting form needs to be stated so it can be refused: that the inverse route is unstable whatever bb is. Fed a random right-hand side at κ=1014\kappa = 10^{14}, the claim that the two routes are six orders apart fails.

How far from the bad end a right-hand side lands by itself

If the good end needed something contrived, the point would be academic. It needs nothing.

The size of the answer over its largest possible size for 200 random right-hand sides at each condition number: the least, the median and the greatestκ = 10²: least 1.6e-1, median 3.3e-1, greatest 6.0e-1; κ = 10⁴: least 8.0e-2, median 2.4e-1, greatest 5.6e-1; κ = 10⁶: least 5.3e-2, median 2.0e-1, greatest 5.4e-1; κ = 10⁸: least 3.3e-2, median 1.7e-1, greatest 5.4e-1; κ = 10¹⁰: least 2.3e-2, median 1.6e-1, greatest 5.4e-1; κ = 10¹²: least 1.8e-2, median 1.5e-1, greatest 5.4e-1; κ = 10¹⁴: least 1.6e-2, median 1.5e-1, greatest 5.4e-1.10⁻³10⁻²10⁻¹1κ = 10²κ = 10⁴κ = 10⁶κ = 10⁸κ = 10¹⁰κ = 10¹²κ = 10¹⁴ρ, over 200 random right-hand sidesdot: the median · bar: least to greatestnobody arrives at 10⁻¹⁴ by chance
Fig. 5 The answer’s size over its largest possible for 200 random right-hand sides at each condition number: the median, and the range.

Over 200 random right-hand sides at κ=1014\kappa = 10^{14} the median ρ\rho is 0.15, the largest is 0.54 and the least is 0.016. At κ=102\kappa = 10^2 the median is 0.33 and the least is 0.16. The numbers barely depend on the conditioning, because a random vector has a component on the bottom left singular vector of relative size about 1/n1/\sqrt{n}, and ρ\rho is about that whatever κ\kappa is. Getting a ρ\rho of 10−1410^{-14} by chance would need bb to miss the bottom singular directions to fourteen digits, on all of them. Nothing but a construction makes that happen, and b=Axb = Ax does it exactly.

So a measurement meant to compare two solvers was done on a right-hand side with a probability of essentially zero under the most natural random model. That makes neither end the true one, and it leaves open where a problem nobody randomised actually lands.

Where problems nobody randomised land

The backward error of the two routes on six problems from outside the random models: a second difference operator with three kinds of data, a Gaussian blur with and without noise, and a Hilbert matrixsecond difference, smooth solution: condition number 7e+3, rho 6e-1, inverse 1e-16, LU 3e-17; second difference, random solution: condition number 7e+3, rho 3e-4, inverse 8e-15, LU 3e-17; second difference, random source: condition number 7e+3, rho 1e-1, inverse 3e-16, LU 3e-17; Gaussian blur, smooth solution: condition number 2e+18, rho 2e-18, inverse 9e-14, LU 8e-17; Gaussian blur, smooth solution plus 1% noise: condition number 2e+18, rho 3e-5, inverse 3e-15, LU 4e-17; Hilbert, order 12, all ones: condition number 2e+16, rho 7e-17, inverse 2e-4, LU 7e-17.10⁻¹⁸10⁻¹⁴10⁻¹⁰10⁻⁶second difference, smooth solution, ρ = 6e-1by the computed inverseby LUsecond difference, random solution, ρ = 3e-4by the computed inverseby LUsecond difference, random source, ρ = 1e-1by the computed inverseby LUGaussian blur, smooth solution, ρ = 2e-18by the computed inverseby LUGaussian blur, smooth solution plus 1% noise, ρ = 3e-5by the computed inverseby LUHilbert, order 12, all ones, ρ = 7e-17by the computed inverseby LUbackward errorred headings: a tenfold gap or morethe operator and the data together
Fig. 6 The backward error of the two routes on six problems from outside the random models, with ρ\rho for each: a second difference operator with three kinds of data, a Gaussian blur with and without noise, and a Hilbert matrix.

The natural guess is that real problems sit at the bad end, since a real problem has a solution first and data second, which is the b=Axb = Ax construction. That guess is wrong for the most common kind of matrix, and for an interesting reason. The operator matters as much as the data, because what sets ρ\rho is how much of the solution lies along the small singular vectors.

Take a second difference operator on 128 points, with a condition number of 6,700, and a smooth solution. A differential operator’s small singular values belong to its smooth modes, so a smooth solution lies almost entirely along them. Then ρ\rho is 0.64, near its top, and the inverse route’s backward error is 1.5⋅10−161.5 \cdot 10^{-16} against LU’s 3.5⋅10−173.5 \cdot 10^{-17}, a gap of four. The same operator with a random solution has ρ\rho of 2.6⋅10−42.6 \cdot 10^{-4} and a gap of 270. With a random source rather than a random solution, ρ\rho is 0.12 and the gap is nine. So the same matrix occupies three different places along the line, according to what it is being asked.

A smoothing operator reverses it. A Gaussian blur has its large singular values on its smooth modes, so a smooth solution lies on the top vectors and ρ\rho falls to the bottom of its range. At a width of three on 64 points the gap between the routes is over a thousand, and on order-12 Hilbert with a right-hand side from the vector of ones it is the full distance, 1.8⋅10−41.8 \cdot 10^{-4} against 6.7⋅10−176.7 \cdot 10^{-17}. Those two matrices have condition numbers above 1/u1/u, so the law’s own prediction is meaningless there, since the smallest singular value cannot be computed at all, and the ordering is the only thing to be read. Add a noise of one per cent to the blur’s data, which is what any measured data would have, and ρ\rho jumps from 10−1810^{-18} to 3⋅10−53 \cdot 10^{-5} while the gap falls from over a thousand to about sixty. A small amount of noise carries the problem a long way along the line, because noise has components on the bottom vectors and the smooth signal did not.

It is no accident that a measurement on the Hilbert matrix found the inverse at its worst. The number that decides nothing and many of the essays that followed use Hilbert matrices, and with b=Axb = Ax that matrix lands where any smoothing operator does. So does a discretised integral equation, the setting of the regularisation field, and there the point is moot in a different way, since nobody there is solving to the bottom of the spectrum.

Which is why it is not an excuse

Median forward error against the condition number at order 30: both routes on a right-hand side arranged as b = Ax, and both on a random oneWith b = Ax: inverse 6e-15, 4e-13, 4e-11, 3e-9, 5e-7, 7e-5, 6e-3, LU 3e-15, 1e-13, 7e-12, 8e-10, 9e-8, 5e-6, 4e-4. With b random: inverse 3e-15, 1e-13, 1e-11, 7e-10, 7e-8, 7e-6, 7e-4, LU 3e-15, 1e-13, 1e-11, 7e-10, 7e-8, 7e-6, 7e-4.10²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁶10⁻¹⁴10⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²1condition numberforward error, median of twelveinverse, b = AxLU, b = Axboth, b randomorder 30a tenfold gap, where the backward gap is 10¹²
Fig. 7 Median forward error against the condition number: both routes on b=Axb = Ax, and both on a random bb.

The forward errors add a second reason for caution. On a random bb the two routes’ forward errors are identical to the figures printed, 7⋅10−47 \cdot 10^{-4} at κ=1014\kappa = 10^{14}, so an inverse costs nothing there. On b=Axb = Ax the inverse route is worse, but by far less than the backward error suggests: 6⋅10−36 \cdot 10^{-3} against 4⋅10−44 \cdot 10^{-4} at 101410^{14}, about fifteen times, where the backward gap is twelve decades. So the extreme instability of the inverse route, the thing that makes it look like a different class of method, is nearly all a statement about blame and almost none about digits. That is the same conclusion the refinement essay reached from another direction: the forward error lands on the LU route’s number after one correction.

And a random right-hand side’s forgiving verdict is not a good outcome for the person holding the answer. At ρ\rho near one, the answer is dominated by what the smallest singular value does to whatever lies along the bottom vector, and that is the setting in which a small residual is not a small error. A backward error of 2⋅10−172 \cdot 10^{-17} says that the computed answer exactly solves a very nearby system. It does not say the answer means anything; at κ=1014\kappa = 10^{14} it has a relative error of 7⋅10−47 \cdot 10^{-4} on a good day, and if the data were measured it has nothing at all. The route is forgiven precisely where the problem has already spent its digits on something else, as the exact answer to a nearby problem sets out.

The refusal this suggests is therefore narrower than a general rule to stop worrying. It is that a code’s backward error cannot be predicted from the route alone, and that a comparison of routes on b=Axb = Ax measures the route at one extreme of its range.

What a person holding a computed inverse should do

None of this argues for forming an inverse. The first essay’s other reasons remain: three times the arithmetic for no benefit, and a dense object in place of a sparse factor. Its side-by-side comparison is also not contradicted. LU is as good as or better than the inverse route at every ρ\rho measured, so there is no right-hand side for which forming the inverse is the better choice, and the two only ever tie.

What it changes is how a caller should read an inverse that already exists, for instance in old code or as the output of a library that only returns one. In those cases the check is cheap and has a clear answer. Compute r=b−Ax^r = b - A\hat x at a cost of n2n^2, and divide. That gives the backward error directly, and it is the very quantity one number that has to be right warns about computing carefully. If it is small then this particular answer is fine, and refining it would achieve nothing. If it is large then one step of refinement repairs it for 2n22n^2. Neither route needs an estimate of κ\kappa. And there is no need for a blanket rule, when the question can be asked of the answer in hand.

There is also something here for anyone writing a test. A solver test using b=Axb = Ax measures behaviour in the corner where ∥x∥\|x\| is small. The test is still worth having, and it is the one that exposes this difference. But a suite containing only that test would not see a route whose error depends on the right-hand side, and could report a stable route as unstable. A small addition, a right-hand side bb drawn at random with its reference answer from a higher precision, covers the other end. This is the same trouble that the elimination field’s accounts of growth have, in which a bound’s worst case is one thing and what occurs in a sampled matrix is something quite different. And a test which draws its solution from the problem’s own smooth modes, rather than at random, shows which end the application is really at.

What order 30 does not show

Thirty is small, and the matrices have singular values spaced evenly in the logarithm with random singular vectors. Those choices remove anything else that might have been going on, and in doing so they set the median ρ\rho of a random right-hand side at about 1/n1/\sqrt{n} or a little below. On a larger matrix the median would fall as the square root of the order, so it would still be many orders of magnitude from the bad end. The constant around 0.1u0.1u depends a little on the order too, and is bounded rather than exact. The right-hand sides in the sweep are combinations of two singular vectors only, chosen to run across all values of ρ\rho with nothing else varying. And the six named problems are single instances, each with one grid and one draw of noise, so they can show where a problem lands and cannot show how far it might wander.

The computed inverse here is formed by solving for each column, which gives the small residual on the side that this analysis uses. An inverse computed from the triangular factors in the way a library routine does it has a small residual on the other side instead, so it may behave differently.

Still open: the inverse with its other side small, and structured right-hand sides

The other side. An inverse formed from its factors by solving XL=U−1XL = U^{-1} has a small left residual X^A−I\hat XA - I and not a small right one. Multiplying bb by it leaves a residual AX^b−bA\hat Xb - b that is not controlled by the same bound. The prediction with a sign is that on the same matrices and the same right-hand sides that form’s backward error exceeds the column form’s by at least a factor of ten at κ=1014\kappa = 10^{14} on random bb, breaking the agreement with LU measured above, while its forward error on b=Axb = Ax falls to within twice LU’s, where the column form’s is fifteen times.

A grid that refines. The second difference operator’s smooth solution stays near the top of the range at one size. The prediction with a sign is that ρ\rho holds above 0.5 on a smooth solution at every size from 32 to 512, while the condition number grows like the square of the size, so that the gap between the two routes stays under ten throughout, and a random solution’s gap grows in proportion to the condition number. If so, refining a grid leaves a smooth problem forgiven however badly conditioned it becomes.

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.

Named objects

A flat tag is an object no other essay names yet.

Backward errorCondition numberForward errorLU factorisationMatrix inverseResidualSingular values