Overview
This section reviews techniques to minimize roundoff error in numerical computations. Key strategies include:
- Simplifying expressions to avoid catastrophic cancellation.
- Algebraic manipulation (e.g., multiplying by the conjugate) to stabilize calculations.
- Rewriting formulas to improve numerical stability.
Example: Avoiding Catastrophic Cancellation
For the function \( f(x) = \frac{x^2 - 1}{x - 1} \), direct evaluation near \( x = 1 \) leads to an indeterminate form. Instead, simplify:
\( f(x) = \frac{(x-1)(x+1)}{x-1} = x+1 \).
This method is crucial in scenarios such as pivoting in LU decomposition or handling trigonometric limits.
Improving Numerical Stability
When evaluating expressions prone to rounding errors or cancellation, try these techniques:
- Algebraic Simplification: Factor and cancel common terms. For example, to compute \( \lim_{x \to 1}\frac{x^2-1}{x-1} \), factor the numerator as \( (x-1)(x+1) \) so the expression simplifies to \( x+1 \).
- Rationalization: Multiply by the conjugate to eliminate radicals. For example, if evaluating \( \sqrt{x+1} - \sqrt{x} \), multiply numerator and denominator by \( \sqrt{x+1}+\sqrt{x} \) to reduce cancellation errors.
- Rearrangement: Sum or subtract numbers from smallest to largest magnitude to minimize loss of significance.
- Series Expansion: Replace problematic expressions with their Maclaurin (or Taylor) series expansion near the point of interest to obtain a more stable approximation.