Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Compute a Riemann Sum

A Riemann sum approximates the area under a curve with rectangles: cut [a,b][a, b] into nn strips of width Δx\Delta x, pick a height in each strip, add the areas. Letting nn grow without bound gives the definite integral.

Recognize the task

"Approximate the integral with nn rectangles", "left / right / midpoint sum", "L4L_4, R6R_6, MnM_n", a table of function values, or a limit lim⁡n→∞∑f(xi) Δx\lim_{n\to\infty}\sum f(x_i)\,\Delta x to be written as an integral. Test: rectangles, a table, or a sum with Δx\Delta x.
The construction is explained under The Riemann Sum Construction in the definite integrals lesson.

Two ways to do it

Left, right or midpoint sumusual choice
Rn=∑i=1nf(xi) Δx,Δx=b−anR_n = \sum_{i=1}^n f(x_i)\,\Delta x, \qquad \Delta x = \frac{b - a}{n}
Left sums use the left edge of each strip, right sums the right edge, midpoint sums the middle. Same Δx\Delta x, different heights.
Limit of the sumsum to integral
∫abf(x) dx=lim⁡n→∞∑i=1nf(xi∗) Δx\int_a^b f(x)\,dx = \lim_{n\to\infty}\sum_{i=1}^n f(x_i^*)\,\Delta x
To turn a given sum into an integral, read Δx=b−an\Delta x = \frac{b - a}{n} for the interval length and the sample point xi=a+i Δxx_i = a + i\,\Delta x for aa.

Steps

StepOn ∫02x2 dx\int_0^2 x^2\,dx with n=4n = 4 right endpoints
1Compute Δx. Δx=b−an\Delta x = \frac{b - a}{n}, the width of every strip.Δx=2−04=0.5\Delta x = \frac{2 - 0}{4} = 0.5
2List the n sample points. Right: x1,…,xnx_1, \ldots, x_n (the right edges). Left: x0,…,xn−1x_0, \ldots, x_{n-1}. Midpoint: the centre of each strip. Exactly nn points.right endpoints: 0.5, 1, 1.5, 20.5,\ 1,\ 1.5,\ 2
3Evaluate f at each sample point. These are the rectangle heights.0.25, 1, 2.25, 40.25,\ 1,\ 2.25,\ 4
4Add the heights and multiply by Δx. The common width comes out as a factor.R4=0.5 (0.25+1+2.25+4)=3.75R_4 = 0.5\,(0.25 + 1 + 2.25 + 4) = 3.75
5Compare with the exact value if it is known. For an increasing function the right sum overestimates and the left sum underestimates; the exact value is F(b) − F(a).exact 83≈2.667\frac{8}{3} \approx 2.667; R4R_4 overestimates

Worked examples

Example 1 · right sum

R₄
∫02x2 dx≈R4\int_0^2 x^2\,dx \approx R_4
Δx=0.5\Delta x = 0.5, points 0.5,1,1.5,20.5, 1, 1.5, 2
R4=0.5 (0.25+1+2.25+4)=3.75R_4 = 0.5\,(0.25 + 1 + 2.25 + 4) = 3.75
overestimate

Example 2 · left sum

L₄
points 0, 0.5, 1, 1.50,\ 0.5,\ 1,\ 1.5
left edges
L4=0.5 (0+0.25+1+2.25)=1.75L_4 = 0.5\,(0 + 0.25 + 1 + 2.25) = 1.75
underestimate

Example 3 · midpoint sum

M₄
points 0.25, 0.75, 1.25, 1.750.25,\ 0.75,\ 1.25,\ 1.75
centres of the strips
M4=0.5 (0.0625+0.5625+1.5625+3.0625)=2.625M_4 = 0.5\,(0.0625 + 0.5625 + 1.5625 + 3.0625) = 2.625
closest to 83\frac{8}{3}

Example 4 · a limit of sums as an integral

read off a, b, f
lim⁡n→∞∑i=1n3n1+3in\lim_{n\to\infty}\sum_{i=1}^n \frac{3}{n}\sqrt{1 + \frac{3i}{n}}
Δx=3n\Delta x = \frac{3}{n}, so b−a=3b - a = 3
xi=1+3in=a+i Δxx_i = 1 + \frac{3i}{n} = a + i\,\Delta x
so a=1a = 1, b=4b = 4, f(x)=xf(x) = \sqrt{x}
=∫14x dx=143= \int_1^4 \sqrt{x}\,dx = \frac{14}{3}

See it happen

Quadraticf(x) = x²
×
880 × 460
Riemann sumS₈ = Σ f(xᵢ*) · Δx, Δx = 0.375 · rule: left
Approximation S₈
7.3828
with n = 8 (left)
True integral
9
closed form
Error
−1.6172
undershoots
Applieda=0b=3n=8rule=leftn drives accuracy · rule drives error sign
Increase nn and watch the staircase hug the curve. Left and right sums bracket the true area when the function is monotone; the midpoint sum usually lands closer than either, because its overshoot on one side of each strip cancels the undershoot on the other.

Common mistakes

Wrong number of heights

✗ five heights for four rectangles
✓ nn rectangles, nn heights: left uses x0,…,xn−1x_0, \ldots, x_{n-1}, right uses x1,…,xnx_1, \ldots, x_n

Forgetting Δx

✗ 0.25+1+2.25+4=7.50.25 + 1 + 2.25 + 4 = 7.5
✓ multiply by Δx=0.5\Delta x = 0.5: 3.753.75

"Right sums always overestimate"

✗ assumed for every function
✓ only for increasing functions; for decreasing ones the right sum underestimates

Δx upside down

✗ Δx=nb−a\Delta x = \frac{n}{b - a}
✓ Δx=b−an\Delta x = \frac{b - a}{n}