A matrix can be mathematically invertible yet catastrophically sensitive to perturbations in its entries or in the right-hand side of a linear system. This sensitivity, called ill-conditioning, is the root cause of accumulated floating-point error in solvers, regression, and Kalman-filter covariance updates. Measuring it before committing to a solve reveals whether the result can be trusted or whether regularisation, pivoting, or reformulation is warranted.
The condition number is the canonical scalar summary of ill-conditioning. Because it requires the norm of the inverse, it depends on a linear solver — which is why it lives in the solvers layer, on top of the math norms, rather than in math itself.
For an invertible square matrix
The condition number bounds the relative error amplification in the solution
The norm of
| Operation | Time | Space | Notes |
|---|---|---|---|
| ConditionNumber | Dominated by the |
Matrix $A = \begin{bmatrix}3 & 1 \ 1 & 2\end{bmatrix}$, 1-norm condition number:
$|A|_1 = \max(4, 3) = 4$ - Solve
$A\mathbf{x} = \mathbf{e}_0$ :$\mathbf{x}_0 = [0.4,, -0.2]^\top$ - Solve
$A\mathbf{x} = \mathbf{e}_1$ :$\mathbf{x}_1 = [-0.2,, 0.6]^\top$ - $A^{-1} = \begin{bmatrix}0.4 & -0.2 \ -0.2 & 0.6\end{bmatrix}$, so
$|A^{-1}|_1 = \max(0.6, 0.8) = 0.8$ $\kappa_1(A) = 4 \times 0.8 = 3.2$
Singular matrices — a row of all zeros makes the system unsolvable. The singularity check fires before entering Gaussian elimination, returning an empty result rather than dividing by zero.
Near-singular matrices — the condition number can be astronomically large without any row being identically zero. Partial-pivoting elimination still completes, and the returned value reflects the ill-conditioning faithfully.
Norm choice — the 1-norm condition number is a practical upper bound on the spectral condition number
The spectral condition number (
-
Solver validation: if
$\kappa(A)\cdot\epsilon_{\text{mach}} \gtrsim 1$ , the solution has no reliable digits. -
Kalman filter covariance: monitoring
$\kappa(P)$ detects numerical collapse of the covariance. - Regression: the design-matrix condition number governs least-squares sensitivity to noise.
- Control design: ill-conditioned system matrices signal near-uncontrollability or near-unobservability.
Gaussian elimination with partial pivoting (solvers::GaussianElimination) supplies the column-wise solves of math::OneNorm) supplies both factors of the product. Cholesky decomposition (solvers::CholeskyDecomposition) is the positive-definite alternative for the inverse solve.
- Golub, G. H. & Van Loan, C. F., "Matrix Computations", 4th ed., Chapter 3 (Gaussian elimination)
- Higham, N. J., "Accuracy and Stability of Numerical Algorithms", 2nd ed., Chapter 6 (condition numbers)
- Trefethen, L. N. & Bau, D., "Numerical Linear Algebra", Lecture 12 (conditioning)