UTILS.
100% in-browser
📊

Riemann Sum Calculator

Approximate the area under f(x) on [a,b] with left, right, midpoint or trapezoid rules and n subintervals, with the error versus the exact integral.

Enter f(x), the interval, subintervals, and a rule. Bounds accept numbers, pi or e.

About this tool

The Riemann Sum Calculator is a free, in-browser calculus tool that approximates the area under a curve y = f(x) on an interval [a, b] by dividing it into n equal subintervals of width Δx = (b − a)/n and summing rectangle or trapezoid areas. It computes all four standard rules: the left sum Σf(xᵢ)·Δx over i = 0…n−1, the right sum over i = 1…n, the midpoint sum using the center of each subinterval, and the trapezoid rule (Δx/2)·[f(x₀) + 2·Σf(xᵢ) + f(xₙ)].

Everything is calculated locally in your browser, so nothing you enter is sent anywhere. Choose the interval, the number of subintervals n, and which rule to highlight; the tool draws the corresponding rectangles or trapezoids over the curve on a canvas so you can see how the approximation covers the region. Type the integrand with the usual operators, ^ for powers, parentheses, the constants pi and e, and functions such as sin, cos, exp, ln and sqrt.

To show accuracy, the calculator also computes a high-resolution reference value with composite Simpson's rule and reports the absolute and relative error of your chosen method against it. As you increase n the rectangles hug the curve more tightly and the error shrinks — the midpoint and trapezoid rules converge much faster than the left or right sums. For x² on [0, 2] the exact area is 8/3 ≈ 2.6667, and the midpoint rule with only 10 subintervals is already very close.

Frequently asked questions

What is the difference between the four rules?
Left and right sums use the function value at the left or right edge of each subinterval as the rectangle height; the midpoint rule uses the value at the center; the trapezoid rule averages the two edge values, forming a trapezoid. Midpoint and trapezoid are usually far more accurate.
How is the error measured?
The tool computes a high-accuracy reference integral with composite Simpson's rule (2000 subintervals) and compares your chosen method to it, reporting the absolute error |estimate − exact| and the relative error as a percentage of the exact value.
What does increasing n do?
More subintervals make each rectangle or trapezoid narrower, so the staircase hugs the curve more closely and the error decreases. Left and right sums improve roughly like 1/n, while midpoint and trapezoid improve like 1/n², converging much faster.
What is the Riemann sum of x² on [0, 2]?
The exact area is ∫₀² x² dx = 8/3 ≈ 2.6667. With n = 10 the left sum underestimates and the right sum overestimates, while the midpoint and trapezoid rules land very close to 2.6667; larger n tightens all four.

More tools