Two errors, and whose fault they are

The condition number is an amplifier

κ is usually introduced as a definition and then quoted. It is a measurement: perturb the input by a known amount, look at how much the output moves, and the largest ratio you can find is the number.

Worth reading first: The exact answer to a nearby problem.

The condition number of a matrix is defined as ‖A‖·‖A⁻¹‖, or equivalently as the ratio of its largest singular value to its smallest. Both of those are correct and neither says what it is for.

What it is for: κ is the largest factor by which a relative change in the input can be amplified into a relative change in the output. Change b by one part in a million; the answer x can change by as much as κ parts in a million, and by no more. That is a statement about the map from b to x — about the problem — and it is true whether the solve is done in floating point, in exact rational arithmetic, or by hand on paper.

It can therefore be measured by doing what it describes.

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⁷00.250.50.751amplification of the input perturbationfraction of directions at or belowκ = 10·10⁵worst found 7.6·10⁵6×6, 200 directionsmedian reaches 0.29 of κ
Fig. 1 Two hundred random perturbation directions, each of a known relative size, applied to the right-hand side of a system and the amplification recorded. The distribution is drawn cumulatively, so the right-hand edge is the worst case found. Drag κ and the whole distribution slides one decade for each decade — its shape does not change.

What the measurement says that the definition does not

Two things, and the second is the useful one.

First, the perturbation route agrees with the singular-value route. That is a check rather than a discovery — the two share no arithmetic, one being a random sampling and the other a Jacobi iteration on the matrix — but it is the check that entitles the site to use κ as an axis. Across four condition numbers and ten seeds each, the constructed κ and the measured κ agree to within a tolerance that is itself bracketed against the noise the construction introduces.

Second, and this is the part a definition cannot supply: random directions get close to the worst case. The worst of two hundred random perturbations reaches about 0.76κ. The median reaches 0.29κ. Even the mildest of the two hundred is amplified by about 0.05κ.

Those numbers hold at κ = 10², 10⁴, 10⁶ and 10⁸ — the ratios are the same at every scale, which is what makes them worth quoting rather than being an accident of one matrix.

Why that matters

Because the usual mental model of the condition number is that it is a pessimistic bound: a worst-case figure describing what could happen in an unlucky case, not what will happen.

For a six-by-six system with logarithmically spread singular values, that model is wrong. A perturbation in a random direction — which is what rounding error looks like — is amplified by nearly a third of the worst case. Ill-conditioning is not a rare misfortune. It is the ordinary behaviour of the matrix, and the worst case is only a factor of three away from the typical one.

The reason is dimensional. A random direction in n dimensions has a component along every right singular vector, including the one belonging to the smallest singular value, and that component is of order 1/√n. So the amplification is of order κ/√n rather than of order 1, and for the sizes of matrices anyone actually inverts by hand, √n is small.

Backward and forward error against the condition number, on 8 × 8 systemsA log–log plot over twelve decades of condition number, at 8 × 8, twenty seeds a point. The backward error is flat — median 6.12·10⁻¹⁷ at κ = 10 and 2.4·10⁻¹⁷ at κ = 10¹³, worst 1.45·10⁻¹⁶ anywhere on the sweep — while the forward error climbs from 4.25·10⁻¹⁶ to 5.72·10⁻⁵. At the right-hand end the two are a factor of 2.38·10¹² apart, and nothing about the computation that produced them differs.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u8×8, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 2 The same fact from the other side, over twenty seeded matrices at each of eight condition numbers. The forward error tracks κ, with the worst of twenty drawn dashed just above the median. If the worst case were rarely approached, the dashed line would sit far above the solid one. It sits close.

That is eight by eight. If κ is the amplifier then the size of the matrix should not be a second amplifier, and the slider is where that gets tested rather than assumed.

Backward and forward error against the condition number, on 30 × 30 systemsA log–log plot over twelve decades of condition number, at 30 × 30, twenty seeds a point. The backward error is flat — median 1.3·10⁻¹⁶ at κ = 10 and 5.09·10⁻¹⁷ at κ = 10¹³, worst 2.4·10⁻¹⁶ anywhere on the sweep — while the forward error climbs from 1.01·10⁻¹⁵ to 4.28·10⁻⁵. At the right-hand end the two are a factor of 8.42·10¹¹ apart, and nothing about the computation that produced them differs.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u30×30, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 3 Thirty by thirty. The worst backward error is 2.40·10⁻¹⁶ and the forward error at the hard end of the sweep is 4.28·10⁻⁵.

Four times the unknowns of the first frame, and the two quantities in the badge have moved by very different amounts. Half again as many, to see which of the two is doing the moving:

Backward and forward error against the condition number, on 45 × 45 systemsA log–log plot over twelve decades of condition number, at 45 × 45, twenty seeds a point. The backward error is flat — median 1.73·10⁻¹⁶ at κ = 10 and 5.51·10⁻¹⁷ at κ = 10¹³, worst 2.86·10⁻¹⁶ anywhere on the sweep — while the forward error climbs from 1.52·10⁻¹⁵ to 5.18·10⁻⁵. At the right-hand end the two are a factor of 9.4·10¹¹ apart, and nothing about the computation that produced them differs.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u45×45, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 4 Forty-five: worst backward 2.86·10⁻¹⁶, forward 5.18·10⁻⁵.

One of those two numbers is growing with the size and the other is not, and four sizes is not quite enough to be sure which — the forward column has bounced from 5.72 to 7.41 to 4.28 to 5.18 without settling. Two more sizes:

Backward and forward error against the condition number, on 60 × 60 systemsA log–log plot over twelve decades of condition number, at 60 × 60, twenty seeds a point. The backward error is flat — median 2.34·10⁻¹⁶ at κ = 10 and 6.36·10⁻¹⁷ at κ = 10¹³, worst 3.56·10⁻¹⁶ anywhere on the sweep — while the forward error climbs from 2.03·10⁻¹⁵ to 7.59·10⁻⁵. At the right-hand end the two are a factor of 1.19·10¹² apart, and nothing about the computation that produced them differs.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u60×60, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 5 Sixty: worst backward 3.56·10⁻¹⁶, forward 7.59·10⁻⁵.
Backward and forward error against the condition number, on 80 × 80 systemsA log–log plot over twelve decades of condition number, at 80 × 80, twenty seeds a point. The backward error is flat — median 2.6·10⁻¹⁶ at κ = 10 and 5.77·10⁻¹⁷ at κ = 10¹³, worst 4.59·10⁻¹⁶ anywhere on the sweep — while the forward error climbs from 2.46·10⁻¹⁵ to 7.84·10⁻⁵. At the right-hand end the two are a factor of 1.36·10¹² apart, and nothing about the computation that produced them differs.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u80×80, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 6 And eighty by eighty, ten times the first: worst backward 4.59·10⁻¹⁶, forward 7.84·10⁻⁵.
n worst backward error ÷ √n forward error at κ = 10¹³ ratio ÷ κ
8 1.45·10⁻¹⁶ 5.13·10⁻¹⁷ 5.72·10⁻⁵ 0.238
16 1.46·10⁻¹⁶ 3.65·10⁻¹⁷ 7.41·10⁻⁵ 0.212
30 2.40·10⁻¹⁶ 4.38·10⁻¹⁷ 4.28·10⁻⁵ 0.084
45 2.86·10⁻¹⁶ 4.26·10⁻¹⁷ 5.18·10⁻⁵ 0.094
60 3.56·10⁻¹⁶ 4.60·10⁻¹⁷ 7.59·10⁻⁵ 0.119
80 4.59·10⁻¹⁶ 5.13·10⁻¹⁷ 7.84·10⁻⁵ 0.136

The backward error grows as √n and nothing else. Dividing it by √n gives 5.13, 3.65, 4.38, 4.26, 4.60 and 5.13 × 10⁻¹⁷ — constant to within 40% while n moves by a factor of ten, and about four tenths of the unit roundoff. That is the elimination accumulating rounding over its own operations, and it is the only place the size appears.

The forward error at the hard end does not depend on n at all. 5.72, 7.41, 4.28, 5.18, 7.59 and 7.84 × 10⁻⁵ across a tenfold range of size — six readings inside a factor of 1.8, with no trend. So the answer’s accuracy at κ = 10¹³ is decided by κ, and the matrix being ten times larger costs nothing in the quantity a caller cares about.

Which is the essay’s claim in the form that can be checked. “The condition number is an amplifier” is a statement that one number governs, and the way to test it is to move a different number and watch nothing happen. The backward error moves — by √n, as the arithmetic requires — and the amplification carries it to the same place regardless.

The last column is the noisiest thing on the page and worth reading with that in mind: the achieved amplification is 0.084 to 0.238 of κ, a factor of 2.8 of scatter across the six sizes, and no trend in n. It is a fraction of κ rather than κ itself — twenty seeded matrices find a fifth of the available amplification at the small sizes and a tenth at the middle ones — and the scatter is the seeds rather than the size.

κ is not a property of the arithmetic

This is the sentence worth repeating until it is automatic, because almost every misuse of the condition number comes from forgetting it.

The Hilbert matrix has κ(H₁₀) = 1.6·10¹³. That number contains no reference to floating point, to double precision, or to any algorithm. It says: there exist two right-hand sides differing by one part in 10¹³ whose exact solutions differ by a factor of order one. That is a fact about the Hilbert matrix, provable on paper, and it would be true in a universe with no computers.

What floating point adds is a guaranteed perturbation of the input, of size u, because the entries of A and b cannot be stored exactly. So a computation in double precision necessarily faces an input perturbation of about 10⁻¹⁶, and κ·u is what that becomes in the answer. For H₁₀ that is 1.6·10⁻³, and the measured forward error is 2.7·10⁻⁴ — within the bound, as the inequality requires.

The practical consequence: when κ·u exceeds the accuracy required, no algorithm will do. Not a better solver, not a more careful implementation, not a library written by cleverer people. The options are more precision, a different formulation of the problem, or accepting the answer is not determined.

Conditioning of other questions

A matrix does not have one condition number; a problem has one, and the same matrix appearing in two different questions can be easy in one and impossible in the other. This is worth spelling out because “the condition number of A” is used loosely everywhere, including on this site.

Solving Ax = b has condition number κ(A) = σ₁/σₙ, which is what has been discussed so far.

Least squares with A has a condition number that depends on the residual as well as on κ(A) — when the data lies close to the column space it behaves like κ(A), and when it does not there is a term in κ(A)² even for the honest QR route. The valley with no bottom is about the geometry underneath that.

Eigenvalues of A have nothing to do with κ(A) at all. A symmetric matrix with κ = 10¹⁵ still gives up its eigenvalues to full absolute accuracy, and a matrix with κ = 1 can have eigenvalues so sensitive that rounding moves them by a hundredth. Symmetry is worth more than precision is that case, and it is one of the sharpest surprises in the subject.

Matrix multiplication by A has condition number 1 in the norm — multiplying is always stable — which is precisely why the algorithms here are built out of multiplications by orthogonal matrices and never out of inverses.

What can be done about it

Three things, in increasing order of how much they help.

Scaling. A matrix whose rows differ wildly in magnitude often has a condition number dominated by that fact rather than by anything intrinsic. Equilibrating the rows and columns can reduce κ by many orders of magnitude and costs nothing. It is the first thing to try and the most frequently skipped.

Reformulating. The basis is part of the problem: fitting a degree-eleven polynomial in the monomial basis gives a design matrix with κ = 1.2·10⁸; the same fit to the same data in a Chebyshev basis gives κ = 2.5. Nothing about the question changed. The matrix is not handed down; it is constructed from a modelling choice, and the choice can be made differently.

Regularising. If the problem genuinely does not determine the answer, adding information does. That is what Tikhonov regularisation, ridge regression and truncated SVD all are: a decision to answer a nearby, better-conditioned question and say so. It is honest when the substitution is declared and dishonest when it is not.

What does not help is precision, except by a fixed number of digits. The order they are added in makes the same point about summation: an algorithmic change buys a rate, and a precision change buys a constant.

Forward error of a 6×6 Hilbert solve at eight precisionsA bar for each significand width from 12 to 53 bits showing the relative error in the computed solution, with the condition number times the unit roundoff marked as a prediction.κ = 1.5·10⁷ · the exact answer is (1, 2, …, 6)12 bits3.316 bits0.8620 bits4.324 bits0.09330 bits7.6·10⁻⁴36 bits6.2·10⁻⁶43 bits2·10⁻⁷53 bits4.5·10⁻¹¹dashed: κ · unit roundoffone matrix, eight arithmeticsmeasured against a known answer
Fig. 7 The constant, bought a bit at a time. The same Hilbert system solved at eight significand widths, with the error measured against the exact answer. Every 3.3 bits buys one decimal digit, and the prediction κ·u is marked. Nothing in this figure is a slope that precision can change.

Where κ comes from, structurally

The singular value decomposition makes it geometric. A = UΣVᵀ maps the unit sphere to an ellipsoid with semi-axes the singular values, so the map stretches by σ₁ in one direction and by σₙ in another. The inverse map does the reverse, and their product — the total distortion between the best- and worst-treated directions — is σ₁/σₙ, which is κ.

That is why κ ≥ 1 always, with equality exactly for orthogonal matrices scaled by a constant. An orthogonal matrix maps the sphere to itself, distorts nothing, and amplifies nothing: κ = 1.

And that is the deep reason orthogonal transformations are the backbone of every stable algorithm in this subject. It is not a preference or a convention. A reflection cannot stop being one is about the structural half of the argument — an orthogonal matrix that has been perturbed by rounding is still very nearly orthogonal — and this is the other half: an orthogonal step cannot amplify an existing error, because its condition number is one.

Compare with what forming AᵀA does. The singular values square, so κ squares, and an error that was being amplified by 10⁶ is now being amplified by 10¹². That is the road that squares the problem, and it is the clearest case on the site of a modelling decision converting a solvable problem into an unsolvable one.

The estimate that is affordable

Computing κ exactly requires the smallest singular value, which costs about as much as the solve itself and rather more code. In production nobody does it. What they do — or should — is estimate it.

The standard trick uses the factorisation already computed. Solving Az = y for a few cleverly chosen y gives a lower bound on ‖A⁻¹‖, and combined with ‖A‖, which is free, that gives a lower bound on κ. LAPACK’s gecon does exactly this and returns its reciprocal; the cost is a few triangular solves against an O(n³) factorisation, which is to say nothing.

A lower bound is the right thing to want. It cannot certify that a problem is well conditioned, but it can warn that it is not, and warning is the case that matters. An estimator that returns 10¹² has said something conclusive. One that returns 10² has said only that it did not find a bad direction, which is weaker, but the estimators are good and the false reassurance rate is low.

A worked estimate, done in the head

The arithmetic that matters in practice is a single subtraction, and it is worth having ready.

Write κ = 10ᵏ and the unit roundoff as 10⁻¹⁶ for double, 10⁻⁷ for single. Then the number of correct decimal digits to expect is about 16 − k in double and 7 − k in single.

That is it. A matrix with κ = 10⁶ leaves ten digits in double and one in single. A matrix with κ = 10¹² leaves four digits in double and nothing at all in single. A matrix with κ = 10¹⁷ leaves nothing in double.

The estimate is a bound rather than a promise, so it errs on the pessimistic side. By how much is worth measuring, because a rule that is conservative by a predictable amount can be sharpened and one that is conservative by an unpredictable amount can only be distrusted.

Forward error divided by κu, against a reference solved exactly in rationals, 16×16, twenty-four seeds at each conditioning:

κ min median max the bound is pessimistic by
10² 5.79·10⁻² 1.05·10⁻¹ 3.56·10⁻¹ 9.5×
10⁴ 1.49·10⁻² 3.90·10⁻² 7.65·10⁻² 26×
10⁶ 3.86·10⁻³ 2.78·10⁻² 6.87·10⁻² 36×
10⁸ 5.56·10⁻³ 2.52·10⁻² 8.16·10⁻² 40×
10¹⁰ 3.84·10⁻³ 1.75·10⁻² 4.57·10⁻² 57×
10¹² 3.68·10⁻³ 2.14·10⁻² 4.93·10⁻² 47×

The bound holds at every one of the 144 solves. No ratio exceeds one, which is what makes it a bound rather than an estimate, and is the property worth keeping.

And it is pessimistic by ten to fifty-seven times, not by five — between one and one and three-quarters of a digit. The slack also settles: for κ ≥ 10⁴ the median ratio sits between 0.017 and 0.039 with no trend, so it is a constant rather than something that grows with the conditioning.

A constant slack is a rule that can be sharpened. The median error is about 0.025·κu = κ·2.8·10⁻¹⁸, so the digits to expect are 17.5 − k rather than 16 − k. That is a digit and a half the conservative form gives away, and giving it away matters here more than it usually would, because the whole value of the rule is that it turns a vague worry into a number — and a number that is a digit and a half out is a different answer to the same question.

Keep both. 16 − k is what can be promised, since nothing in the sweep beat it. 17.5 − k is what will be seen. The gap between them is the width of the band a reader should expect, rather than a source of surprise when the answer comes back better than the bound.

That the estimate is the right first calculation is unchanged by any of this: it turns “is this matrix badly conditioned?” into a question with an answer in digits, and now into one with an answer and an error bar.

The single-precision column is the surprising one. Seven digits of headroom sounds ample and it is consumed by a condition number of 10⁷, which is not a large number: a design matrix for a sixth-degree polynomial fit on equispaced points passes it. The road that squares the problem is where that becomes concrete, and where the same arithmetic explains why forming AᵀA is not a small change of plan — it takes k to 2k, so ten digits become four.

What is asserted here

The claims in this essay are all measurements, and each is run on every build.

No perturbation is allowed to be amplified by more than κ — that is the definition, and if the measurement ever exceeded it, either the measurement or the κ would be wrong. Two hundred random directions must find at least a third of κ, which is the claim that the worst case is reachable. The median must exceed κ/10, which is the claim that random directions are typically close to it. And the mildest of the two hundred must still be amplified by κ/1000, which is the claim that no direction escapes.

Those four thresholds hold at every position of the slider, from κ = 10² to κ = 10⁸, because the frames are generated at build time by the same code that drew the static figure. A reader dragging the control is exploring the claim’s generality, and the build has already checked it there.

The construction of the test matrices is itself checked against two routes. Two routes to a number is the thread; here it means that a matrix built to have κ = 10⁸ is required to measure as having κ = 10⁸, by a one-sided Jacobi SVD that shares only the matrix multiplication with the construction. The tolerance for that agreement is not a round number — it scales with κ, because the assembly’s own rounding limits how precisely the smallest singular value can be planted, and it is bracketed between the measured noise and a factor-of-two miss.

Where κ appears in the rest of the collection

It is the horizontal axis of nearly every figure here, so it is worth listing what it is measuring in each.

In a small residual is not a small error it separates the flat backward-error line from the rising forward-error one, and the vertical distance between them at any point is κ.

In orthogonal is a number it drives the loss of orthogonality, at a rate that identifies the algorithm: κ for modified Gram–Schmidt, κ² for classical, and nothing at all for Householder.

In the road that squares the problem it is the quantity that gets squared, and the essay is about a modelling choice that does the squaring.

In rank is a decision it is the reciprocal of the tolerance: a matrix is numerically rank deficient exactly when κ exceeds 1/tol, and the two vocabularies describe one fact.

The estimate that gets skipped

A closing practical note, because everything above is only useful if the number is actually computed.

LAPACK returns a condition estimate on request from gecon, at a cost of a few triangular solves against a factorisation that already cost n³/3. In relative terms it is free. It is also, in most code that calls a linear solver, never asked for.

The consequence is a class of failures with a characteristic signature: results that are subtly wrong in a way that varies with the input data, discovered late, and attributed to a bug in the solver. The solver is fine. The one number that would have said so was available for the asking, and the asking did not happen.

The habit worth building is small. When a solve matters, request the estimate, print it, and know the arithmetic that turns it into digits: 16 − log₁₀κ in double, 7 − log₁₀κ in single. When it comes back at 10³ nothing further is needed. When it comes back at 10¹² the answer has four digits and the question is whether four is enough — which is a question about the application, and one that can now be answered rather than worried about.

Two quantities that are not this one

The determinant is the scalar most readers reach for before the condition number, and it answers a different question — badly. A tenth of the identity has a condition number of exactly one and a determinant of 10⁻⁶⁰.

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.

Condition numberOrthogonalityPerturbationSensitivitySingular valuesWorst-case analysis