Quant Memo
Core

Numerical Differentiation

Estimating a derivative from function values alone, by nudging the input slightly and measuring the change in output — the practical way quants compute Greeks when no clean formula for the derivative exists.

Prerequisites: Numerical Stability and Error Analysis

A structured product's price comes out of a complicated numerical model — a Monte Carlo simulation or an exotic pricing tree — with no clean algebraic formula. Risk management still needs delta, the sensitivity of price to the underlying's move, to hedge the position. Without a formula to differentiate, the practical answer is to nudge the underlying's price by a tiny amount, rerun the model, and see how much the output moves. That's numerical differentiation: estimating a derivative purely from evaluating the function at nearby points, never touching calculus at all.

An analogy: judging a hill's steepness by walking

If you can't see a topographic map's slope formula but can only measure your altitude at any spot, you can still estimate steepness: walk a short step forward, note how much your altitude changed, and divide the altitude change by the distance walked. A shorter step gives a more precise local estimate of the slope right where you're standing, as long as your altimeter is precise enough to actually detect the small change — a step so short that the altitude change is smaller than your altimeter's precision gives you noise, not a slope.

The math, one piece at a time

The forward difference estimates the derivative of ff at a point xx using one nudge forward:

f(x)f(x+h)f(x)h,f'(x) \approx \frac{f(x+h) - f(x)}{h},

where hh is a small step size. In words: this is exactly the definition of a derivative — the limit of the slope between two nearby points as they get infinitely close — except a computer can't take h0h \to 0, so it uses a small but finite hh instead, and pays a price called truncation error, roughly proportional to hh.

true curve f(x) x x+h forward: one-sided secant x−h central: symmetric secant, closer to true slope
Central difference draws its secant line through points symmetric around x, canceling the leading error term that a one-sided forward difference leaves in.
The **central difference** is more accurate for the same step size, using one nudge in each direction: f(x)f(x+h)f(xh)2h.f'(x) \approx \frac{f(x+h) - f(x-h)}{2h} .

In plain English: instead of comparing xx to a point ahead of it, compare a point ahead to a point behind, which cancels out the leading error term by symmetry — central difference's truncation error shrinks proportional to h2h^2, so halving hh cuts the error by 4x instead of 2x. But shrinking hh too far runs into the opposite problem from earlier: floating-point rounding error in computing f(x+h)f(xh)f(x+h)-f(x-h) (a subtraction of two close numbers — see catastrophic cancellation) grows roughly like ε/h\varepsilon/h as hh shrinks, since a smaller numerator is divided by a smaller hh. The total error is the sum of both effects, and there's an optimal hh that balances them — too big and truncation error dominates, too small and rounding error dominates.

Worked example 1: delta by hand

An option prices at $10.00 with the underlying at $100. Bumping the underlying to $100.01 gives a price of $10.0052; bumping down to $99.99 gives $9.9948. Central difference delta:

Δ10.00529.99482×0.01=0.01040.02=0.52.\Delta \approx \frac{10.0052 - 9.9948}{2 \times 0.01} = \frac{0.0104}{0.02} = 0.52 .

In words: a $1 move in the underlying moves the option price by about $0.52 — a delta of 0.52, computed with no derivative formula at all, purely from three price evaluations (or in this case, two, since central difference doesn't need f(x)f(x) itself).

Worked example 2: finding a good step size

Suppose pricing this option to $0.0001 precision (a realistic Monte Carlo noise floor). With h=0.01h = 0.01: truncation error is roughly proportional to h20.0001h^2 \approx 0.0001, fine. With h=0.0000001h = 0.0000001 (far too small): the price difference f(x+h)f(xh)f(x+h)-f(x-h) is now comparable in size to the pricing model's own $0.0001 noise floor, so the "derivative" computed is dominated by simulation noise, not the true slope — a classic case of hh chosen too small, producing a wildly unstable delta estimate that can even flip sign between reruns. The lesson: the right step size depends on how precisely the underlying function itself can be evaluated, not just on wanting maximum mathematical accuracy.

step size h (log scale, decreasing →) total error truncation rounding optimal h
Truncation error shrinks as the step size h shrinks, but rounding error grows as h shrinks — the total error is minimized at an intermediate step size, not at the smallest h a computer can represent.

What this means in practice

Numerical differentiation via bump-and-reprice is the standard way to compute Greeks for pricing models too complex for closed-form sensitivities — Monte Carlo pricers, exotic-option trees, or any black-box valuation model — and it's also how gradient-based optimizers estimate gradients when no analytic gradient is coded. The choice of step size hh, and whether to use forward or central differences, is a real engineering decision that trades off truncation error against rounding (or simulation) noise, not a detail to default blindly.

Numerical differentiation estimates a derivative from function evaluations at nearby points rather than from an algebraic formula; central differences are more accurate than forward differences for the same step size, but every numerical derivative faces a genuine trade-off between truncation error (from using a finite, not infinitesimal, step) and rounding or noise error (from subtracting two very close function values) — the best step size balances the two rather than minimizing either alone.

The classic mistake is assuming smaller step size always means a more accurate derivative, and shrinking hh toward machine precision to "get closer to the true limit." Past a certain point this makes the estimate worse, not better, because the numerator becomes dominated by rounding or simulation noise rather than the true function change. When a numerically-differentiated Greek looks unstable or noisy between reruns, the fix is often to increase the step size, not decrease it.

Related concepts

Practice in interviews

Further reading

  • Press et al., Numerical Recipes, ch. 5
  • Glasserman, Monte Carlo Methods in Financial Engineering, ch. 7
ShareTwitterLinkedIn