Back to References


Condition Numbers


Learning Objectives

Condition Number Definition

The condition number of a square nonsingular matrix \(A\) is defined by \[ \text{cond}(A) = \kappa(A) = \|A\| \|A^{-1}\| \] which is also the condition number associated with solving the linear system \(A \boldsymbol{x} = \boldsymbol{b}\). A matrix with a large condition number is said to be ill-conditioned.

The condition number can be measured with any \(p\)-norm, so to be precise we typically specify the norm being used, i.e. \(\text{cond}_2\), \(\text{cond}_1, \text{cond}_{\infty}\).

If \(A\) is singular, we can define \(\text{cond}(A) = \infty\) by convention.

Perturbed Matrix Problem and Error Bound

Let \(\boldsymbol{x}\) be the solution of \(A \boldsymbol{x} = \boldsymbol{b}\) and \(\hat{\boldsymbol{x}}\) be the solution of the perturbed problem \(A \hat{\boldsymbol{x}} = \boldsymbol{b} + \Delta \boldsymbol{b}\). Let \(\Delta \boldsymbol{x} = \hat{\boldsymbol{x}} - \boldsymbol{x}\) be the absolute error in output. Then we have \[ A \boldsymbol{x} + A \Delta \boldsymbol{x} = \boldsymbol{b} + \Delta \boldsymbol{b}, \] so \[ A \Delta \boldsymbol{x} = \Delta \boldsymbol{b}. \] Now we want to see how the relative error in output \(\left(\frac{\|\Delta \boldsymbol{x}\|}{\|\boldsymbol{x}\|}\right)\) is related to the relative error in input \(\left(\frac{\|\Delta \boldsymbol{b}\|}{\|\boldsymbol{b}\|}\right)\):

\[\begin{align*} \frac{\|\Delta \boldsymbol{x}\| / \|\boldsymbol{x}\|}{\|\Delta \boldsymbol{b}\| / \|\boldsymbol{b}\|} &= \frac{\|\Delta \boldsymbol{x}\| \|\boldsymbol{b}\|}{\|\boldsymbol{x}\| \|\Delta \boldsymbol{b}\|}\\ &= \frac{\|A^{-1} \Delta \boldsymbol{b}\| \|A \boldsymbol{x}\|}{\|\boldsymbol{x}\| \|\Delta \boldsymbol{b}\|}\\ &\le \frac{\|A^{-1}\| \|\Delta \boldsymbol{b}\| \|A\| \|\boldsymbol{x}\|}{\|\boldsymbol{x}\| \|\Delta \boldsymbol{b}\|} & \text{because $\|A\boldsymbol{x}\| \le \|A\| \|\boldsymbol{x}\|, \forall \boldsymbol{x}$}\\ &= \|A^{-1}\| \|A\|\\ &= \text{cond}(A) \end{align*}\] Then \[\begin{align*} \frac{\|\Delta \boldsymbol{x}\|}{\|\boldsymbol{x}\|} \le \text{cond}(A)\frac{\|\Delta \boldsymbol{b}\|}{\|\boldsymbol{b}\|}. && (1) \end{align*}\] Therefore, if we know the relative error in input, then we can use the condition number of the system to obtain an upper bound for the relative error of our computed solution (output).

Residual vs Error

The residual vector \(\boldsymbol{r}\) of approximate solution \(\hat{\boldsymbol{x}}\) for the linear system \(A \boldsymbol{x} = \boldsymbol{b}\) is defined as \[ \boldsymbol{r} = \boldsymbol{b} - A \hat{\boldsymbol{x}} \] In the perturbed matrix problem described above, we have \[ \boldsymbol{r} = \boldsymbol{b} - (\boldsymbol{b} + \Delta \boldsymbol{b}) = -\Delta \boldsymbol{b} \] Therefore, equation (1) can also be written as \[ \frac{\|\Delta \boldsymbol{x}\|}{\|\boldsymbol{x}\|} \le \text{cond}(A)\frac{\|\boldsymbol{r}\|}{\|\boldsymbol{b}\|} \] If we define relative residual as \(\frac{\|\boldsymbol{r}\|}{\|\boldsymbol{b}\|}\), we can see that small relative residual implies small relative error in approximate solution only if \(A\) is well-conditioned (\(\text{cond}(A)\) is small).

Gaussian Elimination (with Partial Pivoting) is Guaranteed to Produce a Small Residual

When we use Gaussian elimination with partial pivoting to compute the solution for the linear system \(A \boldsymbol{x} = \boldsymbol{b}\) and obtain an approximate solution \(\hat{\boldsymbol{x}}\), the residual vector \(\boldsymbol{r}\) satisfies: \[ \frac{\|\boldsymbol{r}\|}{\|A\| \|\hat{\boldsymbol{x}}\|} \le \frac{\|E\|}{\|A\|} \le c \epsilon_{mach} \] where \(E\) is backward error in \(A\) (which is defined by \((A+E)\hat{\boldsymbol{x}} = \boldsymbol{b}\)), \(c\) is a coefficient related to \(A\) and \(\epsilon_{mach}\) is machine epsilon.

Typically \(c\) is small with partial pivoting, but \(c\) can be arbitrarily large without pivoting.

Therefore, Gaussian elimination with partial pivoting yields small relative residual regardless of conditioning of the system.

For more details, see Gaussian Elimination & Roundoff Error.

Accuracy Rule of Thumb and Example

Suppose we apply Gaussian elimination with partial pivoting and back substitution to the linear system \(A \boldsymbol{x} = \boldsymbol{b}\) and obtain a computed solution \(\hat{\boldsymbol{x}}\). If the entries in \(A\) and \(\boldsymbol{b}\) are accurate to \(s\) decimal digits, and \(\text{cond}(A) \approx 10^t\), then the elements of the solution vector \(\hat{\boldsymbol{x}}\) will be accurate to about \(s-t\) decimal digits.

For a proof of this rule of thumb, please see Fundamentals of Matrix Computations by David S. Watkins.

Example: How many accurate decimal digits in the solution can we expect to obtain if we solve a linear system \(A \boldsymbol{x} = \boldsymbol{b}\) where \(\text{cond}(A) = 10^{10}\) using Gaussian elimination with partial pivoting, assuming we are using IEEE double precision and the inputs are accurate to machine precision?

In IEEE double precision, \(\epsilon_{mach} \approx 2.2\times 10^{-16}\), which means the entries in \(A\) and \(\boldsymbol{b}\) are accurate to \(|\log_{10}(2.2\times 10^{-16})| \approx 16\) decimal digits. Then, using the rule of thumb, we know the entries in \(\hat{\boldsymbol{x}}\) will be accurate to about \(16-10 = 6\) decimal digits.

Review Questions

  1. What is the definition of a condition number?
  2. What is the condition number of solving \(A\mathbf{x} = \mathbf{b}\)?
  3. What is the condition number of matrix-vector multiplication?
  4. Calculate the \(p\)-norm condition number of a matrix for a given \(p\).
  5. Do you want a small condition number or a large condition number?
  6. What is the condition number of an orthogonal matrix?
  7. If you have \(p\) accurate digits in a \(A\) and \(\mathbf{b}\), how many accurate digits do you have in the solution of \(A\mathbf{x} = \mathbf{b}\) if the condition number of \(A\) is \(\kappa\)?
  8. When solving a linear system \(A\mathbf{x} = \mathbf{b}\), does a small residual guarantee an accurate result?
  9. Consider solving a linear system \(A\mathbf{x} = \mathbf{b}\). When does Gaussian elimination with partial pivoting produce a small residual?
  10. How does the condition number of a matrix \(A\) relate to the condition number of \(A^{-1}\)?

ChangeLog