# What is the Riemann sum of f(x)?

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

- Page: https://www.acalculator.org/math/riemann-sum-calculator
- JSON spec: https://www.acalculator.org/math/riemann-sum-calculator.json
- Version: 5d8634a249f7

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | f(x) | The function, in x. |
| a | From x = a | The left end. |
| b | To x = b | The right end, more than a. |
| n | Subintervals n | How many equal pieces [a, b] is cut into. |
| rule | Sample point | Which point of each subinterval sets the rectangle height. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| sum | Riemann sum | Σ f(xᵢ*) Δx with the chosen sample points. |
| left | Left sum Lₙ | Heights at the left ends. |
| right | Right sum Rₙ | Heights at the right ends. |
| midpoint | Midpoint sum Mₙ | Heights at the middles. |
| dx | Width Δx | (b − a) ÷ n, exact from the typed decimals. |
| steps | Rectangles | Each sample point and f there, for n up to 20. |
| name | Rule | The sample point used. |

## 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.

## Assumptions

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

## Worked examples

1. f = x^2, a = 0, b = 2, n = 4, rule = left gives sum = 1.75, left = 1.75, right = 3.75, midpoint = 2.625, dx = 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 = 10 - x^2, a = 1, b = 2, n = 4, rule = right gives 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 - 1)^3 + 4, a = 0, b = 2, n = 4, rule = left gives left = 7.5, right = 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.

## FAQ

### 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.

## Sources

- OpenStax, Calculus Volume 1, section 5.1 Approximating Areas (retrieved 2026-10-03): https://openstax.org/books/calculus-volume-1/pages/5-1-approximating-areas
