Riemann Sum Calculator

Approximate the area under f(x) with left, right, midpoint or trapezoidal Riemann sums, drawn as rectangles and compared with the integral.

Examples: x^2, sqrt(x), 1/x, sin(x), e^(-x). Trig functions use radians.
Sample point
Δx (width)
0.5
Method
Left endpoint
Integral (accurate)
2.6666666667Simpson's rule, 4,000 strips
Error of this sum
−0.916734.4% of the integral
Left endpoint sum, n = 41.75
  • Increase n to make the rectangles thinner; every Riemann sum approaches the definite integral as n grows.

Show the work

  1. Width of each sub-interval: Δx = (b − a) ÷ n = (2 − 0) ÷ 4 = 0.5.
  2. Left endpoint sum: S = Δx × Σ f(xi), using xi = a + iΔx for i = 0 … n−1.
  3. S = 0.5 × [f(0) + f(0.5) + f(1) + f(1.5)]
    = 0.5 × [0 + 0.25 + 1 + 2.25]
    = 0.5 × 3.5
  4. Left endpoint sum = 1.75
00.511.52012345

Blue shapes add area; gold shapes (below the x-axis) subtract it.

Left endpoint Riemann sum terms
iSample xf(x)Rectangle area
1000
20.50.250.125
3110.5
41.52.251.125

A Riemann sum approximates the area under a curve by slicing it into thin strips, replacing each strip with a rectangle (or trapezoid), and adding up the areas. It is the idea the definite integral is built on. This calculator draws the strips, lists every term, and measures how far the approximation is from the true integral.

How to use the Riemann sum calculator

  1. Enter the function, for example x^2, sqrt(x) or sin(x).
  2. Enter the interval start a and end b.
  3. Choose the number of rectangles n.
  4. Choose the sample point: left endpoint, right endpoint, midpoint, or trapezoid.
  5. Read the sum on the tape, the rectangles on the graph, and each term in the table.

Riemann sum formulas

Every version starts with the same width, Δx = (b − a)/n, and the grid points xi = a + iΔx.

Method Formula
Left Ln = Δx[f(x0) + f(x1) + … + f(xn−1)]
Right Rn = Δx[f(x1) + f(x2) + … + f(xn)]
Midpoint Mn = Δx Σ f((xi−1 + xi)/2)
Trapezoid Tn = (Ln + Rn)/2

In sigma notation the general Riemann sum is Σ f(xi)Δx, where xi is any point in the i-th strip. The definite integral is the limit of these sums as n → ∞.

Worked example

Approximate the area under f(x) = x2 from 0 to 2 with n = 4. Then Δx = 0.5.

Left: 0.5 × [f(0) + f(0.5) + f(1) + f(1.5)] = 0.5 × [0 + 0.25 + 1 + 2.25] = 0.5 × 3.5 = 1.75

Right: 0.5 × [0.25 + 1 + 2.25 + 4] = 0.5 × 7.5 = 3.75

Midpoint: 0.5 × [0.0625 + 0.5625 + 1.5625 + 3.0625] = 0.5 × 5.25 = 2.625

Trapezoid: (1.75 + 3.75) ÷ 2 = 2.75

Exact integral: 23/3 = 8/3 ≈ 2.6667

Because x2 is increasing on [0, 2], the left sum underestimates and the right sum overestimates. Because it curves upward, the trapezoid overestimates slightly and the midpoint underestimates by about half as much.

Over- or underestimate? A quick guide

Shape of f on [a, b] Left sum Right sum Midpoint Trapezoid
Increasing under over — —
Decreasing over under — —
Concave up (curving upward) — — under over
Concave down — — over under

When a function both increases and changes concavity on the interval, the errors can partly cancel, so check the table and the error value rather than relying on the rule of thumb.

Why Riemann sums matter

Riemann sums turn a continuous problem into ordinary arithmetic, which is exactly how data is handled in practice. A speedometer read every minute, rainfall measured every hour, or power use logged every 15 minutes can all be totaled with a Riemann sum, with no formula for the underlying function at all. In that setting, the trapezoidal rule is the usual choice.

For a high-accuracy value of the integral itself, use the definite integral calculator; to list function values at evenly spaced points first, try the function table calculator.

Frequently asked questions

Which Riemann sum is most accurate?

For smooth functions the midpoint and trapezoidal sums are usually far more accurate than left or right sums, and the midpoint error is typically about half the trapezoid error with the opposite sign.

When does a left sum overestimate?

When the function is decreasing on the interval: the left edge of each rectangle is its highest point, so every rectangle pokes above the curve. For an increasing function the left sum underestimates.

What happens as n grows?

The rectangles get thinner and every type of sum approaches the definite integral. Doubling n roughly halves the error of left and right sums and quarters the error of midpoint and trapezoid sums.

Why are some rectangles drawn in gold?

Those rectangles lie below the x-axis, where f(x) is negative. They subtract from the total, because a Riemann sum measures signed area.

Last reviewed October 2026 by the CalcFluent editorial team. How we check our calculators.