🎯Computer Arithmetic and Error
Conditioning and Stability
Condition numbers, forward and backward error, stable and unstable algorithms, and chaos
MIT, 1961
Edward Lorenz, a meteorologist at MIT, is running a toy model of the atmosphere on a Royal McBee LGP-30, a computer the size of a desk. He wants to look at one simulation again, so he restarts it from the middle, typing in the numbers from an earlier printout. Then he goes for coffee.
When he returns, the new run has drifted away from the old one, and after about two simulated months the two weather patterns share nothing at all.
The machine stored numbers to six digits. The printout showed three. He had typed 0.506 where the machine had held 0.506127 — a difference of about one part in four thousand.
No bug. No rounding problem in the usual sense. The equations themselves amplified a difference in the fourth decimal into a completely different future. In 1972 he gave a talk whose title, suggested by a colleague, became the most famous phrase in the subject: Does the flap of a butterfly's wings in Brazil set off a tornado in Texas?
Every computed answer is wrong for two separable reasons. The data fed in is not exact — measured, rounded, or truncated. And the algorithm adds its own errors. This lesson separates the two, because they have different cures: a bad algorithm can be replaced; a sensitive problem cannot.
💡The condition number of a problem
The relative condition number measures how much a problem amplifies relative changes in its input:
For evaluating a differentiable function at , this is .
Rule of thumb: with you lose about significant digits, no matter how the answer is computed. In double precision a problem with has no reliable digits at all.
Derivation
Where comes from
Perturb the input by a small relative amount , so becomes . By the first-order Taylor expansion (lesson 1-3) the output changes by
The relative change in the output is that divided by . Divide it by the relative change in the input, :
The cancels: to first order the amplification is the same for every small perturbation, and it depends only on and — the problem, not any algorithm. The examples below are this formula worked out. For , and . For , . For , , which blows up as .
📐Some condition numbers
- : everywhere — square roots halve relative error. Beautifully conditioned.
- : . At , a relative error of in becomes in .
- near : , which is at . This is cancellation seen as a property of the problem, not of the algorithm.
- near : at , .
- Wilkinson's polynomial : change the coefficient of (which is ) by — one part in two billion — and ten of the twenty roots become complex, some with imaginary parts near 2.8. Root-finding from polynomial coefficients can be catastrophically ill-conditioned.
Derivation
How far a root moves when a coefficient changes
Let and lower the coefficient of by : the new polynomial is . A root moves to , where
Differentiate with respect to and set (implicit differentiation):
At the root , every factor of except the vanishing one survives: . So
A change of therefore moves that root by about 5 to first order — far more than the spacing of 1 between neighbouring roots, so they collide and leave the real axis as complex pairs. One coefficient changed in its tenth significant digit; several roots changed in their first.
Forward and backward error. Suppose an algorithm returns for . The forward error is what we care about but usually cannot measure. The backward error asks a different question: for what nearby input is the exact answer, ? The smallest such is the backward error.
An algorithm is backward stable if it always produces the exact answer to a slightly perturbed problem — perturbed by a few units of roundoff. Most good algorithms in this course (Gaussian elimination with pivoting, QR, the FFT, Householder least squares) are backward stable.
The fundamental rule of numerical analysis. A backward stable algorithm (backward error ≈ u) applied to a problem with condition κ gives a forward error of about κu. If that is too large, no algorithm can help — reformulate the problem.
Derivation
Why forward error ≲ κ × backward error
A backward stable algorithm returns for some input , where the backward error is a few units of . The forward error is how far is from the true . Using the derivation of above with :
So the relative forward error is about times the relative backward error. Two numbers decide the accuracy of any computed result, and they come from different places: from the algorithm, from the problem.
Chaos: When the present determines the future but the approximate present does not approximately determine the future.
Unstable algorithms. A problem can be perfectly well conditioned while the algorithm used for it is unstable. The integrals all lie between 0 and , and integration by parts gives the recurrence with .
Run it forward and the rounding error in is multiplied by at every step — by after 25 steps. The computed is , which is impossible for a positive integrand. Run the same recurrence backward, , starting from a crude guess far above the target, and the error is divided by at every step: the answers are correct to full precision. Same mathematics, opposite stability.
Derivation
The recurrence, and why its error grows like
The recurrence. Integrate by parts, differentiating and integrating :
The bracket is . The start is . The bounds come from on : .
The error. The computer stores , with , and then computes exactly as the true values satisfy . Subtract the two:
Run backwards, gives : each step divides the error by . Thirty backward steps from a guess that is wrong by shrink its error by about .
🕰Chaos is unbounded conditioning
For the Lorenz system the separation between two nearby trajectories grows roughly like — 0.9 is its largest Lyapunov exponent. Each extra decimal digit in the initial condition buys only more time units of agreement. Weather forecasts are limited to about two weeks for this reason, however large the computer. The condition number of 'predict the weather in a month' is effectively infinite.
💡Where you will use this
GNSS Navigation: the dilution of precision (DOP) is a condition number — poor satellite geometry amplifies range errors into position errors. Structures and Geotechnical Engineering: nearly singular stiffness matrices are ill-conditioned problems, and a stable solver cannot rescue them. Attitude Control: some orientation parametrisations are singular at certain angles (gimbal lock) — ill-conditioning built into the representation. Orbital Mechanics: long-term propagation of close encounters is chaotic, so its predictions come with growing uncertainty, not a single answer.
📚Further reading
- Lloyd N. Trefethen and David Bau, Numerical Linear Algebra (SIAM, 1997), Lectures 12–15: conditioning, floating-point arithmetic and stability, in thirty clear pages.
- Nicholas Higham, Accuracy and Stability of Numerical Algorithms (2nd ed., SIAM, 2002), chapter 1, 'Principles of Finite Precision Computation' — forward and backward error, with the recurrence examples of this lesson.
- James H. Wilkinson, 'The perfidious polynomial', in Studies in Numerical Analysis (MAA, 1984) — Wilkinson's own account of the polynomial that bears his name.
↓But there is a problem
That completes the vocabulary of error: representation, rounding, cancellation, truncation, conditioning and stability. Every result in the rest of this course will be judged with these words.
Now we start computing things engineers actually need.
The first is deceptively simple: find such that . A pipe-flow engineer needs the friction factor in an equation that cannot be rearranged. A propulsion engineer needs the Mach number that matches a nozzle area. Rearranging fails, formulas do not exist — and in 1944 one engineer turned such an equation into a chart people read by eye for the next half century.