Calculus

Riemann Sums and How an Integral Is Defined

Build the definite integral from rectangle sums, compute a limit by hand, and learn which functions can be integrated.

Key takeaways

  • A Riemann sum adds f(sample point) × width over the pieces of a partition of [a, b].
  • The integral is the common limit of all such sums as the width of the widest piece goes to zero.
  • Every continuous function on a closed, bounded interval is integrable, and so is every monotone function there.
  • Some bounded functions are too erratic to be integrable in Riemann's sense, so the "independent of the sample points" condition has real content.

A definite integral is defined as the limit of sums. You cut the interval into pieces, pick one point in each piece, multiply the function's value there by the width of the piece, and add. If those sums approach one number as every piece shrinks, no matter which points you picked, that number is the integral.

Such a sum is called a Riemann sum, after Bernhard Riemann, who gave this form of the definition in the 1850s, building on earlier work of Augustin-Louis Cauchy on continuous functions.

The ingredients

Start with a function f on an interval [a, b]. A partition is a list of points that splits the interval:

a = x₀ < x₁ < x₂ < … < xₙ = b

The i-th piece runs from xᵢ₋₁ to xᵢ and has width Δxᵢ = xᵢ − xᵢ₋₁. The pieces need not be equal. In each one, choose a sample point cᵢ. The Riemann sum is:

S = f(c₁)Δx₁ + f(c₂)Δx₂ + … + f(cₙ)Δxₙ  =  ∑ f(cᵢ)Δxᵢ

When f is positive, each term is the area of a rectangle with base Δxᵢ and height f(cᵢ), and S approximates the area under the graph. When f is negative, the term is negative. The sigma notation ∑ just means "add these terms for every i".

Four sums for the same curve

Take f(x) = x² on [0, 1] with four equal pieces, each of width 1/4. Different sample points give different sums.

Rule Sample points Sum Decimal
Left endpoints 0, 1/4, 1/2, 3/4 14/64 0.21875
Right endpoints 1/4, 1/2, 3/4, 1 30/64 0.46875
Midpoints 1/8, 3/8, 5/8, 7/8 21/64 0.328125
Average of left and right endpoints 22/64 0.34375

Because x² increases on this interval, the left sum is too small and the right sum is too big, so the true value lies between them. The midpoint sum is already close to 1/3. The last row is the trapezoid rule, one of the methods compared in numerical integration.

Taking the limit by hand

To get the exact value, use n equal pieces of width 1/n and right endpoints i/n. You need the formula for the sum of the first n squares, 1² + 2² + … + n² = n(n + 1)(2n + 1)/6.

Rₙ = ∑ (i/n)² · (1/n)                 (height × width)
   = (1/n³) · ∑ i²                    (pull out constants)
   = (1/n³) · n(n + 1)(2n + 1)/6      (sum of squares)
   = (n + 1)(2n + 1)/(6n²)

Check it at n = 4: 5 × 9/96 = 45/96, which matches 0.46875. At n = 100 it gives 0.33835. As n grows, the expression approaches 2/6 = 1/3. The matching left sum is (n − 1)(2n − 1)/(6n²), which is 0.32835 at n = 100 and has the same limit.

This is real integration with no antiderivative in sight. It also shows why shortcuts are welcome: each new function would need its own summation trick.

How quickly different rules close in

The choice of sample point does not change the limit for an integrable function, but it strongly affects how fast you get there. Compare the errors for x² on [0, 1].

With four pieces, the left sum misses 1/3 by about 0.115 and the right sum by about 0.135. The midpoint sum misses by only about 0.005. With a hundred pieces, the left and right errors are both about 0.005.

Doubling the number of pieces roughly halves the error of an endpoint sum. For the midpoint sum of a smooth function, doubling cuts the error to about a quarter. The reason is cancellation: within each piece, the midpoint rectangle overshoots on one side and undershoots on the other, and the two mistakes nearly offset.

None of this matters to the definition, which only asks that the limit exist. It matters a great deal to anyone computing, because a better sample point can save thousands of function evaluations.

Reading a sum as an integral

The definition can be run in the other direction. A complicated limit of sums is sometimes a Riemann sum in disguise, and then an integral evaluates it.

Consider 1/(n + 1) + 1/(n + 2) + … + 1/(2n) as n grows. Each term can be rewritten:

1/(n + i) = (1/n) · 1/(1 + i/n)      (factor out 1/n)

That is a width of 1/n times the value of 1/(1 + x) at the right endpoint x = i/n. So the whole expression is a right-endpoint sum for 1/(1 + x) on [0, 1], and its limit is the integral of that function, which equals ln 2, about 0.693.

The clue to look for is a factor of 1/n multiplying a function of i/n. Once you see both, name the function, find the interval swept by i/n, and integrate.

The definition in full

The mesh of a partition is the width of its widest piece. We say f is Riemann integrable on [a, b], with integral I, when the following holds: for every tolerance ε > 0 there is a δ > 0 such that every Riemann sum with mesh less than δ is within ε of I. This must work for every partition that fine and every choice of sample points.

We then write I = ∫ₐᵇ f(x) dx.

Requiring the mesh to shrink matters. Letting only the number of pieces grow is not enough, since you could keep one wide piece and chop the rest ever finer.

The structure resembles the definition of a limit, explained in limits before formulas: you are challenged with a tolerance and must answer with a degree of fineness.

From partition to integral
1 Partition Split [a, b] into n pieces of any widths 2 Sample Pick one point inside each piece 3 Sum Add f(sample) times width 4 Refine Send the widest piece toward zero 5 Compare All choices must approach one number Partition Split [a, b] into n pieces of any widths 1 Sample Pick one point inside each piece 2 Sum Add f(sample) times width 3 Refine Send the widest piece toward zero 4 Compare All choices must approach one number 5

Upper and lower sums

Checking every possible sample point sounds hopeless. A tidier version, associated with Gaston Darboux, uses the extremes. For a bounded function, let Mᵢ be the least upper bound of f on the i-th piece and mᵢ the greatest lower bound.

The upper sum ∑ MᵢΔxᵢ and the lower sum ∑ mᵢΔxᵢ trap every Riemann sum for that partition between them. The function is integrable exactly when you can make the upper and lower sums differ by as little as you like.

For an increasing function with equal pieces of width Δx, the gap collapses neatly. The differences telescope to (f(b) − f(a))·Δx, which clearly goes to zero. For x² on [0, 1] with n = 100, the gap is 0.01, matching the numbers above. This argument proves that every monotone function on a closed interval is integrable, even one with infinitely many jumps.

Which functions pass the test

Several broad families are integrable on [a, b]:

  • all continuous functions;
  • all monotone functions;
  • bounded functions with only finitely many points of discontinuity.

Now consider the Dirichlet function, equal to 1 at rational numbers and 0 at irrational numbers. Every piece of every partition contains both kinds of number. Choose rational sample points on [0, 1] and every sum is 1. Choose irrational ones and every sum is 0. No limit exists, so the function is not Riemann integrable.

Unbounded functions fail too, because one sample point near a blow-up can make a sum arbitrarily large. Some of them can still be handled as improper integrals, which add a second limit on top of this definition.

The precise dividing line is Lebesgue's criterion: a bounded function on [a, b] is Riemann integrable exactly when its set of discontinuities has measure zero, meaning it can be covered by intervals of arbitrarily small total length. A broader theory, described in the Lebesgue integral compared with Riemann's, assigns the Dirichlet function the value 0.

Properties that follow from sums

Many rules of integration are simply rules of addition that survive the limit.

  1. Linearity. The integral of f + g is the sum of the integrals, and constant factors come outside.
  2. Splitting. For a < c < b, the integral from a to b equals the integral from a to c plus the integral from c to b.
  3. Order. If f ≤ g on [a, b], then the integral of f is at most the integral of g.
  4. Bounds. If m ≤ f(x) ≤ M, the integral lies between m(b − a) and M(b − a).

By convention, reversing the limits changes the sign, and an integral from a to a is zero.

Traps when working with sums

Three slips are common. The first is using the wrong width: on [a, b] with n equal pieces, each width is (b − a)/n, not 1/n. The second is mislocating the sample points. The right endpoint of piece i is a + iΔx, and the left endpoint is a + (i − 1)Δx.

The third is trusting one convenient choice of points as proof of integrability. The Dirichlet function has right-endpoint sums equal to 1 on [0, 1] with equal pieces, because every endpoint is rational. Those sums converge perfectly well, yet the function is not integrable. A single sequence of sums gives the value of an integral only after you already know, for instance from continuity, that the integral exists.

Why define it this way?

The definition does two jobs. It gives meaning to totals such as area, work or mass before you know any formula for them. It also tells a computer how to approximate them.

It is not how you usually evaluate integrals. The fundamental theorem of calculus lets you replace the limit of sums with two evaluations of an antiderivative whenever you can find one. But when you meet a new physical quantity, the Riemann sum is how you justify writing an integral at all: slice it, approximate each slice, add, and refine.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 39 articles in Calculus →

Latest news on this topic