Comparative numerical laboratory
Floating-Point Error and Cancellation: Comparative Laboratory — Chapter 1
Compare naive and stable algebraic forms for the same mathematical quantity, then inspect how the error changes with scale.
\[
q(x)=\sqrt{x+1}-\sqrt{x}=\frac{1}{\sqrt{x+1}+\sqrt{x}}.
\]
Methods compared
| Method | Convenience | Inconvenience / warning |
|---|---|---|
| Naive subtraction | Simple and direct. | Can lose significant digits when the two square roots are nearly equal. |
| Rationalized form | Numerically stable for large \(x\). | Requires algebraic insight; not always obvious automatically. |
| Relative-error scan | Shows where a formula becomes dangerous. | Needs a trusted reference or a stable equivalent. |
Illustrative plot / animation
Numerical diagnostics
What the student must compare
- absolute error
- relative difference
- scale dependence
- cancellation warning