Riemann Sum Calculator

A Riemann sum approximates the area under a curve by adding the areas of rectangles. For f(x) = x² on [0, 3] with n = 6, the midpoint sum is 8.9375 against an exact integral of 9, an error of −0.0625.

Last updated · By · Runs in your browser, nothing is uploaded

Result

Step-by-Step Solution

Enter your values above to see the full working.

What Is a Riemann Sum?

A Riemann sum approximates the area between a curve and the x-axis by slicing the interval into n thin strips and adding up the areas of simple shapes, usually rectangles. As the strips get thinner, the approximation improves, and in the limit as n → ∞ it becomes the exact definite integral. That limit is how integration is defined.

The choice of where to measure each rectangle’s height gives different methods: the left endpoint, the right endpoint, the midpoint, or averaging both sides (the trapezoid rule). Their accuracy differs, and comparing them on a curve whose exact area you know is the best way to understand them.

The Four Methods for x² on [0, 3], n = 6

MethodHeight taken atSumError vs exact 9
Left endpointLeft side of each strip6.875−2.125
Right endpointRight side of each strip11.375+2.375
MidpointMiddle of each strip8.9375−0.0625
TrapezoidAverage of both sides9.125+0.125

Riemann Sum Formulas

Δx = (b − a) ÷ n Left: Δx · Σ f(a + iΔx) i = 0 … n − 1 Right: Δx · Σ f(a + iΔx) i = 1 … n Mid: Δx · Σ f(a + (i + ½)Δx) i = 0 … n − 1 Trap: (Left + Right) ÷ 2
  • a and b are the limits of integration.
  • n is the number of subintervals, and Δx is the width of each.
  • The left and right sums under- or over-estimate for increasing functions. The midpoint and trapezoid rules are usually more accurate because errors cancel.
  • For an exact answer on polynomials, use the polynomial integral calculator.

Worked Example: ∫₀³ x² dx with the Midpoint Rule

  1. Δx = (3 − 0) ÷ 6 = 0.5.
  2. The midpoints of the six strips are 0.25, 0.75, 1.25, 1.75, 2.25 and 2.75.
  3. Squares: 0.0625, 0.5625, 1.5625, 3.0625, 5.0625, 7.5625, adding to 17.875.
  4. Midpoint sum: 0.5 × 17.875 = 8.9375.
  5. The exact integral is 3³ ÷ 3 = 9, so the error is −0.0625.

Left and Right Sums

The left heights are f(0), f(0.5), …, f(2.5) = 0, 0.25, 1, 2.25, 4, 6.25, which sum to 13.75, giving 0.5 × 13.75 = 6.875 (an underestimate because x² is increasing). The right heights are 0.25, 1, 2.25, 4, 6.25, 9, which sum to 22.75, giving 11.375 (an overestimate). Their average, 9.125, is the trapezoid sum.

More Rectangles, Better Accuracy

Increasing n shrinks the error. For the left and right sums, the error is roughly proportional to 1 ÷ n, so doubling n halves it. For the midpoint and trapezoid rules, it is proportional to 1 ÷ n², so doubling n cuts the error to about a quarter.

Which Methods Over- or Under-Estimate?

CurveLeft sumRight sumMidpointTrapezoid
IncreasingToo lowToo high
Concave up (like x²)Too lowToo high
Concave downToo highToo low

For x² (increasing and concave up), the left sum 6.875 is low, the right sum 11.375 is high, the midpoint 8.9375 is slightly low and the trapezoid 9.125 is slightly high, bracketing the exact value of 9.

Distance from Sampled Speeds

A car’s speed is recorded every 10 seconds as 0, 8, 12, 14 and 15 m/s. The trapezoid rule gives the distance: 10 × (0 ÷ 2 + 8 + 12 + 14 + 15 ÷ 2) = 415 m.

How to Use This Riemann Sum Calculator

  1. Type your polynomial f(x).
  2. Enter the lower limit a and the upper limit b.
  3. Enter the number of subintervals n.
  4. Choose left, right, midpoint or trapezoid.
  5. Read the approximate sum, the exact integral, the error and the width Δx.

For an even better method, try Simpson’s rule, which uses parabolas instead of straight lines.

Where Riemann Sums Are Used

  • Calculus education: the definition of the definite integral.
  • Numerical computing: estimating integrals that have no closed form.
  • Engineering and science: accumulating measured data, such as distance from sampled speeds or total energy from sampled power.
  • Finance and statistics: approximating areas under probability density curves.
  • Computer graphics: numerical integration for lighting calculations.

What Are the Most Common Mistakes With the Riemann Sum Calculator?

  • Wrong width. Δx = (b − a) ÷ n, not b ÷ n.
  • Off-by-one endpoints. The left sum uses the points a to b − Δx, and the right sum uses a + Δx to b.
  • Misreading error signs. Error = approximation − exact in this calculator.
  • Assuming left sums under-estimate always. That is true only for increasing functions. For decreasing functions it reverses.
  • Too few subintervals. Small n gives crude estimates.
  • Ignoring negative areas. Parts of the curve below the axis count as negative.

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What is a Riemann sum?

A sum of areas of rectangles that approximates the area under a curve. As the rectangles get thinner, the sum approaches the exact definite integral.

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

They measure each rectangle’s height at the left end, right end or middle of its strip. The midpoint is usually more accurate.

How does the trapezoid rule work?

It replaces each strip’s top with a straight slanted line, which is the average of the left and right sums.

How many subintervals do I need?

More subintervals give a better approximation. Watch the error as you increase n. Midpoint and trapezoid errors fall roughly with the square of n.

Why is the left sum too low for x²?

Because x² is increasing, so each left-end rectangle is shorter than the curve over its strip.

What is the exact value of ∫₀³ x² dx?

9, since the antiderivative is x³ ÷ 3 and 27 ÷ 3 = 9.