Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Why Condition Numbers Matter

Before we discuss algorithms and their errors, we need to understand: some problems are inherently harder than others.

Consider computing f(x)=tan(x)f(x) = \tan(x) near x=π/2x = \pi/2. Even with infinite precision arithmetic and a perfect algorithm, tiny uncertainties in xx cause huge changes in tan(x)\tan(x). This isn’t a flaw in our algorithm—it’s the nature of the tangent function near its pole.

The condition number quantifies this sensitivity. It answers: if my input is slightly wrong, how wrong might my output be?

Absolute and Relative Error

Before measuring problem sensitivity, we need precise definitions of error.

Why Relative Error Matters

Example 1 (Same Absolute Error, Different Quality)
x=1x = 1, x=2x^* = 2x=106x = 10^6, x=106+1x^* = 10^6 + 1
Absolute error11
Relative error100%100\%0.0001%0.0001\%
QualityTerribleExcellent

Both have the same absolute error, but the first is off by 100% while the second is nearly perfect. Relative error captures what matters.

Condition of ff at xx

When we want to evaluate f(x)f(x), even if xx^* is close to xx, the value f(x)f(x^*) may be far from f(x)f(x). The condition number quantifies this sensitivity.

Simplified Formula via Taylor’s Theorem

Proof 1

Since xx^* is close to xx, we can write x=x+hx^* = x + h and apply Taylor’s theorem:

f(x)=f(x+h)f(x)+f(x)(xx)f(x^*) = f(x + h) \approx f(x) + f'(x)(x - x^*)

This gives us:

f(x)f(x)f(x)(xx)f(x) - f(x^*) \approx f'(x)(x - x^*)

Substituting into the condition number definition:

κ=supxxf(x)f(x)\kappa = \sup_x \left| \frac{x f'(x)}{f(x)} \right|

Examples

Example 2 (Square Root (Well-Conditioned))

Consider f(x)=xf(x) = \sqrt{x} with f(x)=12xf'(x) = \frac{1}{2\sqrt{x}}.

Near xˉ=1\bar{x} = 1, we have yˉ=f(xˉ)=1\bar{y} = f(\bar{x}) = 1. Using a Taylor approximation:

yyˉ=x112(x1)=12(xxˉ)y - \bar{y} = \sqrt{x} - 1 \approx \frac{1}{2}(x - 1) = \frac{1}{2}(x - \bar{x})

Variations in yy are always smaller than variations in xx. Computing the condition number:

κ=xf(x)f(x)=x12xx=12\kappa = \left| \frac{x f'(x)}{f(x)} \right| = \left| \frac{x \cdot \frac{1}{2\sqrt{x}}}{\sqrt{x}} \right| = \frac{1}{2}

Result: κ=1/2\kappa = 1/2 — evaluating x\sqrt{x} is well-conditioned.

Example 3 (Tangent Near π/2 (Ill-Conditioned))

Consider f(x)=tan(x)f(x) = \tan(x) near x=π2x = \frac{\pi}{2}.

Take two points:

x1=π20.001,x2=π20.002x_1 = \frac{\pi}{2} - 0.001, \quad x_2 = \frac{\pi}{2} - 0.002

Then x1x2=0.001|x_1 - x_2| = 0.001, but f(x1)f(x2)500|f(x_1) - f(x_2)| \approx 500. A tiny input change causes a huge output change!

Computing the condition number:

κ=xf(x)f(x)=xcos(x)sin(x)=2xcsc(2x) as xπ/2\kappa = \left| \frac{x f'(x)}{f(x)} \right| = \left| \frac{x}{\cos(x)\sin(x)} \right| = |2x \csc(2x)| \to \infty \text{ as } x \to \pi/2

Result: κ\kappa \to \infty — evaluating tan(x)\tan(x) near π2\frac{\pi}{2} is ill-conditioned.

Example 4 (Logarithm Near 1 (Ill-Conditioned))

Consider f(x)=ln(x)f(x) = \ln(x) near x=1x = 1.

κ=xf(x)f(x)=x(1/x)ln(x)=1ln(x)\kappa = \left| \frac{x f'(x)}{f(x)} \right| = \left| \frac{x \cdot (1/x)}{\ln(x)} \right| = \frac{1}{|\ln(x)|}

As x1x \to 1, we have ln(x)0\ln(x) \to 0, so κ\kappa \to \infty.

Result: κ\kappa \to \infty — evaluating ln(x)\ln(x) near x=1x = 1 is ill-conditioned.

Summary

ProblemCondition NumberWell/Ill-Conditioned
f(x)=xf(x) = \sqrt{x}κ=1/2\kappa = 1/2Well-conditioned
f(x)=x2f(x) = x^2κ=2\kappa = 2Well-conditioned
f(x)=tan(x)f(x) = \tan(x) near π/2\pi/2κ\kappa \to \inftyIll-conditioned
f(x)=ln(x)f(x) = \ln(x) near 1κ\kappa \to \inftyIll-conditioned

The condition number is a property of the mathematical problem—it tells us the best possible accuracy any algorithm could achieve. But even well-conditioned problems can give bad results if we use a bad algorithm. That’s the subject of the next section.