∫Analysis, Built

Book I · Principles of Mathematical Analysis

Part 3 of 10

Integration and the First Function Space

Undergraduatestarts at this level59 min of film17 chaptersprerequisites: Part 1, Part 2

When may two limits be swapped: the limit of a sequence of functions with an integral, a derivative, or continuity itself?

The part opens on Rudin's main problem with three failed swaps: x to the n loses continuity, a bump keeps its limit but not its integral, and sin(nx)/sqrt(n) converges while its slopes blow up. Riemann's integral is built from upper and lower sums, tested on continuous, monotone, Dirichlet's and Thomae's functions, and stretched into the Stieltjes integral, where the Cantor function integrates x to 1/2. Uniform convergence is the first answer to the main problem: uniform limits keep continuity and integrals, and make C(X) a complete metric space. In that space the part finds a continuous function with no derivative anywhere, replaces Heine-Borel by Arzelà-Ascoli, and proves that polynomials are dense, by Weierstrass's kernel and then by Stone-Weierstrass. Power series give exp, cos, sin and pi. The part ends where the series began, with Fourier series: the partial sum is the best mean-square approximation, Parseval accounts for all the energy, the sum of 1/n² is pi²/6, and the sawtooth's overshoot never drops below 8.95% of the jump.

What you need. Calculus, including integration by parts and the trigonometric identities.

What you will be able to do

Undergraduate

  • Compute upper and lower sums and use the criterion U - L < epsilon to prove a function integrable.
  • Tell pointwise from uniform convergence by computing the sup of |f_n - f|, and apply the M-test.
  • Give the three examples in which a limit fails to pass through continuity, an integral and a derivative.

Graduate

  • Prove that a uniform limit of continuous functions is continuous and that integrals pass through uniform limits.
  • Compute Fourier coefficients, and prove Bessel's inequality and the best-approximation property of the partial sums.

Qualifying exam

  • Prove Arzelà-Ascoli by the diagonal process, and Stone-Weierstrass in its four steps, with the example of the conjugate function on the circle for complex algebras.
  • Prove that Rudin's function of Theorem 7.18 is continuous and nowhere differentiable.

Applications

  • Approximate a continuous function by Bernstein polynomials or Fejér means and measure the sup error.
  • Predict the Gibbs overshoot at a jump, and say which sense of convergence (sup, mean-square) a truncated Fourier series can be trusted in.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 24 min · Graduate 46 min · Qualifying exam 59 min · Applications 36 min.

  1. 0The main problem: when may two limits be swapped?Undergraduate3 min
  2. 1Upper and lower sumsUndergraduate3 min
  3. 2Which functions are integrable?Undergraduate3 min
  4. 3Integrating against a staircaseGraduate3 min
  5. 4The fundamental theorem, and the length of a curveUndergraduate3 min
  6. 5Uniform convergenceUndergraduate4 min
  7. 6Uniform limits, and the space C(X)Undergraduate4 min
  8. 7Integrals and derivatives of limitsUndergraduate2 min
  9. 8A continuous function with no derivativeQualifying exam3 min
  10. 9EquicontinuityGraduate3 min
  11. 10Arzelà–Ascoli: compactness in C(X)Qualifying exam3 min
  12. 11Every continuous function is nearly a polynomialApplications3 min
  13. 12Stone–WeierstrassQualifying exam6 min
  14. 13Power series, exp, and the birth of πGraduate5 min
  15. 14Fourier series: the best approximationApplications5 min
  16. 15Parseval, Gibbs, and π²/6Applications4 min
  17. The third 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.

The main problem: when may two limits be swapped?Undergraduate3 min

So far we have built the real numbers and learned to take limits: of sequences, of sums, of difference quotients. That's two rows of the ledger. This part is about the third row, and it starts from the question that Rudin calls the main problem of his seventh chapter.

Here is the grid from the end of Part 2: m over m plus n. Walk along any row, letting n grow, and the entries go to zero; then let m grow, and you still have zero. Walk down any column first, and the entries go to one. Same numbers, two orders, two answers. Rudin's main problem is exactly this: when may two limits be swapped? Continuity, integrals, derivatives and infinite sums are all limits, so the question comes up everywhere.

Here are three sequences of functions where swapping fails. First, x to the n on the interval from zero to one. Each one is continuous. As n grows, the graphs fall to zero everywhere except at one, where they stay at one. The limit jumps, so a limit of continuous functions need not be continuous: approaching one first and then letting n grow gives one, and the other order gives zero. Second, Rudin's example: n squared x times one minus x squared to the n. At every single x these go to zero, but the bump grows taller and narrower, and its area, n squared over two n plus two, goes to infinity. The integral of the limit is zero; the limit of the integrals is infinite. Third, sine of n x over root n. These go to zero as uniformly as you could ask, since the largest value is one over root n. But they wiggle faster and faster: the slope at zero is root n, which grows without bound. The derivatives of the limit are zero, and the limit of the derivatives doesn't exist.

And this is why the question matters for Fourier's series. The sawtooth is the sum of sine k x over k. Integrating it term by term means integrating each sine and adding up, but the sum is itself a limit, so that's a swap of two limits, and we've just seen such swaps fail. This part finds conditions that make them legal.

Here's the plan, following chapters six to eight of Rudin's Principles. First the integral itself: Riemann's version and Stieltjes' generalization, which functions it can handle, and the fundamental theorem of calculus. Then uniform convergence, the condition that makes the swaps legal, and the first space whose points are functions. We'll meet a continuous function with no derivative anywhere, and the compactness theorem of Arzelà and Ascoli. Then approximation: every continuous function is nearly a polynomial. And finally the payoff: power series, and what we can now say about Fourier series.

What it establishes: The ledger; the grid m/(m + n) (7.2); three failed swaps: xⁿ (continuity), n²x(1 − x²)ⁿ (integral, 7.6), sin(nx)/√n (derivative, 7.5); the Fourier question; the plan.; Computed on screen: ∫ of the bump = n²/(2n + 2); sup sin(nx)/√n = 1/√n and slope √n at 0.

1Upper and lower sumsUndergraduate3 min

Riemann defined the integral in 1854, in the same paper where he studied Fourier series. We'll use the version that Darboux streamlined, which is the one Rudin uses: trap the area between two sums.

Take a bounded function on an interval, and ask for the area under its graph. Cut the interval into pieces with a partition: points x zero up to x n. On each piece, build a rectangle as tall as the function's supremum there: the red rectangles cover the area, and their total is the upper sum U. Build them as tall as the infimum instead, and the green rectangles fit under the graph: their total is the lower sum L. Whatever the area is, it must lie between L and U.

Now refine the partition by adding a point. On the piece that gets cut, the supremum over each half is at most the supremum over the whole, so the upper sum can only go down, and by the same argument the lower sum can only go up. Comparing any two partitions through their common refinement shows that every lower sum is at most every upper sum. So the best lower bound, the supremum of all lower sums, sits below the best upper bound, the infimum of all upper sums. These are the lower and upper integrals, and when they're equal the function is called integrable, and that common value is its integral.

Here's the practical test. The difference between the upper and lower sums is the total area of these yellow slivers, the gaps between each red rectangle and its green one. The function is integrable exactly when those gaps can be made as small as you like: for every epsilon, some partition has U minus L below epsilon. For this function, doubling the number of pieces roughly halves the total gap.

For an increasing function the gaps have a beautiful accounting. Take x squared with n equal pieces. Each yellow sliver is one piece wide and as tall as the function's rise across that piece. Slide them all over to the last piece and they stack into a single column, one n-th wide and as tall as the whole rise, from zero to one. So U minus L is exactly one over n. With sixteen thousand pieces, both sums agree with one third to four decimal places: the integral is one third.

What it establishes: Partitions, U and L (6.1–6.2); refinement (6.4); the criterion (6.6); x².; Computed on screen: U − L = 1/n exactly, n = 2 … 2¹⁴.

2Which functions are integrable?Undergraduate3 min

Which functions does this integral handle? Continuous ones, monotone ones, ones with a few jumps, and some surprisingly wild ones. And one simple function it can't handle at all.

Continuous functions on a closed interval are integrable, and the reason is uniform continuity from Part 2. Pick a small number eta. Because the interval is compact, one delta works everywhere: points closer than delta have values closer than eta. So on a partition with pieces shorter than delta, each gap between the supremum and the infimum is less than eta, and the total gap, U minus L, is less than eta times the length of the interval. That can be made as small as we like. Other proofs in the same chapter handle monotone functions, functions with finitely many jumps, and continuous functions of integrable ones.

Monotone functions are integrable even with jumps, by the stacking trick we saw for x squared. On each piece the gap is the function's rise across that piece, jumps included. Slide the slivers to one side: they stack into a single column, one piece wide and as tall as the total rise. So U minus L is the total rise divided by n, and it goes to zero.

Now the function this integral can't handle. Let f be one at every rational and zero at every irrational. Every piece of every partition contains both kinds of points, so every supremum is one and every infimum is zero. The upper sum is always one, the lower sum is always zero, and no refinement ever closes the gap. Dirichlet's function has no Riemann integral. Remember it: in Part 5 a better integral will give it the value zero, because the rationals, though dense, are too few to carry any area.

Compare Thomae's function from Part 2: one over q at the fraction p over q in lowest terms, and zero at irrationals. Again every infimum is zero, so every lower sum is zero. But the supremum on a short piece is one over the smallest denominator of a fraction in that piece, and short pieces only contain fractions with large denominators, apart from a few. Computed exactly on sixteen thousand equal pieces, the upper sum is below one hundredth, and it keeps falling. So this function, discontinuous at every rational, is integrable, with integral zero. Being discontinuous somewhere is harmless; the question, as Lebesgue would show, is how big the set of discontinuities is.

What it establishes: Continuous (6.8), monotone (6.9); Dirichlet (Exercise 6.4); Thomae.; Computed on screen: η = 0.5, δ = 0.2 for the uniform-continuity step; Thomae's U on dyadic partitions to 2¹⁴ (0.0084).

3Integrating against a staircaseGraduate3 min

Rudin's integral has an extra ingredient, an increasing function alpha that measures the pieces. Stieltjes introduced it in 1894. It looks like a technicality, but it lets one integral cover lengths, sums, and stranger things.

In the sums, replace the width of each piece by the increase of alpha across it. Think of alpha as a stretched ruler. Mark equal steps on the alpha scale, and pull them back to the x axis. Where alpha climbs fast, the marks crowd together, and a short stretch of x carries a lot of weight; where alpha is flat, a long stretch counts for little. For a smooth alpha this is just a density: the integral of f d alpha is the integral of f times alpha prime.

Now the extreme case. Let alpha be a single unit step at a point s: zero before it, one after. In any partition, only the piece containing s has an increase in alpha, and as the partition is refined, that piece closes in on s. So the integral of f d alpha is simply f of s: all the weight is concentrated at one point. Stack up countably many steps, of sizes c n at points s n, and the integral becomes the series of c n times f of s n. Sums and integrals are two cases of one idea, which will grow into measures in Part 5.

And now something stranger. Let alpha be the Cantor function from Part 1, the devil's staircase. It's continuous, so it has no jumps, and it's flat on every gap of the Cantor set, so its derivative is zero almost everywhere. Yet it climbs from zero to one. All of its increase happens on the Cantor set. At depth d there are two to the d intervals, each of length three to the minus d, and alpha rises by two to the minus d across each. For f of x equal to x, the gap between the upper and lower sums is three to the minus d, which goes to zero, and the integral is one half, as symmetry demands. The integral of x squared is three eighths. This integral is neither a sum over jumps nor an ordinary integral with a density. It's a third kind of thing, and in Part 5 it will have a name: a singular measure.

What it establishes: The stretched ruler; the unit step (6.14–6.16); the Cantor integrator (Exercise 6.6 territory); 6.17.; Computed on screen: ∫ x dC = 1/2, ∫ x² dC = 3/8 with U − L = 3⁻ᵈ.

4The fundamental theorem, and the length of a curveUndergraduate3 min

Why integration and differentiation undo each other, and what it means for a curve to have a length.

Start with an integrable function f, and let capital F of x be the area under f from a up to x. As x moves right, F grows by the area swept. If f is bounded by M, a step of h changes the area by at most M times h, so F is continuous, even across a jump of f. More: wherever f is continuous, the area added over a short step is nearly f times the step, so the slope of F at that point is the value of f. At the jump, the slope changes abruptly, and F has a corner.

The fundamental theorem goes the other way: if F has derivative f, and f is integrable, then the integral of f is F of b minus F of a. Take any partition. The total rise of F is the sum of its rises over the pieces. By the mean value theorem, each rise is f at some point t i times the width of the piece. That sum lies between the lower and upper sums, for every partition, so the total rise is the integral. Integration by parts and the change of variables formula follow from the same chapter's results.

The same circle of ideas gives curves a length. Inscribe polygons in the curve, with corners at the points of a partition. Refining the partition can only lengthen the polygon, by the triangle inequality, and the length of the curve is defined as the supremum. When the curve has a continuous derivative, that supremum is the integral of the speed.

And a curve without a length. Start with a segment. Replace its middle third by two sides of an equilateral triangle, and repeat on every segment, forever. Each step multiplies the length by four thirds, so the polygons' lengths grow without bound: after twelve steps they're already thirty-one times the original. Zoom in on the first quarter of the curve: it is the whole curve, shrunk by a factor of three. The curve is four such copies, so its length would have to be four thirds of itself, which no finite positive number is. The polygons converge uniformly to a continuous curve, which by the definition has no finite length. Uniform convergence will reappear in a moment: it's the theme of the rest of this part.

What it establishes: F = ∫f is continuous and F′ = f (6.20); the fundamental theorem (6.21); length (6.26–6.27); the Koch curve.; Computed on screen: Inscribed polygon lengths; Koch lengths (4/3)ᵏ; the first quarter of the depth-6 curve is the depth-5 curve shrunk by 3.

5Uniform convergenceUndergraduate4 min

The swaps in the opening failed because the functions converged at each point, but at different speeds at different points. The cure is to ask for one speed everywhere.

Put the two definitions side by side as games. Pointwise convergence: for each x and each epsilon there's an N, and N may depend on x. Uniform convergence: for each epsilon, one N that works for every x at once. Only the order of the quantifiers changed. Picture it as a band of half-width epsilon around the limit: uniform convergence means that from some N on, the entire graph lies inside the band. On the interval from zero to 0.9, x to the n does this: its largest value is 0.9 to the n, and with epsilon a tenth, N equal to 22 works everywhere. On the interval from zero up to, but not including, one, it never does: for every n, the graph climbs to near one before the end, outside any band.

From now on we'll watch sequences of functions through several lenses at once, on a dashboard. Here is x to the n again. The pointwise lens is a probe at one point, here 0.8: the distance there goes to zero. The uniform lens is the band: its half-width is the largest distance from the limit, and for x to the n it stays at one forever. Two more lenses measure the gap on average: the area between the graph and its limit, and the square root of the integral of the squared gap, which we'll call energy. Both go to zero. So this sequence converges in three senses but not uniformly. Uniform convergence is the most demanding, and this chapter shows it's the one that makes the swaps legal.

As with sequences of numbers, we can test uniform convergence without knowing the limit. A sequence of functions converges uniformly exactly when it's uniformly Cauchy: one N for which any two later functions are within epsilon of each other at every point. Here are partial sums of sine k x over k squared, and epsilon is 0.06. The first and second, or the third and tenth, are still too far apart somewhere; from the tenth on, every pair stays inside the band. The proof: at each x the values form a Cauchy sequence of numbers, so they converge to something we call f of x; then letting m go to infinity in the inequality gives uniform convergence to f. Everything is measured by one number, the largest gap, the height of the dot below. That suggests giving functions a size: the sup norm.

The most useful test for uniform convergence of a series is Weierstrass's M-test. If each term is bounded by a number M n, and the M n have a finite sum, the series converges uniformly. Here: sine of n x over n squared, bounded by one over n squared. After N terms, the rest of the series is at most the tail of the M n, so every partial sum lies in a band around the limit of that half-width, at every x at once, and the bands shrink to nothing. The numbers on screen are the actual largest gaps, each under its bound.

What it establishes: Pointwise vs uniform (7.7); the dashboard; Cauchy criterion (7.8) and sup norm (7.9); M-test (7.10).; Computed on screen: N = 22 for xⁿ on [0, 0.9] at ε = 0.1; dashboard lenses (exact sup 1, L¹ = 1/(n + 1)); pair gaps of Σ sin kx/k²; sup errors under their M-test tails.

6Uniform limits, and the space C(X)Undergraduate4 min

Uniform convergence preserves continuity, and that turns the continuous functions into a space of their own, with distances, where Cauchy sequences converge.

Suppose continuous functions f n converge uniformly to f. Why is f continuous? Pick n so large that f n lies within epsilon over three of f everywhere: the band. To compare f at x and at a nearby y, take three hops. Down from f of x to f n of x: less than epsilon over three, by uniform convergence. Along the graph of f n to f n of y: less than epsilon over three, because f n is continuous and y is close to x. Up to f of y: less than epsilon over three, by uniform convergence again, and crucially with the same n, because the convergence is uniform. Pointwise convergence would let the n needed at y be different, and the argument would collapse.

Sometimes pointwise convergence upgrades itself to uniform for free. Dini's theorem: on a compact set, if continuous functions converge monotonically to a continuous limit, the convergence is uniform. Here one plus x over n, to the n, increases to e to the x on the interval from zero to one. The worst gap is at x equal to one, and it shrinks steadily. Compactness matters: x to the n decreases to zero on the half-open interval, and the convergence is not uniform.

Now a change of viewpoint. Measure the distance between two continuous functions on a compact set by their largest gap. Then the continuous functions form a metric space, and each function is a single point in it. On the right is a camera on that space: each function is plotted by two of its values, at one half and at 0.4. Here's a sequence of polynomials closing in on the absolute value of x minus a half: their sup distances shrink, so it's a Cauchy sequence, and on the camera the dots form a trail. Once a function is within r of the limit in the sup norm, its dot lies inside a square of half-width r, and every later dot does too. The limit has a corner, so it's not a polynomial: the polynomials have a hole here. But it is continuous, and that's the theorem: by the previous result, uniform limits of continuous functions are continuous, so this space is complete. It's our first Banach space, though the name will wait for Part 8.

One more exhibit for the museum, from Rudin's exercises. Build a plane curve whose coordinates are series of copies of one continuous zigzag function, scaled by powers of three inside and halved outside. By the M-test both series converge uniformly, so the curve is continuous. But it passes through every point of the square: the ternary digits of the parameter become the binary digits of x and y. A continuous image of a segment can fill a square. Peano found the first such curve in 1890; this one is Schoenberg's.

What it establishes: 7.12 by three hops; Dini (7.13); C(X) complete (7.14–7.15) on the camera; Schoenberg's curve (Exercise 7.14).; Computed on screen: (1 + x/n)ⁿ → eˣ errors; Bernstein's trail with nested sup-ball squares; the curve's exact hits from ternary digits.

7Integrals and derivatives of limitsUndergraduate2 min

The two remaining swaps from the opening, integrals and derivatives. Integrals first. If f n converges to f uniformly on a closed interval, then the integral of the limit is the limit of the integrals. The picture is the whole proof: the difference of the integrals is at most the area between the graphs, and that area fits inside a box as wide as the interval and as tall as the largest gap. Uniform convergence squashes the box. So a uniformly convergent series may be integrated term by term. Fourier's sawtooth series doesn't qualify, because its partial sums can't converge uniformly to a function with a jump. We'll settle it another way in chapter fifteen.

Derivatives are more delicate: uniform convergence of the functions is not enough. Rudin's theorem asks instead for the derivatives to converge uniformly, and then the limit is differentiable with the expected derivative. Here's why the hypothesis is on the derivatives. The functions x over one plus n x squared shrink to zero uniformly: their largest value is one over two root n. But their derivatives at zero are all equal to one, while everywhere else the derivatives go to zero. The derivatives converge, but to a function that jumps at zero, and the limit of the derivatives at zero is one, while the derivative of the limit is zero. Small functions can have large slopes. Control has to come from the derivatives.

So far, then: uniform convergence lets limits pass through continuity and through integrals, and for derivatives we need the derivatives to converge uniformly. Uniformity is a strong demand, and in Part 5 a better integral will let limits pass through integrals under a much weaker condition.

What it establishes: 7.16 with the box bound; 7.17 and x/(1 + nx²); the swaps so far.; Computed on screen: ∫f_n vs ∫f live; sup x/(1 + nx²) = 1/(2√n), f_n′(0) = 1.

8A continuous function with no derivativeQualifying exam3 min

A function that is continuous everywhere and differentiable nowhere. In 1872 Weierstrass showed the Berlin Academy such a function. Uniform convergence makes it easy to build; the hard part is the proof that it has no derivative, and Rudin's version of that proof is short. Rudin uses the zigzag phi: the distance to the nearest even integer. Add copies of it, the n-th one squeezed horizontally by four to the n and shrunk vertically by three quarters to the n. Each new term is smaller, but steeper: its slopes are plus or minus three to the n. The heights form a geometric series, so by the M-test the sum converges uniformly, and the limit is continuous. Every partial sum has corners; the limit, as we'll see, is all corners.

Zoom in at a point. A differentiable function, under enough magnification, looks like a straight line: that's what a derivative is. This one never does. Every zoom by a factor of four shrinks the vertical range by only about three, and new corners keep appearing. Brownian motion, from the stochastic calculus video, has the same property, almost surely: nature produces these functions on its own.

Here's Rudin's proof that there is no derivative at any x, carried out at x equal to 0.3. Step away from x by half of four to the minus m, choosing the sign so that the m-th zigzag has no corner in between. On the right, m is three, and each panel is one term over that step. Every later term repeats exactly over the step, because four to the n times the step is an even integer, the zigzag's period: those terms contribute nothing. The m-th term is a straight piece with slope three to the m, here twenty seven. The earlier terms have slopes at most three to the n, which add up to at most three to the m minus one, over two. So the difference quotient is at least three to the m plus one, over two, which grows without bound as the step shrinks. Computed for other m, the quotients are exactly as big as promised, and they never settle down. There is no derivative at x, and x was any point.

Into the museum. And a teaser: in Part 8, Baire's theorem will show that in a precise sense most continuous functions are like this one, and the smooth ones are the rare exceptions.

What it establishes: Rudin 7.18: construction, the zoom, the proof.; Computed on screen: Each term's share of the quotient at x = 0.3, m = 3 (exact rationals: 1, 3, 9, 27 in size, then 0, 0); quotients to m = 10.

9EquicontinuityGraduate3 min

In R n, closed and bounded sets are compact. In the space of continuous functions, Part 1 already warned us, they are not. Here is what's missing.

Take sine of n x on the interval from zero to two pi. Every one of them is bounded by one, so they all lie in the unit ball of the space. But compute their sup distances: every pair is more than one apart. No subsequence can be Cauchy, so none converges uniformly, and the closed, bounded unit ball is not compact. Rudin shows even more: no subsequence converges at every point.

A second example, from Rudin. These functions are bounded by one and converge to zero at every single point. But each has a bump of height exactly one, at one over n, which slides toward zero and gets narrower. No subsequence can converge uniformly, since the sup distance to zero stays one. Being bounded, even converging pointwise, is not enough. What fails is the steepness: the family gets steeper and steeper.

The missing ingredient is equicontinuity: one delta that works not only for every pair of points, but for every function in the family at once. It's the epsilon-delta game with delta chosen before the point and before the function. On the left, sine k x over k. Every one of them has slope at most one, so a single delta, just over a tenth, keeps every function's change below a tenth, whatever k is. On the right, sine k x without the damping. With ten of them, delta must be a hundredth; with a thousand, a ten-thousandth. No delta serves the whole family: the steep members ruin it.

And equicontinuity is necessary. If continuous functions converge uniformly on a compact set, they form an equicontinuous family. Past some N they're all within a third of epsilon of one function, f N, so they inherit its delta, up to two more thirds. The finitely many before N are each uniformly continuous, and the smallest of their finitely many deltas works for all of them. One column of that width serves the whole family. The next chapter shows the converse, which is the real prize: bounded and equicontinuous is enough for a convergent subsequence.

What it establishes: sin(nx) has no convergent subsequence; 7.21's bumps; 7.22; 7.24.; Computed on screen: Pairwise sup distances > 1; δ = 0.1 for {sin kx/k}, ε/K for {sin kx}; one δ for 24 uniformly convergent functions.

10Arzelà–Ascoli: compactness in C(X)Qualifying exam3 min

The theorem of Arzelà and Ascoli, the compactness theorem for spaces of functions, and one of the most used theorems in analysis.

The theorem: if a sequence of continuous functions on a compact set is pointwise bounded and equicontinuous, then it has a uniformly convergent subsequence. Here's such a family: random functions, all bounded by one, with slopes at most one. The proof has two steps. First, get convergence at countably many points, densely spread, by Cantor's diagonal trick. Then use equicontinuity, and compactness, to spread that convergence to every point, uniformly.

Step one. List the rational points, or any countable dense set: here, the dyadic points one half, one quarter, three quarters, and so on. The values at the first point are bounded, so by Bolzano–Weierstrass some subsequence converges there: that's the first row. From it, extract a further subsequence that converges at the second point as well: the second row. And so on, each row inside the one above. Now take the diagonal: the first function of the first row, the second of the second, and so on. From the n-th place on, the diagonal is a subsequence of the n-th row, so it converges at every one of the points. These are actual indices from a computed family.

Step two. Fix epsilon, and take the delta that equicontinuity provides for the whole family. Because the set is compact, finitely many of the dense points have delta neighborhoods covering all of it. Along the diagonal sequence, the values converge at those finitely many points, so past some index they're Cauchy at all of them at once. Now any x is within delta of one of them, p, and the triangle inequality through p gives three epsilons, at every x, for the same indices. The diagonal sequence is uniformly Cauchy, and since C of K is complete, it converges uniformly.

Here's the proof run on a computer. Four hundred thousand random functions, each bounded by one with slope at most one: a uniformly bounded, equicontinuous family. The diagonal process keeps, at each stage, the functions whose value at the next dyadic point falls in the most crowded small bin, a finite stand-in for converging there. The diagonal functions close in on each other: the largest gap to any later one falls from about a fifth to under three hundredths, uniformly in x.

So here's the dictionary entry. In R k, bounded sequences have convergent subsequences. In the space of continuous functions on a compact set, bounded sequences need one more property, equicontinuity, and then they too have uniformly convergent subsequences. This theorem will produce solutions of differential equations in Part 4 and conformal maps in Part 7.

What it establishes: 7.23 by the diagonal; spreading by equicontinuity; 7.25; the dictionary.; Computed on screen: The actual surviving indices among 400,000 random functions; spreads shrinking stage by stage.

11Every continuous function is nearly a polynomialApplications3 min

In 1885 Weierstrass proved that every continuous function on a closed interval is a uniform limit of polynomials.

However wild the graph, some polynomial stays within any tolerance of it, all along the interval. Rudin's proof uses a family of polynomials that act like a narrowing bump: c n times one minus x squared, to the n, with c n chosen so the area is one. As n grows, the bump gets taller and narrower. The normalizing constant stays below root n, which is what the estimates need. And for any fixed delta, the fraction of the area outside the interval from minus delta to delta goes to zero.

Take a continuous f on the interval from zero to one, vanishing at the ends: any continuous function can be brought to this form by subtracting a straight line. Slide the bump along, and at each x record the bump-weighted average of f near x. That average, as a function of x, is a polynomial, because the bump is a polynomial in t minus x. Where f has a corner, the average rounds it off. As n grows the bump narrows and the average hugs f more closely.

The estimate is the epsilon-over-two trick again. Because the bump has area one, the error at x is at most the bump-weighted average of the gaps between f near x and f at x. Split the average. Near x, within delta, the gaps are below epsilon over two, by uniform continuity. Far from x, the gaps are at most two M, but the bump has almost no mass there. With c n below root n, the far part is at most four M root n times one minus delta squared, to the n, which goes to zero. The bound doesn't depend on x, so the convergence is uniform.

Here's the construction carried out for a tent with two corners. With n equal to ten thousand, the polynomial, of degree twenty thousand, is within five thousandths of the tent everywhere. The error is largest at the corners, and shrinks roughly like one over root n.

There's a second, probabilistic proof, due to Bernstein. At x, flip n coins that each land heads with probability x, and average f over the fraction of heads. That average is a polynomial in x. By the law of large numbers, the fraction of heads concentrates near x, so the average approaches f of x, uniformly. Either proof gives a fact the next chapter needs: the absolute value function is a uniform limit of polynomials on any interval.

What it establishes: 7.26 with the Landau kernel; the near/far estimate; Bernstein.; Computed on screen: c_n < √n; the far mass 0.0051 ≤ 2√n(1 − δ²)ⁿ; sup errors to n = 10⁴ (0.0045).

12Stone–WeierstrassQualifying exam6 min

In 1937 Marshall Stone asked what it is about polynomials that makes Weierstrass's theorem true.

He found that only two properties matter. The setting is an algebra of functions: a family closed under sums, products and constant multiples, like the polynomials. Here is the first thing that can go wrong. The even polynomials on the interval from minus one to one form an algebra, but each one takes the same value at x and at minus x, so none of them can come near the function x: at plus and minus one, the error is at least one. The algebra fails to separate points. Second, the polynomials with no constant term form an algebra, but they all vanish at zero, so none comes near the constant one. All polynomials have neither defect, and they are dense: that was chapter eleven.

Stone's theorem says these two defects are the only obstructions. If an algebra of continuous functions on a compact set separates points and vanishes at no point, then its uniform closure is everything: every continuous function is a uniform limit of members of the algebra. So polynomials in several variables are dense on any compact set in R k, and so are sums of decaying exponentials on the unit interval. And the even polynomials, which failed on the symmetric interval, are dense on the interval from zero to one, where x squared separates points: here they close in on the function x, the very function they could not reach before.

The proof has four steps. Let B be the uniform closure of the algebra; B is itself an algebra, and we want to show it contains every continuous function. Step one: if f is in B, so is its absolute value. f is bounded, say by a, and by Weierstrass's theorem there are polynomials P n converging to the absolute value of y uniformly on the interval from minus a to a. Plug f into them. P n of f is built from f by sums, products and constants, so it lies in B, and it is within the same distance of the absolute value of f. As the degree grows, P n of f converges uniformly to the absolute value of f, and B is closed, so the absolute value is in B.

Step two. The larger of two functions is their average plus half their difference in absolute value, and the smaller is the average minus it. So by step one, B is closed under taking the maximum or the minimum of two functions, and by induction, of finitely many. Step three uses the two hypotheses. Because the algebra separates points and vanishes nowhere, it can match any two values at any two points. For polynomials that's just the line through two points, a combination of one function vanishing at x and one vanishing at y.

Step four builds the approximation, here for e to the x on the interval from zero to one, with epsilon equal to a tenth, using the polynomial algebra. Fix a point x. For each other point y, step three gives a member of the algebra that agrees with f at both x and y: here, the line through the two points of the graph. Each such line exceeds f minus epsilon on an open set around y. These open sets cover the interval, so by compactness finitely many of them do: here, nine. Take the largest of those nine lines. It's in B by step two; it agrees with f at x; and it never drops below f minus epsilon. Call it the cap at x.

Now build a cap at every point. Each cap is below f plus epsilon on an open set around its own point, because it agrees with f there. Compactness again: finitely many of these sets cover, here twenty one. Take the smallest of those caps. It is still above f minus epsilon, since every cap is, and now it's below f plus epsilon everywhere too. Computed, the minimum is within two hundredths of e to the x. Epsilon was arbitrary and B is closed, so f is in B. Separating points and vanishing nowhere were used only in step three, to make the lines exist.

For complex-valued functions there's a catch. On the unit circle, the polynomials in z separate points and contain the constants, yet they can't approximate z bar, the complex conjugate, which runs around the circle the other way. Here's why. Every polynomial times z has average zero around the circle, because each power of e to the i theta integrates to zero. But z bar times z is one. So the distance from z bar to P of z is the size of one minus z P of z, and one minus z P of z averages to exactly one: the curve it traces is centered at one, so it can never stay inside the unit disk. Whatever polynomial we try, somewhere the error is at least one. The fix, Rudin 7.33, is to require the algebra to contain the conjugate of each of its members. Adding z bar gives the trigonometric polynomials, and those are dense: the key to Fourier series, three chapters from now.

What it establishes: 7.28–7.33: the obstructions, the theorem, the four steps, z̄.; Computed on screen: Even polynomials on [0, 1] approaching x; Bernstein's

13Power series, exp, and the birth of πGraduate5 min

Uniform convergence pays off first for power series. Rudin uses them to define the exponential function, and from it the sine, the cosine, and the number pi, without drawing a single triangle.

Rudin's theorem 8.1: a power series with radius of convergence R converges uniformly on every smaller closed interval. Here's the geometric series, whose sum is one over one minus x. On the interval up to 0.8, the largest error of the N-th partial sum is 0.8 to the N plus one, over 0.2, which goes to zero. On the whole open interval the convergence is never uniform: near one the sum is unbounded, and every partial sum is bounded. Uniform convergence on each smaller interval is all chapter seven needs. The sum is continuous, and it may be differentiated term by term, since the differentiated series has the same radius. Repeating, a power series is infinitely differentiable, and its coefficients are its Taylor coefficients.

At the edge of the interval, uniform convergence can fail, and Abel's theorem fills the gap: if the series converges at x equal to one, then its sum there is the limit of the function as x approaches one from below. The series with coefficients plus and minus one over n sums to the logarithm of one plus x inside the interval. At x equal to one it becomes the alternating harmonic series, which converges by Part 2's alternating test, slowly. Abel's theorem identifies its sum: the logarithm of two. Summing the series at x closer and closer to one gives values marching up to it. The converse is false: one minus one plus one, and so on, has an Abel limit of one half but no sum. That kind of averaged sum comes back in Part 7, for Fourier series.

Rudin defines E of z as the sum of z to the n over n factorial, for every complex z. Multiplying two such series, by Part 2's Cauchy product, gives the law E of z times E of w equals E of z plus w, and on the real line E is the exponential function. Now put in i times t. Each term is the previous one turned by a right angle and scaled by t over n, so the partial sums spiral inward. Where do they land? E of i t times E of minus i t is E of zero, which is one, so the landing point is always on the unit circle. Its coordinates are, by definition, the cosine and the sine of t. As t grows, the spiral's endpoint runs around the circle, and since the derivative of E of i t has length one, it runs at unit speed: by chapter four, the arc it has covered has length exactly t.

Now pi. The cosine series starts at one, and at t equal to two it's already negative, since after the first few terms the series alternates with shrinking terms. By the intermediate value theorem the cosine has a first positive zero, and Rudin defines pi to be twice that zero. We can find it from the series alone, by bisection: halve the interval, keep the half where the sign changes, and repeat. Twice the midpoint gains a correct digit about every three steps. After sixty halvings, it agrees with pi in all fourteen decimal places shown. The rest follows from the addition law: E of i pi over two is i, E is periodic with period two pi i, and since the circle is traced at unit speed, pi is half its circumference. Not one triangle was needed.

One more gift of these series: the fundamental theorem of algebra, Rudin 8.8. The size of a polynomial grows without bound far out, so it has a smallest value somewhere. Suppose that smallest value were not zero. Take a small circle around the point. Its image under P is a loop around P of z zero, and a loop around a point can't stay outside the circle through that point: part of it dips closer to zero. So the value wasn't the smallest after all. Repeat the step from the new point, and the values march down to zero, at a root. In Part 7 the same theorem will take one line.

What it establishes: 8.1, Abel (8.2), exp/cos/sin (8.6–8.7), π, 8.8.; Computed on screen: r^(N+1)/(1 − r); Abel sums to ln 2; 20 terms of e^(2i); π by 60 bisections (12 digits); a descent to a root of z³ − 2z + 2.

14Fourier series: the best approximationApplications5 min

In 1807 Fourier claimed that every function is a sum of sines and cosines, and in 1829 Dirichlet proved it for a large class of functions.

Rudin starts not from convergence but from a geometric question: which trigonometric polynomial is closest to f? The key fact is orthogonality. Take two different sine waves, multiply them, and integrate over a period: the positive and negative parts cancel exactly. The same wave times itself is positive, and integrates to pi. In complex form, the exponentials e to the i n x behave like perpendicular unit vectors: the average of one times the conjugate of another is one if they're the same and zero otherwise. So the Fourier coefficient c n, the average of f times e to the minus i n x, is the coordinate of f along the n-th axis.

Rudin's theorem 8.11: among all trigonometric polynomials of degree at most N, the one whose coefficients are f's Fourier coefficients is the closest to f in mean square. Here's the sawtooth, its Fourier partial sum of degree six, and one competitor. I tried five hundred random competitors near the partial sum: every one has a larger squared error. Even the best of them has nearly twice the squared error. The reason is Pythagoras. The error f minus s N is orthogonal to every trigonometric polynomial of degree N, so for any competitor t, the squared distance from f to t is the squared distance to s N plus the squared distance from s N to t. The Fourier partial sum is the foot of the perpendicular from f. This is the first glimpse of Hilbert space, the subject of Part 6.

Take the competitor t to be zero. Pythagoras says the energy of f is the energy of its partial sum plus the energy of the error, so the partial sum has less energy than f. By orthogonality, the energy of the partial sum is the sum of the squared coefficients. That's Bessel's inequality: the sum of the squares of the Fourier coefficients never exceeds the average of f squared. For the sawtooth, the bar's length is pi squared over twelve, and the squared coefficients, one over two n squared for each pair plus and minus n, stack up inside it. In particular the coefficients go to zero. Whether they fill the bar completely is the question of the next chapter.

To study convergence, write the partial sum as an integral: it's an average of f against the Dirichlet kernel, the sum of the exponentials up to N. Like the Landau kernel, it has total signed area two pi and a tall central peak. Unlike it, it isn't positive: its side lobes alternate in sign and don't shrink fast. The area under its absolute value, computed here, grows without bound, like the logarithm of N. That growth has a price. Du Bois-Reymond found a continuous function whose Fourier series diverges at a point; in Part 8, the uniform boundedness principle will turn this table of numbers into a proof that such functions exist.

Pointwise convergence needs a little regularity. Dini's test: if f is Lipschitz at x, the partial sums converge to f of x. Subtract f of x and the error becomes the integral of a function g against a sine of higher and higher frequency. Because f is Lipschitz at x, g is bounded, even near zero, where the denominator vanishes. Here it is for the sawtooth at x equal to one; its jump is harmless. As N grows, the positive and negative lobes cancel better and better, and Bessel's inequality, applied to g, shows the integral goes to zero. Computed: at pi over two and at one, the partial sums close in on the sawtooth's values. Part 2 proved that this series converges everywhere, but not to what. Now we know: pi minus x, over two.

What it establishes: Orthogonality (8.9), 8.11, Bessel (8.12), the Dirichlet kernel (8.13), Dini (8.14).; Computed on screen: The 7 × 7 Gram matrix; best = 0.4804 vs 500 competitors; Lebesgue constants to N = 500; s_N(π/2) → π/4.

15Parseval, Gibbs, and π²/6Applications4 min

The payoff: in what sense does a Fourier series converge to its function? First, density. The trigonometric polynomials, sums of c n e to the i n x, form an algebra of functions on the circle that contains the constants, separates points, and is closed under complex conjugation. So by Stone's theorem, every continuous periodic function is a uniform limit of trigonometric polynomials. Here are such polynomials closing in on a continuous function with three corners. They are an explicit choice, found by Fejér in 1900: averages of the Fourier partial sums, which damp the high frequencies. Fejér's kernel is positive, like Landau's, and the averages converge uniformly.

Now Parseval's theorem, Rudin 8.16. For every Riemann-integrable function, the mean square error of the partial sums goes to zero, and Bessel's inequality becomes an equality. The proof chains three approximations. f is close in mean square to a continuous function; that is uniformly close to a trigonometric polynomial; and the Fourier partial sum is at least as close as any polynomial of its degree. In the picture from last chapter, the bar now fills completely. The red gap is the energy the partial sum is still missing, which is exactly its mean square error, and it shrinks to zero.

Parseval's equation, applied to the sawtooth, sums a famous series. On one side, the average of the square of pi minus x over two. That integral is pi squared over twelve. On the other side, the coefficients: from the sawtooth's series, each pair plus and minus n contributes one over two n squared. Multiply by two: the sum of one over n squared is pi squared over six. Euler found this in 1734; a 3Blue1Brown video proves it with lighthouses. Here it falls out of the geometry of Fourier series.

Put the sawtooth's partial sums on the dashboard. The probe at one closes in, as Dini's test promised. The energy of the error goes to zero, as Parseval promised. But the uniform lens is stuck: just to the right of the jump the partial sums are near zero while the sawtooth is near pi over two. A uniform limit of continuous functions is continuous, so this convergence can never be uniform.

Zoom in on the jump. Next to it, every partial sum overshoots. As N grows, the overshoot moves closer to the jump and gets narrower, but not lower: its height tends to about nine percent of the jump, precisely the integral of sine t over t from zero to pi, over pi, minus a half. Here is why it never gets lower. Stretch the picture by N near the jump, and every partial sum lands on the same curve: the integral of sine u over u, from zero to t. Its first peak, at t equals pi, is the overshoot, and stretching sideways doesn't change heights. Wilbraham noticed it in 1848 and Gibbs explained it in 1899. It's the visible face of non-uniform convergence, and it's why sharp edges in compressed images and audio come with ringing.

Rudin's chapter ends with the gamma function, which we'll keep to one card. It interpolates the factorials, and it's the only interpolation whose logarithm is convex and which obeys the factorial's recursion: that's the theorem of Bohr and Mollerup. Stirling's formula estimates it: the ratio of n factorial to the formula goes to one, already within a hundredth of a percent at a thousand.

What it establishes: 8.15 (Fejér), Parseval (8.16), π²/6 (Exercise 8.13), the dashboard, Gibbs, Γ.; Computed on screen: Fejér errors; missing energy = tail; Σ_{n ≤ 10⁶} 1/n²; the overshoot ratio → 0.08949; Stirling's ratio → 1.

The third row of the ledgerAll tracks2 min

Let's take stock. We built the Riemann integral from upper and lower sums, found which functions it can integrate, and generalized it to integrals against a staircase. The fundamental theorem tied it to derivatives, and gave curves a length, though not every curve has one. Then the main problem: limits of functions. Uniform convergence makes limits pass through continuity and integrals, and turns the continuous functions into a complete space, where Weierstrass's monster lives. Equicontinuity is what compactness costs there, by Arzelà and Ascoli. Polynomials, and any algebra that separates points and vanishes at no point, approximate everything. Power series gave us the exponential and pi, and Fourier series turned out to be best approximations: they converge in energy, which summed one over n squared, and at jumps they overshoot by nine percent.

And the ledger gets its third row. The space: continuous functions on a compact set, with the sup norm. It's complete, because uniform limits of continuous functions are continuous. Its compact sets are the closed, bounded, equicontinuous ones. The swap it makes legal: the limit of the integrals is the integral of the limit, when the convergence is uniform. And Fourier's series: they converge in mean square, pointwise where the function is Lipschitz, and with Gibbs' overshoot at jumps.

Next time, in Part 4, calculus in many dimensions. A map of the plane bends a square grid. Up close, it acts like a linear map: a small square goes to almost a parallelogram, the one the derivative predicts. In many dimensions the derivative is that linear map. From it come contractions, the inverse and implicit function theorems, and Picard's theorem, which solves differential equations by iterating in the space of continuous functions we just built.

This part followed chapters six to eight of Rudin's Principles of Mathematical Analysis. Thanks for watching, and see you in Part 4.

Where it goes next. C[a, b] with the sup distance is the complete space in which Picard solves differential equations in Part 4. Dirichlet's function and term-by-term integration of the sawtooth are settled by Lebesgue's integral in Part 5, and Bessel, Parseval and best approximation become the geometry of Hilbert space in Part 6.

Key results

The part's results in one place, for revision.

Riemann's criterion\(\displaystyle f\in\mathscr{R}(\alpha)\iff \forall\varepsilon>0\ \exists P:\ U(P,f,\alpha)-L(P,f,\alpha)<\varepsilon\)
Integrals pass through uniform limits\(\displaystyle f_n\in\mathscr{R}\ \text{on}\ [a,b],\ \sup_{[a,b]}|f_n-f|\to 0\ \Longrightarrow\ \int_a^b f\,dx=\lim_{n\to\infty}\int_a^b f_n\,dx\)
Arzelà-Ascoli\(\displaystyle K\ \text{compact},\ (f_n)\subset C(K)\ \text{pointwise }\allowbreak \text{bounded }\allowbreak \text{and }\allowbreak \text{equicontinuous}\ \Longrightarrow\ \text{a }\allowbreak \text{subsequence }\allowbreak \text{converges }\allowbreak \text{uniformly}\)
Stone-Weierstrass\(\displaystyle \mathscr{A}\subset C(K;\mathbb{R})\ \text{an }\allowbreak \text{algebra }\allowbreak \text{that }\allowbreak \text{separates }\allowbreak \text{points }\allowbreak \text{and }\allowbreak \text{vanishes }\allowbreak \text{nowhere}\ \Longrightarrow\ \overline{\mathscr{A}}=C(K;\mathbb{R})\)
Parseval\(\displaystyle f(x)\sim\sum_{n=-\infty}^{\infty}c_n e^{inx}\ \Longrightarrow\ \frac{1}{2\pi}\int_{-\pi}^{\pi}|f(x)|^2\,dx=\sum_{n=-\infty}^{\infty}|c_n|^2\)
Gibbs's overshoot, as a share of the jump\(\displaystyle \frac{\operatorname{Si}(\pi)}{\pi}-\frac12=0.0895\ldots,\qquad\allowbreak \operatorname{Si}(\pi)=\int_0^{\pi}\frac{\sin t}{t}\,dt\)

Try it

Lab 3 · The sawtooth under four lenses

Sum sin(kx)/k toward (pi - x)/2 on (0, 2 pi) and measure the convergence four ways: the sup error (it does not shrink), the mean-square error (exactly the tail of 1/k²), the Gibbs overshoot, and the best-approximation property.

Figure produced by Lab 3: The sawtooth under four lenses
Produced by the lab below, seed 0, in 0.4 s.
python -m videos.analysis.labs 3 needs numpy, scipy, matplotlib · download lab03.py · source on GitHub
Parseval: (1/pi) ∫ f²                              1.644934   (pi²/6 = 1.644934)
N =   4: sup error, mean-square error              1.569   0.22132   (tail of 1/k²: 0.22132)
N =  16: sup error, mean-square error              1.566   0.06059   (tail of 1/k²: 0.06059)
N =  64: sup error, mean-square error              1.551   0.01550   (tail of 1/k²: 0.01550)
N = 256: sup error, mean-square error              1.490   0.00390   (tail of 1/k²: 0.00390)
largest s_N - f near the jump, over the jump       0.0916   0.0896   0.0895   0.0895   (Si(pi)/pi - 1/2 = 0.0895)
largest value of the Fejér mean                    0.9613   1.2613   1.4034   1.4843   (sup f = pi/2 = 1.5708)
degree 8: error of s_8, least error of 500 rivals  0.3692   0.7359
Pythagoras: largest |err - (best + distance²)|     4.2e-05

The series converges to the sawtooth in mean square, with the missing energy equal to the tail of 1/k², but not uniformly: the overshoot stays at 8.95% of the jump. Averaging (Fejér) removes the overshoot.
The code (103 lines; it asserts its own result)
"""Lab 3: look at the sawtooth's Fourier series through four lenses: sup error, mean-square error, Gibbs, Fejér."""

from math import pi

import numpy as np
from scipy.special import sici

from videos.coursekit import labs

TITLE = "The sawtooth under four lenses"
GOAL = ("Sum sin(kx)/k toward (pi - x)/2 on (0, 2 pi) and measure the convergence four ways: the sup error (it does "
        "not shrink), the mean-square error (exactly the tail of 1/k²), the Gibbs overshoot, and the best-approximation property.")
TASKS = [
    "Replace the sawtooth by the triangle wave |x| on [-pi, pi]. Show that its sup error now goes to 0, and at what rate.",
    "Replace the partial sums by Fejér means in the mean-square table. Are they better or worse than s_N in that lens, and why must they be?",
    "Measure the L1 norm of the Dirichlet kernel for N up to 500 and fit it against (4/pi²) ln N.",
]


def partial_sum(x, n):
    k = np.arange(1, n + 1)
    return (np.sin(np.outer(x, k)) / k).sum(axis=1)


def fejer(x, n):
    k = np.arange(1, n + 1)
    return (np.sin(np.outer(x, k)) / k * (1 - k / (n + 1))).sum(axis=1)


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()
    x = np.linspace(0, 2 * pi, 20_001)
    f = (pi - x) / 2  # the one-sided values at the two ends, where every partial sum is 0
    si_pi = sici(pi)[0]
    gibbs = si_pi / pi - 0.5

    energy = integral(f * f, x) / pi
    lab.row("Parseval: (1/pi) ∫ f²", f"{energy:.6f}   (pi²/6 = {pi * pi / 6:.6f})")
    assert abs(energy - pi * pi / 6) < 1e-6

    ns = [4, 16, 64, 256]
    sup, mse, tail, over, fej_max, fej_far = [], [], [], [], [], []
    for n in ns:
        s = partial_sum(x, n)
        sup.append(np.abs(s - f)[1:-1].max())
        mse.append(integral((s - f) ** 2, x) / pi)
        tail.append(pi * pi / 6 - np.sum(1.0 / np.arange(1, n + 1) ** 2))
        near = np.linspace(0, 3 * pi / (n + 1), 2001)[1:]  # the first peak sits at pi / (n + 1)
        over.append((partial_sum(near, n) - (pi - near) / 2).max() / pi)
        sg = fejer(x, n)
        fej_max.append(sg.max())
        far = (x > 0.5) & (x < 2 * pi - 0.5)
        fej_far.append(np.abs(sg - f)[far].max())
        lab.row(f"N = {n:>3}: sup error, mean-square error", f"{sup[-1]:.3f}   {mse[-1]:.5f}   (tail of 1/k²: {tail[-1]:.5f})")
    assert all(e > 1.4 for e in sup), "no uniform convergence: the sup error stays near pi/2"
    assert np.allclose(mse, tail, rtol=2e-3), "the missing energy is exactly the tail"
    lab.row("largest s_N - f near the jump, over the jump", "   ".join(f"{o:.4f}" for o in over) + f"   (Si(pi)/pi - 1/2 = {gibbs:.4f})")
    assert abs(over[-1] - gibbs) < 1e-3 and all(o > 0.08 for o in over), "Gibbs: the overshoot does not shrink"
    lab.row("largest value of the Fejér mean", "   ".join(f"{m:.4f}" for m in fej_max) + f"   (sup f = pi/2 = {pi / 2:.4f})")
    assert all(m < pi / 2 for m in fej_max), "Fejér's kernel is nonnegative: no overshoot"
    assert fej_far[-1] < 0.02 and fej_far[-1] < fej_far[0], "Fejér means converge uniformly away from the jump"

    # Best approximation: among trigonometric polynomials of degree 8, the Fourier partial sum has the least error.
    n, trials = 8, 500
    k = np.arange(1, n + 1)
    xs = x[::10]
    fs, s8 = f[::10], partial_sum(x[::10], n)
    basis = np.hstack([np.ones((xs.size, 1)), np.cos(np.outer(xs, k)), np.sin(np.outer(xs, k))])
    base = integral((fs - s8) ** 2, xs)
    worst_gap, pyth = np.inf, 0.0
    for _ in range(trials):
        d = basis @ (rng.normal(0, 0.15, 2 * n + 1))
        err = integral((fs - s8 - d) ** 2, xs)
        worst_gap = min(worst_gap, err - base)
        pyth = max(pyth, abs(err - base - integral(d * d, xs)))
    lab.row("degree 8: error of s_8, least error of 500 rivals", f"{base:.4f}   {base + worst_gap:.4f}")
    lab.row("Pythagoras: largest |err - (best + distance²)|", f"{pyth:.1e}")
    assert worst_gap > 0 and pyth < 1e-3
    lab.note = ("The series converges to the sawtooth in mean square, with the missing energy equal to the tail of "
                "1/k², but not uniformly: the overshoot stays at 8.95% of the jump. Averaging (Fejér) removes the overshoot.")

    fig, ax = labs.figure(2, size=(11, 4.2))
    z = np.linspace(0, 0.9, 1500)
    ax[0].plot(z, (pi - z) / 2, color=labs.INK, lw=2, label="the sawtooth")
    for n, color in zip((16, 64, 256), (labs.BLUE, labs.PURPLE, labs.PINK)):
        ax[0].plot(z, partial_sum(z, n), color=color, lw=1.2, label=f"s_N, N = {n}")
    ax[0].plot(z, fejer(z, 64), color=labs.GREEN, lw=1.4, label="Fejér mean, N = 64")
    ax[0].axhline(si_pi, color=labs.GOLD, ls="--", lw=1, label="Si(pi) = 1.8519")
    ax[0].set(title="Near the jump: the peak moves in, its height stays", xlabel="x", ylim=(0.65, 2.0))
    ax[0].legend(loc="lower right", ncols=2)
    ax[1].loglog(ns, sup, "o-", color=labs.PINK, label="sup error of s_N")
    ax[1].loglog(ns, np.sqrt(mse), "o-", color=labs.BLUE, label="root-mean-square error of s_N")
    ax[1].loglog(ns, np.sqrt(tail), "--", color=labs.GOLD, label="square root of the tail of 1/k²")
    ax[1].loglog(ns, fej_far, "o-", color=labs.GREEN, label="sup error of Fejér, 0.5 away from the jump")
    ax[1].set(title="Two lenses, two verdicts", xlabel="N", ylim=(3e-3, 20))
    ax[1].legend(loc="upper right")
    lab.fig = fig
    return lab

Now change it

  1. Replace the sawtooth by the triangle wave |x| on [-pi, pi]. Show that its sup error now goes to 0, and at what rate.
  2. Replace the partial sums by Fejér means in the mean-square table. Are they better or worse than s_N in that lens, and why must they be?
  3. Measure the L1 norm of the Dirichlet kernel for N up to 500 and fit it against (4/pi²) ln N.

Notes and sources

Sources

Fact-check notes and sources

The mathematics follows W. Rudin, Principles of Mathematical Analysis, 3rd ed. (McGraw-Hill, 1976), chapters 6–8; theorem numbers on screen are that edition's.

  • Riemann (1854) for the integral, Darboux (1875) for upper and lower sums, Stieltjes (1894).
  • Weierstrass presented his nowhere-differentiable function to the Berlin Academy in 1872 (published by du Bois-Reymond in 1875); the version on screen is Rudin's 7.18. Weierstrass's approximation theorem is from 1885.
  • Ascoli (1883–84) and Arzelà (1889) for the compactness theorem; Dini (1878) for his theorems.
  • Stone (1937; the simpler proof Rudin gives is from 1948). Bernstein (1912); Landau (1908) for the kernel.
  • Schoenberg (1938) for the space-filling curve of Rudin's Exercise 7.14; von Koch (1904).
  • Fourier (1807/1822), Dirichlet (1829), Fejér (1900), du Bois-Reymond (1873, a continuous function whose Fourier series diverges at a point), Wilbraham (1848) and Gibbs (1899).
  • Euler (1734) for Σ 1/n² = π²/6; the 3Blue1Brown video on the Basel problem proves it differently.

On-screen simplifications:

  • The Weierstrass zoom rescales each view vertically; the panel says so.
  • The Stone–Weierstrass interpolants are lines (the polynomial algebra); the proof needs only some member of the algebra through two points.
  • The sawtooth's Gibbs table uses N up to 1000; the limit 0.08949 is Si(π)/π − 1/2.
About this partfrom its README

Part 3 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 chapters 6 to 8 of Principles of Mathematical Analysis, in a hook, fifteen chapters and an outro, organized around Rudin's "main problem" (7.1): when may two limits be swapped?

  • The integral. Upper and lower sums squeezing the area (U − L = 1/n for x², computed to n = 2¹⁴); refinement; the integrability criterion. Continuous functions (uniform continuity pays), monotone functions (the stacked differences), Dirichlet's function (never), Thomae's function (yes: U → 0). Riemann–Stieltjes integrals as a stretched ruler: a step integrator makes a sum, the Cantor function makes an integral that is neither (∫ x dC = 1/2, ∫ x² dC = 3/8). The fundamental theorem by telescoping and the mean value theorem; curve length as a supremum of polygons; the Koch curve, whose length would have to be four thirds of itself.
  • Uniform convergence. Pointwise against uniform as two orders of quantifiers; the convergence dashboard (pointwise, sup, area and energy lenses); the Cauchy criterion; the sup norm; the M-test. Uniform limits of continuous functions are continuous (three hops), Dini's theorem, and C(X) as a complete metric space, seen on the function camera. Schoenberg's space-filling curve. Integrals pass through uniform limits; derivatives need more (x/(1 + nx²)).
  • The first function space. Rudin's nowhere-differentiable function, zoomed at 0.3, and its proof as one panel per term. Equicontinuity (one δ for a family), Rudin 7.24, and Arzelà–Ascoli by the diagonal process run on 400,000 random 1-Lipschitz functions. Weierstrass's approximation theorem with the Landau kernel (and its near/far split computed), Bernstein's polynomials. Stone–Weierstrass: the two obstructions, the four-step proof on a proof map with the lattice step computed on eˣ, and z̄ on the circle (its error loop has mean exactly 1).
  • Power series and Fourier series. Uniform convergence inside the radius; Abel's theorem and ln 2; exp, cos and sin from one series (the spiral of terms), π as twice the first zero of cos by bisection; the fundamental theorem of algebra by d'Alembert's step. Orthogonality, the Fourier partial sum as the best approximation (500 random competitors; Pythagoras), Bessel, the Dirichlet kernel and its growing L¹ norm (du Bois-Reymond), Dini's test. Fejér's means, Parseval (the missing energy is the tail), Σ 1/n² = π²/6, the dashboard verdicts for the sawtooth, Gibbs' 8.95%, and the gamma function on one card.

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 Checks
failures the hook's three sequences ∫ bump = n²/(2n + 2); sup = 1/√n; slope √n
riemann U, L for x² U − L = 1/n
thomae Thomae's upper sums on dyadic partitions decreasing to 0.0084 at 2¹⁴
stieltjes the Cantor integrator from its intervals ∫ x dC = 1/2, ∫ x² dC = 3/8, U − L = 3⁻ᵈ
koch Koch polygons lengths (4/3)ᵏ exactly
mtest partial sums of Σ sin nx/n² sup errors ≤ Σ_{n > N} 1/n²
dini (1 + x/n)ⁿ increasing, sup errors decreasing
cauchyc Bernstein polynomials of x − ½
peano Schoenberg's curve exact rational hits from ternary digits
weier Rudin 7.18 at x = 0.3
equi δ for {sin kx/k} and {sin kx} brute-force checks of both δ's
arzela the diagonal process on 400,000 random functions spreads monotone; survivors nested
landau Landau kernels and approximants; Bernstein c_n < √n; far mass under its bound; errors decreasing
stone the lattice step; y
power cos and π; Abel; e^(it); d'Alembert π to 10⁻¹²; ln 2 to 10⁻⁴;
fourier best approximation; Gram; Dirichlet kernels; Dini 500 competitors worse; Pythagoras; L¹ norms increasing like (4/π²) ln N
parseval Parseval, Gibbs, Fejér, Stirling mse = tail; lhs = rhs = π²/12; overshoot → Si(π)/π − ½; Fejér kernel ≥ 0
Chapter notes
0:00 The main problem: when may two limits be swapped?
2:49 1. Upper and lower sums
5:06 2. Which functions are integrable?
7:43 3. Integrating against a staircase
9:58 4. The fundamental theorem, and the length of a curve
12:23 5. Uniform convergence
15:34 6. Uniform limits, and the space C(X)
18:41 7. Integrals and derivatives of limits
20:32 8. A continuous function with no derivative
22:58 9. Equicontinuity
25:17 10. Arzelà–Ascoli: compactness in C(X)
28:12 11. Every continuous function is nearly a polynomial
30:51 12. Stone–Weierstrass
36:05 13. Power series, exp, and the birth of π
40:20 14. Fourier series: the best approximation
44:25 15. Parseval, Gibbs, and π²/6
48:06 The third row of the ledger
Chapter notes
# Scene What it establishes Computed on screen
0 Hook The ledger; the grid m/(m + n) (7.2); three failed swaps: xⁿ (continuity), n²x(1 − x²)ⁿ (integral, 7.6), sin(nx)/√n (derivative, 7.5); the Fourier question; the plan. ∫ of the bump = n²/(2n + 2); sup sin(nx)/√n = 1/√n and slope √n at 0.
1 UpperLower Partitions, U and L (6.1–6.2); refinement (6.4); the criterion (6.6); x². U − L = 1/n exactly, n = 2 … 2¹⁴.
2 WhoIsIntegrable Continuous (6.8), monotone (6.9); Dirichlet (Exercise 6.4); Thomae. η = 0.5, δ = 0.2 for the uniform-continuity step; Thomae's U on dyadic partitions to 2¹⁴ (0.0084).
3 Stieltjes The stretched ruler; the unit step (6.14–6.16); the Cantor integrator (Exercise 6.6 territory); 6.17. ∫ x dC = 1/2, ∫ x² dC = 3/8 with U − L = 3⁻ᵈ.
4 FTC F = ∫f is continuous and F′ = f (6.20); the fundamental theorem (6.21); length (6.26–6.27); the Koch curve. Inscribed polygon lengths; Koch lengths (4/3)ᵏ; the first quarter of the depth-6 curve is the depth-5 curve shrunk by 3.
5 Uniform Pointwise vs uniform (7.7); the dashboard; Cauchy criterion (7.8) and sup norm (7.9); M-test (7.10). N = 22 for xⁿ on [0, 0.9] at ε = 0.1; dashboard lenses (exact sup 1, L¹ = 1/(n + 1)); pair gaps of Σ sin kx/k²; sup errors under their M-test tails.
6 UniformContinuity 7.12 by three hops; Dini (7.13); C(X) complete (7.14–7.15) on the camera; Schoenberg's curve (Exercise 7.14). (1 + x/n)ⁿ → eˣ errors; Bernstein's trail with nested sup-ball squares; the curve's exact hits from ternary digits.
7 IntegralsDerivatives 7.16 with the box bound; 7.17 and x/(1 + nx²); the swaps so far. ∫f_n vs ∫f live; sup x/(1 + nx²) = 1/(2√n), f_n′(0) = 1.
8 Nowhere Rudin 7.18: construction, the zoom, the proof. Each term's share of the quotient at x = 0.3, m = 3 (exact rationals: 1, 3, 9, 27 in size, then 0, 0); quotients to m = 10.
9 Equicontinuity sin(nx) has no convergent subsequence; 7.21's bumps; 7.22; 7.24. Pairwise sup distances > 1; δ = 0.1 for {sin kx/k}, ε/K for {sin kx}; one δ for 24 uniformly convergent functions.
10 ArzelaAscoli 7.23 by the diagonal; spreading by equicontinuity; 7.25; the dictionary. The actual surviving indices among 400,000 random functions; spreads shrinking stage by stage.
11 Approximation 7.26 with the Landau kernel; the near/far estimate; Bernstein. c_n < √n; the far mass 0.0051 ≤ 2√n(1 − δ²)ⁿ; sup errors to n = 10⁴ (0.0045).
12 StoneWeierstrass 7.28–7.33: the obstructions, the theorem, the four steps, z̄. Even polynomials on [0, 1] approaching x; Bernstein's
13 PowerSeries 8.1, Abel (8.2), exp/cos/sin (8.6–8.7), π, 8.8. r^(N+1)/(1 − r); Abel sums to ln 2; 20 terms of e^(2i); π by 60 bisections (12 digits); a descent to a root of z³ − 2z + 2.
14 FourierSeries Orthogonality (8.9), 8.11, Bessel (8.12), the Dirichlet kernel (8.13), Dini (8.14). The 7 × 7 Gram matrix; best = 0.4804 vs 500 competitors; Lebesgue constants to N = 500; s_N(π/2) → π/4.
15 Parseval 8.15 (Fejér), Parseval (8.16), π²/6 (Exercise 8.13), the dashboard, Gibbs, Γ. Fejér errors; missing energy = tail; Σ_{n ≤ 10⁶} 1/n²; the overshoot ratio → 0.08949; Stirling's ratio → 1.
16 Outro Recap; the ledger's third row; Part 4 preview (a map of the plane and its derivative); sources. —
The visual language

Part 3 adds three instruments:

  • The convergence dashboard (dashboard.py): one sequence of functions under several lenses at once (a probe at a point, the sup tube, the area between, the energy), each with a live number and a lamp that lights green or red when the verdict is asserted.
  • The function camera: each function becomes one dot, plotted by two of its values; a Cauchy sequence is a trail, and a sup-norm ball casts a square shadow.
  • The proof map (proofmap.py): a long proof's steps as a flowchart that lights up as the narration reaches each one (Stone–Weierstrass, Arzelà–Ascoli).
Concept Color
ε, tolerances, the sup lens yellow
δ, one δ for a family teal
the sequence, the hero function blue
approximants, partial sums magenta
area between graphs orange
energy, orthogonality lilac
counterexamples red

Build the film

python -m videos.analysis.analysis3.compute        # the part's numbers, into .cache/analysis3
python tools/build.py analysis3                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py analysis3 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/analysis/analysis3. 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.analysis3.compute                # once: every computed item (about a minute; cached in .cache/analysis3)
python tools/build.py analysis3 -q k --fps 60     # the full-quality cut: 2160p60 + subtitles + chapters -> renders/analysis3_2160p.mp4
python tools/build.py analysis3                   # 1080p30 -> renders/analysis3.mp4
python tools/build.py analysis3 -q l              # fast 480p preview
python tools/export_script.py analysis3           # regenerate SCRIPT.md from the code
python tools/check_narration.py analysis3         # Whisper listen test of every narration line

Part 3 imports helpers from Parts 1 and 2 (polyline, endpoint, plain_axes) and three instruments from explainer/analysis: the convergence dashboard and the function camera (dashboard.py) and the proof map (proofmap.py).