The Definite Integral and Riemann Sums
Learning Objectives
- Build and compute left, right, midpoint, and trapezoid Riemann sums for a function on with subintervals.
- State the definition of the definite integral as a limit over all tagged partitions whose mesh shrinks to zero, and say which functions are guaranteed to have one.
- Tell net signed area apart from total area, and explain why .
- Apply linearity, additivity over intervals, orientation reversal, and comparison to rewrite and bound integrals.
- Predict how fast each rule converges as doubles, and recognize when that rate degrades.
- Use integrals to estimate the cost of a sum, such as the work of a nested loop.
Context & Motivation
The previous lesson, antiderivatives-and-initial-value-problems, ran differentiation backwards. This one starts from a question that looks unrelated: how much accumulates under a curve? Distance from a speed log, total energy from a power reading, probability mass from a density, total cost of a loop whose body gets more expensive each iteration: all of these are a rate multiplied by a small step and added up. The definite integral is the exact value that this adding-up approaches as the steps shrink.
The definition below never mentions a derivative. That is deliberate. It makes the integral a limit of finite sums, which a computer can actually evaluate, and it makes the next lesson, the-fundamental-theorem-of-calculus, a real discovery: the two ideas (rates and accumulation) were defined independently and turn out to be inverses.
Core Theory
Partitions and Riemann sums
A partition of is a list of points . The subinterval widths are and the mesh is the largest of them. Pick a tag in each subinterval . The Riemann sum is
Each term is the signed area of one rectangle: width times height, with negative height where . With equal widths and , three tag choices give the standard rules:
- Left:
- Right:
- Midpoint:
The trapezoid rule averages the first two: .
The definition
Let be bounded on . It is Riemann integrable with integral if for every there is a such that every tagged partition with satisfies . Then we write .
The phrase "every tagged partition" matters: equal widths and left tags are just one family. A numerical test on , , with random partition points and a random tag in each piece gives sums of 0.3460 (10 pieces), 0.33360 (100), 0.333304 (1000), and 0.33333335 (100000 pieces, largest piece about 0.0001). All head to the same .
Which functions qualify? A function that is continuous on is integrable, and so is a bounded function with finitely many discontinuities, and so is a monotone function. The hypotheses are not decoration, and two failures are worth seeing.
- Unbounded. Define on and . Right sums with pieces equal the harmonic number : 2.93 for , 5.19 for , 7.49 for , 12.09 for . They keep growing, and a tag chosen near can inflate a sum as much as we like. No limit exists. Some unbounded functions, like , get a value through a second limit (see
improper-integrals), which is a different object. - Bounded but too discontinuous. Let at rational and at irrational on . Every subinterval, however small, holds both kinds of number. Rational tags give for every partition and irrational tags give , so no single works.
Net signed area
The integral counts area above the axis as positive and below as negative. For on the two humps cancel, so the integral is , while the total area is .
Properties
For integrable and on the intervals involved:
Also , , if then (for ), and . Both inequalities assume : with , , the second would read . There is no product rule of this kind: in general.
Bracketing and convergence rates
If is increasing on , each left rectangle sits under the curve and each right rectangle over it, so and . That gives a certified error bar from the sums alone. (For decreasing the inequalities flip.) For on with : , width .
How fast do the rules close in? The script output below is for on , where .
textn left right midpoint trapezoid |err L| |err M| 4 0.21875 0.46875 0.328125 0.34375 1.15e-01 5.21e-03 8 0.27344 0.39844 0.332031 0.33594 5.99e-02 1.30e-03 16 0.30273 0.36523 0.333008 0.33398 3.06e-02 3.26e-04 64 0.32556 0.34119 0.333313 0.33337 7.77e-03 2.03e-05 128 0.32944 0.33725 0.333328 0.33334 3.90e-03 5.09e-06
Doubling halves the left and right errors (ratio 1.995 and 2.005 from to ) and quarters the midpoint and trapezoid errors (ratio 4.0). For smooth with , the left and right errors behave like , which is ; midpoint and trapezoid are . For the midpoint rule, the over- and underestimates within each piece largely cancel. For the trapezoid rule, the leading errors of the left and right sums have opposite signs, so averaging the two removes them. The guarantee needs smoothness. For on the slope is unbounded at , and the midpoint error ratio on doubling from to is only 2.79, about , not 4.
Worked Examples
Example 1: sums by hand
Take on with , so .
The trapezoid value is . The midpoint is already within of , an error more than 20 times smaller than the left sum's .
Example 2: the exact value as a limit
Use with right tags on :
As the fraction tends to , so . Check: , gives , the value from Example 1. Writing also explains the error seen in the table. A symbolic integration and a numerical quadrature both return for .
Example 3: net area versus area
Midpoint sums of on for are all zero up to rounding (), because the midpoints pair off with opposite sine values. So , while (both confirmed symbolically and by quadrature).
Example 4: bounding the cost of a loop
Suppose iteration of a loop does units of work, for . Total work is , a right sum with for on . Because is increasing,
For the true sum is , between and . The ratio of the sum to is 1.155 at , 1.015 at , and 1.0015 at . The work is , and no closed form was needed.
Common Misconceptions & Pitfalls
- "The integral is the area, full stop." It is the net signed area. Regions below the axis subtract. Use for total area (and split at sign changes to compute it).
- "Every bounded function is integrable." The rational-indicator function is bounded and has no Riemann integral. Continuity, or at least finitely many jumps, is what the usual theorems assume.
- "Left, right, and midpoint rules are equally good." They converge to the same limit, but for smooth functions the midpoint and trapezoid errors shrink like against for the others. The exception proves the point: for on the endpoint values are both , so the left, right, and trapezoid sums coincide and all three are .
- "Left sums always underestimate." Only for increasing is that guaranteed. For decreasing they overestimate, and for a function that rises and falls neither bound is guaranteed (for on every left sum happens to fall below , but that is not a rule).
- "." Integration is linear in , not multiplicative. With on : but .
Summary
A Riemann sum adds up over a partition. The definite integral is the number every such sum approaches as the mesh goes to zero, for every choice of partition and tags, and it exists for continuous functions and for bounded functions with finitely many discontinuities. It fails to exist for unbounded functions and for functions like the rational indicator that are too discontinuous. The integral measures net signed area. For smooth integrands the left and right rules have error and the midpoint and trapezoid rules , which the table above shows directly, and for increasing the left and right sums bracket the true value. Comparing a sum with an integral is a standard way to bound the running time of a loop. Computing integrals by limits of sums works but is slow, and the next lesson, the-fundamental-theorem-of-calculus, replaces it with antiderivatives.