Condition Number of a Matrix
The condition number of a matrix, κ(A) = ‖A‖ · ‖A⁻¹‖, measures how sensitive the solution of Ax = b is to small changes in A or b. A condition number near 1 means the system is well-conditioned. A large condition number means small input errors can become large errors in x.
Before this lesson: Gauss-Seidel Method, Inverse Matrices and Absolute and Relative Error
Why some systems amplify errors
Every real right-hand side b has some error: rounding, measurement or earlier computation. The question is how much that error can change the answer x. For some systems, a 0.05% change in b moves x by 100%. For others, x barely moves.
Geometrically, each equation of a 2 × 2 system is a line, and the solution is where the lines cross. If the lines cross at a wide angle, shifting one line a little moves the crossing point a little. If the lines are nearly parallel, the same small shift slides the crossing point a long way.
The condition number turns this picture into a number. It needs a way to measure the size of a matrix, called a matrix norm.
Condition number formula
Matrix norms
The infinity norm of A is its largest absolute row sum, and the 1-norm is its largest absolute column sum:
\|A\|_\infty = \max_i \sum_j |a_{ij}|,\qquad \|A\|_1 = \max_j \sum_i |a_{ij}|For a vector, ‖x‖∞ is the largest absolute entry. These norms satisfy ‖Ax‖∞ ≤ ‖A‖∞ ‖x‖∞.
The condition number
For an invertible square matrix A,
\kappa(A) = \|A\| \, \|A^{-1}\| \ge 1If A is singular, κ(A) = ∞. The value depends on the norm, so write κ∞, κ₁ or κ₂ when it matters. In the 2-norm, κ₂(A) = σₘₐₓ / σₘᵢₙ, the ratio of the largest and smallest singular values.
What the condition number tells you
If b changes to b + δb, the solution changes to x + δx, and
\dfrac{\|\delta \mathbf{x}\|}{\|\mathbf{x}\|} \le \kappa(A)\, \dfrac{\|\delta \mathbf{b}\|}{\|\mathbf{b}\|}So the relative error in x can be up to κ(A) times the relative error in b. A useful rule of thumb: when solving Ax = b on a computer, expect to lose about log₁₀ κ(A) significant digits.
| κ(A) | Description | Digits lost (about) |
|---|---|---|
| 1 to 10 | Well-conditioned | 0 to 1 |
| 10³ | Moderately ill-conditioned | 3 |
| 10⁸ | Ill-conditioned | 8 of the 16 in double precision |
| ∞ | Singular | No unique solution |
Condition number examples
Example 1: A well-conditioned matrix
Find κ∞(A) for A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}.
\|A\|_\infty = \max(|4| + |1|,\ |2| + |3|) = \max(5, 5) = 5
Largest absolute row sum.
\det A = 4(3) - 1(2) = 10
Find the determinant.
A^{-1} = \dfrac{1}{10}\begin{bmatrix} 3 & -1 \\ -2 & 4 \end{bmatrix}Swap the diagonal, negate the off-diagonal, divide by det A (see inverse matrices).
\|A^{-1}\|_\infty = \max\left(\dfrac{3 + 1}{10},\ \dfrac{2 + 4}{10}\right) = \max(0.4, 0.6) = 0.6Largest absolute row sum of A⁻¹.
\kappa_\infty(A) = 5(0.6) = 3
Multiply the norms.
Answer: κ∞(A) = 3. Errors in b can be magnified at most 3 times, so this system is well-conditioned.
Example 2: A nearly singular matrix
Find κ∞(A) for A = \begin{bmatrix} 1 & 1 \\ 1 & 1.001 \end{bmatrix}.
\|A\|_\infty = \max(1 + 1,\ 1 + 1.001) = 2.001
Largest absolute row sum.
\det A = 1(1.001) - 1(1) = 0.001
The determinant is tiny.
A^{-1} = \dfrac{1}{0.001}\begin{bmatrix} 1.001 & -1 \\ -1 & 1 \end{bmatrix} = \begin{bmatrix} 1001 & -1000 \\ -1000 & 1000 \end{bmatrix}Use the 2 × 2 inverse formula; 1/0.001 = 1000.
\|A^{-1}\|_\infty = \max(1001 + 1000,\ 1000 + 1000) = 2001Largest absolute row sum of A⁻¹.
\kappa_\infty(A) = 2.001(2001) = 4004.001
Multiply the norms.
Answer: κ∞(A) ≈ 4004. Errors in b can be magnified about 4000 times, and about log₁₀ 4004 ≈ 3.6 digits can be lost.
Example 3: Seeing the error magnification
Solve Ax = b with the matrix from Example 2 for b = (2, 2.001), then for the slightly changed b = (2, 2.002). Compare the relative changes.
x + y = 2,\quad x + 1.001y = 2.001
Original system.
0.001y = 0.001 \Rightarrow y = 1,\quad x = 2 - 1 = 1
Subtract the first equation from the second.
x + y = 2,\quad x + 1.001y = 2.002
Changed system.
0.001y = 0.002 \Rightarrow y = 2,\quad x = 2 - 2 = 0
Subtract again.
\dfrac{\|\delta\mathbf{b}\|_\infty}{\|\mathbf{b}\|_\infty} = \dfrac{0.001}{2.001} \approx 0.0004998Relative change in b (about 0.05%).
\dfrac{\|\delta\mathbf{x}\|_\infty}{\|\mathbf{x}\|_\infty} = \dfrac{\max(|0 - 1|, |2 - 1|)}{1} = 1Relative change in x (100%), measured against the original x = (1, 1).
\dfrac{1}{0.0004998} \approx 2001 \le 4004Magnification factor, within the bound κ∞(A).
Answer: x jumps from (1, 1) to (0, 2). A 0.05% change in b caused a 100% change in x, a magnification of about 2001, consistent with κ∞ ≈ 4004.
Example 4: The 3 × 3 Hilbert matrix
The Hilbert matrices are a classic ill-conditioned family. Find κ∞(H₃), given its inverse.
H_3 = \begin{bmatrix} 1 & \tfrac{1}{2} & \tfrac{1}{3} \\ \tfrac{1}{2} & \tfrac{1}{3} & \tfrac{1}{4} \\ \tfrac{1}{3} & \tfrac{1}{4} & \tfrac{1}{5} \end{bmatrix},\qquad H_3^{-1} = \begin{bmatrix} 9 & -36 & 30 \\ -36 & 192 & -180 \\ 30 & -180 & 180 \end{bmatrix}1 + \tfrac{1}{2} + \tfrac{1}{3} = \tfrac{6}{6} + \tfrac{3}{6} + \tfrac{2}{6} = \tfrac{11}{6}Row 1 has the largest sum (see adding and subtracting fractions).
\|H_3\|_\infty = \tfrac{11}{6}Rows 2 and 3 sum to 13/12 and 47/60, which are smaller.
9 + 36 + 30 = 75,\quad 36 + 192 + 180 = 408,\quad 30 + 180 + 180 = 390
Absolute row sums of the inverse.
\|H_3^{-1}\|_\infty = 408The largest.
\kappa_\infty(H_3) = \tfrac{11}{6}(408) = 748Multiply: 408 ÷ 6 = 68 and 68 × 11 = 748.
\log_{10} 748 \approx 2.87Digits that can be lost.
Answer: κ∞(H₃) = 748, so about 3 digits can be lost even for this small matrix. The condition number of Hₙ grows very fast with n.
Example 5: Measuring two similar chemicals (word problem)
A lab finds the masses x and y (in grams) of two chemicals from two instrument readings: x + y = 10.00 and x + 1.01y = 10.05. Each reading may be off by 0.01 g. How reliable is the solution?
0.01y = 10.05 - 10.00 = 0.05 \Rightarrow y = 5,\quad x = 10 - 5 = 5
Solve the system.
\|A\|_\infty = \max(2,\ 2.01) = 2.01
A has rows (1, 1) and (1, 1.01).
A^{-1} = \dfrac{1}{0.01}\begin{bmatrix} 1.01 & -1 \\ -1 & 1 \end{bmatrix} = \begin{bmatrix} 101 & -100 \\ -100 & 100 \end{bmatrix}det A = 1.01 − 1 = 0.01.
\kappa_\infty(A) = 2.01(201) = 404.01
‖A⁻¹‖∞ = 101 + 100 = 201.
404.01 \cdot \dfrac{0.01}{10.05} \approx 0.402Bound on the relative error of x: κ times the relative error of b.
0.01y = 10.06 - 10.00 = 0.06 \Rightarrow y = 6,\quad x = 4
Check one case: the second reading is 0.01 g too high.
Answer: the computed masses are 5 g and 5 g, but they could be off by up to about 40%. A reading error of only 0.01 g changes them to 4 g and 6 g, a 20% change. The lab needs a measurement that separates the chemicals better, not more decimal places in the arithmetic.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using the determinant as the condition number | Calling 0.1I (10 × 10, det 10⁻¹⁰) ill-conditioned | Scaling changes det A but not κ(A); here κ = 1. |
| Mixing norms | Multiplying ‖A‖∞ by ‖A⁻¹‖₁ | Use the same norm for A and A⁻¹. |
| Using column sums for the infinity norm | Taking ‖A‖∞ as the largest column sum | Infinity norm: rows. 1-norm: columns. |
| Forgetting absolute values | Row (−1000, 1000) summed to 0 | Add |−1000| + |1000| = 2000. |
| Blaming the algorithm | Expecting pivoting to fix an ill-conditioned system | Pivoting controls round-off growth; it cannot remove the sensitivity built into A. |
Related methods
Estimating the condition number
Computing A⁻¹ just to find κ(A) is expensive. Software such as MATLAB’s condest or LAPACK estimates ‖A⁻¹‖₁ from the LU factorization with a few extra solves.
Residuals versus errors
The residual r = b − Ax̂ can be tiny even when x̂ is far from x. The two are linked by ‖x − x̂‖ / ‖x‖ ≤ κ(A) ‖r‖ / ‖b‖, so a small residual guarantees a small error only when κ(A) is small.
Practice problems
- Find ‖A‖∞ and ‖A‖₁ for A = \begin{bmatrix} 3 & -2 \\ 1 & 4 \end{bmatrix}.
- Find κ∞(A) for A = \begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}.
- What is the condition number of the identity matrix? Of 5I?
- Find κ∞(A) for the diagonal matrix with entries 10 and 0.1.
- Find κ∞(A) for A = \begin{bmatrix} 1 & 2 \\ 2 & 4.01 \end{bmatrix}.
- If κ(A) = 10⁵ and b has relative error 10⁻⁸, bound the relative error in x.
- In double precision (about 16 significant digits), κ(A) ≈ 10⁸. About how many digits of the computed solution can you trust?
- What is κ(A) for A = \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}? Why?
- A survey solves 2x + 3y = 13 and 2x + 3.02y = 13.04. The data have relative error 0.1%. Solve the system and bound the relative error in the solution using κ∞.
- Does a small determinant always mean a matrix is ill-conditioned? Give an example.
Show answers
1.
\max(3 + 2,\ 1 + 4) = 5
Row sums of absolute values.
\max(3 + 1,\ 2 + 4) = 6
Column sums of absolute values.
Answer: ‖A‖∞ = 5 and ‖A‖₁ = 6
2.
\|A\|_\infty = \max(3, 2) = 3
Row sums.
\det A = 2 - 1 = 1,\quad A^{-1} = \begin{bmatrix} 1 & -1 \\ -1 & 2 \end{bmatrix}2 × 2 inverse formula.
\|A^{-1}\|_\infty = \max(2, 3) = 3Row sums of the inverse.
Answer: κ∞(A) = 3 · 3 = 9
3.
\|I\| \, \|I^{-1}\| = 1 \cdot 1 = 1The identity is its own inverse.
\|5I\| \, \|\tfrac{1}{5}I\| = 5 \cdot \tfrac{1}{5} = 1Scaling does not change κ.
Answer: both have condition number 1, the smallest possible
4.
\|A\|_\infty = 10,\quad \|A^{-1}\|_\infty = \max(0.1, 10) = 10A⁻¹ has diagonal entries 0.1 and 10.
Answer: κ∞(A) = 10 · 10 = 100
5.
\|A\|_\infty = \max(3,\ 6.01) = 6.01
Row sums.
\det A = 4.01 - 4 = 0.01
Nearly singular.
A^{-1} = 100\begin{bmatrix} 4.01 & -2 \\ -2 & 1 \end{bmatrix} = \begin{bmatrix} 401 & -200 \\ -200 & 100 \end{bmatrix}2 × 2 inverse formula.
\|A^{-1}\|_\infty = \max(601,\ 300) = 601Row sums of the inverse.
Answer: κ∞(A) = 6.01 · 601 = 3612.01
6.
10^5 \cdot 10^{-8} = 10^{-3}Use the error bound.
Answer: relative error at most 10⁻³ (0.1%)
7.
16 - \log_{10} 10^8 = 16 - 8 = 8Subtract the digits lost.
Answer: about 8 significant digits
8.
\det A = 4 - 4 = 0
Row 2 is twice row 1.
Answer: κ(A) = ∞, because A is singular and has no inverse
9.
0.02y = 13.04 - 13 = 0.04 \Rightarrow y = 2
Subtract the equations.
2x + 3(2) = 13 \Rightarrow 2x = 7 \Rightarrow x = 3.5
Back-substitute.
\det A = 6.04 - 6 = 0.04,\quad A^{-1} = 25\begin{bmatrix} 3.02 & -3 \\ -2 & 2 \end{bmatrix}1/0.04 = 25.
\|A\|_\infty = 5.02,\quad \|A^{-1}\|_\infty = 25(6.02) = 150.5Row sums.
\kappa_\infty = 5.02(150.5) = 755.51,\quad 755.51(0.001) \approx 0.76
Bound on the relative error.
Answer: (x, y) = (3.5, 2), but the relative error could be as large as about 76%
10.
\det(0.1 I_{10}) = 0.1^{10} = 10^{-10},\quad \kappa(0.1 I_{10}) = 0.1 \cdot 10 = 1A scaled 10 × 10 identity.
Answer: no; 0.1I₁₀ has a tiny determinant but condition number 1, the best possible
Condition number FAQ
What is the condition number of a matrix?
It is κ(A) = ‖A‖ ‖A⁻¹‖, a number at least 1 that bounds how much relative errors in b (or A) can be magnified in the solution of Ax = b.
What is a good condition number?
Values near 1 are ideal. As a rule of thumb, you lose about log₁₀ κ digits, so κ = 10³ costs about 3 of the 16 digits in double precision. When κ approaches 10¹⁶, double-precision answers can be meaningless.
How do you calculate the condition number of a matrix?
Find a norm of A, find A⁻¹ and its norm in the same norm, and multiply. For the 2-norm, divide the largest singular value by the smallest.
What does ill-conditioned mean?
A matrix is ill-conditioned when its condition number is large, so tiny changes in the data can cause large changes in the solution. It is a property of the problem, not of the method used to solve it.
Summary
- κ(A) = ‖A‖ ‖A⁻¹‖ ≥ 1; κ = ∞ for a singular matrix.
- ‖A‖∞ is the largest absolute row sum; ‖A‖₁ is the largest absolute column sum.
- Relative error in x ≤ κ(A) · relative error in b.
- Expect to lose about log₁₀ κ(A) digits.
- Nearly parallel lines (nearly dependent rows) mean ill-conditioning; a small determinant alone does not.
Previous lesson: Gauss-Seidel Method
Next lesson: Power Method
Back to the Numerical Methods Index