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

MethodConvenienceInconvenience / warning
Naive subtractionSimple and direct.Can lose significant digits when the two square roots are nearly equal.
Rationalized formNumerically stable for large \(x\).Requires algebraic insight; not always obvious automatically.
Relative-error scanShows where a formula becomes dangerous.Needs a trusted reference or a stable equivalent.

Illustrative plot / animation

Numerical diagnostics

What the student must compare