---
title: "Measure and the Lebesgue integral: the ideas"
heading: Slicing the range instead of the domain, and why graduate courses need it
eyebrow: "A14 · Lesson 46 · Measure and the Lebesgue integral"
xp: 40
---

::: hook
The Riemann integral breaks under limits: the indicator of the rationals in [0, 1] is a pointwise limit of functions that are each zero except at finitely many points, and every one of those has integral 0, yet the limit has no Riemann integral at all. Lebesgue fixed this by measuring sets more cleverly and by slicing the *range* of a function instead of its domain. The payoff is an integral that limits pass through cleanly, a space $L^2$ that's complete, and a rigorous foundation for probability, where an expected value is an integral and an event of probability 0 is a set of measure 0. Graduate courses in signal processing, control and communications assume it; this lesson gives the ideas without the full construction.
:::

::: play
- Riemann slices the domain into strips. Lebesgue slices the range: the staircase rounds $x^2$ down to multiples of $\frac1n$, then adds up each level times the *measure* (total length) of the set where f is at that level.
- However wild the function, the rounded version is within $\frac1n$ of it everywhere (readout), so the sums converge.
- For a function like the indicator of the rationals, the set where f = 1 has measure 0, so Lebesgue gives its integral as 0 at once, where Riemann's upper and lower sums never meet.
:::
:::

```sim plot
view: graph
x: x = 0..1
y: y = 0..1.05
slider: n = 2..30 step 1 = 5
plot: x^2 | label: f(x) = x²
plot: floor(n*x^2)/n | samples: 1600 | dashed | label: f rounded down to levels of 1/n
readout: largest gap between them, at most = 1/n
readout: layer-cake integral ∫₀¹ (1 − √t) dt = 1/3
```

::: predict
## What's the total length (measure) of the rational numbers in [0, 1]?

- [ ] 1
- [ ] ½
- [x] 0
- [ ] It isn't defined

::: reveal
0. The rationals can be listed $q_1, q_2, \ldots$; cover $q_k$ by an interval of length $\varepsilon/2^k$, and the whole cover has total length at most ε, for any ε > 0. Any countable set has measure 0, even a dense one. The irrationals in [0, 1] therefore have measure 1.
:::
:::

::: nameit
## Measure

**Lebesgue measure** extends length from intervals to a huge family of sets: the measure of a set is the smallest total length of countably many intervals covering it. Properties:

- the measure of [a, b] is b − a;
- countably additive: disjoint sets' measures add, even infinitely many;
- every countable set has measure 0; so does the Cantor set (lesson 11), which is uncountable.

A property holds **almost everywhere** (a.e.) if it fails only on a set of measure 0. Functions equal a.e. have the same integral and are the same element of $L^2$.

## The Lebesgue integral

For a nonnegative measurable f, approximate it from below by **simple functions** (finitely many levels, each on a measurable set): $\int\sum c_k\mathbf 1_{E_k} = \sum c_k\,\mu(E_k)$, and take the supremum. Equivalently, the **layer-cake formula**:

$$\int f\,d\mu = \int_0^\infty\mu\{x : f(x) > t\}\,dt$$

## How it relates to Riemann

- Every Riemann-integrable function is Lebesgue integrable, with the same integral.
- A bounded function on [a, b] is Riemann integrable exactly when its set of discontinuities has measure 0.
- Lebesgue integrates far more (the indicator of the rationals: integral 0) and, crucially, behaves under limits (lesson 47).

## Probability

A probability is a measure with total mass 1, an event is a measurable set, a random variable is a measurable function, and $E[X] = \int X\,dP$. "With probability 1" means "almost everywhere": a uniformly random number in [0, 1] is irrational with probability 1.
:::

::: example
## Compute $\int_0^1x^2\,dx$ by the layer-cake formula.

::: solution
1. **The level sets.** On [0, 1], $x^2 > t$ exactly when $x > \sqrt t$, a set of measure $1 - \sqrt t$ (for 0 ≤ t ≤ 1).
2. **Integrate the measures.**
   $$\begin{aligned} \int_0^1x^2 &= \int_0^1(1 - \sqrt t)\,dt \\ &= 1 - \frac23 \\ &= \frac13 \end{aligned}$$
3. **Check.** That's $\frac13$, as expected, found by integrating the measures of the level sets instead of the heights over the strips.

**Answer:** $\int_0^1x^2\,dx = \frac13$.
:::
:::

::: example
## Cover the rationals in [0, 1] by intervals of total length at most 0.001.

::: solution
1. **List the rationals.** $q_1 = 0, q_2 = 1, q_3 = \frac12, q_4 = \frac13, \ldots$
2. **Cover each one.** Put an interval of length $0.001/2^k$ around $q_k$.
3. **Add the lengths.**
   $$\begin{aligned} \text{total} &= 0.001\left(\frac12 + \frac14 + \cdots\right) \\ &= 0.001 \end{aligned}$$
4. **Conclude.** However small the budget, a cover exists, so the measure is 0.

**Answer:** an interval of length $0.001/2^k$ around the kth rational covers them all with total length 0.001, so the rationals in [0, 1] have measure 0.
:::
:::

::: example
## For f(x) = x on [0, 1], compare Chebyshev's (Markov's) bound on $\mu\{f \ge 0.8\}$ with the truth.

::: solution
1. **Markov's bound.**
   $$\begin{aligned} \mu\{f \ge t\} &\le \frac{1}{t}\int f \\ &= \frac{0.5}{0.8} \\ &= 0.625 \end{aligned}$$
2. **The truth.** The actual measure of $\{x \ge 0.8\}$ is 0.2.
3. **Why use it.** The bound is loose but general: it needs only the integral, and it holds for every nonnegative measurable function.
4. **In probability.** It's the reason a random variable can't often be far above its mean, and squaring first (Chebyshev's inequality) sharpens it when the variance is known.

**Answer:** Markov's bound gives 0.625, against an actual measure of 0.2.
:::
:::

::: check
given: p = 2 | 3 | 0.5 | 4
answer: 1/(p + 1)
tolerance: 0.1%

## Using the layer-cake formula with $\mu\{x \in [0, 1] : x^p > t\} = 1 - t^{1/p}$, what's $\int_0^1x^{\given{p}}dx$?

::: right
Right. $\int_0^1(1 - t^{1/p})\,dt = 1 - \frac{p}{p + 1} = \frac{1}{p + 1}$ = {answer}.
:::

::: misses
- [p/(p + 1)] That's $\int_0^1t^{1/p}dt$; subtract it from 1.
- [any] Not yet. $\int_0^1(1 - t^{1/p})\,dt$.
:::
:::

::: check
given: e = 0.01 | 0.0001 | 0.5
answer: e
tolerance: 0.1%

## The rationals in [0, 1] are covered by intervals of length $\given{e}/2^k$ for k = 1, 2, 3, .... What's the total length?

::: right
Right. $\varepsilon\sum 2^{-k} = \varepsilon$ = {answer}.
:::

::: misses
- [2*e] The series $\sum_{k\ge 1}2^{-k}$ adds to 1, not 2.
- [any] Not yet. A geometric series.
:::
:::

::: check
given: n = 5 | 12 | 30
answer: 1 - (2/3)^n
tolerance: 0.1%

## How much total length has been removed after {n} stages of the Cantor construction?

::: right
Right. $1 - (2/3)^n$ = {answer}, which tends to 1: the Cantor set has measure 0.
:::

::: misses
- [(2/3)^n] That's what's left.
- [any] Not yet. Stage k removes $\frac13\left(\frac23\right)^{k-1}$.
:::
:::

::: check
given: a = 0 | 2; b = 3 | 7; c = 1 | 5
answer: c*(b - a)
tolerance: 0.1%

## f equals {c} on [{a}, {b}] except at the rational points, where it's 0. What's its Lebesgue integral over [{a}, {b}]?

::: right
Right. The rationals have measure 0, so $\int f = c(b - a)$ = {answer}.
:::

::: misses
- [0] The set where f = 0 has measure 0 and doesn't count.
- [any] Not yet. Change f on a set of measure 0: the integral doesn't change.
:::
:::

::: check
given: n = 4 | 10 | 50
answer: 1/n
tolerance: 0.1%

## Rounding a function down to multiples of $\frac1{\given{n}}$: how far can the rounded version be from the function, at most?

::: right
Right. Less than {answer}, everywhere, whatever the function.
:::

::: misses
- [any] Not yet. Each value drops by less than one level.
:::
:::

::: check
kind: choice

## A number is chosen uniformly at random from [0, 1]. What's the probability it's rational?

- [ ] Positive but tiny
- [x] 0, though rational outcomes are possible
- [ ] ½
- [ ] Undefined

::: misses
- [1] The rationals have measure exactly 0.
- [3] The irrationals have all the measure.
- [4] It's the measure of a countable set: 0.
:::
:::

::: check
kind: parts
given: p = 1 | 2 | 3; t = 0.5 | 0.8

## $f(x) = x^{\given{p}}$ on [0, 1].

::: part
answer: 1/((p + 1)*t)
tolerance: 0.5%

### What bound does Markov's inequality give on $\mu\{f \ge \given{t}\}$?

::: misses
- [any] $\frac{1}{t}\int f = \frac{1}{(p + 1)t}$.
:::
:::

::: part
answer: 1 - t^(1/p)
tolerance: 0.5%

### What is the actual measure?

::: misses
- [any] $x^p \ge t$ when $x \ge t^{1/p}$.
:::
:::
:::

::: check
kind: derivation
vars: p = 0.5..5

## The layer-cake formula $\int_0^1f = \int_0^1\mu\{f > t\}\,dt$ for $f = x^p$.

::: step
answer: 1 - p/(p + 1)

### With $\mu\{x^p > t\} = 1 - t^{1/p}$, what is the integral?
:::

::: right
Right. $\frac{1}{p + 1}$, the same as integrating $x^p$ directly.
:::
:::

::: explain
## Why does slicing the range (Lebesgue) handle wild functions that slicing the domain (Riemann) can't?

::: model
Riemann's sums need the function to be nearly constant on each small strip of the domain, which fails for a function that jumps around everywhere, like the indicator of the rationals: every strip contains both values, so the upper and lower sums never agree. Lebesgue instead groups the points by the function's value: all the points where f is near a given level, wherever they are, form one set, and its size is measured, however scattered it is. That only requires measuring complicated sets, which Lebesgue measure does, and the rounding error is controlled by the spacing of the levels, not by how the function behaves on strips. So any measurable function can be integrated, and limits of functions are handled level by level.
:::
:::

::: practice

::: check
given: p = 0.25 | 0.5 | 2 | 3 | 4 | 6
answer: 1/(p + 1)
tolerance: 0.1%

## $\int_0^1x^{\given{p}}dx$ by the layer-cake formula?

::: misses
- [any] $\frac{1}{p + 1}$.
:::
:::

::: check
given: n = 2..40 int
answer: 1 - (2/3)^n
tolerance: 0.1%

## Length removed after {n} Cantor stages?

::: misses
- [any] $1 - (2/3)^n$.
:::
:::

::: check
given: a = 1 | 4; b = 6 | 9; c = 2 | 3
answer: c*(b - a)
tolerance: 0.1%

## Integral of {c} on [{a}, {b}] with 0 at the rationals?

::: misses
- [any] Measure-zero changes don't count.
:::
:::
:::
