What a Riemann sum does
A Riemann sum estimates the area under a curve by cutting the interval [a, b] into n strips of equal width Δx = (b − a) ÷ n and adding up simple shapes. The methods differ only in where they measure the height of each strip. As n grows, every method closes in on the definite integral. Use it to check homework, to see why the integral is defined as a limit, or to estimate an integral you can't do by hand.
The five methods
Right: Rₙ = Δx [f(x₁) + f(x₂) + … + f(xₙ)]
Midpoint: Mₙ = Δx [f(m₁) + f(m₂) + … + f(mₙ)], mᵢ the middle of each strip
Trapezoid: Tₙ = (Δx ÷ 2) [f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]
Simpson (n even): Sₙ = (Δx ÷ 3) [f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)]
Here xᵢ = a + iΔx. Simpson's rule fits a parabola through each pair of strips, which is why it needs an even n. It's also a weighted average of the other two good rules: S₂ₙ = (2Mₙ + Tₙ) ÷ 3.
Worked example
Estimate ∫₀² x² dx with n = 4. Then Δx = 0.5, the endpoints are 0, 0.5, 1, 1.5, 2, and the midpoints are 0.25, 0.75, 1.25, 1.75. The midpoint sum is 0.5 × (0.0625 + 0.5625 + 1.5625 + 3.0625) = 2.625. The exact integral is 2³ ÷ 3 = 8/3 ≈ 2.666667.
| Method (n = 4) | Value | Minus 8/3 |
|---|---|---|
| Left | 7/4 = 1.75 | −0.916667 |
| Right | 15/4 = 3.75 | 1.083333 |
| Midpoint | 21/8 = 2.625 | −0.041667 |
| Trapezoid | 11/4 = 2.75 | 0.083333 |
| Simpson | 8/3 = 2.666667 | 0 |
The left sum is too low and the right sum too high, because x² is increasing. Simpson's rule is exact here, because it's exact for every polynomial up to degree 3.
How big is the error?
If |f″(x)| ≤ M on [a, b], the midpoint error is at most M(b − a)³ ÷ (24n²) and the trapezoid error at most M(b − a)³ ÷ (12n²). If |f⁽⁴⁾(x)| ≤ M, Simpson's error is at most M(b − a)⁵ ÷ (180n⁴). Doubling n cuts the midpoint and trapezoid errors by about 4 and Simpson's by about 16. Left and right sums only improve in proportion to 1 ÷ n.
Limitations
- The "integral" row is exact for polynomials. For other functions it's a high-accuracy numerical value, and the page says so. If the function misbehaves, no reference is shown.
- If f is undefined at a point a method needs, such as 1/x at x = 0, that method is marked instead of returning a wrong number. An improper integral needs a limit, not a sum.
- Results are signed: area below the x-axis counts as negative.
Sources
- OpenStax Calculus Volume 1, 5.1: Approximating areas (left and right endpoint sums)
- OpenStax Calculus Volume 2, 3.6: Numerical integration (midpoint, trapezoidal and Simpson's rules, error bounds)
- NIST Digital Library of Mathematical Functions, §3.5: Quadrature (trapezoidal and Simpson's rules, with error terms)