Numerical Integration

Compares Riemann sums, the trapezoid rule, and Simpson’s rule for approximating a definite integral.
Author

Apurva Nakade

Published

July 13, 2026

NoteConvergence plots

Approximates \(\int_a^b f(x)\, dx\) by replacing \(f\) with a simple piecewise interpolant on \(n\) equally spaced subintervals of width \(h=(b-a)/n\), at nodes \(x_i=a+ih\), and integrating that interpolant exactly:

\[ L_n = h\sum_{i=0}^{n-1} f(x_i), \qquad M_n = h\sum_{i=0}^{n-1} f\!\left(x_i+\tfrac{h}{2}\right), \]

\[ T_n = h\left(\tfrac{1}{2}f(x_0)+f(x_1)+\cdots+f(x_{n-1})+\tfrac{1}{2}f(x_n)\right), \]

\[ S_n = \frac{h}{3}\Big(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+\cdots+4f(x_{n-1})+f(x_n)\Big)\quad(n\text{ even}), \]

a left or midpoint rectangle sum, a trapezoid sum, or (for Simpson’s rule) a quadratic through each pair of subintervals.