3. The definite integral as a limit

📖 Reading · 15 min
💡 Every code box below is live — edit it and hit Run.

Last lesson built Riemann sums and took one limit. This lesson pins down what that limit asserts, which functions have one, and what properties follow — before the Fundamental Theorem makes computing them easy and you stop thinking about sums entirely.

The definition

\int_a^b f(x)\,dx = \lim_{\|P\|\to0}\sum_{i=1}^{n}f(x_i^*)\,\Delta x_i

f is Riemann integrable on [a,b] if this limit exists and takes the same value for every partition and every choice of sample points.

"Every choice" is the demanding part. It's a statement about all possible ways of chopping and sampling agreeing on one number.

The notation's parts:

  • \int — an elongated S, for summa
  • f(x) — the integrand, a rectangle's height
  • dx — what \Delta x became, a rectangle's width, and the marker of which variable is being integrated
  • a, b — the limits of integration

x is a dummy variable. \int_a^bf(x)dx = \int_a^bf(t)dt; the name doesn't survive the integration, exactly as the index in \sum_{i=1}^n a_i doesn't.

Which functions are integrable

Two sufficient conditions cover essentially everything you'll meet:

  1. f continuous on [a,b] ⟹ integrable.
  2. f bounded on [a,b] with finitely many discontinuities ⟹ integrable.

So jumps are fine. A step function integrates perfectly well, and a single misplaced point can't change the answer — changing f at finitely many points changes no Riemann sum's limit, because those points contribute rectangles of vanishing total width.

What fails:

  • Unbounded functions. \frac1x on [0,1] has no Riemann integral — sampling near 0 makes rectangles arbitrarily tall. §4.10's improper integrals handle it by a separate limit.
  • Too many discontinuities. The Dirichlet function (§1.2) is bounded and discontinuous everywhere: sampling rationals gives 1, irrationals gives 0. Two choices, two answers, no limit.

The exact criterion — integrable iff bounded and discontinuous only on a set of measure zero — is Lebesgue's, and §15.4 states it properly. "Measure zero" makes "finitely many" and even "countably many" precise, and it's why the Dirichlet function (discontinuous everywhere) fails while a function with discontinuities at every rational still passes.

Upper and lower sums

The clean route to the definition, and the one §15.4 uses.

On each subinterval take the supremum M_i and the infimum m_i of f:

L(f,P) = \sum m_i\Delta x_i \le \text{any Riemann sum} \le \sum M_i\Delta x_i = U(f,P)

Refining a partition raises L and lowers U, so they close in. f is integrable exactly when

\sup_P L(f,P) = \inf_P U(f,P)

A squeeze, §1.3, with the partition as the parameter. The integral is the common value, and U - L \to 0 is the checkable condition.

The properties

All follow from the corresponding facts about sums.

\int_a^b\left[f+g\right] = \int_a^bf+\int_a^bg, \qquad \int_a^bcf = c\int_a^bf

Integration is linear, and just like differentiation that's all it is: there is no product rule for definite integrals either.

\int_a^bf = \int_a^cf + \int_c^bf

Additivity over intervals, which holds for any c — even outside [a,b], once you adopt the conventions:

\int_a^af = 0, \qquad \int_b^af = -\int_a^bf

Reversing the limits flips the sign. That's a convention chosen precisely to make additivity hold universally, and it's what lets the Fundamental Theorem be stated without case analysis.

Comparison. If f \le g on [a,b] then \int_a^bf \le \int_a^bg. In particular f \ge 0 gives \int f\ge0, and

\left|\int_a^bf\right| \le \int_a^b|f|

— the integral triangle inequality, and the workhorse of every estimate in analysis.

Bounds. If m \le f \le M then

m(b-a) \le \int_a^bf \le M(b-a)

Crude, free, and often enough to tell you an answer is wrong.

The Mean Value Theorem for integrals

If f is continuous on [a,b], there is a c\in[a,b] with \int_a^bf(x)\,dx = f(c)(b-a)

Some rectangle of the interval's full width has exactly the region's area, and its height is a value the function actually attains. That height,

f_{\text{avg}} = \frac{1}{b-a}\int_a^bf(x)\,dx

is the average value of f — the continuous analogue of averaging a list, and §5.6 develops it.

The proof is the IVT (§1.8) applied to the bounds above: the integral divided by (b-a) lies between m and M, and a continuous function hits every value in between.

Doing it in Python

The exact Riemann sum and its limit, symbolically:

import sympy as sp

n, i = sp.symbols('n i', positive=True, integer=True)

for power in (1, 2, 3):
    R = sp.simplify(sp.summation((i/n)**power * (1/n), (i, 1, n)))
    print(f"int_0^1 x^{power}:  R_n = {sp.expand(R)}")
    print(f"{'':14}limit = {sp.limit(R, n, sp.oo)}\n")

print("the leading term is the answer; everything else is O(1/n) error")

Upper and lower sums closing in:

def bounds(f, a, b, n, samples=400):
    """Upper and lower sums, with sup/inf found by sampling each subinterval."""
    w = (b - a) / n
    lo = hi = 0.0
    for k in range(n):
        left = a + k * w
        vals = [f(left + j * w / samples) for j in range(samples + 1)]
        lo += min(vals) * w
        hi += max(vals) * w
    return lo, hi

f = lambda x: x*x*x - x + 1

print(f"{'n':>6} {'lower':>12} {'upper':>12} {'gap':>12}")
for n in (2, 4, 8, 16, 32, 64):
    lo, hi = bounds(f, 0, 2, n)
    print(f"{n:>6} {lo:>12.6f} {hi:>12.6f} {hi-lo:>12.6f}")

print("\nthe gap closes to zero: that IS integrability, and the common value")
print("is the integral (here 2 + 4 - 2 = 4 exactly... check: x^4/4 - x^2/2 + x")
print("at 2 gives 4 - 2 + 2 = 4)")

The Dirichlet function refusing to be integrable:

from fractions import Fraction
import random

random.seed(11)

def dirichlet_rational_samples(n):
    """Sample only rationals: every height is 1."""
    return sum(1 * (1/n) for _ in range(n))

def dirichlet_irrational_samples(n):
    """Sample only irrationals: every height is 0."""
    return sum(0 * (1/n) for _ in range(n))

print(f"{'n':>8} {'rational sampling':>20} {'irrational sampling':>22}")
for n in (10, 100, 1000, 10000):
    print(f"{n:>8} {dirichlet_rational_samples(n):>20.6f} "
          f"{dirichlet_irrational_samples(n):>22.6f}")

print("\nboth are legitimate Riemann sums for the same partitions.")
print("they converge to 1 and 0. no single limit exists -- not integrable.")

The properties, verified numerically:

from math import sin, cos, pi

def integrate(f, a, b, n=400000):
    w = (b - a) / n
    return sum(f(a + (i + 0.5) * w) for i in range(n)) * w

f = lambda x: x*x
g = sin

print(f"int(f+g)        = {integrate(lambda x: f(x)+g(x), 0, 2):.8f}")
print(f"int f + int g   = {integrate(f,0,2) + integrate(g,0,2):.8f}\n")

print(f"int_0^2 f       = {integrate(f, 0, 2):.8f}")
print(f"int_0^1 + int_1^2 = {integrate(f,0,1) + integrate(f,1,2):.8f}\n")

print(f"int_0^2 f       = {integrate(f, 0, 2):.8f}")
print(f"-int_2^0 f      = {-integrate(f, 2, 0):.8f}   (reversed limits flip the sign)")

The average value, and the point where it's attained:

from math import sin, pi

def integrate(f, a, b, n=200000):
    w = (b - a) / n
    return sum(f(a + (i + 0.5) * w) for i in range(n)) * w

a, b = 0, pi
avg = integrate(sin, a, b) / (b - a)
print(f"average of sin on [0, pi] = {avg:.8f}   (exactly 2/pi = {2/pi:.8f})")

# find c with f(c) = avg
lo, hi = 0.0, pi/2
for _ in range(60):
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if sin(mid) < avg else (lo, mid)

c = (lo + hi) / 2
print(f"attained at c = {c:.8f}, where sin(c) = {sin(c):.8f}")
print(f"check: rectangle {avg:.6f} x {b-a:.6f} = {avg*(b-a):.6f}")
print(f"       integral                        = {integrate(sin,a,b):.6f}")

Worked example

Given \int_0^3f = 5 and \int_0^6f = 2, find \int_6^3f.

Additivity over [0,6] split at 3:

\int_0^6f = \int_0^3f + \int_3^6f \implies 2 = 5 + \int_3^6f \implies \int_3^6f = -3

Then reverse the limits:

\int_6^3f = -\int_3^6f = \boxed{3}

What the numbers say. \int_3^6f = -3 is negative, so f spends more of [3,6] below the axis than above — enough to cancel 3 units of the 5 accumulated on [0,3].

A bound you get for free. If additionally |f|\le4 on [0,6], then \left|\int_0^6f\right| \le 4\times6 = 24, and our value 2 is comfortably inside. Had the given value been 30, the data would be inconsistent — a check worth running when a problem hands you numbers.

Your turn

1. If \int_1^4f = 7 and \int_1^4g = -2, find \int_1^4(3f - 2g).

2. Without computing, explain why \int_0^1x^2dx < \int_0^1x\,dx.

3. Find bounds on \int_0^2e^{x^2}dx using m \le f \le M.

4. Find the average value of f(x)=x^2 on [0,3], and the c where it's attained.

Solutions

1. Linearity:

\int_1^4(3f-2g) = 3\int_1^4f - 2\int_1^4g = 3(7) - 2(-2) = 21+4 = \boxed{25}

2. On (0,1), x^2 < x — squaring a number between 0 and 1 makes it smaller. By the comparison property,

\int_0^1x^2dx \le \int_0^1x\,dx

and the inequality is strict because the functions differ on an interval of positive length, not just at isolated points.

(Values: \frac13 < \frac12 ✓. And note the comparison property alone gives \le; upgrading to < needs the extra observation that the gap isn't confined to a measure-zero set — the same "strict inequalities go soft" caution from §1.3.)

3. e^{x^2} is increasing on [0,2], so its extremes are at the endpoints:

m = e^0 = 1, \qquad M = e^4 \approx 54.6

1(2) \le \int_0^2e^{x^2}dx \le 54.6(2)

\boxed{2 \le \int_0^2e^{x^2}dx \le 109.2}

Very crude — the true value is about 16.45 — but obtained with no work at all, and e^{x^2} has no elementary antiderivative (§4.0), so crude bounds and numerics are all there is. Splitting into subintervals and bounding each tightens this quickly, which is exactly what §4.11's error analysis formalises.

4. Average value:

f_{\text{avg}} = \frac{1}{3-0}\int_0^3x^2dx = \frac13\cdot\frac{27}{3} = \frac13(9) = \boxed{3}

For the point: solve c^2 = 3, giving c = \sqrt3 \approx 1.732 (taking the root in [0,3]).

Note \sqrt3 is not the interval's midpoint 1.5 — it's to the right of it, because x^2 grows faster later and the larger values pull the average up. The MVT for integrals guarantees such a c exists but says nothing about where, and assuming the midpoint is a common and wrong instinct.

Check yourself in code

Compute Riemann sums symbolically and take their limits.

For \int_0^1 x^p\,dx with p = 1, 2, 3 using right endpoints, print the closed form of R_n (expanded) and its limit as n\to\infty.

Print exactly this:

int_0^1 x    R_n = 1/2 + 1/(2*n)   limit = 1/2
int_0^1 x^2  R_n = 1/3 + 1/(2*n) + 1/(6*n**2)   limit = 1/3
int_0^1 x^3  R_n = 1/4 + 1/(2*n) + 1/(4*n**2)   limit = 1/4
import sympy as sp

n, i = sp.symbols('n i', positive=True, integer=True)

for label, p in (("x", 1), ("x^2", 2), ("x^3", 3)):
    # sum (i/n)^p * (1/n) for i = 1..n, expand it, then take n -> oo
    print(f"int_0^1 {label:<4} R_n = ...")
import sympy as sp

n, i = sp.symbols('n i', positive=True, integer=True)

for label, p in (("x", 1), ("x^2", 2), ("x^3", 3)):
    R = sp.simplify(sp.summation((i/n)**p * (1/n), (i, 1, n)))
    print(f"int_0^1 {label:<4} R_n = {sp.expand(R)}   limit = {sp.limit(R, n, sp.oo)}")

The definite integral is the limit of Riemann sums over every partition and every sampling choice — and demanding agreement across all of them is what integrability means. Continuous functions qualify; so do bounded ones with finitely many discontinuities; unbounded ones and the Dirichlet function don't. The integral is linear, additive over intervals, and order-preserving, with the reversed-limits sign convention chosen to make additivity universal. And the MVT for integrals says the area equals some attained height times the width, which defines the average value of a function.

Next: the theorem that makes all of this computable, and links it back to §2.