Conditioning and Floating-Point Arithmetic
A problem's condition number measures how much its answer moves when its data is perturbed, independent of any algorithm. Subtraction is ill-conditioned under cancellation, and for a linear system the amplifier is the matrix condition number κ(A).
╌╌╌╌
Two questions about a computation are easy to confuse. One is whether the problem is sensitive: whether its answer changes sharply when its data is perturbed. The other is whether an algorithm is good: whether it computes the answer accurately. They are separate, and keeping them apart is the discipline of error analysis. Conditioning is the first question, a property of the problem alone, and it bites because of the perturbations that floating-point arithmetic supplies at every step.
Measuring error
Before sensitivity can be quantified, error itself needs a measure. For a computed approximating :
- Absolute error — the raw size of the deviation.
- Relative error — the deviation as a fraction of the quantity, and so a count of correct significant digits.
- Componentwise relative error — relative error demanded of every entry at once, which preserves the zero/nonzero (sparsity) pattern of the data.
Which one applies is a modeling choice: relative error for physical quantities and for rounding, absolute error for numbers on a fixed scale such as probabilities or counts.1 Relative error is the default below unless noted.
Conditioning of a problem
Model a computation as evaluating a map , from data to result. Data is never exact — it comes from measurement, or from rounding it into the machine — so instead of one gets for some perturbed input .
Ill-conditioning is a fact about the mathematical model. It has nothing to do with
computers or algorithms: a sensitive problem is sensitive even under exact
arithmetic, and the right response is sometimes to question why the quantity is
being computed at all.2 For definiteness, take as
ill-conditioned
in what follows.
The geometric archetype is intersecting two lines. Each line is known only to within its drawn width. When the lines cross squarely, the intersection is pinned down about as tightly as the lines themselves. When they meet at a shallow angle — a glancing intersection — a sliver of uncertainty in the lines spreads the crossing point across a long interval. Same problem, opposite conditioning, set by the crossing angle alone.
For a differentiable scalar map , linearizing turns the definition into a closed formula. With respect to componentwise relative error in and relative error in ,
Applying it to the elementary operations settles which arithmetic is safe.
Multiplication, division, and square root have small, constant condition numbers, and addition of like-signed numbers is condition . The single dangerous operation is subtraction of nearly equal numbers: when , the denominator collapses and explodes. This is cancellation.
For example, subtract two numbers agreeing to eight digits but each uncertain in the ninth:
The uncertain digit, buried in the ninth place of the inputs, has surfaced to the third significant place of the result: six significant digits were lost, and here . The general statement is worth memorizing:
The condition number of a linear system
For the central problem , the amplifier of relative error is the condition number of the matrix. Perturb the right-hand side to ; the solution moves by , and
Perturbing itself gives the same bound. The amplifying factor gets a name.
In the Euclidean norm this factor is the ratio of the largest to the smallest singular value, . Geometrically, maps the unit sphere to an ellipsoid whose semi-axes are the singular values; is that ellipsoid's eccentricity. A well-conditioned matrix maps the sphere to a nearly round ball, so no direction of the answer is much more sensitive than another; an ill-conditioned one maps it to a long thin sliver, and directions near the short axis are badly amplified.
Kahan's theorem sharpens the meaning of : its reciprocal is the relative distance from to the nearest singular matrix.
So a large condition number is literal proximity to non-invertibility. If is only known to relative accuracy and , then 's uncertainty ball reaches a singular matrix, and is effectively indistinguishable from one; such a matrix is called -singular. When is the machine precision, it is numerically singular.
Conditioning worsens sharply with ; in double precision, subtracting the digits lost from the roughly sixteen available leaves only what the last column records.
| digits lost | correct digits (double) | ||
|---|---|---|---|
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 |
By , solving in double precision returns only about nine correct digits, before any algorithmic error enters.
Machine numbers
The perturbations that conditioning amplifies are supplied, unavoidably, by finite-precision arithmetic. A -digit floating-point number in base is
normalized so the leading digit is nonzero. The set of all such numbers, plus zero, is the machine numbers . Rounding sends a real to the nearest machine number; it is monotone and idempotent. Its error is bounded relative to the number, not absolutely.
The spacing between machine numbers grows with their magnitude: they are dense near zero and sparse for large values, so the relative gap stays fixed at across the whole range. Between consecutive powers of the numbers are evenly spaced; at each power the spacing jumps by a factor of .
The IEEE 754 standard fixes two binary formats used by essentially all hardware. Every arithmetic operation and the square root return the correctly rounded exact result, which gives the standard model of machine arithmetic.
| Single precision | Double precision | |
|---|---|---|
| Storage | 32 bits | 64 bits |
| Mantissa length | bits | bits |
| Precision | ||
| Decimal digits | ||
| Overflow threshold |
The standard also defines (from ) and (from or ) so exceptions propagate predictably rather than halting. One warning: machine addition and multiplication are not associative or distributive, so parenthesization is a numerical decision, not a cosmetic one.3
The unavoidable error
Rounding strikes before any computation. Merely reading data into the machine replaces with , at componentwise relative error . Even with subsequent arithmetic done exactly, the answer to the perturbed input already differs from the true answer by the amount conditioning dictates:
This is a floor. No algorithm, however clever, can beat it, because the error is baked in at data entry. The best one can ask of an algorithm is that it not add appreciably to this unavoidable error — and that demand defines stability. For the floor is : in double precision, a matrix with yields a solution good to only about six digits, no matter how the solve is organized. A stable algorithm such as pivoted reaches this floor, leaving the conditioning of the matrix as the whole of the error and nothing more.
Footnotes
- Bornemann, Numerical Linear Algebra, §10 — Error Measures: absolute, relative, and componentwise relative error, and the modeling choice between them. ↩
- Bornemann, §11 — Conditioning of a Problem: the condition-number definition, the linearized formula , the elementary-operation table with cancellation, the linear-system condition number , and Kahan's distance-to-singularity theorem. ↩ ↩2 ↩3
- Bornemann, §12 — Machine Numbers: floating-point representation, , IEEE 754 single/double formats, the standard model , and input-rounding error. ↩
╌╌ END ╌╌