acalculator

What is the Riemann sum of f(x)?

Type a function of x, an interval [a, b] and a number of subintervals n, and pick left, right or midpoint sample points. The page gives the Riemann sum, the other two sums for comparison, and each rectangle for n up to 20.

Your numbers

Sample point
Riemann sum
1.75

The left Riemann sum of x^2 from 0 to 2 with n = 4 is 1.75.

Left sum Lₙ
1.75
Right sum Rₙ
3.75
Midpoint sum Mₙ
2.625
Width Δx
0.5
Rectangles
x1* = 0: f = 0; x2* = 0.5: f = 0.25; x3* = 1: f = 1; x4* = 1.5: f = 2.25
Rule
left

Riemann sum: 1.75. The left Riemann sum of x^2 from 0 to 2 with n = 4 is 1.75.

How it is worked out

How to calculate

Finds the left, right and midpoint Riemann sums of f(x) on [a, b] with n equal subintervals, with every sample point.

Example with the default inputs (f(x) x^2, From x = a 0, To x = b 2, Subintervals n 4, Sample point Left): The left Riemann sum of x^2 from 0 to 2 with n = 4 is 1.75.

Method: Δx = (b − a)/n. Lₙ = Δx Σ f(a + (i − 1)Δx), Rₙ = Δx Σ f(a + iΔx), Mₙ = Δx Σ f(a + (i − ½)Δx), i = 1 … n.

  • Sample points are exact from the typed decimals before f is evaluated.
  • Angles in radians.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. f(x) x^2, From x = a 0, To x = b 2, Subintervals n 4, Sample point Left gives Riemann sum 1.75, Left sum Lₙ 1.75, Right sum Rₙ 3.75, Midpoint sum Mₙ 2.625, Width Δx 0.5.Source: OpenStax, Calculus Volume 1, section 5.1 Approximating Areas (https://openstax.org/books/calculus-volume-1/pages/5-1-approximating-areas), Example 5.4: L₄ = 1.75 and R₄ = 3.75
  2. f(x) 10 - x^2, From x = a 1, To x = b 2, Subintervals n 4, Sample point Right gives Riemann sum 7.28125.Source: OpenStax, Calculus Volume 1, section 5.1 Approximating Areas (https://openstax.org/books/calculus-volume-1/pages/5-1-approximating-areas), Example 5.5: the lower sum (right ends) is about 7.28
  3. f(x) (x - 1)^3 + 4, From x = a 0, To x = b 2, Subintervals n 4, Sample point Left gives Left sum Lₙ 7.5, Right sum Rₙ 8.5.Source: OpenStax, Calculus Volume 1, section 5.1 Approximating Areas (https://openstax.org/books/calculus-volume-1/pages/5-1-approximating-areas), the opening example (Figure 5.7 to 5.9): L₄ = 7.5, R₄ = 8.5

How it works

For f(x), numbers a < b and a whole number n from 1 to 1,000:

  • Δx = (b − a)/n.
  • Left sum: Lₙ = Δx [f(x₀) + f(x₁) + … + f(xₙ₋₁)], where xᵢ = a + iΔx.
  • Right sum: Rₙ = Δx [f(x₁) + f(x₂) + … + f(xₙ)].
  • Midpoint sum: Mₙ = Δx [f(m₁) + … + f(mₙ)], where mᵢ = a + (i − ½)Δx.

The sample points are worked out exactly from the typed decimals (as fractions), then turned into computer numbers before f is evaluated. The values of f are divided by a power of two before they are added, so the sum cannot overflow on the way. The chosen sum heads the answer; the other two show when f is real at their points too. There is no answer when f has no real value at a point the chosen rule uses, or a value past the largest computer number (about 1.8 × 10³⁰⁸, e^x at x = 710). Angles are in radians.

Worked examples by hand

f(x) = x² on [0, 2], n = 4 (OpenStax Calculus Volume 1, Example 5.4). Δx = 0.5. L₄ = 0.5 (0 + 0.25 + 1 + 2.25) = 1.75. R₄ = 0.5 (0.25 + 1 + 2.25 + 4) = 3.75. M₄ = 0.5 (0.0625 + 0.5625 + 1.5625 + 3.0625) = 2.625.

f(x) = 10 − x² on [1, 2], n = 4, right ends (Example 5.5, the lower sum, since f decreases). Δx = 0.25 and the points are 1.25, 1.5, 1.75, 2: R₄ = 0.25 (8.4375 + 7.75 + 6.9375 + 6) = 0.25 × 29.125 = 7.28125 (233/32), which OpenStax rounds to 7.28.

f(x) = (x − 1)³ + 4 on [0, 2], n = 4 (the opening example of section 5.1). Δx = 0.5. L₄ = 0.5 (3 + 3.875 + 4 + 4.125) = 7.5 and R₄ = 0.5 (3.875 + 4 + 4.125 + 5) = 8.5.

Other questions people ask

What is a Riemann sum?

An estimate of the area under y = f(x) from a to b. Cut [a, b] into n pieces of width Δx = (b − a)/n, pick a sample point xᵢ* in each, and add the rectangle areas: Σ f(xᵢ*) Δx. As n grows, the sums of a continuous f approach the definite integral ∫ₐᵇ f(x) dx.

What is the difference between left and right Riemann sums?

A left sum Lₙ uses the left end of each subinterval as the height, a right sum Rₙ the right end. For f(x) = x² on [0, 2] with n = 4: L₄ = 0.5(0 + 0.25 + 1 + 2.25) = 1.75 and R₄ = 0.5(0.25 + 1 + 2.25 + 4) = 3.75.

Is a Riemann sum an overestimate or an underestimate?

For an increasing f, the left sum is too small and the right sum too large; for a decreasing f it is the other way round. The midpoint sum is often much closer than either.

What are upper and lower sums?

The upper sum takes the largest value of f on each subinterval, the lower sum the smallest. For a function that only increases (or only decreases) on [a, b], these are the right and left sums (or the left and right sums).

How large should n be?

The page takes n up to 1,000. The error of the left and right sums shrinks about like 1/n, and of the midpoint sum like 1/n² for a smooth f. Compare with the Simpson’s rule calculator, whose error shrinks like 1/n⁴.

How do I write the sum in sigma notation?

Lₙ = Σ_{i=1}^{n} f(a + (i − 1)Δx) Δx, Rₙ = Σ_{i=1}^{n} f(a + iΔx) Δx and Mₙ = Σ_{i=1}^{n} f(a + (i − ½)Δx) Δx.