Riemann Sum Calculator

Calculate definite integrals and approximate the area under a curve with our Riemann Sum Calculator. Choose from Left, Right, Midpoint, or Trapezoidal sums, enter your function, interval, and number of subintervals, and get a step-by-step solution.

Share Your Feedback

How was your experience with this calculator?

Use this free Riemann sum calculator to approximate the area under a curve. Enter your function, set the interval and the number of subintervals, choose a method, and get the answer with every step worked out. It works for left, right, midpoint and trapezoidal sums, so you can compare methods side by side and check your homework with confidence.

How to Use the Riemann Sum Calculator

  1. Enter the function f(x). For example, x^2, sin(x), e^x or 1/x.
  2. Set the limits. Type the lower limit a and the upper limit b of the interval [a, b].
  3. Choose the number of subintervals (n). More subintervals give a more accurate approximation.
  4. Select the method. Pick Left, Right, Midpoint or Trapezoidal.
  5. Click Calculate. You will see the width of each subinterval, the sample points, the function values and the final sum, with each step shown.

Tip: Run the same function with n = 4, 8 and 16 to watch the approximation approach the exact value of the integral.

What Is a Riemann Sum?

A Riemann sum is a way to estimate the area between a function and the x-axis by splitting the region into thin rectangles (or trapezoids), finding the area of each, and adding them up. It is named after the German mathematician Bernhard Riemann and is the idea behind the definite integral.

If you divide the interval [a, b] into n equal pieces, each piece has width:

\(\Delta\) x = \(\frac{b-a}{n}\)

On each piece you pick a sample point, measure the height of the function there, and multiply height by width. Adding all of these gives the Riemann sum. As n grows and Δx shrinks, the sum gets closer to the true area. In the limit, it becomes the definite integral:

\[ \int_a^b f(x)\,dx = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^*)\,\Delta x \]

Here \[ x_i^* \] is the sample point chosen in the i-th subinterval.

Riemann Sum Formulas

The four methods differ only in where the height of each rectangle is measured. In every formula below, the subinterval endpoints are:

\[ x_i = a + i\,\Delta x \]

Left Riemann Sum Formula

The height comes from the left endpoint of each subinterval.

\[L_n = \Delta x \sum_{i=0}^{n-1} f(x_i) = \Delta x \left[ f(x_0) + f(x_1) + \cdots + f(x_{n-1}) \right]\]

Right Riemann Sum Formula

The height comes from the right endpoint of each subinterval.

\[R_n = \Delta x \sum_{i=1}^{n} f(x_i) = \Delta x \left[ f(x_1) + f(x_2) + \cdots + f(x_n) \right]\]

Midpoint Riemann Sum Formula

The height comes from the middle of each subinterval, where the midpoint is:

\[m_i = \frac{x_{i-1} + x_i}{2}\]

\[M_n = \Delta x \sum_{i=1}^{n} f(m_i) = \Delta x \left[ f(m_1) + f(m_2) + \cdots + f(m_n) \right]\]

Trapezoidal Rule Formula

Instead of rectangles, each slice is a trapezoid whose top edge joins the two endpoint heights.

\[T_n = \frac{\Delta x}{2} \left[ f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n) \right]\]

The trapezoidal sum is also the average of the left and right sums:

\[T_n = \frac{L_n + R_n}{2}\]

Worked Example

Problem: Approximate the area under f(x) = x² on [0, 2] using n = 4 subintervals.

Step 1: Find Δx.

\[\Delta x = \frac{2-0}{4} = 0.5\]

Step 2: List the points.

\[ x_0 = 0,\; x_1 = 0.5,\; x_2 = 1,\; x_3 = 1.5,\; x_4 = 2 \]

Step 3: Compute each sum.

Left sum: the heights at 0, 0.5, 1 and 1.5 are 0, 0.25, 1 and 2.25.

\[L_4 = 0.5 \times (0 + 0.25 + 1 + 2.25) = 0.5 \times 3.5 = 1.75\]

Right sum: the heights at 0.5, 1, 1.5 and 2 are 0.25, 1, 2.25 and 4.

\[R_4 = 0.5 \times (0.25 + 1 + 2.25 + 4) = 0.5 \times 7.5 = 3.75\]

Midpoint sum: the midpoints are 0.25, 0.75, 1.25 and 1.75, with heights 0.0625, 0.5625, 1.5625 and 3.0625.

\[M_4 = 0.5 \times (0.0625 + 0.5625 + 1.5625 + 3.0625) = 0.5 \times 5.25 = 2.625\]

Trapezoidal sum:

\[T_4 = \frac{0.5}{2} \left[ 0 + 2(0.25) + 2(1) + 2(2.25) + 4 \right] = 0.25 \times 11 = 2.75\]

Step 4: Compare with the exact value. The exact integral is:

\[\int_0^2 x^2\,dx = \left[ \frac{x^3}{3} \right]_0^2 = \frac{8}{3} \approx 2.6667\]

MethodApproximationError
Left1.75−0.9167 (underestimate)
Right3.75+1.0833 (overestimate)
Midpoint2.625−0.0417 (underestimate)
Trapezoidal2.75+0.0833 (overestimate)

The midpoint and trapezoidal methods are far more accurate than the left and right sums for the same n.

Which Method Should You Use?

MethodBest forAccuracy
LeftQuick estimates, textbook exercisesLowest
RightQuick estimates, textbook exercisesLowest
MidpointSmooth functions, better accuracy with the same nHigh
TrapezoidalTabulated data and curves without sharp changesHigh

Overestimate or Underestimate?

For a function that is increasing on the interval, the left sum underestimates the area and the right sum overestimates it. For a decreasing function, it is the other way around.

For a function that is concave up (curving upward), the trapezoidal rule overestimates and the midpoint rule underestimates. For a concave down function, the reverse is true.

How Accurate Is the Approximation?

Accuracy improves as you increase n. These standard error bounds show how fast, where K bounds |f″(x)| and M bounds |f′(x)| on [a, b]:

Left and Right:

\[ |E_L|,\ |E_R| \le \frac{M\,(b-a)^2}{2n} \]

Trapezoidal:

\[ |E_T| \le \frac{K\,(b-a)^3}{12\,n^2} \]

Midpoint:

\[ |E_M| \le \frac{K\,(b-a)^3}{24\,n^2} \]

Because the midpoint and trapezoidal errors shrink with n², doubling the number of subintervals cuts their error by roughly a factor of four. The midpoint rule typically has about half the error of the trapezoidal rule.

Why Riemann Sums Matter

Riemann sums are more than a classroom exercise. They are used to:

  • Define the definite integral and prove the Fundamental Theorem of Calculus
  • Estimate area, distance and accumulated change when no antiderivative is available
  • Work with data tables, such as speed readings taken every few seconds
  • Power numerical integration in physics, engineering, economics and computer science

Common Mistakes to Avoid

  • Using the wrong Δx. Always divide the interval length by n, not by n + 1.
  • Mixing up endpoints. The left sum skips the last point, and the right sum skips the first.
  • Forgetting the midpoints. The midpoint method evaluates f at the center of each piece, not at the endpoints.
  • Mistakes in the trapezoid weights. Only the first and last values are counted once. All the others are doubled.
  • Calculator in the wrong mode. For trigonometric functions, make sure you are using radians unless the problem says otherwise.

Frequently Asked Questions

What is a Riemann sum calculator?

It is a tool that approximates the definite integral of a function by adding up the areas of rectangles or trapezoids under the curve. Ours also shows each calculation step.

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

They measure the height of each rectangle at a different place: the left end, the right end or the middle of the subinterval. The midpoint method is usually the most accurate of the three.

How many subintervals should I use?

Use as many as you need for the accuracy you want. For homework, follow the n given in the problem. To see convergence, try n = 10, 100 and 1,000.

Is the trapezoidal rule a Riemann sum?

Strictly speaking it is a related approximation, but it equals the average of the left and right Riemann sums, so it is usually taught alongside them.

Can a Riemann sum be negative?

Yes. Where the function lies below the x-axis, the heights are negative, so those parts count as negative area.

Can I use the calculator for functions that change sign?

Yes. The result is the net signed area: area above the x-axis minus area below it.

How is a Riemann sum different from an integral?

A Riemann sum is an approximation using a finite number of pieces. The definite integral is the exact value you get in the limit as the number of pieces goes to infinity.

Is this calculator free?

Yes. It is completely free, with no sign-up required.

Conclusion

Whether you are learning how integration works or checking a tricky problem, this Riemann sum calculator gives you fast, clear and fully worked-out answers. Enter your function, pick a method, and see exactly how the area under the curve is built, one slice at a time.