Simpson’s 3/8 Rule for Numerical Integration

← Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

Simpson’s 3/8 rule approximates a definite integral \(\int_a^b f(x)\,dx\) from values of \(f\) at equally spaced points. It splits \([a,b]\) into \(n\) subintervals of width \(h=(b-a)/n\), with nodes \(x_i=a+ih\) for \(i=0,1,\dots,n\), and on each block of three subintervals \([x_{3k-3},x_{3k}]\) it replaces \(f\) by the cubic through the four nodes. Adding the areas under the cubics gives the composite rule \[ S^{3/8}_n = \frac{3h}{8}\sum_{k=1}^{n/3}\left[f(x_{3k-3})+3f(x_{3k-2})+3f(x_{3k-1})+f(x_{3k})\right], \] or, collecting the weights, \[ S^{3/8}_n = \frac{3h}{8}\left[f(x_0)+f(x_n)+3\sum_{0<i<n,\ i\not\equiv 0\,(\mathrm{mod}\,3)} f(x_i)+2\sum_{0<i<n,\ i\equiv 0\,(\mathrm{mod}\,3)} f(x_i)\right]. \]

Each cubic spans three subintervals, so \(n\) must be a multiple of 3. The sums converge to the integral for any continuous \(f\), but the error formula below needs \(f\) to be four times continuously differentiable on \([a,b]\), \(f\in C^4[a,b]\).

Like Simpson’s rule, the 3/8 rule is exact for every cubic. The general result, as Mathews states it: if \(f\in C^4[a,b]\), there is a \(c\) with \(a<c<b\) such that \[ \int_a^b f(x)\,dx - S^{3/8}_n = -\frac{(b-a)\,f^{(4)}(c)}{80}\,h^4 . \] The error is therefore \(O(h^4)\), and halving \(h\) typically divides it by about 16. The order is the same as Simpson’s rule, but the constant \(1/80\) is \(9/4\) times Simpson’s \(1/180\), so for smooth \(f\) at the same \(h\) the 3/8 rule’s error is typically about 2.25 times larger. The animation on this page does not show the \(h^4\) rate, because its integrand is not in \(C^4[0,2]\).

Case 1 shows what happens when that hypothesis fails. Its integrand \(f(x)=e^{-x}\sin(8x^{2/3})+1\) has \(f'\) unbounded at \(x=0\), and the error shrinks only like \(h^{5/3}\): in the table below, halving \(h\) divides it by 4.32, then 3.40, then 3.22, approaching \(2^{5/3}\approx 3.17\), not 16. The coarse frames also show the cost of wide panels: at \(n=6\) the first cubic, on \([0,1]\), never rises above 1.37 while \(f\) peaks at about 1.92 near \(x=0.080\), and the error grows from \(-0.132\) at \(n=3\) to \(-0.226\).

\(n\) \(h\) \(S^{3/8}_n\) \(S^{3/8}_n-I\) ratio
15 \(2/15\) 1.994094 \(-0.02219\)
30 \(1/15\) 2.011141 \(-0.005139\) 4.32
60 \(1/30\) 2.014767 \(-0.001513\) 3.40
120 \(1/60\) 2.015810 \(-0.0004693\) 3.22

The rows are frames of Case 1, each halving \(h\), against \(I=\int_0^2 f(x)\,dx\approx 2.016280\); the ratio is the previous row’s error divided by this row’s.

Simpson’s 3/8 rule is the degree-3 member of the Newton-Cotes family, between Simpson’s Rule and Boole’s Rule, and the two Simpson rules combine: when \(n\ge 5\) is odd, one 3/8 block plus Simpson’s rule on the remaining even number of subintervals covers \([a,b]\).

Animations

Each animation below shows the Simpson’s 3/8 rule diagram over \([0,2]\) for \(y = e^{-x}\sin(8x^{2/3})+1\). Each frame recomputes the approximation across the full interval with a denser partition where \(n\) remains a multiple of 3. Red dots mark the sample points \(x_i\), and vertical red lines mark the panel boundaries \(x_{3k}\).

Julia source scripts that generated these animations are linked under each case.

Case 1 — Composite Simpson’s 3/8 Rule, \(f(x)=e^{-x}\sin(8x^{2/3})+1\) on \([0,2]\)

Behavior: Piecewise cubic panels over triplets of subintervals are rebuilt at increasing density. Every approximation shown lies below the true integral \(\int_0^2 f(x)\,dx \approx 2.016280\). The error grows from 4 to 7 sample points, then shrinks at every later frame; the last frame (121 sample points) gives 2.01581, about 0.00047 low. The \(x^{2/3}\) term makes \(f'\) unbounded at \(x=0\) (\(f'(x)\approx \tfrac{16}{3}x^{-1/3}\) near \(0\)), so the textbook error order, which assumes smooth \(f\), does not hold for this integrand. The measured error shrinks like \(O(h^{5/3})\) rather than \(O(h^4)\): halving \(h\) divides it by about 3.22 (from 60 to 120 subintervals), tending to \(2^{5/3}\approx 3.17\), instead of 16.

Julia source

Simpson’s 3/8 Rule animation over [0,2] with full-interval density refinement: after an opening frame showing only f, each frame shows the sample points as red dots, the panel boundaries as vertical red lines, the piecewise cubic panels and the global approximation

Legacy note: this animation reconstructs Mathews’ archived animation Simpsonaa.gif. It uses the same integrand and interval and ends at the same 121-point approximation, 2.015810, but steps through a different sequence of intermediate \(n\).

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.