Skip to content

Composite quadrature

Composite quadrature adds local integration rules across a partition. Compare trapezoid, midpoint and Simpson weights, errors and refinement on one exact benchmark.

Composite quadrature approximates a definite integral by splitting its interval into smaller pieces, applying a numerical integration rule locally, and adding the results. The word composite describes this repeated construction; the chosen rule determines the weights and accuracy.

For a quant, this turns an integral for an expected payoff, probability or accumulated cash flow into a finite set of function evaluations. Refining the partition can reduce integration error without changing the financial model. It cannot correct a misspecified density or missing payoff feature.

What gets added

Take a<ba<b, choose nn equal subintervals and set

h=b−an,xi=a+ih,fi=f(xi).h=\frac{b-a}{n},\qquad x_i=a+ih,\qquad f_i=f(x_i).

The composite trapezoid rule integrates the straight line connecting each pair of neighbouring values:

Tn=h[f02+∑i=1n−1fi+fn2].T_n=h\left[\frac{f_0}{2}+\sum_{i=1}^{n-1}f_i+\frac{f_n}{2}\right].

Interior nodes have full weight because they belong to two neighbouring trapezoids; each endpoint belongs to only one. The composite midpoint rule instead samples once in the middle of each subinterval:

Mn=h∑i=1nf(xi−1+xi2).M_n=h\sum_{i=1}^{n}f\left(\frac{x_{i-1}+x_i}{2}\right).
Composite Simpson's rule fits a quadratic on each pair of adjacent subintervals. With even nn, its weights are
Sn=h3[f0+4∑i=1\i oddn−1fi+2∑i=2\i evenn−2fi+fn].S_n=\frac{h}{3}\left[f_0+4\sum_{\substack{i=1\i\text{ odd}}}^{n-1}f_i+2\sum_{\substack{i=2\i\text{ even}}}^{n-2}f_i+f_n\right].

Here nn counts subintervals, so Simpson uses n/2n/2 quadratic pieces and n+1n+1 sampled nodes. The three formulas require different samples and weights. Endpoint data alone do not supply the midpoint values, and these equal-spacing weights should not be copied onto an irregular grid.

The construction is explained through interpolation in Driscoll and Braun's numerical integration chapter. For Simpson's rule, SciPy's documentation also distinguishes equal-spacing cubic exactness from the weaker exactness on irregular samples.

Four subintervals, three answers

Use the dimensionless benchmark f(x)=x2f(x)=x^2 on [0,1][0,1]. Its exact integral is I=1/3I=1/3. One financial reading is the second moment E[X2]\mathbb{E}[X^2] of a synthetic uniform risk factor XX on [0,1][0,1], whose density is one on that interval. This is a mathematical benchmark, not a fitted return distribution.

For n=4n=4, h=1/4h=1/4 and the endpoint samples are 0,1/16,1/4,9/16,10,1/16,1/4,9/16,1. The midpoint samples are taken at 1/8,3/8,5/8,7/81/8,3/8,5/8,7/8.

RuleApproximationSigned error Qn−IQ_n-I
Trapezoid11/32=0.34375011/32=0.343750+1/96+1/96
Midpoint21/64=0.32812521/64=0.328125−1/192-1/192
Simpson1/31/300
Four equal subintervals for dimensionless x squared on zero to one: trapezoid 11/32 with error plus 1/96, midpoint 21/64 with error minus 1/192, Simpson exactly 1/3.
Four equal subintervals for dimensionless x squared on zero to one: trapezoid 11/32 with error plus 1/96, midpoint 21/64 with error minus 1/192, Simpson exactly 1/3.
Original synthetic benchmark. Straight lines overestimate this convex curve, midpoint rectangles underestimate its integral, and Simpson reproduces the quadratic exactly. Errors use approximation minus exact integral.

Simpson's exact answer here does not mean that every composite approximation is exact, or that Simpson is exact for arbitrary smooth functions. On an equally spaced grid with even nn, it integrates every polynomial through degree three exactly. Trapezoid and midpoint are exact for affine functions.

More pieces improve resolution, not the rule's order

For this quadratic, a single trapezoid of width hh overestimates its local integral by h3/6h^3/6. Summing nn such errors gives nh3/6=1/(6n2)nh^3/6=1/(6n^2) on [0,1][0,1]. Thus the local cubic error becomes a global quadratic error as the number of pieces grows.

Doubling nn from four to eight reduces the trapezoid error from 1/961/96 to 1/3841/384, and the midpoint error magnitude from 1/1921/192 to 1/7681/768. Both fall by a factor of four. Composition has reduced the size of the errors while retaining second-order convergence.

More generally, on a fixed finite interval with a continuous second derivative, trapezoid and midpoint errors are O(h2)O(h^2). Simpson's error is O(h4)O(h^4) when the fourth derivative is continuous. In a regime where a nonzero leading error term dominates, halving hh gives error ratios approaching four or sixteen respectively. Exactness, cancellation, kinks and numerical rounding can change those observed ratios. A midpoint estimate is not guaranteed to beat a trapezoid estimate for every smooth function.

When pricing a payoff with a known kink, placing a partition boundary at the kink can be more useful than assuming a smooth-function error formula applies across it. For an unbounded integral, error from truncating the domain is another calculation: adding panels inside a fixed window does not account for omitted tails.

Finally, preserve units. If f(t)f(t) is a discounted cash-flow rate in USD/year and hh is in years, every weighted contribution and the final sum are in USD. Signed rates must retain their signs; taking absolute areas changes the integral.

For a finance-focused continuation, Root-Finding and Numerical Integration connects a composite trapezoid calculation to expectations and pricing. Its preview is public; the full lesson requires membership.

Sources

  • James Stewart, Single Variable Calculus: Early Transcendentals, 6th edition, Thomson Brooks/Cole, 2008, §7.7, “Approximate Integration”: composite formulas and derivative-based error bounds.
  • Tobin A. Driscoll and Richard J. Braun, Fundamentals of Numerical Computation, §5.6, “Numerical integration”: weighted samples, piecewise interpolation and global trapezoid convergence.
  • SciPy, scipy.integrate.simpson: composite Simpson integration and polynomial exactness under equal and unequal spacing.
Last updated
  • numerical integration
  • quadrature
  • trapezoid
  • midpoint
  • simpson
  • convergence
← Back to the glossaryBack to top ↑