Book II · Real and Complex Analysis
Part 5 of 10Measure and the Lebesgue Integral
When may a limit pass through an integral if the convergence is not uniform?
The part opens with powers of cos(m! pi x), continuous functions whose double limit is Dirichlet's function, which has no Riemann integral, and with three sequences of integral 1 that go to zero at every point: mass escapes by growing tall, sliding away or spreading thin. Lebesgue's answer starts with length: cover a set by countably many intervals as cheaply as possible. The rationals and the Cantor set get measure zero, a fat Cantor set gets measure 1/2 without containing an interval, and Vitali's set gets no length at all, so the theory keeps to a sigma-algebra of measurable sets. The integral is a supremum over simple functions, and three limit theorems govern it: monotone convergence, Fatou's lemma, and dominated convergence, which needs only a lid, one integrable function above the whole sequence. Riesz's representation theorem then builds Lebesgue measure from the Riemann integral, Lusin shows measurable functions are nearly continuous, and Fubini allows either order of integration when the absolute value is integrable. The part ends by integrating the sawtooth series term by term, with the constant 2 as the lid.
What you need. Parts 1 to 3, or a first course in real analysis: compactness, uniform convergence, the Riemann integral.
What you will be able to do
Undergraduate
- Show that a countable set and the Cantor set have outer measure zero by exhibiting the covers.
- Give three sequences of integral 1 that converge to zero at every point, and say how the mass escapes in each.
Graduate
- Prove the monotone convergence theorem, deduce Fatou's lemma, and deduce dominated convergence from Fatou applied to 2g - |f_n - f|.
- Justify a swap of limit and integral, or of two integrals, by naming the lid or checking that the absolute value is integrable.
- State Lebesgue's criterion for Riemann integrability and apply it to Thomae's and Dirichlet's functions.
Qualifying exam
- Construct Vitali's set and prove it cannot be given a length that is countably additive and rotation invariant.
- Outline the proof of the Riesz representation theorem, and prove Egorov's and Lusin's theorems.
Applications
- Recognise a conditionally convergent integral such as that of sin x / x, which is an improper Riemann integral but not a Lebesgue integral.
- Bound a convolution by the product of the two L1 norms, and compute an integral from its level sets by the layer cake formula.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 8 min · Graduate 24 min · Qualifying exam 29 min · Applications 10 min.
- 0Limits under the integral, without uniformityUndergraduate3 min
- 1A length for every setUndergraduate3 min
- 2A set with no lengthQualifying exam2 min
- 3Sigma-algebras and measurable functionsGraduate2 min
- 4MeasuresGraduate1 min
- 5The integral, and monotone convergenceGraduate3 min
- 6Fatou's lemmaGraduate1 min
- 7Dominated convergenceGraduate3 min
- 8Every positive functional is an integralQualifying exam2 min
- 9Lebesgue measure, and Riemann revisitedGraduate2 min
- 10Measurable is nearly continuousQualifying exam1 min
- 11Product measures and FubiniGraduate2 min
- 12Convolution and the layer cakeApplications2 min
- The fifth row of the ledgerAll tracks2 min
Also on this page: Lecture · Key results · Try it · Lab · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
Limits under the integral, without uniformityUndergraduate3 min
Four rows of the ledger, and the same column keeps asking the same question: when may a limit pass through an integral? So far the answer has been: when the convergence is uniform. This part changes the integral, and gets a far better answer.
Here's a function from Part 3's museum, built as a limit. Take the cosine of m factorial pi x, raised to the power two n. As n grows, the curve collapses onto spikes at the points where m factorial times x is a whole number. Now let m grow too. The spikes multiply, and in the double limit we get Dirichlet's function: one at every rational, zero at every irrational. Every stage is continuous, and every limit in n has integral zero, but the final limit has no Riemann integral at all. The integral itself breaks under limits.
The theme of this part is mass escaping. Here are three sequences of functions, each with integral exactly one. The first gets taller and narrower; the second slides off to the right; the third spreads thinner and thinner. At every single point, all three go to zero, so the limit has integral zero, while every function in the sequence has integral one. What would stop the escape is a lid: one integrable function lying above every function of the sequence. Here the smallest possible lids have infinite integral. Lebesgue's dominated convergence theorem will say that a lid is all you need.
Lebesgue described his integral with a picture of counting money: rather than adding the coins in the order you meet them, sort them by value first. Riemann slices the domain into strips. Lebesgue slices the range into layers, and for each layer he needs the total length of the set where f exceeds that level. But the picture hides the real change. Here the set above one half is a few intervals. Those sets can be complicated: for Dirichlet's function, the set where it exceeds one half is the set of rationals, which is everywhere and contains no interval at all. The new idea is a way to give a length to such sets, and the first chapter is about exactly that.
The plan follows Rudin's Real and Complex Analysis. First, which sets can have a length, and why not all of them can. Then the integral and its three great limit theorems: monotone convergence, Fatou's lemma and dominated convergence. Then where measures come from, and how the new integral compares with Riemann's. And finally, integrals in several variables, Fubini's theorem, and convolution.
1A length for every setUndergraduate3 min
How to give a length to sets that are not intervals. Lebesgue's idea, from his thesis of 1902: cover a set by countably many intervals, add up their lengths, and take the smallest total you can get. That's the outer measure. Here's a set made of a few intervals and points. A crude cover, two overlapping intervals, has total length one point oh five. Tighter covers do better, and the infimum over all countable covers is the outer measure. Two properties are immediate: bigger sets have bigger outer measure, and the outer measure of a countable union is at most the sum of the outer measures.
The rationals between zero and one are dense, but they can be listed, as Part 1 showed. Cover the first by an interval of length epsilon over two, the second by epsilon over four, the k-th by epsilon over two to the k. Together the intervals have total length at most epsilon, and every rational is covered. Since epsilon was arbitrary, the rationals have outer measure zero: dense, but no length at all.
Part 1's Cantor set is uncountable, as big as the whole interval by counting. But its stages cover it: two to the n intervals with total length two thirds to the n, which goes to zero. So the Cantor set has outer measure zero. Counting and measuring are different kinds of size.
Now change the recipe. At stage n, remove from the middle of each piece an interval of length only four to the minus n. The removed lengths add up to one half, so what remains has measure one half. Yet the remaining pieces shrink to nothing: each stage more than halves the longest one. Magnify a piece sixty times and the same pattern of holes is there again. So the set contains no interval at all. It's nowhere dense, full of holes everywhere, and still has half the length of the line. Being thin and having measure zero are different things.
A sanity check: does an interval get its usual length? Covering it by itself shows the outer measure is at most b minus a. The other direction is where compactness enters. Widen each interval of a countable cover slightly to an open one, at a total cost of epsilon. By Heine–Borel, finitely many of them already cover the closed interval, and finitely many intervals that chain across it must have total length at least its length. So the outer measure of an interval is its length, as it should be.
2A set with no lengthQualifying exam2 min
Why some sets must be left without a length. Outer measure is defined for every set, but it isn't additive on every set. Could some cleverer definition be? We'd want three things on the circle: the length of a disjoint countable union is the sum of the lengths; turning a set doesn't change its length; and the whole circle has length two pi. In 1905 Vitali showed that no length function on all subsets can do all three.
The construction uses rotation of the circle by one radian. Since one radian is not a rational multiple of a full turn, the orbit of a point never comes back to it. It fills the circle densely: after two thousand steps, the largest gap is less than a hundredth of a radian.
Call two points equivalent if they differ by a whole number of radians. Each class is one orbit, countable and dense; here are five of them, though there are uncountably many. Using the axiom of choice, pick one point from every class, and call the resulting set V. This step can only be drawn as a schematic. Now rotate V by one radian, by two, by minus one, and so on. These copies are disjoint, and since every point is in some class, they fill the whole circle. If V had a length, countable additivity and rotation invariance would make two pi a sum of infinitely many copies of the same number: zero if the number is zero, infinite otherwise, because copies of any positive length, laid end to end, go around the circle again and again. Neither is two pi. So V has no length, and a theory of length must restrict itself to a smaller class of sets: the measurable ones. In three dimensions the same idea gives the Banach–Tarski paradox.
3Sigma-algebras and measurable functionsGraduate2 min
The sets that get a length, and the functions we will integrate. The sets that get a length form a sigma-algebra: a family that contains the whole space and is closed under complements and countable unions, so countable intersections too. Start from the open sets. Their complements are the closed sets, and countable unions of closed sets include the rationals, a union of single points. Keep going and you reach the Borel sets, the smallest sigma-algebra containing the open sets. Lebesgue's sigma-algebra is a little larger still, and Vitali's set lies outside it, among the sets no length can handle.
Which functions can we integrate? Part 2 characterized continuity by preimages: the preimage of every open set is open. A function is measurable if the preimage of every open set is measurable. Same template, weaker demand. And here is the point: limits are free. The supremum, infimum, upper limit and limit of measurable functions are measurable, so Dirichlet's function, a double limit of continuous ones, is measurable, though it is nowhere continuous: raise cosine of m factorial pi x to a high power and it becomes spikes at the fractions with denominator m factorial; then let m grow.
Every non-negative measurable function is the limit of an increasing sequence of simple functions, functions with finitely many values. The recipe slices the range: at stage n, round f down to the nearest multiple of one over two to the n. Each layer's preimage is a measurable set, so each stage is a finite combination of indicator functions. Each stage refines the last, so the sequence increases, and where f is below n, the error is at most one over two to the n. This is the honest version of Lebesgue's coins.
4MeasuresGraduate1 min
Measures, the abstract notion of size. A measure assigns a size, possibly infinite, to each set of a sigma-algebra, so that the size of a countable disjoint union is the sum of the sizes. Counting measure counts points. A Dirac mass puts weight one at a single point and none anywhere else. And length, Lebesgue's measure, which chapter nine builds properly.
Countable additivity makes measures continuous along monotone sequences. If sets increase to a union, their measures increase to the measure of the union: the intervals from zero to one minus one over n fill out the half-open unit interval, and their lengths climb to one. For decreasing sets you need a finite start. The rays from n to infinity shrink to the empty set, but every one of them has infinite length.
Sets of measure zero are invisible to integrals, which gives the phrase almost everywhere: true except on a set of measure zero. Dirichlet's function is one on the rationals, here drawn up to denominator forty, and zero elsewhere. The rationals have measure zero, so the function is zero almost everywhere, and its Lebesgue integral is simply zero. The function Riemann could not integrate is, to Lebesgue, the same as zero.
5The integral, and monotone convergenceGraduate3 min
The integral itself, and its first limit theorem. The integral of a simple function is what it should be: each value times the measure of the set where it's taken, added up. The integral of a non-negative measurable function is the supremum of the integrals of the simple functions below it. With the dyadic simple functions from the last chapter, the areas climb, and close in on the area under f.
The first limit theorem is the monotone convergence theorem: if non-negative functions increase to a limit at every point, their integrals increase to the integral of the limit. Here the functions are one over root x, cut off at height n. Each is bounded; the limit is not. Their integrals are two minus one over n, climbing to two, the integral of one over root x. No uniform convergence was needed, and no lid: only that the functions increase.
The proof is short and worth seeing. The integrals of f n increase, so they have a limit alpha, at most the integral of f. For the other direction, fix a simple function s below f, and a number c a little less than one. Let E n be the set where f n has already climbed above c times s. Because f n increases to f, which is above c s wherever s is positive, these sets grow and swallow everything. On E n, the integral of f n is at least c times the integral of s over E n, and by continuity of the measure from below, that tends to c times the integral of s. So alpha is at least c times the integral of s, for every c less than one and every simple s below f, which by definition means alpha is at least the integral of f.
A corollary: for non-negative functions, the integral of a series is the series of the integrals, always. The function minus log of one minus x, over x, is the sum of x to the k minus one over k, all non-negative. Integrate term by term: each term gives one over k squared. So the integral is pi squared over six, Part 3's Basel sum once more, and the numerical integral agrees.
6Fatou's lemmaGraduate1 min
Fatou's lemma, the inequality that limits always satisfy. When functions don't increase, we still get an inequality. Fatou's lemma: the integral of the lower limit is at most the lower limit of the integrals. The proof takes the infimum of the tail, from the k-th function on. These infima increase to the lower limit. Each is below the k-th function, so its integral is smaller. Monotone convergence moves the limit through the integral, and the inequality survives.
Here the inequality is strict. The functions one plus cosine n x all have the same integral, two pi, but they oscillate faster and faster. Their running minimum sinks toward zero: for almost every x, the multiples of x wrap densely around the circle, so cosine of n x keeps returning close to minus one. The lower limit is zero almost everywhere, with integral zero, while the integrals themselves stay at two pi.
The opening's three escapes fit the same pattern. In every case the lower limit is zero, with integral zero, while the integrals stay at one. Fatou's inequality points one way only: in the limit, mass can escape, but it can never appear from nowhere. The next chapter shows how to stop it escaping.
7Dominated convergenceGraduate3 min
Lebesgue's dominated convergence theorem, the answer this part promised. The theorem: if f n converges to f at every point, and the absolute values of all the f n lie under one integrable function g, the lid, then the integrals converge, and in fact the integral of the difference goes to zero. The proof is Fatou's lemma applied to the right functions. Two g minus the difference is non-negative, and it converges to two g, so Fatou bounds the integral of two g by the lower limit of its integrals. Pull out the integral of two g, which is finite because the lid is integrable, and the upper limit of the integral of the difference is at most zero. The lid is the whole story.
Compare two sequences on the half-line. On the left, the spreading sequence: it converges to zero uniformly, the strongest convergence Part 3 knew, yet every function has integral one. Part 3's theorem needed a bounded interval. On the right, one minus x over n, to the n. These lie under the single integrable lid, e to the minus x, so dominated convergence applies: the integrals, n over n plus one, converge to the integral of the limit, which is one.
Convergence of integrals and convergence at points are genuinely different. The typewriter sequence sweeps an indicator across the interval, then sweeps again at half the width, and so on. Its integrals go to zero. But every point is covered once in every sweep, so at no point do the values converge: they keep returning to one. Converging in area does not imply converging at points, though, as Part 6 will show, a subsequence always does.
One more bridge back to Part 3. Egorov's theorem: on a space of finite measure, convergence almost everywhere is uniform once you remove a set of arbitrarily small measure. x to the n converges to zero except at one, but not uniformly. Cut out a sliver of width epsilon at the right end, and on the rest the convergence is uniform: the largest value is one minus epsilon to the n. On an infinite measure space this fails: indicators of the rays from n to infinity converge to zero everywhere, but never uniformly.
8Every positive functional is an integralQualifying exam2 min
Where measures come from. The answer is the Riesz representation theorem. Think of an integral as a machine: a function goes in, a number comes out, and the machine is linear and positive. The Riemann integral is one such machine. Evaluating at a point is another, and so is any positive combination of point evaluations. The Riesz representation theorem says that every such machine on the continuous functions with compact support is integration against exactly one regular measure. The measure is hidden inside the functional, and the theorem pulls it out.
The functional only sees continuous functions, so the proof needs continuous functions that imitate sets. Urysohn's lemma provides them: for a compact set inside an open set, there's a continuous plateau, equal to one on the compact set and fading to zero before it leaves the open set.
Now the construction. For an open set V, let mu of V be the largest value the functional gives to plateau functions living inside V. For other sets, approximate from outside by open sets. Run it for the Riemann integral. The open set is four random intervals; the plateaus have collars of width one fifth, one twentieth, one hundredth, and so on. Their integrals climb to the total length of V. The machine has produced length.
The rest of the proof has four steps: define mu on open sets, extend it to all sets by approximating from outside, find a sigma-algebra on which it is countably additive, and finally show the functional is integration against mu. That last step slices f into horizontal layers of thickness epsilon: the functional of f is close to the sum of epsilon times the measure of each level set. Lebesgue's layer picture from the opening, now doing honest work inside the proof.
9Lebesgue measure, and Riemann revisitedGraduate2 min
Lebesgue measure, and how the new integral compares with Riemann's. Feed the Riemann integral into the Riesz machine and out comes Lebesgue measure. A box gets its volume. Sliding a set doesn't change its measure. Every measurable set is squeezed between a closed set inside and an open set outside, with as little room between them as you like. And these properties pin it down: it's the only translation-invariant measure that gives the unit cube measure one.
Which functions could Riemann integrate? Lebesgue answered exactly: a bounded function is Riemann integrable if and only if its points of discontinuity form a set of measure zero, and then the two integrals agree. Thomae's function is discontinuous at the rationals, a null set: Riemann can integrate it, and so can Lebesgue. Dirichlet's function is discontinuous everywhere: Riemann cannot. Lebesgue can, because it is zero almost everywhere. Every Riemann-integrable function is Lebesgue integrable, with the same integral.
One honest caveat. Sine x over x has an improper Riemann integral from zero to infinity: the positive and negative humps cancel more and more exactly, and the integral up to N converges to pi over two. But the humps' total area, without the cancellation, grows like the logarithm of N. A Lebesgue integral requires the absolute value to have a finite integral, so this function is not Lebesgue integrable. Conditionally convergent integrals are like conditionally convergent series in Part 2: useful, but fragile.
10Measurable is nearly continuousQualifying exam1 min
How wild measurable functions can be, which is: not very. Littlewood summed up the theory in three principles. Every measurable set is nearly a finite union of intervals. Every measurable function is nearly continuous. And every convergent sequence of functions is nearly uniformly convergent, which was Egorov's theorem. Nearly means: except on a set of measure as small as you like.
Lusin's theorem makes the second principle precise: a measurable function agrees with a continuous one except on a set of measure less than epsilon. Here f is a step function with a hundred random steps. The continuous g replaces each jump by a steep ramp; zoom in on one. The two functions differ only on the little intervals around the jumps, of total measure just under a twentieth.
A consequence we'll need in Part 6: continuous functions with compact support are dense among integrable functions. For our step function, the area between f and its repair is about four thousandths. A close cousin, the Vitali–Carathéodory theorem, squeezes every real integrable function between semicontinuous ones whose integrals are as close as you like.
11Product measures and FubiniGraduate2 min
Integrals over products, and the order of integration. The product of two measures gives rectangles their area, and every measurable set in the plane can be measured by slices. Slide a vertical line across the region and record the length of each vertical section; the integral of those lengths is the area. Slicing horizontally instead gives the same number.
Fubini's theorem, with Tonelli's version, for sigma-finite measures: for a non-negative measurable function, or for any function whose absolute value has a finite double integral, the two iterated integrals agree with the double integral. The proof climbs a ladder: rectangles, where both sides are just length times length; then all measurable sets, built from rectangles using monotone classes; then simple functions, which are finite sums of sets; then everything, by monotone convergence. The condition is not decoration.
The classic counterexample: x squared minus y squared, over the square of x squared plus y squared, on the unit square. It's positive below the diagonal and negative above, and huge near the corner. Integrate in y first: each vertical line gives one over one plus x squared, and integrating that in x gives pi over four. Integrate in x first: each horizontal line gives minus one over one plus y squared, and the total is minus pi over four. Two orders, two answers, exactly like Part 3's grid. The absolute value has infinite integral near the corner, so Fubini's hypothesis fails.
12Convolution and the layer cakeApplications2 min
Convolution, and one last look at slicing. Convolution averages one function against another. At each point x, weight the values of f near x by a bump g, and add. Slide the bump along: the averages trace a smoothed copy of f. This is Part 3's Landau construction, now for any integrable f.
Is the convolution of two integrable functions integrable? The proof is Fubini at work. Bound the integral of the absolute value by a double integral, swap the order, which Tonelli allows for non-negative functions, and the inner integral is just the integral of f, shifted. The norm of a convolution is at most the product of the norms. Checked on twenty random pairs.
And now the question that opened Part 3: may the sawtooth series be integrated term by term? Its partial sums never exceed the sine integral of pi, about 1.85, at any point, for any N. So on the interval from zero to one, the constant two is a lid, and dominated convergence makes the swap legal. Integrating term by term gives the sum of one minus cosine k over k squared; integrating the sawtooth itself gives pi over two minus a quarter. They agree to six decimal places. The convergence is not uniform, there's a jump, and it doesn't matter: a lid is enough.
Finally, Lebesgue's coins as a theorem: the layer cake formula. The integral of a non-negative function is the integral, over all heights t, of the measure of the set where f exceeds t. Slice the area into horizontal layers; each layer's width is the measure of a level set, and as a function of t, those widths have the same total area. It's Tonelli's theorem, applied to the region under the graph.
The fifth row of the ledgerAll tracks2 min
Let's take stock. Lebesgue gave lengths to sets by covering them as cheaply as possible, and Vitali showed that some sets must be left out. The sets that remain form a sigma-algebra, and measurable functions are closed under limits. The integral is a supremum over simple functions, and three limit theorems govern it: monotone convergence, Fatou's lemma, and dominated convergence, which needs only a lid. Riesz showed that measures come from positive functionals; Lebesgue measure comes from Riemann's integral, and agrees with it whenever Riemann's exists. Measurable functions are nearly continuous; Fubini lets us integrate in either order, when the absolute value is integrable; and the sawtooth can finally be integrated term by term.
The ledger's fifth row. The space: a set with a sigma-algebra and a measure. Its completeness theorem belongs to the next part. Lebesgue measure is regular, approximated by compact sets from inside. The swap: the limit of the integrals is the integral of the limit, under a lid. And Fourier's series may now be integrated term by term.
Next time, in Part 6: distances between functions. The p-norms measure functions in different ways; in the plane their unit balls run from a diamond, through the circle, to a square. With Lebesgue's integral, every one of these spaces is complete. And the case p equals two has angles and projections: Pythagoras in infinitely many dimensions, which is exactly the geometry Fourier series were waiting for.
This part followed chapters one, two and eight of Rudin's Real and Complex Analysis. Thanks for watching, and see you in Part 6.
Where it goes next. With Lebesgue's integral the spaces of p-th power integrable functions are complete: that theorem and the geometry of the case p = 2 are Part 6, which also shows that a sequence converging in area has a subsequence converging at almost every point and uses the density of continuous functions with compact support.
Key results
The part's results in one place, for revision.
Try it
Lab 5 · Dominated convergence: a lid is all you need
Take three sequences with integral 1 that tend to 0 at every point and measure the integral of their smallest lid; then check two sequences that do have an integrable lid, where the limit passes through the integral.
python -m videos.analysis.labs 5
needs numpy, scipy, matplotlib · download lab05.py ·
source on GitHubtall spike: ∫ f_n = 1, ∫ limit = 0 ∫ smallest lid for n <= 60: 4.681 (theory 4.680)
sliding block: ∫ f_n = 1, ∫ limit = 0 ∫ smallest lid for n <= 60: 60.001 (theory 60.000)
spreading slab: ∫ f_n = 1, ∫ limit = 0 ∫ smallest lid for n <= 60: 4.680 (theory 4.680)
(1 - x/n)^n under e^(-x): ∫ f_n at n = 320 0.99688 = n/(n + 1); ∫ |f_n - e^(-x)| = 3.1e-03
sawtooth: largest partial sum on [0, 1], N <= 300 1.8467 (Si(pi) = 1.8519 < 2)
sum of the integrals, integral of the sum 1.320796 1.320796 (sup error of s_300 near 0: 1.42)
Without an integrable lid the integral of the limit (0) is smaller than the limit of the integrals (1), as Fatou allows; under a lid the two agree, even where the convergence is not uniform.
The code (99 lines; it asserts its own result)
"""Lab 5: watch mass escape from three sequences of integral 1, and integrate the sawtooth series under a lid."""
from math import pi
import numpy as np
from scipy.integrate import quad
from scipy.special import sici
from videos.coursekit import labs
TITLE = "Dominated convergence: a lid is all you need"
GOAL = ("Take three sequences with integral 1 that tend to 0 at every point and measure the integral of their "
"smallest lid; then check two sequences that do have an integrable lid, where the limit passes through the integral.")
TASKS = [
"Add the typewriter sequence (indicators sweeping [0, 1] at widths 1, 1/2, 1/4, ...). Its integrals go to 0: does it converge at any point? Does it have a lid?",
"Compute the two iterated integrals of (x² - y²)/(x² + y²)² over the unit square and the integral of its absolute value over [eps, 1]² as eps shrinks.",
"Replace the lid 2 for the sawtooth by the exact envelope: the largest partial sum at each x. How close to Si(pi) does it come, and where?",
]
H = lambda n: float(np.sum(1.0 / np.arange(1, n + 1))) # noqa: E731
def escapes(n, x):
"""The three escaping sequences at index n, on the grid x of [0, 70]."""
return {"tall spike": n * ((x > 0) & (x <= 1 / n)), "sliding block": 1.0 * ((x >= n) & (x <= n + 1)),
"spreading slab": ((x >= 0) & (x <= n)) / n}
def integral(y, x):
return float(np.sum((y[1:] + y[:-1]) / 2 * np.diff(x)))
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
# a grid of [0, 70], fine near 0 where the spikes live
x = np.unique(np.concatenate([np.geomspace(1e-7, 1, 30_000), np.linspace(1, 70, 30_000)]))
n_max = 60
probes = np.sort(rng.uniform(0.05, 50, 6)) # random points at which to watch f_n(x) -> 0
lids = {name: np.zeros_like(x) for name in escapes(1, x)}
lid_int = {name: [] for name in lids}
for n in range(1, n_max + 1):
for name, fn in escapes(n, x).items():
if n in (5, 60):
assert abs(integral(fn, x) - 1) < 2e-3, "every function has integral 1"
lids[name] = np.maximum(lids[name], fn)
lid_int[name].append(integral(lids[name], x))
late = escapes(4000, probes)
assert all(np.all(v == 0) or np.all(v < 1e-3) for v in late.values()), "f_n(x) -> 0 at every probe"
theory = {"tall spike": H(n_max), "sliding block": float(n_max), "spreading slab": H(n_max)}
for name in lids:
lab.row(f"{name}: ∫ f_n = 1, ∫ limit = 0", f"∫ smallest lid for n <= 60: {lid_int[name][-1]:.3f} (theory {theory[name]:.3f})")
assert abs(lid_int[name][-1] - theory[name]) < 0.01 * theory[name]
assert lid_int[name][-1] > 1.5 * lid_int[name][4], "the lid's integral keeps growing: no integrable lid"
# A sequence with a lid: (1 - x/n)^n on [0, n] lies under e^(-x), and its integrals n/(n + 1) tend to 1.
ns = [1, 2, 5, 20, 80, 320]
ints, l1 = [], []
for n in ns:
fn = lambda s, n=n: (1 - s / n) ** n if s < n else 0.0 # noqa: E731
assert all(fn(s) <= np.exp(-s) + 1e-15 for s in rng.uniform(0, 2 * n, 200)), "under the lid"
ints.append(quad(fn, 0, n)[0])
l1.append(quad(lambda s: np.exp(-s) - fn(s), 0, n, limit=200)[0] + np.exp(-n))
assert np.allclose(ints, [n / (n + 1) for n in ns], atol=1e-9) and np.allclose(l1, [1 / (n + 1) for n in ns], atol=1e-8)
lab.row("(1 - x/n)^n under e^(-x): ∫ f_n at n = 320", f"{ints[-1]:.5f} = n/(n + 1); ∫ |f_n - e^(-x)| = {l1[-1]:.1e}")
# The sawtooth series on [0, 1]: partial sums never exceed Si(pi) < 2, so the constant 2 is a lid.
grid = np.linspace(0, 1, 2001)
k = np.arange(1, 301)
partial = np.cumsum(np.sin(np.outer(grid, k)) / k, axis=1)
si_pi = sici(pi)[0]
assert 0 <= partial.max() < si_pi < 2 and partial.min() >= 0, "the lid: 0 <= s_N <= Si(pi) on [0, 1]"
sup_err = np.abs(partial[1:, -1] - (pi - grid[1:]) / 2).max()
kk = np.arange(1, 2_000_001)
termwise = float(np.sum((1 - np.cos(kk)) / kk ** 2))
lab.row("sawtooth: largest partial sum on [0, 1], N <= 300", f"{partial.max():.4f} (Si(pi) = {si_pi:.4f} < 2)")
lab.row(" sum of the integrals, integral of the sum", f"{termwise:.6f} {pi / 2 - 0.25:.6f} (sup error of s_300 near 0: {sup_err:.2f})")
assert abs(termwise - (pi / 2 - 0.25)) < 2e-6 and sup_err > 1, "the swap holds though the convergence is not uniform"
lab.note = ("Without an integrable lid the integral of the limit (0) is smaller than the limit of the integrals "
"(1), as Fatou allows; under a lid the two agree, even where the convergence is not uniform.")
fig, ax = labs.figure(2, size=(11, 4.2))
idx = np.arange(1, n_max + 1)
for name, color, width in zip(lids, (labs.BLUE, labs.PURPLE, labs.GOLD), (5, 1.8, 1.4)):
ax[0].plot(idx, lid_int[name], color=color, lw=width, alpha=0.6 if width > 2 else 1,
label=f"{name}: ∫ of its smallest lid")
ax[0].plot(idx, idx / (idx + 1), color=labs.GREEN, label="(1 - x/n)ⁿ: ∫ fₙ, under the lid e⁻ˣ")
ax[0].axhline(1, color=labs.MUTED, ls="--", lw=1)
ax[0].set(title="The escaping sequences have no integrable lid", xlabel="n", yscale="log", ylim=(0.4, 900))
ax[0].legend(loc="upper left")
for n, color in zip((3, 10, 40, 300), (labs.BLUE, labs.PURPLE, labs.PINK, labs.ORANGE)):
ax[1].plot(grid, partial[:, n - 1], color=color, lw=1.2, label=f"s_N, N = {n}")
ax[1].plot(grid[1:], (pi - grid[1:]) / 2, color=labs.INK, lw=1.6, label="(pi - x)/2")
ax[1].axhline(2, color=labs.GOLD, lw=1.4, label="the lid 2")
ax[1].axhline(si_pi, color=labs.GOLD, ls="--", lw=1, label="Si(pi)")
ax[1].set(title="The sawtooth's partial sums on [0, 1], under a lid", xlabel="x", ylim=(0, 2.6))
ax[1].legend(loc="upper right", ncols=3)
lab.fig = fig
return lab
Now change it
- Add the typewriter sequence (indicators sweeping [0, 1] at widths 1, 1/2, 1/4, ...). Its integrals go to 0: does it converge at any point? Does it have a lid?
- Compute the two iterated integrals of (x² - y²)/(x² + y²)² over the unit square and the integral of its absolute value over [eps, 1]² as eps shrinks.
- Replace the lid 2 for the sawtooth by the exact envelope: the largest partial sum at each x. How close to Si(pi) does it come, and where?
Notes and sources
Sources
W. Rudin, Principles of Mathematical Analysis, 3rd ed. (1976); Real and Complex Analysis, 3rd ed. (1987); Functional Analysis, 2nd ed. (1991). Theorem numbers on screen are those editions'. Each part's credits scene lists the original authors and the companion texts.
About this partfrom its README
Part 5 of a ten-part series that builds mathematical analysis from the holes in the rational numbers to the spectral theorem, following the arc of Walter Rudin's three textbooks. This part covers chapter 11 of Principles and chapters 1, 2 and 8 of Real and Complex Analysis, in a hook, 12 chapters and an outro.
Why Riemann's integral is not enough (three ways mass escapes), outer measure and null sets (the Cantor set, the rationals, a fat Cantor set), the Vitali set, sigma-algebras and measurable functions, simple functions, the monotone and dominated convergence theorems, Fatou, Egorov and Lusin, the Riesz representation theorem that builds Lebesgue measure from the Riemann integral, and Fubini with its counterexample.
Every number the narration states is computed in compute.py and asserted; most scenes also assert the specific values they display.
What is computed and builtComputations (compute.py)
| Item | What is computed and asserted |
|---|---|
escapes |
the spike n 1_(0, 1/n], the runaway 1_[n, n+1], the spreading (1/n) 1_[0, n]: integral 1, limit 0 |
cantor |
covers of the Cantor set (total (2/3)^n) and of the rationals (total eps); the fat Cantor set (removed lengths 4^-n, measure 1/2, no interval) |
vitali |
the orbit of rotation by 1 radian on the circle: dense (its largest gap) |
simple |
Rudin 1.17's dyadic simple functions for f = x^2 + sin 5x + 1: sup |
mct |
min(1/sqrt x, n) on (0, 1]: integrals 2 - 1/n increasing to 2 |
dct |
n sin(x/n)/x -> 1 under the lid 1 (integrals n Si(1/n)); the typewriter; Egorov for x^n |
riesz |
the Riesz construction for the Riemann integral: mu(V) = sup Lambda f over f < V, for random open V |
lusin |
a 100-step function repaired to a continuous one off a set of measure < eps |
fubini |
(x^2 - y^2)/(x^2 + y^2)^2 on the unit square: iterated integrals +pi/4 and -pi/4 convolution |
Chapter notes
0:00 Limits under the integral, without uniformity
2:37 1. A length for every set
5:08 2. A set with no length
6:54 3. Sigma-algebras and measurable functions
8:52 4. Measures
10:12 5. The integral, and monotone convergence
12:23 6. Fatou's lemma
13:44 7. Dominated convergence
16:04 8. Every positive functional is an integral
17:59 9. Lebesgue measure, and Riemann revisited
19:39 10. Measurable is nearly continuous
20:59 11. Product measures and Fubini
22:37 12. Convolution and the layer cake
24:29 The fifth row of the ledger
Chapter notes
| # | Scene | Chapter |
|---|---|---|
| 0 | Hook |
Limits under the integral, without uniformity |
| 1 | Length |
1. A length for every set |
| 2 | Vitali |
2. A set with no length |
| 3 | SigmaAlgebras |
3. Sigma-algebras and measurable functions |
| 4 | Measures |
4. Measures |
| 5 | Integral |
5. The integral, and monotone convergence |
| 6 | Fatou |
6. Fatou's lemma |
| 7 | Dominated |
7. Dominated convergence |
| 8 | RieszRepresentation |
8. Every positive functional is an integral |
| 9 | Lebesgue |
9. Lebesgue measure, and Riemann revisited |
| 10 | NearlyContinuous |
10. Measurable is nearly continuous |
| 11 | Products |
11. Product measures and Fubini |
| 12 | Convolution |
12. Convolution and the layer cake |
| 13 | Outro |
The fifth row of the ledger |
Build the film
python -m videos.analysis.analysis5.compute # the part's numbers, into .cache/analysis5
python tools/build.py analysis5 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py analysis5 Hook # one chapter, silent, with a contact sheet
Scenes: videos/analysis/analysis5. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
The finished video is not stored in the repository. From the repo root, after the one-time setup in the top-level README:
python -m videos.analysis.analysis5.compute # once: every computed item (cached in .cache/analysis5)
python tools/build.py analysis5 -q k --fps 60 # the full-quality cut: 2160p60 + subtitles + chapters -> renders/analysis5_2160p.mp4
python tools/build.py analysis5 # 1080p30 -> renders/analysis5.mp4
python tools/build.py analysis5 -q l # fast 480p preview
python tools/export_script.py analysis5 # regenerate SCRIPT.md from the code
python tools/check_narration.py analysis5 # Whisper listen test of every narration line
The scenes share the series' instruments in explainer/analysis and helpers from earlier parts (see common.py). The full narration is in SCRIPT.md.