Assume \(\mathbf{A} \in \mathbb{R}^{n \times n}\) is nonsingular and consider the system of linear equation \[
\mathbf{A} \mathbf{x} = \mathbf{b}.
\] The solution is \[
\mathbf{x} = \mathbf{A}^{-1} \mathbf{b}.
\] We want to know how the solution changes with a small perturbation of the input \(\mathbf{b}\) (or \(\mathbf{A}\)).
\(\kappa(\mathbf{A}) = \|\mathbf{A}\| \|\mathbf{A}^{-1}\|\) is called the condition number for linear equation. It depends on the matrix norm being used.
\(\kappa_p\) means condition number defined from matrix-\(p\) norm.
Large condition number means “bad”.
Some facts: \[
\begin{eqnarray*}
\kappa(\mathbf{A}) &=& \kappa(\mathbf{A}^{-1}) \\
\kappa(c\mathbf{A}) &=& \kappa(\mathbf{A}) \\
\kappa(\mathbf{A}) &\ge& 1 \\
%\kappa_1(\mathbf{A}) &=& \kappa_\infty (\mathbf{A}^T) \\
\kappa_2 (\mathbf{A}) &=& \kappa_2 (\mathbf{A}^T) = \frac{\sigma_1(\mathbf{A})}{\sigma_n(\mathbf{A})} \\
\kappa_2(\mathbf{A}^T \mathbf{A}) &=& \frac{\lambda_1(\mathbf{A}^T \mathbf{A})}{\lambda_n(\mathbf{A}^T \mathbf{A})} = \kappa_2^2(\mathbf{A}) \ge \kappa_2(\mathbf{A}).
\end{eqnarray*}
\] The last fact says that the condition number of \(\mathbf{A}^T \mathbf{A}\) can be much larger than that of \(\mathbf{A}\).
The smallest singular value \(\sigma_n\) indicates the distance to the trouble.
Condition number for the least squares problem is more complicated. Roughly speaking,
the method based on normal equation (Cholesky, sweep) has a condition depending on \([\kappa_2(\mathbf{X})]^2\)
QR for a small residuals least squares problem has a condition depending on \(\kappa_2(\mathbf{X})\)
Consider the simple case \[
\begin{eqnarray*}
\mathbf{X} = \begin{pmatrix}
1 & 1 \\
10^{-3} & 0 \\
0 & 10^{-3}
\end{pmatrix}.
\end{eqnarray*}
\] Forming normal equation yields a singular Gramian matrix \[
\begin{eqnarray*}
\mathbf{X}^T \mathbf{X} = \begin{pmatrix}
1 & 1 \\
1 & 1
\end{pmatrix}
\end{eqnarray*}
\] if executed with a precision of 6 decimal digits.
1 Implementation
Julia function cond computes \(\kappa_p\) for \(p=1\), 2 (default), or \(\infty\).
Julia function condskeel computes the Skeel condition number.
2 Longley example
The Longley (1967) macroeconomic data set is a famous test example for numerical software in early days.