Choose a function and method, drag the interval and subdivisions
slider — watch the shaded bars home in on the exact area under the
curve.
—
Approximation
—
Exact integral
—
Error
—
Riemann Sums
A Riemann sum approximates the area under f(x) by summing the
areas of n rectangles (or trapezoids) of equal width Δx = (b−a)/n.
As n → ∞ the sum converges to the exact definite integral ∫ₐᵇ f(x)
dx.
Left rule: rectangle height = f(xᵢ) |
Right rule: f(xᵢ₊₁) |
Midpoint: f(xᵢ + Δx/2) |
Trapezoid: [f(xᵢ)+f(xᵢ₊₁)]/2 |
Simpson: [f(xᵢ)+4f(mid)+f(xᵢ₊₁)]/6 per pair.
∫ Riemann Integral
About this simulation
A Riemann sum estimates the area under a curve by slicing the interval
into thin strips and adding up the area of each one — the foundational
idea behind the definite integral. Numerical integration like this powers
everything from physics engines and signal processing to financial
modelling, where exact antiderivatives often do not exist. It is
fascinating to watch jagged rectangles tighten into the smooth, exact area
as you add more subdivisions.
How it works
Pick a function f(x) and an interval [a, b].
The interval is split into n strips of equal width Δx = (b−a)/n.
Each strip's height is sampled by the chosen rule (left, right, midpoint, trapezoid or Simpson).
The strip areas are summed and compared against the exact integral to reveal the error.
Key equations
∫[a,b] f(x) dx ≈ Δx · Σ f(x_i) — Δx = (b−a)/n is the strip
width, x_i the sample points, and the sum runs over all n strips.
Controls
Method tabs — switch between Left, Right, Midpoint, Trapezoid and Simpson rules.
Function — choose the curve f(x) to integrate.
a / b sliders — set the lower and upper limits of the interval.
n slider — change the number of subdivisions and watch the error shrink.
Did you know?
Simpson's rule fits a parabola through each pair of strips, so it
integrates any cubic polynomial exactly — even though it only looks at
three sample points. That extra accuracy is almost free, which is why it
remains a workhorse of scientific computing.