Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 39 · Integrals

Riemann Sums and the Definite Integral

Understand the definite integral as the limit of Riemann sums: area under a curve by rectangles, sigma notation, properties and runnable code.

How do you find the area of a shape with a curved edge? Rectangles and triangles have formulas, but the region under y = x² does not. The trick, which goes back to ancient Greek mathematicians and was made precise in the 1800s, is to chop the region into thin rectangles, add up their areas, and let the rectangles get thinner and thinner. The number you approach is the definite integral.

Approximating area with rectangles

We want the area under f(x) = x² from x = 0 to x = 2. Split the interval [0, 2] into n equal pieces. Each piece has width

Text
Δx = (b - a) / n = 2 / n

On each piece we build a rectangle whose height is the value of f at some sample point in that piece. Three common choices:

  • Left sum: sample at the left end of each piece.
  • Right sum: sample at the right end.
  • Midpoint sum: sample in the middle.

Adding up the rectangle areas gives a Riemann sum, written with sigma notation (Σ means "add up"):

Text
Rₙ = Σ f(xᵢ) · Δx     (for i = 1 to n)

For an increasing function such as x² on [0, 2], the left sum is too small (an underestimate) and the right sum is too big (an overestimate), because each rectangle falls just short of the curve or sticks out past it.

Python Left, right and midpoint sums

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

As n grows, all three columns close in on the same number, 8/3 ≈ 2.6667. That shared limit is what we call the area.

The definite integral

If f is continuous on [a, b], the Riemann sums approach a single number as n → ∞, no matter how you choose the sample points. That number is the definite integral:

Text
∫ from a to b of f(x) dx = lim (n → ∞) Σ f(xᵢ) Δx

Here a and b are the limits of integration. Unlike the indefinite integral, which is a family of functions, the definite integral is a single number.

The definite integral measures signed area. Area above the x-axis counts as positive; area below the axis counts as negative. So ∫ from 0 to 2π of sin x dx = 0: the positive hump and the negative hump cancel.

Seeing the rectangles

The plot below draws a midpoint sum with 8 rectangles under x² on [0, 2], together with the curve itself.

Python Draw the rectangles

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Properties of the definite integral

These rules follow from the Riemann-sum definition and are very useful:

Property Statement
Same limits ∫ from a to a of f dx = 0
Reversing limits ∫ from b to a of f dx = -∫ from a to b of f dx
Constant multiple ∫ k·f dx = k ∫ f dx
Sum ∫ (f + g) dx = ∫ f dx + ∫ g dx
Splitting ∫ from a to c of f dx = ∫ from a to b of f dx + ∫ from b to c of f dx
Constant function ∫ from a to b of k dx = k(b - a)

The constant function rule is just the area of a rectangle: height k, width b - a.

Geometry shortcuts

Sometimes you can find a definite integral from a known area formula without any calculus. For example, ∫ from 0 to 4 of x dx is the area of a right triangle with base 4 and height 4, which is 8. And ∫ from -3 to 3 of √(9 - x²) dx is the area of a half-disk of radius 3, which is (1/2)π(3²) = 9π/2.

A physical meaning

If v(t) is velocity (in m/s), then ∫ from t₁ to t₂ of v(t) dt is the net displacement in meters. If a car travels at a constant 20 m/s for 10 s, the integral of the constant 20 over [0, 10] is 20 × 10 = 200 m: the area of a rectangle. When the velocity varies, the area under the velocity graph is the displacement.

Python Displacement from a velocity graph

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The approximation is a little too small because the car is speeding up and the left sum uses the slower speed at the start of each step. With smaller dt it gets closer.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. For an increasing function, a left Riemann sum is

    Each left-end rectangle uses the smallest value on its piece, so it falls short of the curve.
  2. 2. What does ∫ from a to b of f(x) dx give?

    The definite integral is a number, the limit of Riemann sums, counting area below the axis as negative.
  3. 3. What is ∫ from 0 to 5 of 3 dx?

    It is the area of a rectangle with height 3 and width 5.
  4. 4. If you swap the limits of integration, the value

    ∫ from b to a of f dx = -∫ from a to b of f dx.

Summary

  • A Riemann sum adds up areas of thin rectangles of width Δx = (b - a)/n.
  • The definite integral is the limit of Riemann sums as n → ∞; it is a number measuring signed area.
  • It obeys properties for sums, constants, splitting and reversing limits.
  • Integrating velocity gives displacement.

Next: The Fundamental Theorem of Calculus