The area under a curve, approximated by rectangles
The definite integral ∫f(x)dx from a to b is defined as the signed area between a curve and the x-axis. Bernhard Riemann's approach — the one taught first because it is the most direct — is to slice the interval [a,b] into n strips of width Δx = (b−a)/n, approximate the curve over each strip by a rectangle, and sum the rectangle areas:
Riemann sum = Σ f(xᵢ*) · Δx, i = 1 to n Δx = (b - a) / n xᵢ* = a sample point inside the i-th subinterval — which one you pick defines the rule
As n grows and Δx shrinks toward zero, the sum converges to the exact integral for any function that is continuous (or has only finitely many jump discontinuities) on [a,b] — this convergence, made rigorous, is what actually defines the Riemann integral, before it is ever connected to antiderivatives via the fundamental theorem of calculus.
Left, right, midpoint: where you sample matters
The four common rules differ only in the choice of xᵢ* and, for the trapezoid rule, in what shape replaces the rectangle. The left rule samples the left edge of each strip, the right rule the right edge; for a monotonically increasing function these systematically under- and over-estimate the true area respectively (and vice-versa for a decreasing function), so the true integral is always trapped between them. The midpoint rule samples the centre of each strip and its errors from the two sides of the curve mostly cancel, making it noticeably more accurate for the same n.
The trapezoid rule does not use a rectangle at all — it connects f(xᵢ) and f(xᵢ₊₁) with a straight line and sums trapezoid areas instead:
trapezoid sum = Δx · [ f(x₀)/2 + f(x₁) + f(x₂) + ... + f(xₙ₋₁) + f(xₙ)/2 ]
Convergence rates: why midpoint and trapezoid beat left/right
Error analysis via Taylor expansion shows the left and right rules have error that shrinks as O(1/n) — halving the strip width only halves the error. The midpoint and trapezoid rules both have error O(1/n²) — halving the strip width quarters the error — because their sampling cancels the leading-order curvature term of the Taylor expansion that left/right sampling does not. Interestingly the midpoint rule's error is typically about half the size of the trapezoid rule's, and of opposite sign, which is exactly why Simpson's rule (not covered by these four, but a natural next step) combines them 2:1 to cancel the O(1/n²) term entirely and reach O(1/n⁴).
Where each rule struggles
Every rule assumes f is reasonably smooth over each strip. Functions like sqrt(x) near x = 0, where the derivative blows up, or |x| near a kink, degrade the convergence rate of every rule — the trapezoid and midpoint rules lose their O(1/n²) advantage and fall back toward O(1/n) near such points, because the Taylor expansion that guarantees the faster rate assumes bounded second derivatives. Oscillatory functions like sin(x) at high strip counts converge as expected once each strip is narrower than the function's own wiggle, but at low n a rectangle can straddle a peak and a trough and cancel out real area entirely.
Why this matters beyond a calculus exercise
Most integrals that show up in physics, engineering and statistics have no closed-form antiderivative — the Gaussian ∫e^(−x²)dx being the most famous example — so numerical quadrature is not a fallback, it is the only option. The same left/right/midpoint/trapezoid family, extended to two and three dimensions, underlies finite-element structural analysis, and the underlying idea of approximating an integral by a weighted sum of sampled function values scales all the way up to Monte Carlo integration for the high-dimensional integrals that appear in computational finance and rendering.
Frequently asked questions
Why does the midpoint rule beat both the left and right rules for the same number of rectangles?
The left and right rules have error that shrinks proportionally to the strip width (O(1/n)), because they systematically over- or under-shoot on curved functions. The midpoint rule's error shrinks with the square of the strip width (O(1/n²)) because sampling the centre causes the curvature error on each side of the sample point to cancel to first order.
Is the trapezoid rule the same as averaging the left and right rules?
Yes, algebraically they are identical — the trapezoid sum equals the average of the left-rule sum and the right-rule sum. That is also why it inherits the same O(1/n²) convergence as the midpoint rule: averaging two O(1/n) estimates whose leading errors are opposite in sign cancels that leading error term.
Why do sqrt(x) and |x| make every rule converge more slowly?
The O(1/n²) error bound for the midpoint and trapezoid rules assumes the function has a bounded, continuous second derivative on each strip. sqrt(x) has a derivative that blows up at x = 0, and |x| has a kink with no second derivative at all, so near those points every rule falls back to something closer to its worst-case O(1/n) behaviour.
Try it live
Everything above runs in your browser — open Riemann Integral and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Riemann Integral simulation