Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Recap: Forward and Backward Error

We introduced forward and backward error earlier. The golden rule connects them:

relative forward errorκ×relative backward error\text{relative forward error} \lesssim \kappa \times \text{relative backward error}

The key questions for linear systems:

  1. What is the condition number κ(A)\kappa(A)?

  2. When is a system ill-conditioned?

  3. Which algorithms achieve small backward error?

Sensitivity of Linear Systems

How sensitive is the solution x\mathbf{x} to perturbations in AA and b\mathbf{b}?

For a function f(x)f(x), we perturbed the input xx. But a linear system Ax=bA\mathbf{x} = \mathbf{b} has two inputs: the matrix AA and the vector b\mathbf{b}. Both are subject to errors:

So we must understand how errors in both AA and b\mathbf{b} propagate to errors in x\mathbf{x}.

The Condition Number

The sensitivity theorem motivates the following definition:

Rule of thumb: Expect to lose log10κ(A)\log_{10}\kappa(A) digits of accuracy.

Condition NumberDigits Lost
κ10k\kappa \approx 10^k~kk digits
κ1/εmach1016\kappa \gtrsim 1/\varepsilon_{\text{mach}} \approx 10^{16}All digits

But what does it mean for a matrix to be ill-conditioned? The next section provides the key insight.

The Deep Insight: Numerically Singular Matrices

Residuals and Backward Error

For linear systems, backward error has a simple form:

The computed solution x^\hat{\mathbf{x}} exactly solves Ax^=brA\hat{\mathbf{x}} = \mathbf{b} - \mathbf{r}. The relative backward error is r/b\|\mathbf{r}\|/\|\mathbf{b}\|.

Practical Guideline: Always Check the Condition Number

Since the forward error satisfies

x^xxκ(A)εmach\frac{\|\hat{\mathbf{x}} - \mathbf{x}\|}{\|\mathbf{x}\|} \lesssim \kappa(A) \cdot \varepsilon_{\text{mach}}

we should always estimate κ(A)\kappa(A) before trusting the solution. But how?

The Challenge

Computing κ(A)=AA1\kappa(A) = \|A\| \|A^{-1}\| exactly requires A1A^{-1}, which costs O(n3)O(n^3) operations—as expensive as solving the system! We need a cheaper approach.

Hager’s Algorithm: A Clever Trick

The key insight (Hager, 1984; refined by Higham) is that we can estimate A1\|A^{-1}\| using only a few solves with the already-factored matrix.

Cost: Each iteration requires two triangular solves. Typically converges in 2–5 iterations, so total cost is O(n2)O(n^2)—much cheaper than the O(n3)O(n^3) factorization.

See the Condition Number Estimation notebook for a Python implementation.

What LAPACK Does

LAPACK’s routines (e.g., dgecon) implement this estimation automatically. When you call np.linalg.cond(A) or use SciPy’s linear solvers with condition estimation, this is what happens behind the scenes.

Stability of Algorithms: A Preview

An algorithm is backward stable if it produces a solution with backward error εmach\sim \varepsilon_{\text{mach}}. Combined with the golden rule:

forward errorκ(A)εmach\text{forward error} \lesssim \kappa(A) \cdot \varepsilon_{\text{mach}}

This is the best we can hope for—any algorithm must contend with the condition number.

Coming up: We’ll see that: