Numerical Linear Algebra/Numerical Stability and Backward Error Analysis

Lesson 8.41,101 words

Numerical Stability and Backward Error Analysis

An algorithm is backward stable when its computed answer is the exact answer to a slightly perturbed problem. Combined with the condition number this gives the governing rule of thumb: forward error is at most condition times stability.

╌╌╌╌

Conditioning is a property of the problem; it fixes a floor on the achievable error and cannot be improved by better arithmetic. Stability is a property of the algorithm: whether the specific sequence of rounded operations stays near that floor or adds error of its own. Which algorithms stay near it is settled by a single governing rule.

Backward stability

An algorithm for evaluating is a decomposition into elementary steps, . Running it in floating point produces a perturbed map , each step carrying its rounding errors. There are two ways to be a good approximation.

In Trefethen and Bau's phrasing, a stable algorithm gives nearly the right answer to nearly the right question; a backward stable one gives exactly the right answer to nearly the right question.1 The virtue of the backward view is that it is checkable: it compares a perturbation of the input against the uncertainty already in the input, without ever needing the true answer.

Backward analysis: the computed is read as the exact image of a perturbed input. Backward error is the horizontal gap ; forward error is the vertical gap .

The rule of thumb

Backward stability plus conditioning gives the forward error at once. If with , then by the definition of the condition number,

The rule separates blame cleanly: a large forward error comes either from an ill-conditioned problem (unavoidable, blame the model) or from an unstable algorithm (avoidable, blame the code), and backward analysis distinguishes them.

Accumulated rounding error across the steps of an algorithm. A stable method holds the error near the machine-precision floor; an unstable one lets it grow, so the two diverge even on the same well-conditioned problem.

The standard model makes the elementary operations backward stable by definition, and this propagates to the BLAS kernels: inner products (Level-1), matrix–vector products (Level-2), and each column of a matrix–matrix product (Level-3) are all computed backward stably, with backward error of order in the operands.1

Three cancellation case studies

The recurring source of instability is genuine subtraction of nearly equal numbers. Three short examples show how to spot it and how to route around it.

Evaluating . Near the problem is well-conditioned, yet computing it as log(1 + x) first forms , which loses the information in a tiny to cancellation, then takes a logarithm near its root, where is ill-conditioned. Kahan's rearrangement multiplies by a factor equal to one in exact arithmetic but whose two cancellations are perfectly correlated and annihilate:

which is stable. This is the log1p function, and it illustrates a general principle: an imprecise intermediate result is harmless whenever its error is compensated later.2

ProblemNaive algorithmFailureStable fix
Root direct formulacancellation for Vieta:
, log(1+x)cancels in , root of Kahan / log1p
Variance one-pass (b)cancels large sumstwo-pass (a)

Error analysis of

Given an approximate solution of , the two errors have very different accessibility. The forward error needs the unknown true . The backward error does not, because it has a closed form in terms of the residual .

The residual is computable, so is computable, and one declares success when . Feeding it through the rule of thumb bounds the forward error:

A small residual certifies a small backward error ; the forward error is that backward error magnified by .

A factorization-based solve (with a triangular or unitary end section) is backward stable exactly when the factors do not grow: the backward error in is of order , so the solve is stable in the benign case and at risk in the malignant case .3

  • QR is unconditionally benign. Because is unitary, . Solving via QR is always backward stable.
  • Cholesky is benign. For s.p.d. , , so it too is always backward stable.
  • depends on growth. Wilkinson's theorem gives backward error of order , benign only when .

Pivoting and stability

The malignant case for is the near-zero pivot from Gaussian elimination. Take

Without pivoting, and have entries of size , so : malignant. Swapping the two rows by partial pivoting produces factors with and : benign. Pivoting converts an unstable factorization into a stable one on the same matrix.

Growth factor across pivoting choices. No pivoting can blow up (); partial pivoting caps multipliers at and keeps near for essentially all matrices met in practice.

Stability of pivoted is governed by the growth factor . The multiplier bound limits it to in the worst case, achieved by a contrived Wilkinson matrix that is itself well-conditioned yet produces exponential growth. In practice such matrices essentially never arise, and stays near , so pivoted is backward stable for all practical purposes — at half the cost of QR.

When the growth factor is a concern, one cheap correction restores full accuracy. Iterative refinement computes the residual, solves for a correction using the already-computed factors, and adds it back.

Algorithm:IterativeRefinement(A,b,L,U,p)\textsc{IterativeRefinement}(A, b, L, U, p) — one refinement sweep
  1. 1
    xx \gets solve LUx=PbLU x = P^\ast b
    reuse the stored factorization
  2. 2
    rbAxr \gets b - A x
    residual (compute in higher precision if available)
  3. 3
    ww \gets solve LUw=PrLU w = P^\ast r
    correction via the same factors
  4. 4
    xx+wx \gets x + w
  5. 5
    return xx

Skeel's theorem makes this precise: if , a single step of iterative refinement makes pivoted backward stable.3 The factorization is computed once, and each refinement adds only an solve, so accuracy is restored cheaply.

QR's unconditional benignity is the reason it, not the normal equations, is the stable way to solve least-squares problems.

Footnotes

  1. Bornemann, Numerical Linear Algebra, §13 — Stability of an Algorithm: definitions of stability and backward stability, the nearly right answer to nearly right question framing, the forward-error rule , and backward stability of the BLAS kernels. 2 3
  2. Bornemann, §14 — Three Exemplary Error Analyses: the quadratic-formula/Vieta, /Kahan, and one-pass versus two-pass sample-variance case studies of cancellation. 2 3
  3. Bornemann, §15 — Error Analysis of Linear Systems of Equations: the Rigal–Gaches residual formula for the backward error, the benign/malignant factorization criterion versus , Wilkinson's growth-factor theorem, and Skeel's one-step iterative-refinement result. 2

╌╌ END ╌╌