Riemann Sum Calculator

A Riemann sum approximates the area under a curve by adding up the areas of thin rectangles. Left, right and midpoint sums use different heights for each rectangle, and the trapezoidal rule uses trapezoids instead. This calculator computes the sum, compares it with the exact integral, and draws every strip.

Try:

How to use the riemann sum calculator

  1. Type the function and the interval.
  2. Choose the number of strips n and the method.
  3. Press Calculate to see the sum, the error and the rectangles.

Formula

Δx=b−an\Delta x = \frac{b - a}{n}
∫abf(x) dx≈∑if(xi∗) Δx\int_a^b f(x)\,dx \approx \sum_{i} f(x_i^*)\,\Delta x

Worked example: x² on [0, 2], 8 midpoints

  • f(x) =: x^2
  • From x =: 0
  • To x =: 2
  • Number of rectangles n: 8
  • Method: Midpoints

✓ Answer checked

midpoint sum≈2.65625\text{midpoint sum} \approx 2.65625
Exact integral
2.6666666672.666666667
Error
−0.01042-0.01042
Width Δx
0.250.25
0.511.5212345f(x)
8 rectangles of width 0.25. Their total area, 2.65625, approximates the exact area 2.6666667.
Step-by-step working (4 steps)
  1. Width of each strip

    Split [0, 2] into 8 equal strips.

    Δx=b−an=0.25\Delta x = \frac{b - a}{n} = 0.25
  2. Rectangle heights Midpoint sum

    Each rectangle's height is f at the middle of its strip.

    S=Δx∑if(xi∗)S = \Delta x \sum_{i} f(x_i^*)
  3. Add them up

    Sum the areas of all the strips.

    ≈2.65625\approx 2.65625
  4. Compare with the exact integral

    More strips give a smaller error.

    ∫02x2 dx=2.666666667\int_{0}^{2} x^{2}\,dx = 2.666666667
Formulas used
Δx=b−an\Delta x = \frac{b-a}{n}
∫abf(x) dx=lim⁡n→∞∑f(xi∗) Δx\int_a^b f(x)\,dx = \lim_{n\to\infty} \sum f(x_i^*)\,\Delta x
How this was checked
  • ✓ Adding the strips in reverse order gives the same total.

Frequently asked questions

Which Riemann sum is most accurate?

For smooth functions, the midpoint and trapezoidal rules are usually much more accurate than left or right sums with the same n.

What happens as n gets bigger?

The strips get thinner and the sum gets closer to the exact integral. In the limit, it equals the integral.

When is a left sum an overestimate?

When the function is decreasing, because each rectangle uses the higher left-hand value.

Related calculators

Related guides