Riemann Sum Calculator
- Free
- No sign-up
- Works on phones
- Shows the working
This Riemann sum calculator approximates a definite integral \( \int_a^b f(x)\,dx \) by adding up the areas of \( n \) thin strips. Choose left, right, midpoint, trapezoid or Simpson’s rule, and it gives you the approximation, the exact value of the integral, and the absolute error between them.
It is made for the Riemann sum questions in Calculus 1 and AP Calculus, and for seeing how quickly each method converges as \( n \) grows. Free, no sign-up.
How to use the Riemann sum calculator
- Enter \( f(x) \) using
^for powers,sqrt(),sin(),ln(),e^(x)andpi. Implicit products like2xandx e^(-x)work. - Enter the interval \( a \) to \( b \) and the number of subintervals \( n \) (a whole number from 1 to 100,000).
- Choose the method: Left, Right, Midpoint, Trapezoid or Simpson.
- Press Approximate. The highlighted row is your sum; below it are the exact integral and the absolute error.
Formulas
Split \( [a, b] \) into \( n \) equal pieces of width \( \Delta x = \frac{b - a}{n} \), with grid points \( x_i = a + i\,\Delta x \). The five methods differ only in which heights they use:
$$\begin{aligned}L_n &= \Delta x \sum_{i=0}^{n-1} f(x_i) \\ R_n &= \Delta x \sum_{i=1}^{n} f(x_i) \\ M_n &= \Delta x \sum_{i=0}^{n-1} f\!\left(x_i + \tfrac{\Delta x}{2}\right)\end{aligned}$$
The trapezoid rule is the average of the left and right sums, \( T_n = \frac{L_n + R_n}{2} \). Simpson’s rule fits parabolas through pairs of strips:
$$S_n = \frac{\Delta x}{3}\left[f(x_0) + 4f(x_1) + 2f(x_2) + \cdots + 4f(x_{n-1}) + f(x_n)\right]$$
Simpson’s rule needs an even \( n \). If you enter an odd one, the calculator uses \( n + 1 \) and tells you so. As \( n \to \infty \), every method approaches the exact integral; the Riemann sums guide explains why and how to set these up from a table of values.
Worked example
Approximate \( \int_1^2 \frac{1}{x}\,dx \) with \( n = 4 \). The exact value is \( \ln 2 \approx 0.693147 \) (see the integral of 1/x).
Here \( \Delta x = \frac{2 - 1}{4} = 0.25 \), and the grid is 1, 1.25, 1.5, 1.75, 2.
Midpoint sum. The midpoints are 1.125, 1.375, 1.625 and 1.875:
$$M_4 = 0.25\left(\tfrac{1}{1.125} + \tfrac{1}{1.375} + \tfrac{1}{1.625} + \tfrac{1}{1.875}\right) \approx 0.691220$$
Left and right sums. \( L_4 = 0.25\left(1 + 0.8 + 0.66667 + 0.57143\right) \approx 0.759524 \) and \( R_4 \approx 0.634524 \). Because \( \frac1x \) is decreasing, the left sum overestimates and the right sum underestimates.
Trapezoid and Simpson. \( T_4 = \frac{L_4 + R_4}{2} \approx 0.697024 \), and
$$S_4 = \tfrac{0.25}{3}\left(1 + 4(0.8) + 2(0.66667) + 4(0.57143) + 0.5\right) \approx 0.693254$$
| Method | \( n = 4 \) value | Error |
|---|---|---|
| Left | 0.759524 | 0.0664 |
| Right | 0.634524 | 0.0586 |
| Midpoint | 0.691220 | 0.0019 |
| Trapezoid | 0.697024 | 0.0039 |
| Simpson | 0.693254 | 0.0001 |
Enter 1/x, 1, 2 and \( n = 4 \) in the calculator above and switch between methods to reproduce each row.
Which method is most accurate?
- Left and right sums have error roughly proportional to \( \frac1n \): doubling \( n \) about halves the error.
- Midpoint and trapezoid have error proportional to \( \frac{1}{n^2} \). Midpoint is typically about twice as accurate as trapezoid, with the opposite sign.
- Simpson’s rule has error proportional to \( \frac{1}{n^4} \) for smooth functions, and it is exact for polynomials up to degree 3.
- Over or under? For an increasing function, left sums are too low and right sums too high. For a concave-up function, the trapezoid rule overestimates and the midpoint rule underestimates.
Try raising \( n \) in the calculator and watch the error column shrink at these different rates. To see the rectangles themselves, turn on the Riemann layer in the graphing calculator.
Related guides
- Riemann Sums: Left, Right, Midpoint and Simpson’s Rule
- Fundamental Theorem of Calculus (Parts 1 and 2) Explained
- Integral of 1/x: Why It’s ln|x| + C (Not x⁰/0)
Further reading
- Area Problem (Paul’s Online Math Notes) — left, right and midpoint rectangles and the idea of a Riemann sum.
- Approximating Definite Integrals (Paul’s Online Math Notes) — the midpoint, trapezoid and Simpson’s rules with error bounds.
FAQ
How do you calculate a Riemann sum?
Find \( \Delta x = \frac{b - a}{n} \), evaluate \( f \) at the chosen point of each subinterval (left end, right end or midpoint), add those heights and multiply by \( \Delta x \).
Does the calculator show the exact integral too?
Yes. Every result includes the exact value of the definite integral and the absolute error of your approximation, so you can judge its accuracy. For the exact value alone, including improper integrals, use the definite integral calculator.
Why does Simpson’s rule need an even number of subintervals?
Each parabola spans two subintervals, so the strips must pair up. With an odd \( n \), the calculator automatically uses \( n + 1 \).
Can I use the Riemann sum calculator for a table of data?
It needs a formula for \( f(x) \). For tabulated data, apply the formulas above directly to the table values.
