Skip to main content

7  Conditioning and Numerical Stability

A computed vector can satisfy the equations closely and still be far from the exact solution. We first relate these two errors using the condition number. We then ask whether a computed vector exactly solves a nearby problem. The size of the required change in the data is its backward error.

Conditioning concerns the sensitivity of the mathematical problem. Backward stability concerns the algorithm. Keeping the two questions separate lets us determine whether lost accuracy comes from the data or from the computation.

7.1 Residual, Forward Error, and Backward Error

Let \(\bA\) be nonsingular, let \(\bx^*\) denote the exact solution, and let \(\hat{\bx}\) be an approximation. We can evaluate \(\bb-\bA\hat{\bx}\) using the available data. We cannot evaluate \(\hat{\bx}-\bx^*\) unless we already know the solution. This distinction is why residuals are used to assess a computation.

NoteDefinition: Forward Error, Residual, and Backward Error

For a computed approximation \(\hat{\bx}\):

  1. The forward error is the vector difference \(\Delta\bx = \hat{\bx} - \bx^*\), with relative measure \(\frac{\|\hat{\bx} - \bx^*\|}{\|\bx^*\|}\).

  2. The residual is the vector defect \(\br = \bb - \bA\hat{\bx}\), with relative measure \(\frac{\|\br\|}{\|\bA\|\|\hat{\bx}\| + \|\bb\|}\).

  3. The backward error is the smallest perturbation \((\delta\bA, \delta\bb)\) such that \(\hat{\bx}\) is the exact solution to the perturbed system \((\bA + \delta\bA)\hat{\bx} = \bb + \delta\bb\).

A backward error is a scalar size assigned to allowable changes in the data, rather than the pair of perturbations itself. We must specify which data may change and how their changes are measured. The theorem on normwise backward error below uses one relative bound for both \(\delta\bA\) and \(\delta\bb\). Relative forward error requires \(\bx^*\neq\bzero\). If a denominator in a residual test vanishes, use an absolute error test instead.

NoteTheorem: The Fundamental Residual-Error Bound

Let \(\bA \in \fR^{n \times n}\) be nonsingular, let \(\bb \neq \bzero\), and let \(\bx^*\) satisfy \(\bA\bx^* = \bb\). For any vector \(\hat{\bx}\) with residual \(\br = \bb - \bA\hat{\bx}\), the relative forward error satisfies \[ \begin{align} \frac{1}{\kappa(\bA)}\frac{\|\br\|}{\|\bb\|} \leq \frac{\|\hat{\bx} - \bx^*\|}{\|\bx^*\|} \leq \kappa(\bA) \frac{\|\br\|}{\|\bb\|}, \end{align} \] where \(\kappa(\bA) = \|\bA\|\|\bA^{-1}\|\) is the condition number of \(\bA\).

Let \(\be=\hat{\bx}-\bx^*\). Subtract the exact and approximate matrix products: \[ \begin{align} \br=\bb-\bA\hat{\bx} =\bA\bx^*-\bA\hat{\bx}=-\bA\be. \end{align} \] Thus \(\be=-\bA^{-1}\br\). The sign has no effect on a norm.

For the upper error bound, consistency applied to this last identity gives \(\|\be\|\leq\|\bA^{-1}\|\|\br\|\). We need to normalize by the unknown exact solution norm. Since \(\bb=\bA\bx^*\), \[ \begin{align} \|\bb\|\leq\|\bA\|\|\bx^*\|, \qquad \frac1{\|\bx^*\|}\leq\frac{\|\bA\|}{\|\bb\|}. \end{align} \] The divisions are legitimate because \(\bb\neq\bzero\) and invertibility makes \(\bx^*\neq\bzero\). Multiply the two estimates: \[ \begin{align} \frac{\|\be\|}{\|\bx^*\|} \leq\|\bA^{-1}\|\|\br\|\frac{\|\bA\|}{\|\bb\|} =\kappa(\bA)\frac{\|\br\|}{\|\bb\|}. \end{align} \] For the lower bound, use \(\br=-\bA\be\) to obtain \(\|\be\|\geq\|\br\|/\|\bA\|\). Also \(\bx^*=\bA^{-1}\bb\) gives \(\|\bx^*\|\leq\|\bA^{-1}\|\|\bb\|\). A lower bound for the numerator and an upper bound for its positive denominator give \[ \begin{align} \frac{\|\be\|}{\|\bx^*\|} \geq\frac{\|\br\|/\|\bA\|}{\|\bA^{-1}\|\|\bb\|} =\frac1{\kappa(\bA)}\frac{\|\br\|}{\|\bb\|}. \end{align} \] Combining the upper and lower inequalities proves the statement. They are separate estimates, rather than one being obtained by reversing the other.

NoteExample

(A small residual does not guarantee a small error) Consider the diagonal system \[ \begin{align} \bA = \begin{pmatrix} 1 & 0 \\ 0 & 10^{-8} \end{pmatrix}, \qquad \bb = \begin{pmatrix} 1 \\ 10^{-8} \end{pmatrix}. \end{align} \] The exact solution is \(\bx^* = (1, 1)^T\). Suppose an algorithm produces the approximation \(\hat{\bx} = (1, 0)^T\). The residual evaluates to \[ \begin{align} \br = \bb - \bA\hat{\bx} = \begin{pmatrix} 1 \\ 10^{-8} \end{pmatrix} - \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 10^{-8} \end{pmatrix}, \end{align} \] which satisfies \(\|\br\|_2 / \|\bb\|_2 \approx 10^{-8}\). However, the forward error is \(\hat{\bx} - \bx^* = (0, -1)^T\), yielding a relative forward error of \(\|\hat{\bx} - \bx^*\|_2 / \|\bx^*\|_2 = 1/\sqrt{2} \approx 0.707\) (a seventy percent error). The matrix has condition number \(\kappa_2(\bA) = 10^8\), which amplifies the small residual into an \(O(1)\) error in the solution.

7.2 Sensitivity to Perturbations in the Data

the referenced result measures the error of a given approximation through its residual. A related question asks how far the exact solution moves when the data \(\bA\) and \(\bb\) are perturbed. The answer is again governed by the condition number \(\kappa(\bA)=\|\bA\|\|\bA^{-1}\|\) of the referenced result. Perturbing \(\bA\) requires one preliminary fact, namely that a sufficiently small perturbation of a nonsingular matrix remains nonsingular.

NoteLemma: Perturbation of the Identity

Let \(\|\cdot\|\) be an induced matrix norm and let \(\bM\) be a square matrix with \(\|\bM\|<1\). Then \(\bI+\bM\) is nonsingular and \[ \begin{align} \|(\bI+\bM)^{-1}\|\leq\frac{1}{1-\|\bM\|}. \end{align} \]

Put \(q=\|\bM\|\), so \(0\leq q<1\).

  1. If \((\bI+\bM)\bz=\bzero\), then \(\bz=-\bM\bz\). Taking norms gives \(\|\bz\|\leq q\|\bz\|\), or \((1-q)\|\bz\|\leq0\). Since \(1-q>0\), we obtain \(\bz=\bzero\). A square matrix with trivial null space is nonsingular.

  2. Given any \(\by\), let \(\bz=(\bI+\bM)^{-1}\by\). Rearrange \(\by=\bz+\bM\bz\) to obtain \(\bz=\by-\bM\bz\). Therefore \[ \begin{align} \|\bz\|\leq\|\by\|+q\|\bz\|, \qquad (1-q)\|\bz\|\leq\|\by\|. \end{align} \] For nonzero \(\by\), division gives \[ \begin{align} \frac{\|(\bI+\bM)^{-1}\by\|}{\|\by\|}\leq\frac1{1-q}. \end{align} \] Taking the supremum over inputs proves the inverse-norm bound.

NoteTheorem: Perturbation Bound for Linear Systems

Let \(\bA\) be nonsingular, let \(\bb\neq\bzero\), and let \(\bA\bx=\bb\). Suppose the perturbations \(\delta\bA\) and \(\delta\bb\) satisfy \(\kappa(\bA)\|\delta\bA\|/\|\bA\|<1\). Then \(\bA+\delta\bA\) is nonsingular, and the solution of \((\bA+\delta\bA)(\bx+\delta\bx)=\bb+\delta\bb\) satisfies \[ \begin{align} \frac{\|\delta\bx\|}{\|\bx\|} \leq \frac{\kappa(\bA)}{1-\kappa(\bA)\|\delta\bA\|/\|\bA\|} \left(\frac{\|\delta\bA\|}{\|\bA\|}+\frac{\|\delta\bb\|}{\|\bb\|}\right). \end{align} \]

Write \(q=\|\bA^{-1}\|\|\delta\bA\|\). The hypothesis is \(q<1\), because \(q=\kappa(\bA)\|\delta\bA\|/\|\bA\|\).

Factor the perturbed matrix: \[ \begin{align} \bA+\delta\bA=\bA(\bI+\bA^{-1}\delta\bA). \end{align} \] Consistency gives \(\|\bA^{-1}\delta\bA\|\leq q<1\). The inverse lemma makes the second factor nonsingular and bounds its inverse by \(1/(1-q)\). The first factor is nonsingular by assumption, so the product is nonsingular as well.

Expand the perturbed equation before subtracting \(\bA\bx=\bb\): \[ \begin{align} \bA\bx+\bA\delta\bx+\delta\bA\bx+\delta\bA\delta\bx &=\bb+\delta\bb,\\ (\bA+\delta\bA)\delta\bx&=\delta\bb-\delta\bA\bx. \end{align} \] Use the factorization of the inverse to solve this equation: \[ \begin{align} \delta\bx=(\bI+\bA^{-1}\delta\bA)^{-1} \bA^{-1}(\delta\bb-\delta\bA\bx). \end{align} \] Taking norms, applying consistency, and then the triangle inequality yields \[ \begin{align} \|\delta\bx\| \leq\frac{\|\bA^{-1}\|}{1-q} (\|\delta\bb\|+\|\delta\bA\|\|\bx\|). \end{align} \] Since \(\bb\neq\bzero\), its exact solution is nonzero. Divide by \(\|\bx\|\). From \(\|\bb\|=\|\bA\bx\|\leq\|\bA\|\|\bx\|\) we obtain \[ \begin{align} \frac{\|\delta\bb\|}{\|\bx\|} \leq\|\bA\|\frac{\|\delta\bb\|}{\|\bb\|}. \end{align} \] Substitute this estimate, factor out \(\|\bA^{-1}\|\|\bA\|=\kappa(\bA)\), and replace \(q\) by its relative expression. This produces precisely the bound in the statement. Every denominator used is positive by the hypotheses.

To first order, relative perturbations of size \(\varepsilon\) in \(\bA\) and in \(\bb\) change the solution by a relative amount of at most about \(2\kappa(\bA)\varepsilon\). The hypothesis \(\kappa(\bA)\|\delta\bA\|/\|\bA\|<1\) cannot be dropped, because a larger perturbation may make \(\bA+\delta\bA\) singular. In the Euclidean norm, the smallest perturbation that does so has \(\|\delta\bA\|_2=\sigma_{\min}(\bA)=\|\bA\|_2/\kappa_2(\bA)\) by the referenced result. The reciprocal \(1/\kappa_2(\bA)\) is therefore the relative distance from \(\bA\) to the nearest singular matrix.

7.3 Backward Error and Backward Stability

The perturbation bound describes the problem and makes no reference to an algorithm. To apply it to a computed solution \(\hat{\bx}\), we need perturbations \(\delta\bA\) and \(\delta\bb\) for which \(\hat{\bx}\) is the exact solution. The smallest such perturbations can be computed from the residual.

NoteTheorem: Rigal–Gaches Theorem on Normwise Backward Error

In the Euclidean vector norm and its induced matrix norm, let \(\hat{\bx}\neq\bzero\) have residual \(\br = \bb - \bA\hat{\bx}\). The smallest relative perturbation size satisfying \((\bA + \delta\bA)\hat{\bx} = \bb + \delta\bb\) with \(\|\delta\bA\|_2 \leq \eta \|\bA\|_2\) and \(\|\delta\bb\|_2 \leq \eta \|\bb\|_2\) is \[ \begin{align} \eta(\hat{\bx}) = \frac{\|\br\|_2}{\|\bA\|_2\|\hat{\bx}\|_2 + \|\bb\|_2}. \end{align} \] An algorithm is backward stable if, for every nonsingular \(\bA\) and every \(\bb\), the computed solution satisfies \(\eta(\hat{\bx})\leq c_n u\), where \(u\) is the unit roundoff and \(c_n\) grows at most polynomially with \(n\).

Rigal and Gaches proved this formula for the normwise backward error (Rigal and Gaches 1967). The proof below constructs the minimizing perturbations explicitly.

Let \(d=\|\bA\|_2\|\hat{\bx}\|_2+\|\bb\|_2>0\). We first bound any admissible perturbations, then construct ones attaining the bound.

Rearrange the perturbed equation to get \[ \begin{align} \br=\bb-\bA\hat{\bx}=\delta\bA\hat{\bx}-\delta\bb. \end{align} \] If both relative perturbations are bounded by \(\eta\), then \[ \begin{align} \|\br\|_2 &\leq\|\delta\bA\|_2\|\hat{\bx}\|_2+\|\delta\bb\|_2\\ &\leq\eta\|\bA\|_2\|\hat{\bx}\|_2+\eta\|\bb\|_2=\eta d. \end{align} \] Thus every admissible value satisfies \(\eta\geq\|\br\|_2/d\).

To attain this value, define the nonnegative weights \[ \begin{align} a=\frac{\|\bA\|_2\|\hat{\bx}\|_2}{d}, \qquad b=\frac{\|\bb\|_2}{d},\qquad a+b=1, \end{align} \] and choose \[ \begin{align} \delta\bA=a\frac{\br\hat{\bx}^T}{\|\hat{\bx}\|_2^2}, \qquad \delta\bb=-b\br. \end{align} \] The assumption \(\hat{\bx}\neq\bzero\) makes this matrix well defined. Multiplying it by \(\hat{\bx}\) cancels the squared norm in its denominator, so \(\delta\bA\hat{\bx}=a\br\). Consequently \[ \begin{align} \delta\bA\hat{\bx}-\delta\bb=(a+b)\br=\br. \end{align} \] This is exactly the rearranged perturbed equation. Thus the constructed perturbations really make \(\hat{\bx}\) an exact solution.

For a rank-one matrix \(\bu\bv^T\), consistency and Cauchy–Schwarz give norm at most \(\|\bu\|_2\|\bv\|_2\), and a unit input along \(\bv\) attains it when both vectors are nonzero. Therefore \[ \begin{align} \|\delta\bA\|_2 &=a\frac{\|\br\|_2}{\|\hat{\bx}\|_2} =\frac{\|\br\|_2}{d}\|\bA\|_2,\\ \|\delta\bb\|_2 &=b\|\br\|_2=\frac{\|\br\|_2}{d}\|\bb\|_2. \end{align} \] The same equalities hold when the residual is zero, by taking zero perturbations. Both perturbation bounds are attained at the lower bound for \(\eta\), proving minimality. This is the normwise backward-error formula of Rigal and Gaches (1967).

NoteCorollary: Forward Error of a Backward Stable Solution

In the Euclidean norm, let \(\hat{\bx}\) have backward error \(\eta=\eta(\hat{\bx})\) as in the referenced result, and suppose \(\kappa_2(\bA)\eta<1\). Then \[ \begin{align} \frac{\|\hat{\bx}-\bx\|_2}{\|\bx\|_2}\leq\frac{2\kappa_2(\bA)\eta}{1-\kappa_2(\bA)\eta}. \end{align} \]

The backward-error theorem provides perturbations satisfying \[ \begin{align} (\bA+\delta\bA)\hat{\bx}&=\bb+\delta\bb,\\ \frac{\|\delta\bA\|_2}{\|\bA\|_2}&\leq\eta, &\frac{\|\delta\bb\|_2}{\|\bb\|_2}&\leq\eta. \end{align} \] Set \(\delta\bx=\hat{\bx}-\bx\). Then \(\bx+\delta\bx=\hat{\bx}\), so these are precisely the perturbed data and solution in the perturbation theorem.

Let \(\kappa=\kappa_2(\bA)\). Its smallness hypothesis holds because \[ \begin{align} \kappa\frac{\|\delta\bA\|_2}{\|\bA\|_2}\leq\kappa\eta<1. \end{align} \] Apply that theorem and then replace each perturbation ratio by its upper bound: \[ \begin{align} \frac{\|\hat{\bx}-\bx\|_2}{\|\bx\|_2} &\leq\frac{\kappa}{1-\kappa\|\delta\bA\|_2/\|\bA\|_2} \left(\frac{\|\delta\bA\|_2}{\|\bA\|_2} +\frac{\|\delta\bb\|_2}{\|\bb\|_2}\right)\\ &\leq\frac{\kappa}{1-\kappa\eta}(\eta+\eta) =\frac{2\kappa\eta}{1-\kappa\eta}. \end{align} \] The second step uses a lower bound for the positive denominator and upper bounds for the nonnegative numerator terms. This explains the direction of the inequality.

WarningExercise
  1. Let \(\bA = \begin{pmatrix} 1 & 1 \\ 1 & 1 + 10^{-10} \end{pmatrix}\). Compute \(\bA^{-1}\) explicitly and evaluate \(\kappa_\infty(\bA)\).

  2. Suppose \(\bA\bx = \bb\) is solved using a backward stable algorithm in arithmetic with unit roundoff \(u \approx 10^{-16}\). If \(\kappa_2(\bA) = 10^{11}\), estimate the number of correct decimal digits in the computed solution.

  3. Prove that for any two nonsingular matrices \(\bA\) and \(\bB\), \(\kappa(\bA\bB) \leq \kappa(\bA)\kappa(\bB)\).

  4. Show that for an orthogonal matrix \(\bQ\), \(\kappa_2(\bQ\bA) = \kappa_2(\bA)\) for any square matrix \(\bA\).

For a backward stable algorithm, \(\eta\) is a modest multiple of \(u\), and the referenced result bounds the relative forward error by about \(2\kappa_2(\bA)u\). In double precision, with \(u\approx1.1\times10^{-16}\), a system with \(\kappa_2(\bA)=10^{10}\) can therefore be solved to about five correct digits by a stable method, and this is a worst-case accuracy estimate, not a limit attained for every right-hand side. A large forward error with a small backward error indicates an ill-conditioned problem, not an unstable algorithm.