Math ★☆☆ Easy

∫ Riemann Integral

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.

About this simulation

This simulator visualizes how Riemann sums approximate the definite integral ∫ab f(x) dx by splitting the interval [a, b] into n equal-width strips, Δx = (b−a)/n, and adding up the area of a rectangle or trapezoid built from each strip. Five sampling rules are implemented: left (height f(xᵢ)), right (f(xᵢₕ₁)), midpoint (f at the strip center), trapezoid (the average of the two endpoint heights), and Simpson's rule, which fits a parabola through the left endpoint, midpoint, and right endpoint of each strip pair. As you adjust the function, interval, subdivision count n, or rule, the canvas redraws the shaded strips live while the panel below reports the approximate sum, the closed-form exact integral, and the absolute error between them.

What it shows

The live convergence of five Riemann sum rules (left, right, midpoint, trapezoid, Simpson) toward the exact definite integral of a chosen function over [a, b], with the numeric error shrinking as the subdivision count n grows.

How to use it

Pick a function from the dropdown, drag the a / b sliders to set the interval, choose a sampling rule from the tabs, then drag the n slider — watch the shaded strips tighten around the curve and the error value fall.

Did you know?

Simpson's rule fits a parabola through just three sample points per strip pair, yet it integrates any cubic polynomial exactly — extra accuracy that costs almost nothing over the plain trapezoid rule.

Frequently Asked Questions

What is a Riemann sum?

A Riemann sum estimates the area under a curve f(x) on an interval [a, b] by dividing that interval into n equal-width strips of width Δx = (b−a)/n, choosing a sample height for each strip, and adding up the resulting rectangle (or trapezoid) areas. As n increases and Δx shrinks, the sum converges to the exact definite integral ∫ab f(x) dx — this simulator lets you watch that convergence happen for several functions and sampling rules at once.

What is the difference between the left, right, and midpoint rules?

All three build one rectangle per strip but sample f(x) at a different point: the left rule uses the height at the strip's starting point, the right rule uses the height at its endpoint, and the midpoint rule uses the height at the strip's center. For a monotonic function the left and right rules consistently over- or under-estimate the true area on opposite sides, while the midpoint rule's errors from either side of the strip largely cancel, which is why it is noticeably more accurate for the same n.

Why is Simpson's rule more accurate than the others?

Simpson's rule approximates each strip pair with a parabola through its left endpoint, midpoint, and right endpoint instead of a flat or linear top. Because a parabola can match the curvature of the function, not just its slope, Simpson's rule integrates any polynomial up to degree three exactly and its error shrinks much faster than the other rules as n grows, which you can confirm by comparing the Error readout across methods at the same n.

What does the n subdivisions slider actually control?

It sets how many equal-width strips the interval [a, b] is cut into, with each strip's width computed as Δx = (b−a)/n. This simulator lets n range from 1 to 200: at low n you see a handful of coarse rectangles that clearly miss the curve's shape, while at high n the strips become so thin that, for a smooth function, the shaded region visually merges with the true area under the curve.

Why does the error shrink as n increases?

As Δx = (b−a)/n gets smaller, each strip covers a shorter, straighter-looking piece of the curve, so the sampled height is a better stand-in for the strip's actual average height. The rate differs by rule: left and right sums converge roughly in proportion to Δx, midpoint and trapezoid converge roughly in proportion to Δx squared, and Simpson's rule converges roughly in proportion to Δx to the fourth power for smooth functions — which is exactly why dragging the n slider higher shrinks Simpson's error dramatically faster than the left or right sums.