Newton-Cotes Integration
Source inspiration: (Mathew 2000-2019).
Description
Newton-Cotes formulas approximate \(\int_a^b f(x)\,dx\) by interpolating \(f\) on equally spaced nodes and integrating the interpolating polynomial on each panel. Familiar composite rules include trapezoidal (degree 1), Simpson’s \(1/3\) (degree 2), Simpson’s \(3/8\) (degree 3), and Boole’s rule (degree 4).
For spacing \(h\), representative composite forms are: \(T_n = h\big[\tfrac12 f(x_0)+\sum_{i=1}^{n-1}f(x_i)+\tfrac12 f(x_n)\big]\), \(S_n = \tfrac{h}{3}[f(x_0)+f(x_n)+4\sum f(x_{2k-1})+2\sum f(x_{2k})]\).
The animations below follow the legacy style by increasing point density over the full interval between frames.
Animations
Each case uses \(f(x)=e^{-x}\sin(8x^{2/3})+1\) on \([0,2]\) and shows a different closed Newton-Cotes construction while sample density increases frame by frame.
Case 1 — Composite Trapezoidal Rule
Behavior: Linear segments connect adjacent sample points, creating trapezoids that refine as nodes get denser.

Case 2 — Composite Simpson’s Rule (1/3)
Behavior: Pairs of subintervals are approximated by quadratics, producing a visibly smoother top boundary than trapezoids.

Case 3 — Composite Simpson’s 3/8 Rule
Behavior: Triplets of subintervals are approximated by cubics, giving a higher-order piecewise fit to the curve.

Case 4 — Composite Boole’s Rule
Behavior: Blocks of four subintervals use quartic interpolation. As density rises, the piecewise quartic envelope tracks oscillations closely.

Legacy note: the archive is incomplete for some quadrature assets (notably Simpson’s 3/8 GIF), so the 3/8 case is reconstructed from method formulas and the available module examples.
Derivation Notes
The closed Newton-Cotes family on equally spaced nodes increases algebraic order by fitting higher-degree interpolants per panel. Higher-order rules reduce truncation error for smooth functions, but can become less robust for very high degree on wide panels.