Condition Numbers University of Massachusetts Amherst
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) f ( x ) = tan ( x ) near x = π / 2 x = \pi/2 x = π /2 . Even with infinite precision arithmetic and a perfect algorithm, tiny uncertainties in x x x cause huge changes in tan ( x ) \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 = 1 x = 1 x = 1 , x ∗ = 2 x^* = 2 x ∗ = 2 x = 1 0 6 x = 10^6 x = 1 0 6 , x ∗ = 1 0 6 + 1 x^* = 10^6 + 1 x ∗ = 1 0 6 + 1 Absolute error 1 1 Relative error 100 % 100\% 100% 0.0001 % 0.0001\% 0.0001% Quality Terrible Excellent
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 f f f at x x x ¶ When we want to evaluate f ( x ) f(x) f ( x ) , even if x ∗ x^* x ∗ is close to x x x , the value f ( x ∗ ) f(x^*) f ( x ∗ ) may be far from f ( x ) f(x) f ( x ) . The condition number quantifies this sensitivity.
Proof 1
Since x ∗ x^* x ∗ is close to x x x , we can write x ∗ = x + h x^* = x + h x ∗ = x + h and apply Taylor’s theorem:
f ( x ∗ ) = f ( x + h ) ≈ f ( x ) + f ′ ( x ) ( x − x ∗ ) f(x^*) = f(x + h) \approx f(x) + f'(x)(x - x^*) f ( x ∗ ) = f ( x + h ) ≈ f ( x ) + f ′ ( x ) ( x − x ∗ ) This gives us:
f ( x ) − f ( x ∗ ) ≈ f ′ ( x ) ( x − x ∗ ) f(x) - f(x^*) \approx f'(x)(x - x^*) f ( x ) − f ( x ∗ ) ≈ f ′ ( x ) ( x − x ∗ ) Substituting into the condition number definition:
κ = sup x ∣ x f ′ ( x ) f ( x ) ∣ \kappa = \sup_x \left| \frac{x f'(x)}{f(x)} \right| κ = x sup ∣ ∣ f ( x ) x f ′ ( x ) ∣ ∣ Examples ¶ Example 2 (Square Root (Well-Conditioned))
Consider f ( x ) = x f(x) = \sqrt{x} f ( x ) = x with f ′ ( x ) = 1 2 x f'(x) = \frac{1}{2\sqrt{x}} f ′ ( x ) = 2 x 1 .
Near x ˉ = 1 \bar{x} = 1 x ˉ = 1 , we have y ˉ = f ( x ˉ ) = 1 \bar{y} = f(\bar{x}) = 1 y ˉ = f ( x ˉ ) = 1 . Using a Taylor approximation:
y − y ˉ = x − 1 ≈ 1 2 ( x − 1 ) = 1 2 ( x − x ˉ ) y - \bar{y} = \sqrt{x} - 1 \approx \frac{1}{2}(x - 1) = \frac{1}{2}(x - \bar{x}) y − y ˉ = x − 1 ≈ 2 1 ( x − 1 ) = 2 1 ( x − x ˉ ) Variations in y y y are always smaller than variations in x x x . Computing the condition number:
κ = ∣ x f ′ ( x ) f ( x ) ∣ = ∣ x ⋅ 1 2 x x ∣ = 1 2 \kappa = \left| \frac{x f'(x)}{f(x)} \right| = \left| \frac{x \cdot \frac{1}{2\sqrt{x}}}{\sqrt{x}} \right| = \frac{1}{2} κ = ∣ ∣ f ( x ) x f ′ ( x ) ∣ ∣ = ∣ ∣ x x ⋅ 2 x 1 ∣ ∣ = 2 1 Result: κ = 1 / 2 \kappa = 1/2 κ = 1/2 — evaluating x \sqrt{x} x is well-conditioned .
Example 3 (Tangent Near π/2 (Ill-Conditioned))
Consider f ( x ) = tan ( x ) f(x) = \tan(x) f ( x ) = tan ( x ) near x = π 2 x = \frac{\pi}{2} x = 2 π .
Take two points:
x 1 = π 2 − 0.001 , x 2 = π 2 − 0.002 x_1 = \frac{\pi}{2} - 0.001, \quad x_2 = \frac{\pi}{2} - 0.002 x 1 = 2 π − 0.001 , x 2 = 2 π − 0.002 Then ∣ x 1 − x 2 ∣ = 0.001 |x_1 - x_2| = 0.001 ∣ x 1 − x 2 ∣ = 0.001 , but ∣ f ( x 1 ) − f ( x 2 ) ∣ ≈ 500 |f(x_1) - f(x_2)| \approx 500 ∣ f ( x 1 ) − f ( x 2 ) ∣ ≈ 500 . A tiny input change causes a huge output change!
Computing the condition number:
κ = ∣ x f ′ ( x ) f ( x ) ∣ = ∣ x cos ( x ) sin ( x ) ∣ = ∣ 2 x csc ( 2 x ) ∣ → ∞ 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 κ = ∣ ∣ f ( x ) x f ′ ( x ) ∣ ∣ = ∣ ∣ cos ( x ) sin ( x ) x ∣ ∣ = ∣2 x csc ( 2 x ) ∣ → ∞ as x → π /2 Result: κ → ∞ \kappa \to \infty κ → ∞ — evaluating tan ( x ) \tan(x) tan ( x ) near π 2 \frac{\pi}{2} 2 π is ill-conditioned .
Example 4 (Logarithm Near 1 (Ill-Conditioned))
Consider f ( x ) = ln ( x ) f(x) = \ln(x) f ( x ) = ln ( x ) near x = 1 x = 1 x = 1 .
κ = ∣ x f ′ ( x ) f ( x ) ∣ = ∣ x ⋅ ( 1 / x ) ln ( x ) ∣ = 1 ∣ ln ( x ) ∣ \kappa = \left| \frac{x f'(x)}{f(x)} \right| = \left| \frac{x \cdot (1/x)}{\ln(x)} \right| = \frac{1}{|\ln(x)|} κ = ∣ ∣ f ( x ) x f ′ ( x ) ∣ ∣ = ∣ ∣ ln ( x ) x ⋅ ( 1/ x ) ∣ ∣ = ∣ ln ( x ) ∣ 1 As x → 1 x \to 1 x → 1 , we have ln ( x ) → 0 \ln(x) \to 0 ln ( x ) → 0 , so κ → ∞ \kappa \to \infty κ → ∞ .
Result: κ → ∞ \kappa \to \infty κ → ∞ — evaluating ln ( x ) \ln(x) ln ( x ) near x = 1 x = 1 x = 1 is ill-conditioned .
Summary ¶ Problem Condition Number Well/Ill-Conditioned f ( x ) = x f(x) = \sqrt{x} f ( x ) = x κ = 1 / 2 \kappa = 1/2 κ = 1/2 Well-conditioned f ( x ) = x 2 f(x) = x^2 f ( x ) = x 2 κ = 2 \kappa = 2 κ = 2 Well-conditioned f ( x ) = tan ( x ) f(x) = \tan(x) f ( x ) = tan ( x ) near π / 2 \pi/2 π /2 κ → ∞ \kappa \to \infty κ → ∞ Ill-conditioned f ( x ) = ln ( x ) f(x) = \ln(x) f ( x ) = ln ( x ) near 1κ → ∞ \kappa \to \infty κ → ∞ Ill-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 .