Midpoint Rule

Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

The midpoint rule is a Riemann-style quadrature method that evaluates \(f\) at subinterval midpoints instead of endpoints. For a uniform partition of \([a,b]\) into \(n\) pieces with \(\Delta x=(b-a)/n\), the composite midpoint approximation is

\[ M_n = \Delta x \sum_{i=0}^{n-1} f\!\left(a + \left(i+\tfrac12\right)\Delta x\right). \]

Geometrically, each subinterval contributes a rectangle centered at its midpoint sample. The method is often much more accurate than left/right endpoint sums at the same \(n\).

Animations

The animation below shows the midpoint-rectangle construction for \(y = e^{-x}\sin(8x^{2/3})+1\) on \([0,2]\). Each frame increases sample-point density across the full interval and updates the integral estimate.

Legacy midpoint animation assets are partially missing from the archive; this reconstruction uses the same function, interval, and density-increase pacing seen in the available quadrature GIFs.

Case 1 — Midpoint Rule, \(y = e^{-x}\sin(8x^{2/3})+1\)

Behavior: The midpoint sample in each subinterval tracks local curve height better than endpoint samples, so the estimate stabilizes quickly as density increases.

Julia source

Midpoint Rule animation over [0,2]: each frame increases partition density and recomputes midpoint-rectangle area

Derivation Notes

For smooth \(f\), midpoint rule has global error order \(O(\Delta x^2)\), i.e. doubling the number of subintervals reduces error by roughly a factor of 4.

Worked Example

Using \(f(x)=e^{-x}\sin(8x^{2/3})+1\) on \([0,2]\), the frame-by-frame approximation in the animation converges as \(n\) grows.

Implementation Notes

The script keeps axis limits fixed so only density and approximation change between frames, mirroring legacy animation behavior.

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.