Understanding the matrix condition number calculator — concept and principle
This calculator finds the condition number of a square matrix in three norms: κ₂ from the singular values, and κ₁ and κ∞ from column and row sums. It also estimates how many digits of accuracy can be lost when solving Ax = b. Use it in numerical linear algebra, data fitting and engineering models to judge whether a system is trustworthy.
How it is calculated
κ(A) = ‖A‖ × ‖A⁻¹‖
2-norm: κ₂ = σ_max ÷ σ_min (largest ÷ smallest singular value)
1-norm: ‖A‖₁ = largest absolute column sum
∞-norm: ‖A‖∞ = largest absolute row sum
Digits that can be lost ≈ log₁₀ κ₂
- κ is at least 1, equals 1 for orthogonal matrices, and is infinite for a singular matrix.
- Singular values are found with a one-sided Jacobi SVD.
The principle
Solving Ax = b amplifies errors. If b or A carries a small relative error, the relative error in x can be up to about κ times larger. Geometrically, A stretches space by different amounts in different directions; σ_max is the largest stretch and σ_min the smallest. When σ_min is tiny, A nearly flattens some direction, and undoing that (computing A⁻¹) blows small errors up. The rule of thumb: with κ ≈ 10ᵏ, expect to lose about k significant digits.
Worked example
Default input: the 3 × 3 Hilbert matrix A = [1 1/2 1/3; 1/2 1/3 1/4; 1/3 1/4 1/5].
- Singular values: largest σ_max = 1.40832, smallest σ_min = 0.00268734.
- κ₂ = 1.40832 ÷ 0.00268734 = 524.057.
- ‖A‖₁ = 1 + 1/2 + 1/3 = 11/6, and A⁻¹ = [9 −36 30; −36 192 −180; 30 −180 180] has ‖A⁻¹‖₁ = 408, so κ₁ = 11/6 × 408 = 748.
- A is symmetric, so row and column sums agree: κ∞ = 748.
- Digits that can be lost ≈ log₁₀ 524 = 2.7.
How to read the result
κ near 1 is excellent; κ in the hundreds, as here, means about three digits may be lost; κ above about 10¹⁰ with ordinary double-precision arithmetic (about 16 digits) leaves few reliable digits. Hilbert matrices get worse very quickly with size and are a classic test case. A large κ does not mean a solution is wrong, only that it is sensitive to errors in the data.
Common mistakes
- Judging conditioning by the determinant; a small determinant does not by itself mean ill-conditioning.
- Comparing condition numbers in different norms as if they were equal.
- Rounding entries before entering them, which changes an ill-conditioned matrix a lot.
- Ignoring κ when interpreting regression coefficients.
Frequently asked questions
What is a good condition number?
Close to 1. Each factor of 10 costs roughly one significant digit of accuracy.
Why is the Hilbert matrix ill-conditioned?
Its columns are nearly parallel, so the smallest singular value is tiny.
Is the condition number the same in every norm?
No, but the norms give values of the same order of magnitude for small matrices.
Sources: J. Demmel, UC Berkeley Math 221 lecture notes, Lecture 3 (2011) · E. W. Weisstein, "Matrix Norm", Wolfram MathWorld