Composite Numerical Integration
Composite midpoint, trapezoid, and Simpson calculations
In the equal-panel composite rules used here, the interval is divided into equal pieces and a local rule is applied on each piece. The sample locations and weights depend on the rule. These estimates need not equal the exact integral.
Panels and samples
A panel is one subinterval, so n equal panels on [a,b] have panel width h=(b−a)/n. The endpoint nodes are x0=a,x1,…,xn=b: there are n+1 of them. Midpoint samples instead lie halfway across the panels, giving exactly n sample locations.
For a composite rule, check the interval length, the panel count, and the locations where the function was measured before inserting values.
If x has units of time and f(x) has units of rate per time, multiplying a weighted sum of rates by h gives the corresponding accumulated quantity. The rule's weighted sum alone does not have those integral units.
Choosing and weighting a rule
The composite trapezoid rule uses endpoint samples: Tn=h[f0/2+f1+⋯+fn−1+fn/2]. Each shared interior node gets full weight in this collapsed expression because it contributes half an endpoint weight from each adjacent panel. Only the two outer endpoints are halved.
The composite midpoint rule uses one midpoint value per panel: Mn=h∑i=1nf(mi), where mi is the midpoint of panel i. The composite Simpson rule uses endpoint nodes but needs an even panel count: Sn=3h[f0+4f1+2f2+⋯+4fn−1+fn]. Its odd-indexed nodes have coefficient 4; its shared interior even-indexed nodes have coefficient 2.
Worked example
Suppose two panels span [0,4], with endpoint values f(0)=1, f(2)=3, and f(4)=9. The width is h=(4−0)/2=2, so the composite trapezoid estimate is T2=2[1/2+3+9/2]=16. The middle sample is counted fully, while the two outer samples each contribute half their value inside the bracket.
For the midpoint rule on these same panels, endpoint values alone are insufficient: it would need f(1) and f(3). Simpson can use the three stated endpoint values because two panels form one complete pair. Different rules may give different estimates from the same underlying function.
Three equal panels cover [0,6], and f at their midpoints 1,3,5 is 2,5,8. What is the composite midpoint estimate?
A table gives f at five equally spaced nodes x₀ through x₄. Which weighting is the composite Simpson estimate for four panels of width h?