Skip to content

Midpoint rule

The midpoint rule samples the centre of each integration panel. See why it is exact for affine functions and how curvature controls its error.

The midpoint rule approximates a definite integral by multiplying an interval's width by the function's value at its centre. The composite version repeats that calculation on smaller intervals and adds the contributions. Each rectangle uses one sampled height.
For a quant, the same construction can approximate an expected payoff against a density or accumulate a changing cash-flow rate. The important choice is where to evaluate the whole integrand. For an expectation, that includes both the payoff and its probability density.

Middle of the interval, not average of the heights

On one interval [a,b][a,b], the approximation is

∫abf(x) dx≈(b−a)f(a+b2).\int_a^b f(x)\,dx\approx (b-a)f\left(\frac{a+b}{2}\right).
The average happens inside ff: evaluate the function at the average of the two endpoints. Averaging the endpoint function values instead gives the trapezoidal rule. For f(x)=x2f(x)=x^2 on [0,1][0,1], these heights are f(1/2)=1/4f(1/2)=1/4 and [f(0)+f(1)]/2=1/2[f(0)+f(1)]/2=1/2. They are different calculations. MIT's description of numerical integration rules makes this sampling distinction explicit.

For nn equal panels, let h=(b−a)/nh=(b-a)/n and mi=a+(i−1/2)hm_i=a+(i-1/2)h. Then

Mn=h∑i=1nf(mi).M_n=h\sum_{i=1}^{n}f(m_i).

This is a particular Riemann integral approximation, using the middle of every panel. You need access to those midpoint values: a table containing only the panel endpoints does not provide them without an extra interpolation assumption. An irregular partition is also possible, but each panel then needs its own width and midpoint.

Watching a second moment come into focus

Take the dimensionless benchmark

I=∫01x2 dx=13.I=\int_0^1 x^2\,dx=\frac13.

It is also E[X2]\mathbb{E}[X^2] for a synthetic uniform risk factor XX on [0,1][0,1], since its density there is one. This gives a simple exact target for checking an integration routine, rather than a model fitted to financial data.

One panel samples x=1/2x=1/2 and gives M1=1/4M_1=1/4. Two panels sample 1/41/4 and 3/43/4, giving M2=5/16M_2=5/16. With four panels,

M4=14[(18)2+(38)2+(58)2+(78)2]=2164=0.328125.M_4=\frac14\left[\left(\frac18\right)^2+\left(\frac38\right)^2+\left(\frac58\right)^2+\left(\frac78\right)^2\right]=\frac{21}{64}=0.328125.
Midpoint rectangles for dimensionless x squared on zero to one: one panel gives 1/4 with error -1/12, two give 5/16 with error -1/48, and four give 21/64 with error -1/192.
Midpoint rectangles for dimensionless x squared on zero to one: one panel gives 1/4 with error -1/12, two give 5/16 with error -1/48, and four give 21/64 with error -1/192.
Original synthetic benchmark. Filled dots mark the sampled values. Each doubling of the panel count divides the error magnitude by four; signed errors are approximation minus exact integral.
A rectangle crosses the curve within its panel, so it is not everywhere below it. Its total area is too small here. More generally, midpoint integration underestimates the integral of a convex function on an increasing integration interval, and overestimates for a concave function. Monotonicity alone does not determine this error's sign.

Why curvature matters

At a midpoint mm, the linear part of a function is symmetric: its excess on one side cancels its deficit on the other. This makes midpoint integration exact for every affine function, even one with a steep slope.

For our quadratic, write x=m+sx=m+s on a panel of width hh. Direct integration gives

∫−h/2h/2(m+s)2 ds=m2h+h312.\int_{-h/2}^{h/2}(m+s)^2\,ds=m^2h+\frac{h^3}{12}.

The rectangle retains m2hm^2h and misses h3/12h^3/12. On [0,1][0,1], summing over nn panels gives the exact law

Mn=13−112n2.M_n=\frac13-\frac{1}{12n^2}.

The local error scales as h3h^3; the total error on a fixed interval scales as h2h^2, because the number of panels grows as 1/h1/h.

For a general ff with a continuous second derivative on [a,b][a,b], where a<ba<b and ∣f′′(x)∣≤K\lvert f''(x)\rvert\le K, the midpoint error bound is
∣Mn−∫abf(x) dx∣≤K(b−a)324n2.\left|M_n-\int_a^b f(x)\,dx\right|\le\frac{K(b-a)^3}{24n^2}.
Here K=2K=2, and the bound equals the actual error magnitude. Usually a bound is more conservative. Second-order convergence describes the smooth refinement regime; it does not promise an exact factor of four for every integrand and panel count, or guarantee midpoint beats every competing rule. Kinks, discontinuities and rounding need separate attention. Composite quadrature compares how several rules behave under refinement.

Keep the units and signs: a rate in USD/year times a panel width in years contributes USD. Negative rates contribute negative amounts. Ordinary midpoint quadrature also assumes an ordinary integral; choosing midpoint samples in a stochastic integral involves different definitions.

For more rectangle geometry and an affine log-return-rate example, read Areas and Distances: The Riemann Sum. Its preview is public; the full lesson requires membership.

Sources

Last updated
  • midpoint rule
  • numerical integration
  • quadrature
  • curvature
  • convergence
← Back to the glossaryBack to top ↑