Skip to episode

How Quants Think · Numerical Thinking · Episode 16 of 30

Why Stable Algorithms Beat Clever Algorithms

See how mathematically equivalent quant formulas can behave differently in floating-point arithmetic.

Why this question matters

A concise formula and a more careful implementation may be mathematically equivalent but produce very different computed results. Numerical stability is about preventing small rounding errors from becoming large output errors.

How a quant approaches it

Subtracting nearly equal quantities, using vanishing denominators or producing huge intermediate numbers can make an otherwise correct computation fragile. Stable reformulations and special handling of limits often matter more than elegance.

A practical perspective

Variance computed as the difference between a second moment and the square of a mean can be inaccurate when both terms are huge. Working with deviations from the mean avoids much of that cancellation.

What you will learn

Watch the video above for the complete explanation, reasoning and worked examples.

Slides and related lessons

How Quants Think slides on GitHub ↗ · Computations in Finance on YouTube ↗

Related study: Computational Finance, Lecture 9 — Monte Carlo Simulation. Browse Computational Finance or all 30 episodes.