Numerical integration: trapezoid, Simpson and Gauss
NUM · Chapter 311 min readAsked at Optiver, Citadel Securities, Akuna, Jump
After this lesson you should be able to
- Rank the standard quadrature rules by accuracy per evaluation.
- Say when quadrature beats Monte Carlo and when it cannot.
- Handle an integrand with a kink or an infinite range.
Option pricing is full of integrals: an expectation against a density, a variance swap against a strip of strikes, a characteristic-function inversion. In one or two dimensions quadrature is far more accurate than simulation for the same effort, and knowing which rule to use is mostly a matter of how smooth the integrand is.
| Rule | Exact for | Error | Evaluations |
|---|---|---|---|
| Midpoint | Linear | ||
| Trapezoid | Linear | ||
| Simpson | Cubic | , even | |
| Gauss–Legendre, points | Degree | Spectral, for smooth integrands |
Why Gauss buys so much. The other rules fix the evaluation points at equal spacing and choose the weights. Gauss chooses *both*, which doubles the free parameters and therefore doubles the polynomial degree it can integrate exactly: points handle degree rather than . For a smooth integrand the accuracy improves faster than any power of , so ten Gauss points can beat a thousand trapezoid ones. The catch is that the points are not where you would choose them, so if your integrand is only known at fixed places — market strikes, say — Gauss is unavailable.
Example 3.2
Integrating a smooth function, trapezoid with 100 points gives an error of . What error would 1,000 points give, and what would Simpson give with 100?
Show the worked solutionHide the worked solution
Worked solution
- Formula
- Substitute
- Solve
- Answer
Sanity check. Simpson at a hundred points beats trapezoid at a thousand by two orders of magnitude, for a tenth of the function evaluations. When each evaluation is an expensive pricing call, the choice of rule is the whole performance story.
The rest of this lesson is in Premium
You have read the opening. 11 more sections follow, including 3 worked examples and 3 quick checks.
Nothing is charged for 7 days, and you can cancel before then. Or read Complexity: reading it off, and deriving it in full, free.