Two errors, and whose fault they are

A condition number scaling cannot move

Skeel's componentwise condition number is invariant under any row scaling — exactly, before any norm is taken, because two diagonal factors cancel entry by entry. It is never larger than the normwise one and can be arbitrarily smaller, and the ratio between them is a diagnostic for which kind of ill-conditioning a matrix has.

Worth reading first: The units the matrix is measured in · The condition number is an amplifier.

The units the matrix is measured in used the componentwise condition number as a foil — a second number, flat, drawn beside a first number that climbs. This essay takes it seriously as an object: what it is, what it bounds, why the invariance is exact rather than approximate, and what its ratio to κ is worth as a diagnostic.

Its definition is one line, and the only thing in it that is unusual is where the absolute values go.

cond(A)  =  ‖ |A⁻¹| · |A| ‖_∞

Take the inverse. Take the absolute value of every entry of both matrices. Then multiply, and then take a norm. The normwise condition number is ‖A⁻¹‖·‖A‖, where the norms are taken first and the entries never meet.

Two perturbation bounds and the error that was measured, on a 8×8 matrix spread over 8 decades of unitsThree curves against the size of an entrywise relative perturbation. The normwise bound κ_∞·ε is a valid bound and sits 4·10⁷ times above the componentwise one cond(A, x)·ε, which is also a bound and is nearly attained by the worst of forty random perturbations at each size.10⁻¹⁴10⁻¹³10⁻¹²10⁻¹¹10⁻¹⁰10⁻⁹10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³1relative size of the entrywise perturbationrelative forward errorκ_∞ · εcond(A,x) · εmeasuredboth bounds holdκ_∞(A)1.9·10⁸cond(A, x)4.8ratio of the bounds4·10⁷both curves above the data are boundsand only one of them is a measurement
Fig. 1 Both bounds against the error that was measured, on an 8×8 whose rows are spread over eight decades of units. Both hold. The normwise one is above the data by nearly eight orders of magnitude and the componentwise one is nearly attained. Drag the spread of the units to zero and the two coincide.
Two perturbation bounds and the error that was measured, on a 8×8 matrix spread over 4 decades of unitsThree curves against the size of an entrywise relative perturbation. The normwise bound κ_∞·ε is a valid bound and sits 4120 times above the componentwise one cond(A, x)·ε, which is also a bound and is nearly attained by the worst of forty random perturbations at each size.10⁻¹⁴10⁻¹³10⁻¹²10⁻¹¹10⁻¹⁰10⁻⁹10⁻¹⁵10⁻¹³10⁻¹¹10⁻⁹10⁻⁷10⁻⁵relative size of the entrywise perturbationrelative forward errorκ_∞ · εcond(A,x) · εmeasuredboth bounds holdκ_∞(A)2·10⁴cond(A, x)4.8ratio of the bounds4120both curves above the data are boundsand only one of them is a measurement
Fig. 2 The same pair of bounds at four decades of units rather than eight. The gap between them is four decades, which is the whole of the claim in one picture: the separation is the spread and nothing else.

Why the absolute values matter

The absolute values are the whole of the difference, and they are what makes the number a statement about entrywise relative perturbation.

A normwise bound answers: move A by a matrix of norm ε‖A‖ — how far can x move? The perturbation is described by one number for the whole matrix, and it is free to put all of its weight anywhere.

A componentwise bound answers: move every entry a_ij by at most ε|a_ij| — how far can x move? This constrains the perturbation entry by entry — the perturbation of a tiny entry is tiny — and the constant that comes out is cond(A, x) = ‖ |A⁻¹| |A| |x| ‖_∞ / ‖x‖_∞, with the solution in it.

Rounding a matrix into a floating-point format is exactly the second kind of perturbation. So is storing it in a narrower one, and so is a measurement whose error is a percentage. The first kind is a mathematical convenience.

The invariance, in three lines

Write A = D·A₀ with D diagonal and positive. Then A⁻¹ = A₀⁻¹D⁻¹ and

|A⁻¹| |A|  =  (|A₀⁻¹| |D⁻¹|)(|D| |A₀|)  =  |A₀⁻¹| (|D⁻¹| |D|) |A₀|  =  |A₀⁻¹| |A₀|

because |D⁻¹||D| is exactly the identity — a diagonal matrix times its own inverse, entry by entry, no cancellation of unequal quantities anywhere. The product is the same matrix, not merely the same norm, so the equality survives whichever norm is taken afterwards.

That is a stronger statement than a bound, and it is worth noticing what it rules out. It says the componentwise number cannot be improved by scaling either: there is no diagonal D that makes it smaller, because there is no diagonal D that changes it. Equilibration takes κ down by eight orders of magnitude and takes cond down by exactly nothing, and the second sentence is the reason the first one is not a repair for every problem.

Measured, because the arithmetic is not the algebra

assertSkeelIsInvariantUnderRowScaling computes the number twice, by inverting two different matrices, and checks agreement at 10⁻⁸ relative. The algebra above is exact; the two inversions round, and the scaled matrix’s inversion rounds worse because its entries span eight decades.

Measured on the site’s test matrix the two come out 6.976397983091772 and 6.976397983091762 — agreement to fourteen digits, on a matrix whose κ₂ has moved by 3.7·10⁷ between the two computations. The two digits that differ are the arithmetic’s, and they are exactly where the site expects to find them.

The assertion also runs a third scaling, drawn at random over twelve decades and unrelated to the one the test matrix was built with. An invariance checked only against the construction that produced it is an invariance checked against itself, and this site has recorded that mistake in another library already.

Two condition numbers of one 8×8 system, as its rows are put into different unitsFour curves against the spread of the row units, in decades. κ_∞ of the scaled matrix rises from 9.83 to 1.9·10⁶ while the componentwise condition number stays at 6.98 throughout — the same system, the same solution, and one of the two numbers is a fact about the units. Hilbert's two numbers are drawn flat beside them at 3.4·10¹⁰ and 1.2·10¹⁰: a matrix whose sensitivity no scaling repairs.0123456110²10⁴10⁶10⁸10¹⁰10¹²spread of the row units (decades)condition numberκ_∞(DA)cond(DA)Hilbert κ_∞Hilbert condone system, two numbersκ_∞ at no spread9.8κ_∞ at 6 decades1.9·10⁶cond, either end7Hilbert, equilibrated1.3·10¹⁰the solution is the same at every spreadand one of these curves knows it
Fig. 3 The two numbers over six decades, with Hilbert’s pair drawn flat through them. One curve is a property of the units and three of the four are not.

What the ratio says

cond(A) ≤ κ_∞(A) always, and the gap can be anything. So the ratio is information, and it is the most useful thing in this essay:

κ_∞ ≫ cond. The matrix is badly described. Its rows differ enormously in size, a normwise perturbation is a bad model of what will happen to it, and a diagonal scaling will bring κ down to near cond. Measured here: 2.7·10⁷ for the eight-decade matrix.

κ_∞ ≈ cond. The matrix is badly conditioned, or well conditioned, and either way the normwise number is telling the truth and no scaling will help. Measured here: 2.9 for the Hilbert matrix at n = 8, with both numbers near 10¹⁰.

Two condition numbers of one 8×8 system, as its rows are put into different unitsFour curves against the spread of the row units, in decades. κ_∞ of the scaled matrix rises from 9.83 to 2·10⁴ while the componentwise condition number stays at 6.98 throughout — the same system, the same solution, and one of the two numbers is a fact about the units. Hilbert's two numbers are drawn flat beside them at 3.4·10¹⁰ and 1.2·10¹⁰: a matrix whose sensitivity no scaling repairs.01234110²10⁴10⁶10⁸10¹⁰10¹²spread of the row units (decades)condition numberκ_∞(DA)cond(DA)Hilbert κ_∞Hilbert condone system, two numbersκ_∞ at no spread9.8κ_∞ at 4 decades2·10⁴cond, either end7Hilbert, equilibrated1.3·10¹⁰the solution is the same at every spreadand one of these curves knows it
Fig. 4 The two numbers over a narrower spread of units, with Hilbert’s pair drawn through them. The point of the narrower range is that the separation begins immediately: two decades of units is already two decades of gap between the two condition numbers.

The Hilbert row is the one that makes the diagnostic usable. Without it a reader has a rule that says compute both and scale if they differ, which is fine and expensive; with it there is a second rule that says if they do not differ, stop looking for a repair.

How much a perturbation of the right-hand side is amplified, κ = 10¹⁰The cumulative distribution of the amplification factor over two hundred random perturbation directions, with the condition number marked as the upper limit.110¹10²10³10⁴10⁵10⁶10⁷10⁸10⁹10¹⁰10¹¹10¹²00.250.50.751amplification of the input perturbationfraction of directions at or belowκ = 10¹⁰worst found 7.6·10⁹6×6, 200 directionsmedian reaches 0.29 of κ
Fig. 5 A condition number is a supremum over perturbation directions, and a random direction gets a fraction of it. The relationship between cond(A) and cond(A, x) is that same distinction one level up.

The bound, and how tight it is

The componentwise perturbation theorem says: if |ΔA| ≤ ε|A| and |Δb| ≤ ε|b|, then to first order

‖Δx‖_∞ / ‖x‖_∞   ≤   2ε · cond(A, x)  /  (1 − ε·cond(A))

and for the sizes of ε that matter the denominator is 1. The hero figure is that bound against a measurement, and the measurement is the worst of forty random perturbations at each of six sizes.

At ε = 10⁻⁹ the numbers are: measured worst 2.1·10⁻⁹, componentwise bound 4.8·10⁻⁹, normwise bound 0.19. The componentwise bound is within a factor of 2.3 of what actually happened. The normwise bound is a valid statement that predicts nothing.

Both directions are asserted, and it matters that they are. A single assertion saying “the componentwise bound is better” would pass on a matrix where both were hopeless. What is checked is that the normwise bound holds, that the componentwise bound holds, that they are orders apart, and that the componentwise one is nearly attained — which is the claim that it is a prediction rather than a smaller number.

The version with x in it

cond(A, x) is smaller still than cond(A), and the difference is worth a paragraph because it carries an idea this site has met before.

cond(A) takes a norm over all right-hand sides. cond(A, x) is about the solution in hand. A matrix can be very sensitive for some b and not for others — the sensitivity lives in the direction of x relative to the small singular directions — and cond(A) reports the worst case over all of them.

That is the same relationship as between κ(A) and the amplification a particular perturbation achieves, which the condition number is an amplifier measured: a random perturbation direction is amplified by 0.29 of κ at the median and 0.76 at the worst of 200. A condition number is a supremum, and a supremum is attained by one direction out of infinitely many.

How much a perturbation of the right-hand side is amplified, κ = 10⁸The cumulative distribution of the amplification factor over two hundred random perturbation directions, with the condition number marked as the upper limit.110¹10²10³10⁴10⁵10⁶10⁷10⁸10⁹10¹⁰00.250.50.751amplification of the input perturbationfraction of directions at or belowκ = 10⁸worst found 7.6·10⁷6×6, 200 directionsmedian reaches 0.29 of κ
Fig. 6 The earlier measurement, at κ = 10⁸: how much of the available amplification a random perturbation actually gets. The relationship between cond(A) and cond(A, x) is the same relationship one level up.

The backward error it pairs with

A condition number is only half of the site’s identity. The other half is the backward error, and it has a componentwise form too, which is where the pairing becomes an argument rather than a definition.

The normwise backward error of a computed x has a closed form — ‖Ax − b‖ / (‖A‖‖x‖ + ‖b‖) — and this site has printed it on figures since its first commit. The componentwise one, due to Oettli and Prager, is

ω  =  max_i  |r_i|  /  ( |A||x| + |b| )_i

with r the residual, and it answers: what is the smallest ε such that x is the exact solution of some (A + ΔA)x = b + Δb with |ΔA| ≤ ε|A| and |Δb| ≤ ε|b|? It is a maximum over rows of a ratio of computed quantities, so it costs one matrix–vector product and no inverse at all.

The two halves then compose in the same shape as the site’s spine:

forward error  ⪅  cond(A, x) × ω

and both factors are componentwise. That inequality is the one whose right-hand side was nearly attained in the hero figure, and it is the reason the componentwise pair is worth carrying rather than merely noting: the normwise identity and the componentwise identity are both true, and only one of them predicts the number.

Backward error, forward error and the condition number, with measured valuesTwo boxes at the top — the problem posed and the nearby problem the algorithm answered exactly — and two answers below them, with the distances between all four labelled by numbers from a Hilbert solve.the problem you posedA = H12b = A·(1, 2, …, 12)the problem it answered exactlyA + δA, b + δb‖δ‖ / ‖A‖ = 1.8·10⁻¹⁷the answer you wantedx = (1, 2, …, 12), exactlythe answer you gotx̂, wrong by 0.02 relativebackward error 1.8·10⁻¹⁷forward error 0.02κ = 1.8·10¹⁶κ · η = 0.33, and the measured forward error is 0.02.The algorithm is not at fault. The problem is.H12, LU with partial pivotingresidual and error differ
Fig. 7 The identity both pairs live in. Swapping the normwise condition number for the componentwise one and the normwise backward error for Oettli and Prager’s leaves the shape of this picture unchanged and changes what it predicts.

What Skeel’s theorem is actually about

The componentwise condition number is usually called Skeel’s, and the paper it comes from is not about a condition number. It is about iterative refinement, and the result is startling enough to restate.

Gaussian elimination with partial pivoting is normwise backward stable and is not componentwise backward stable: the ΔA it is exact for can be small in norm and enormous relative to individual entries, which is exactly what happens on a badly scaled matrix. Skeel’s theorem says that one step of iterative refinement, with the residual computed in the working precision, repairs that — the refined solution has a componentwise backward error of order u, provided cond(A) is not too large.

The italics are the surprising part. Buying the accuracy back measured refinement in the setting it is usually presented in: a low-precision factorisation, a residual computed in a higher precision, and the reward is forward accuracy. Skeel’s version needs no extra precision anywhere and buys something different — not a more accurate answer, but an answer that is the exact solution of a problem whose every entry is within a rounding of the one that was handed over.

Iterative refinement from a 24-bit factorisation, κ = 10⁴A semi-logarithmic plot of forward error against refinement step. One curve falls steeply to the level of a double-precision solve; the other is nearly flat.012345610⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴10⁻¹refinement step‖x − x*‖ / ‖x*‖a full double-precision solveresidual in24-bitresidual indoubleone argument apartκ·u of the factorisation6·10⁻⁴double residual, final3.2·10⁻¹³same-precision, final1.3·10⁻⁴30×30, κ = 10⁴, same factors in both runsidentical cost
Fig. 8 Refinement as the site has drawn it before: a factorisation at 24 bits, a residual, and a correction. The version in Skeel’s theorem changes nothing about this loop except the precision of the residual and what is claimed at the end of it.

That is a different guarantee and it is the right one for a scaled problem, because a componentwise backward error is invariant under row scaling for the same reason cond is: the scaling divides out of the ratio row by row.

Iterative refinement from a 24-bit factorisation, κ = 10⁴A semi-logarithmic plot of forward error against refinement step. One curve falls steeply to the level of a double-precision solve; the other is nearly flat.012345610⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴10⁻¹refinement step‖x − x*‖ / ‖x*‖a full double-precision solveresidual in24-bitresidual indoubleone argument apartκ·u of the factorisation6·10⁻⁴double residual, final3.2·10⁻¹³same-precision, final1.3·10⁻⁴30×30, κ = 10⁴, same factors in both runsidentical cost
Fig. 9 Refinement at a 24-bit factorisation. Skeel’s theorem is about the same loop with the residual in the working precision, and what it buys is componentwise backward stability rather than forward accuracy.

Two matrices with the same κ and different cond

The clearest way to see that these are separate quantities is to hold one fixed and move the other.

Take the badly scaled matrix at eight decades: κ_∞ = 1.9·10⁸, cond = 6.98. Now take an ordinary random matrix and give it a genuine spread of singular values until its κ_∞ reaches 1.9·10⁸ as well. Its rows are all about the same size, so its cond is also near 10⁸.

Two matrices, the same normwise condition number, componentwise numbers seven orders apart. A solver handed either of them and told only κ would budget for the same loss of accuracy, and would be right about one of them. Equilibrating the first takes κ to about 7 and leaves the answer exactly where it was; equilibrating the second does nothing at all.

The site’s own Hilbert matrix is the second case at n = 8, and it is drawn in every figure in this essay for that reason.

The exact solution of a 13×13 Hilbert system beside the computed oneTwo columns of numbers: the exact answer, which is the integers one to thirteen, and the answer double-precision elimination returns, with the number of correct digits beside each.H13 x = b, b formed exactly so that x = (1, 2, …, 13)12345678910111213exact1.00002.00003.00133.97865.18864.993010.46720.048921.2657-2.575319.21478.906013.5113computed6.6 correct digits4.8 correct digits3.4 correct digits2.3 correct digits1.4 correct digit0.8 correct digitno correct digitsno correct digitsno correct digitsno correct digitsno correct digits0.6 correct digit1.4 correct digitbackward error2.2·10⁻¹⁷κ = 1.7·10¹⁸The algorithm solved a neighbouring problem perfectly. That problem's answer is this one.right-hand side built in BigInt rationalsthe truth is known
Fig. 10 Hilbert at n = 13, where the answer is known exactly because the inverse is known in closed form. No diagonal scaling recovers any of the digits this figure is about, and the componentwise condition number is what says so in advance.
Two perturbation bounds and the error that was measured, on a 8×8 matrix spread over 10 decades of unitsThree curves against the size of an entrywise relative perturbation. The normwise bound κ_∞·ε is a valid bound and sits 4·10⁹ times above the componentwise one cond(A, x)·ε, which is also a bound and is nearly attained by the worst of forty random perturbations at each size.10⁻¹⁴10⁻¹³10⁻¹²10⁻¹¹10⁻¹⁰10⁻⁹10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³1relative size of the entrywise perturbationrelative forward errorκ_∞ · εcond(A,x) · εmeasuredboth bounds holdκ_∞(A)1.9·10¹⁰cond(A, x)4.8ratio of the bounds4·10⁹both curves above the data are boundsand only one of them is a measurement
Fig. 11 Ten decades of units, which is where the two bounds are furthest apart and the normwise one is at its least useful. Nothing about the problem changed between this figure and the one at zero spread.

Why nothing computes it

cond(A) needs the entries of A⁻¹, not its action. Every other quantity in a solve — the answer, the residual, an estimate of κ — can be got from the factorisation by solving with it. This one needs n solves to form the inverse, which costs more than the factorisation did, and then an n×n product on top.

That is why it is not in the routine every library exposes, and why the number a reader has in hand is the normwise one. LAPACK’s expert drivers do return a componentwise error bound, computed by Skeel’s iterative-refinement argument rather than by forming the inverse, and it is the right thing to ask for when the answer matters. It is also three letters longer to type than the simple driver and correspondingly rare.

There is a cheaper diagnostic that costs nothing at all: look at the row norms. If the largest is within a couple of orders of the smallest, κ and cond are close and κ is honest. If they span eight decades, κ is mostly reporting that fact. That is not a substitute for computing the number, and it is available before any solve at all.

What the solver reported, and what it achievedFinal relative residual and final relative error against the working precision, on a logarithmic vertical axis. The residual sits at the stopping tolerance at every precision — the method converged, by every test available to it. The error runs from 1.4·10⁻¹³ at 53 bits to 0.00597 at 8, tracking the unit roundoff, which is drawn beside it.614223038465410⁻¹³10⁻¹⁰10⁻⁷10⁻⁴working significand bitsrelative sizeerrorresidualuthe gap the solver cannot seeerror ÷ residual at 24 bits1.5·10⁶error ÷ residual at 16 bits2.3·10⁷error ÷ residual at 8 bits2.4·10¹⁰every convergence test passesand the answer is wrong in proportion to u
Fig. 12 The quantity a solver can see, against the one it cannot. A componentwise backward error is the version of the left-hand side that a row scaling does not move.

Where the two numbers come apart in practice

Three places, and none of them is contrived.

Assembled physical models. A stiffness matrix couples displacements to rotations to forces, and the constants of the physics set the row scales. κ reports the constants; cond reports the geometry.

Least squares with a weighting. Weighted least squares multiplies each row of A and b by a weight, which is a row scaling performed deliberately and often over many orders of magnitude — a measurement trusted a thousand times more than another gets a weight a thousand times larger. The normwise condition number of the weighted matrix is then partly a report of the weights. The projection and the right angle has the unweighted version; the weighting is a diagonal on the left of it.

Interior-point steps. The linear system inside an interior-point iteration has a diagonal that goes to zero and to infinity as the iteration converges, which is a row scaling with an enormous and deliberately growing spread. Its κ blows up along the path by construction. Whether the steps are actually getting harder to compute is a question about cond, and the practical answer — that they are not, that these systems solve accurately right up to the boundary — is one of the reasons interior point methods work at all.

In each case a reader who watches κ sees a number that grows and concludes the problem is deteriorating. A reader who watches the ratio sees a number that does not.

How close Hager's estimate is to the true κ₁, over 200 seeded 8×8 matricesFive bars. The estimate is exactly the true condition number on 81% of the sample and inside ten per cent on 87%; the worst underestimate in the whole sample returns 38% of the truth. The last bar is the matrix built to defeat it, at 7.7%, well below anything the random sample reached.each bar is a percentage — of the sample, or of the true condition numberexactly right80.5%inside 10%87.0%inside a factor of 287.0%worst in the sample, ×10037.7%the constructed matrix, ×1007.7%usually exactexact share0.81worst of the sample0.38the constructed matrix0.077a routine that is right most of the timeand never wrong in the safe direction
Fig. 13 And the number a library actually prints in place of either of these. It is an estimate of the normwise one, obtained from a handful of solves, and it is a lower bound.

What is worth carrying

The componentwise condition number is exactly invariant under row scaling, and the exactness is structural — two diagonal matrices cancel entry by entry inside the absolute values, before any norm is taken. Nothing is being estimated.

It is the constant in the bound that models what a machine actually does to a matrix, which is a relative perturbation of each entry, and on a badly scaled matrix it is nearly attained where the normwise bound is loose by eight orders.

And the ratio of the two is a diagnostic that says which kind of trouble a matrix is in. Far apart: the units. Together: the matrix. The first is repairable by a diagonal and the second is not repairable at all.

The next essay is about the number a library actually prints in place of κ, and about the matrix on which that number is wrong by any factor at all: an estimate that can be fooled.

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 errorComponentwise condition numberCondition numberForward errorHilbert matrixIterative refinementPerturbationRelative errorRow scaling