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 S. Dilshan · Runs in your browser, nothing is uploaded
Step-by-Step Solution
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
| Method | Height taken at | Sum | Error vs exact 9 |
|---|---|---|---|
| Left endpoint | Left side of each strip | 6.875 | −2.125 |
| Right endpoint | Right side of each strip | 11.375 | +2.375 |
| Midpoint | Middle of each strip | 8.9375 | −0.0625 |
| Trapezoid | Average of both sides | 9.125 | +0.125 |
Riemann Sum Formulas
aandbare the limits of integration.nis the number of subintervals, andΔxis 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
- Δx = (3 − 0) ÷ 6 = 0.5.
- The midpoints of the six strips are 0.25, 0.75, 1.25, 1.75, 2.25 and 2.75.
- Squares: 0.0625, 0.5625, 1.5625, 3.0625, 5.0625, 7.5625, adding to 17.875.
- Midpoint sum: 0.5 × 17.875 = 8.9375.
- 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?
| Curve | Left sum | Right sum | Midpoint | Trapezoid |
|---|---|---|---|---|
| Increasing | Too low | Too high | ||
| Concave up (like x²) | Too low | Too high | ||
| Concave down | Too high | Too 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
- Type your polynomial f(x).
- Enter the lower limit a and the upper limit b.
- Enter the number of subintervals n.
- Choose left, right, midpoint or trapezoid.
- 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:
- OpenStax: algebra and calculus textbooks
- NIST Digital Library of Mathematical Functions
- Wolfram MathWorld
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.