Skip to content

The condition number and numerical stability

5 min read

Short answer

The condition number κ(A)=∥A∥ ∥A−1∥\kappa(A)=\|A\|\,\|A^{-1}\| bounds how errors in b\mathbf b are magnified in x\mathbf x: ∥δx∥∥x∥≤κ(A)∥δb∥∥b∥\dfrac{\|\delta\mathbf x\|}{\|\mathbf x\|}\le\kappa(A)\dfrac{\|\delta\mathbf b\|}{\|\mathbf b\|}. A large κ\kappa (nearly singular AA) means tiny data errors can ruin the answer, no matter how good the algorithm is.

Well-conditioned compared with Ill-conditionedWell-conditionedκ close to 1Orthogonal matriceshave κ = 1Small error in b:small error in xIll-conditionedκ huge (10⁶ or more)Rows nearly parallelSmall error in b: hugeerror in x
Roughly log₁₀ κ digits of accuracy are lost.

A fragile system

The system (1111.0001)x=(22)\begin{pmatrix}1&1\\1&1.0001\end{pmatrix}\mathbf x=\begin{pmatrix}2\\2\end{pmatrix} has two nearly parallel lines. Changing the right side in the fifth digit moves the solution a long way.

What you can do

You cannot fix ill-conditioning by changing the algorithm: it is a property of the problem. Options: rescale variables, reformulate, add regularization (as in ridge regression), or obtain more precise data.

Worked example

For A=(1111.0001)A=\begin{pmatrix}1&1\\1&1.0001\end{pmatrix}, solve with b=(2,2)\mathbf b=(2,2) and with b=(2,2.0001)\mathbf b=(2,2.0001).

First: x2=0x_2=0, x1=2x_1=2, so x=(2,0)\mathbf x=(2,0). Second: subtracting equations gives 0.0001x2=0.00010.0001x_2=0.0001, so x2=1x_2=1, x1=1x_1=1, x=(1,1)\mathbf x=(1,1). A change of 0.00010.0001 in one entry of b\mathbf b moved the solution by about 1.41.4: this AA has κ\kappa in the tens of thousands.

Try it yourself

If κ(A)=106\kappa(A)=10^6 and your data has 16 digits of precision, roughly how many digits can you trust in x\mathbf x?

Show the answer

About 16−6=1016-6=10 digits.

Keep going with practice

Vidi's linear algebra lessons explain why nearly dependent columns make least-squares fits unstable.