∫Analysis, Built

Book I · Principles of Mathematical Analysis

Part 2 of 10

Limits: Sequences, Series, Continuity and the Derivative

Undergraduatestarts at this level57 min of film16 chaptersprerequisites: Part 1

When does an infinite process settle on a value, and can the order of the terms change that value?

The part opens with one series, 1 - 1/2 + 1/3 - ..., which sums to ln 2 in its natural order and, reordered by a greedy rule, to pi, to -1 or to infinity. To explain that, limits are built as a game: epsilon moves first, then N. Cauchy sequences let convergence be checked without knowing the limit, and upper and lower limits record the high- and low-water marks of a tail. Series get the comparison, condensation, root and ratio tests, the number e with its irrationality, power series, summation by parts, and Riemann's rearrangement theorem, proved by the opening's algorithm. The same game with delta defines continuity; compactness then gives extreme values and uniform continuity, and connectedness gives intermediate values. The derivative is the limit seen by zooming in, and the mean value theorem, L'Hôpital's rule and Taylor's theorem follow. The part ends with exp(-1/x²), smooth but not the sum of its Taylor series, and with the mean value inequality for vector-valued functions.

What you need. Calculus: derivatives, the logarithm and the geometric series as computations.

What you will be able to do

Undergraduate

  • Play the epsilon-N and epsilon-delta games: given epsilon, produce an N or a delta and prove it works.
  • Decide the convergence of a series by comparison, condensation, the root test or the ratio test.
  • State and use the extreme value, intermediate value and mean value theorems, and give an example showing each hypothesis is needed.

Graduate

  • Prove that Cauchy sequences converge in Euclidean space, and that a continuous function on a compact set is uniformly continuous.
  • Compute a radius of convergence from the upper limit of the n-th roots, and prove Taylor's theorem with Lagrange's remainder.

Qualifying exam

  • Prove Riemann's rearrangement theorem for prescribed upper and lower limits of the partial sums.
  • Prove Dirichlet's test by summation by parts, and Mertens's theorem, with the example showing that the Cauchy product can diverge without absolute convergence.

Applications

  • Bound the error of a truncated series before computing it, as for e with the tail bound 1/(n! n).
  • Explain why the order of summation matters in a conditionally convergent sum and not in an absolutely convergent one.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 41 min · Graduate 49 min · Qualifying exam 57 min · Applications 41 min.

  1. 0One series, any sum you likeUndergraduate3 min
  2. 1Sequences and their limitsUndergraduate3 min
  3. 2Cauchy sequences and completenessUndergraduate6 min
  4. 3Upper and lower limitsGraduate4 min
  5. 4Series, and the comparison testsUndergraduate4 min
  6. 5The number eUndergraduate3 min
  7. 6Root, ratio and power seriesGraduate3 min
  8. 7Summation by parts, and multiplying seriesQualifying exam4 min
  9. 8RearrangementsQualifying exam3 min
  10. 9ContinuityUndergraduate4 min
  11. 10Continuity and compactnessUndergraduate4 min
  12. 11Continuity and connectednessUndergraduate3 min
  13. 12The derivativeUndergraduate3 min
  14. 13Mean value theoremsUndergraduate3 min
  15. 14Taylor's theoremUndergraduate3 min
  16. Vector-valued functions, and the second row of the ledgerAll tracks3 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.

One series, any sum you likeUndergraduate3 min

In Part 1 we built the real numbers: a line with no holes, where every bounded set has a least upper bound. That's the first row of our ledger. Now we put it to work on limits: sequences, infinite sums, continuity and derivatives. And we start with a warning about infinite sums.

Here's the alternating harmonic series: one, minus a half, plus a third, minus a quarter, and so on. Add it up one term at a time and the running total swings back and forth, each swing smaller than the last, closing in on the natural log of two, about 0.693.

Now take exactly the same terms, and add them in a different order. Use positive terms, one, a third, a fifth, and so on, until the total passes pi. Then use negative terms until it drops back below pi. Then positive terms again. Watch where the total goes.

Plot the running total against the number of terms used. It overshoots pi, falls back, overshoots again, and the swings shrink, because each swing is at most the size of the last term used. After a million terms, the total is within a hundred-thousandth of pi. Reaching pi takes about a hundred and thirty-four positive terms for every negative one, but every term of the original series gets used, exactly once.

And pi isn't special. Aim at minus one instead, and the same recipe lands on minus one. Keep raising the target and the total runs off to infinity. Same terms, every time; only the order changes, and in the natural order they add up to log two.

This is Riemann's rearrangement theorem, which we'll prove in chapter eight. The lesson: an infinite sum is not a sum. It's a limit, and limits can depend on the order in which you take them, which is exactly the thesis of this series. So before we can trust any manipulation with infinitely many terms, we need to say precisely what convergence means.

Here's the plan, following chapters three to five of Rudin's Principles. First, sequences and series: convergence, Cauchy sequences, upper and lower limits, the convergence tests, the number e, and what you may and may not do with an infinite sum. Then continuity, and what it gains from compactness and connectedness. And then the derivative: the mean value theorem, and Taylor's theorem.

What it establishes: The ledger so far; 1 − 1/2 + 1/3 − ⋯ = ln 2 in its natural order; the greedy rearrangement to π, to −1 and to +∞; the plan.; Computed on screen: The rearrangements to 10⁶ terms (within 10⁻⁵ of π and −1); Pringsheim's ratio of positive to negative terms (≈ 134 for π).

1Sequences and their limitsUndergraduate3 min

Cauchy, in 1821, said a sequence converges to a limit when its terms get, and stay, arbitrarily close to it. Making arbitrarily close precise is the whole subject.

Here's a sequence: one plus or minus one and a half over n, alternating sides of one. Rudin's definition: p n converges to p if for every epsilon greater than zero there's an N such that every term after the N-th is within epsilon of p. Read it as a game with two players.

The first player, epsilon, picks a band around the limit: here, half-width a half. The second player answers with an N: past N, every dot must sit inside the band. N equals 3 works. Epsilon tightens the band to 0.2; now N has to be 7. At 0.05, N is 30. The sequence converges because the second player can always answer, however small the band.

Notice the order of the moves. Epsilon goes first, and N is allowed to depend on it. Swapping the order would demand one N that works for every epsilon at once, which only an eventually constant sequence could satisfy. This game, with different rules about who moves when, will define almost everything in this series.

Here's a sequence that loses: minus one, one, minus one, one. Epsilon picks a band of half-width one half. Whatever limit you propose, and however far out you set N, the band can't hold both one and minus one. Slide the proposed limit anywhere: some dots always escape. The sequence diverges.

Two quick consequences. A sequence can't have two limits: if it approached both p and p prime, take epsilon to be half the distance between them. The two bands don't overlap, and from some point on the terms would have to be in both. And a convergent sequence is bounded: all but finitely many terms sit in one band.

And limits respect arithmetic. Take sums. The error of s n plus t n is at most the error of s n plus the error of t n, by the triangle inequality. Ask each sequence to get within epsilon over two, which each can do past its own threshold; past both thresholds, the total error is less than epsilon. This is the epsilon over two trick, and it, with its cousin epsilon over three, does most of the routine work in analysis.

Last idea for this chapter: subsequences. Keep some of the terms, in order, and you get a subsequence; its limits are called subsequential limits. This sequence has no limit, but its even terms converge to one, and its odd terms to minus one. And Part 1 pays off immediately: in a compact space, every sequence has a convergent subsequence, because an infinite set of terms must pile up somewhere. In particular, every bounded sequence of real numbers does.

What it establishes: Convergence (3.1) on the sequence game board; (−1)ⁿ diverges; uniqueness and boundedness (3.2); limit laws and the ε/2 trick (3.3); subsequences (3.5–3.6).; Computed on screen: For pₙ = 1 + (−1)ⁿ1.5/n, the smallest N for ε = 0.5, 0.2, 0.05: 3, 7, 30.

2Cauchy sequences and completenessUndergraduate6 min

To check that a sequence converges, the definition makes you name the limit first. Cauchy found a test that doesn't.

In the hook we used the fact that one minus a half plus a third, and so on, sums to the natural log of two. But suppose you didn't know that. How could you tell these partial sums converge at all? Cauchy's answer: call a sequence Cauchy if for every epsilon there's an N such that any two terms past N are within epsilon of each other. No limit appears anywhere: the terms are only compared with one another.

Rudin repackages this with the tail of the sequence: E N, everything from the N-th term on. The sequence is Cauchy exactly when the diameter of the tail shrinks to zero. Here the terms alternate, and each step is smaller than the last, so the whole tail lies between s N and s N plus one, and its diameter is one over N plus one. Epsilon picks a tolerance, say a tenth; and the tail fits once N reaches 10. For one twentieth, N is 20. Convergence, checked without ever mentioning log two.

One direction is easy. If p n converges to p, then any two late terms are close to each other, because each is close to p: the triangle inequality, routed through the limit, with the epsilon over two trick. The converse is the interesting direction, and whether it holds depends on the space you're in.

Here's a space where it fails: the rational numbers. Start at one and repeatedly send p over q to p plus 2 q over p plus q. Every term is a fraction, alternating sides of root two. Each tail lies between two consecutive terms, and its diameter is one over the product of their denominators, so the sequence is Cauchy. Zoom in after it, keeping the tail the same size on screen.

The tails shrink by a factor of nearly six each time. And they're closing in on a point that isn't there: root two, which Part 1 proved is not a fraction. In the rationals this sequence is Cauchy, and it has no limit.

So when does Cauchy imply convergent? Rudin's first answer: in a compact space, always. Here's a Cauchy sequence in the plane, spiraling in. Draw its tail, and close it up. As N grows the closed tails are nested, each inside the last, they're compact, and their diameters go to zero. Nested compact sets with diameters shrinking to zero meet in exactly one point, and that point is the limit, because every term of the N-th tail is within the tail's diameter of it.

And in R k, the same is true, with no compactness assumed. A Cauchy sequence is bounded: one tail has a finite diameter, and there are only finitely many terms before it. So the whole sequence sits in a closed box, and Part 1's Heine-Borel theorem says the box is compact. Part 1 pays off again.

A space where every Cauchy sequence converges is called complete. R k is complete, and so is every compact space, and every closed subset of a complete space. The rationals are not, and neither is the interval from zero to one with zero removed: one over n is Cauchy there, with nowhere to go. The function spaces of this series will be complete too, and proving it will be real work: continuous functions with the sup distance in Part 3, and square integrable functions in Part 5. Completeness is so useful that Banach and Hilbert spaces are defined to have it. And every metric space can be completed, by adding the missing limits: that's how Cantor and Méray built the reals from the rationals.

There's one more way to know a sequence converges without knowing its limit, and it uses the least-upper-bound property directly. A monotone, bounded sequence converges, to its supremum. Take one plus one over n, to the n-th power: it increases, and it never reaches 3. Three is an upper bound, and so are smaller numbers, down to a least one.

Call the least upper bound s star. Given epsilon, s star minus epsilon is not an upper bound, so some term s N is above it; and since the sequence increases, every later term is trapped between s star minus epsilon and s star. For a tenth, every term from the thirteenth on is trapped. Chapter five identifies this supremum: it's the number e.

And in the rationals this fails too: the decimal truncations of root two increase, stay bounded, and have no rational supremum. Completeness, in either form, is exactly what the rationals lack.

What it establishes: Cauchy sequences (3.8); diam Eₙ → 0 (3.9); convergent ⇒ Cauchy (3.11a); Q is incomplete; compact ⇒ complete, Rᵏ complete (3.11b–c), via nested closed tails; complete spaces (3.12); monotone bounded sequences (3.14).; Computed on screen: The tails of 1 − 1/2 + ⋯ have diameter 1/(N + 1) (N = 10 for ε = 0.1, 20 for 0.05); the convergents p/q of √2, diam Eₙ = 1/(qₙqₙ₊₁) exactly; hulls of a spiral's tails, nested; (1 + 1/n)ⁿ within 0.1 of e from n = 13 on.

3Upper and lower limitsGraduate4 min

Most sequences don't converge, but even a divergent sequence has a largest and a smallest place where it keeps coming back. Cauchy already needed this, in 1821, for the root test.

Take the sequence that alternates near one and minus one, approaching each from outside. Collect every subsequential limit into a set E, allowing plus and minus infinity. The upper limit, lim sup, is the largest element of E; the lower limit, lim inf, is the smallest. Here E is just minus one and one.

There's a more hands-on way to see it. For each N, mark the highest value in the tail from N on: the high-water mark. Dropping terms can only lower it, so it decreases, and here it comes down to one. The low-water mark rises, to minus one. The limit of the high-water mark is exactly the upper limit, and the limit of the low-water mark is the lower limit.

Rudin pins the upper limit down with two properties. Some subsequence converges to it, and above it the sequence is eventually absent: pick any level x above one. Only finitely many terms are higher: two terms for x equal to 1.2, nine for 1.05. Push x below one and infinitely many terms are above it. So one is the dividing line, and no other number has both properties.

And a sequence converges exactly when its upper and lower limits agree: the high-water and low-water marks squeeze together, onto the limit.

E can be much bigger than two points. List every fraction between zero and one, by denominator: zero, one, a half, a third, two thirds, and so on. Pick any point, say one over root two. From each block of the list take the fraction nearest to it: that's a subsequence converging to one over root two. The same works for every point of the interval, so E is the whole interval from zero to one. Its upper limit is one, its lower limit zero.

Rudin collects five limits that the convergence tests will lean on: one over n to a positive power goes to zero; the n-th root of a positive number goes to one; the n-th root of n goes to one; any power of n over an exponential goes to zero; and x to the n goes to zero when x is smaller than one in size. Let's look at two of them.

The n-th root of n is the subtle one: n grows, but the root shrinks the exponent. Who wins? Write the root as one plus x n. By the binomial theorem, n is at least one term of the expansion, n times n minus one over two, times x n squared. Rearranged, x n is squeezed to zero. On a logarithmic scale, out to a million, the root peaks at n equal to 3 and then sinks toward one, under the bound.

And powers against exponentials. n to the tenth over 1.1 to the n: the numerator starts far ahead. On a log scale, the ratio climbs to about seven quadrillion at n equal to 105. But each step multiplies the denominator by 1.1, and multiplies the numerator by less and less, so from n equal to 686 on the ratio stays below one, and it goes to zero. Any power, any exponential base above one: the exponential always wins.

What it establishes: Upper and lower limits (3.16), the tail sup and inf; 3.17; convergence ⇔ lim sup = lim inf; every rational listed gives E = [0, 1]; the special sequences (3.20).; Computed on screen: Tail sups and infs; the subsequence nearest 1/√2; n^(1/n) to 10⁶ under the bound 1 + √(2/(n − 1)); n¹⁰/1.1ⁿ peaking near 7 × 10¹⁵ at n = 105, below 1 from n = 686.

4Series, and the comparison testsUndergraduate4 min

A series is a sequence in disguise: the sequence of its partial sums. Everything from the last two chapters applies, and a few new tools appear.

A series converges to s when its partial sums do. So the Cauchy criterion carries over: the series converges exactly when every block of consecutive terms far enough out, however long, adds up to something small. A block can be a single term, so the terms must go to zero. That's necessary, but it's not enough, and the classic example is seven centuries old.

The harmonic series: one, plus a half, plus a third, and so on. The terms shrink to zero. But group them in blocks that double in length: a half; a third and a quarter; the next four; the next eight. In each block every term is at least the last one, so the block is at least its length times its last term, which is exactly one half. Infinitely many halves: the sum grows without bound. This argument is from Nicole Oresme, around 1350.

It diverges, but slowly: on a logarithmic scale the partial sums are a straight line, hugging the natural log of n plus Euler's constant. A million terms add up to only about fourteen point four.

The basic tool is comparison. If each term is at most the corresponding term of a convergent series of positive terms, the series converges, because its blocks are smaller. If each term is at least a divergent series's terms, it diverges. The standard series to compare with is the geometric series: one plus a half plus a quarter, and so on, each term covering half the remaining distance to two.

Cauchy's condensation test turns a slowly decreasing series into a fast one. If the terms decrease to zero, the series converges exactly when the condensed series, two to the k times the term at two to the k, converges. Here's why, with n to the minus three halves. Over each block from two to the k up to the next power of two, the terms are at most the first one, so a box of height a at two to the k covers the block: the partial sums are bounded by the condensed series. And under each block fits a box of the block's last height, which gives the reverse bound, up to a factor of two. The two series converge or diverge together.

Applied to one over n to the p, the condensed series is geometric, with ratio two to the one minus p. It converges exactly when p is bigger than one. The partial sums: for p equal to one they climb forever; for three halves they level off near 2.612; and for p equal to two at pi squared over six, a value Euler found in 1734. Notice how slowly the three-halves series settles: after a million terms it's still two thousandths short.

Condensation keeps going. One over n log n still diverges, but only like log log n: a million terms add up to about three point four. Raise the log to the power 1.01 and it converges. And there's no last word: Rudin's exercises show that for any divergent series there's one diverging more slowly, and for any convergent series one converging more slowly. There is no sharp line between convergence and divergence.

What it establishes: Series and the Cauchy criterion (3.22); terms → 0 (3.23); Oresme's blocks; comparison (3.25); the geometric series (3.26); condensation (3.27); Σ 1/nᵖ (3.28); Σ 1/(n log n) (3.29); Exercises 3.11–3.12.; Computed on screen: Oresme's blocks ≥ 1/2 in exact fractions; Σ 1/nᵖ for p = 1, 1.5, 2 to 10⁶ terms (14.39; ζ(3/2) still 0.002 away; π²/6); the condensation inequalities; Σ 1/(n log n) ≈ 3.42 at 10⁶.

5The number eUndergraduate3 min

The number e, defined twice, and a proof, entirely from the tail of a series, that it isn't a fraction.

Rudin defines e as the sum of one over n factorial. How fast does it converge? The error after n terms is the tail. Each later factorial is at least the first one times a power of n plus one, so the tail is smaller than a geometric series, and summing it, the error is less than one over n factorial times n. That's fast: s ten, which stops at one over ten factorial, is within three parts in a hundred million of e. Hold on to this inequality: it will prove that e is irrational.

The other definition of e is compound interest: one plus one over n, to the n-th power. Expand it with the binomial theorem. The k-th term is one over k factorial, times k minus one factors, each a little less than one. So in this picture each orange bar sits inside its blue box, of height one over k factorial: the compound-interest number is less than the series. As n grows, each shortfall factor tends to one, and the bars rise to fill their boxes.

Squeezed from above by the series and, for each fixed number of terms, from below, the limit is e. The two definitions agree. But the compound interest version is slow: at n equal to ten it's still off by an eighth, where the series was off by three parts in a hundred million.

Now the proof that e is irrational, as Rudin gives it. Multiply the tail estimate by q factorial: q factorial times e minus s q lies strictly between zero and one over q. Now suppose e were a fraction p over q. Then q factorial times e is an integer, and so is q factorial times s q, since every denominator in s q divides q factorial. So their difference is an integer strictly between zero and one, and there isn't one. Here's the actual quantity for q from 1 to 15: always inside the yellow window, which shrinks, and never reaching an integer.

In fact e isn't a root of any polynomial with integer coefficients: Hermite proved that in 1873, and Rudin points to a short proof.

What it establishes: e = Σ 1/n! and the tail bound 1/(n!·n); lim (1 + 1/n)ⁿ = e (3.31) by the binomial bars; e is irrational (3.32).; Computed on screen: The tail bound for n ≤ 15 (60-digit arithmetic); the binomial terms of (1 + 1/n)ⁿ for n up to 200; q!(e − s_q) ∈ (0, 1/q) for q = 1 … 15.

6Root, ratio and power seriesGraduate3 min

The geometric series is the yardstick: the root and ratio tests are ways of laying a series against it.

The root test. Take the upper limit of the n-th roots of the terms, and call it alpha. If alpha is less than one, the series converges; if it's bigger than one, it diverges; if it's exactly one, the test says nothing. Here's a series from Rudin that interleaves powers of a half and of a third. On a logarithmic scale a geometric series is a straight line. The n-th roots approach one over root two at most, so choose beta between that and one: from some point on, every term lies under beta to the n, and comparison with the geometric series does the rest.

The ratio test compares consecutive terms instead. If the ratios are eventually below something less than one, the series converges. For the same series, the ratios jump between two thirds to the k, which goes to zero, and half of three halves to the k, which goes to infinity. The ratio test can't decide. But the n-th roots settle down, below one: the root test proves convergence.

This is no accident. The upper limit of the roots is always at most the upper limit of the ratios, so whenever the ratio test gives an answer, the root test gives the same one. The ratio test is just easier to compute.

The root test's best use is power series, where z is a complex number. A power series converges inside a disk and diverges outside it; the radius is one over the upper limit of the n-th roots of the coefficients. For the sum of z to the n over n, the radius is one. Each picture is the path of partial sums in the plane. Inside the disk, the path spirals in to a limit. On the boundary anything can happen: at minus one it converges, to minus log two; at one it's the harmonic series, crawling off to infinity. Outside, the terms themselves grow, and the path spirals out.

One last puzzle. One over one plus x squared is as smooth as a function can be, on the whole real line. Its power series is one minus x squared plus x to the fourth, and so on. But the series only converges between minus one and one: past that, the partial sums flail. Nothing happens to the function at x equal to one. So why stop there? Look in the complex plane. The function blows up at i and at minus i, where one plus z squared is zero, and a disk centered at zero can't grow past them. Its radius is one, and the real interval is just the disk's shadow. The real line can't see the reason. We'll come back to this in Part 7, where power series turn out to live naturally in the complex plane.

What it establishes: Root test (3.33) as a geometric envelope; ratio test (3.34) and Rudin's example 3.35(b); 3.37; power series (3.39); 1/(1 + x²) and its poles at ±i.; Computed on screen: Ratios → 0 and → ∞ while the n-th roots → 1/√2; partial-sum paths of Σ zⁿ/n at |z| = 0.9, z = −1, z = 1, |z| = 1.1 (−ln 2 at z = −1).

7Summation by parts, and multiplying seriesQualifying exam4 min

Some series converge not because their terms are small, but because they cancel. The tool for cancellation is summation by parts, and with it we can finally answer a question about the sawtooth.

Here's summation by parts as a picture. Lay the terms a n end to end along the horizontal axis, so the marks are the partial sums A n, and over each one stand a strip of height b n, with the b n decreasing. The total area is the sum of a n times b n. Now slice the same region horizontally instead. Each slab has width A n, the partial sum, and height b n minus b n plus one, the drop between consecutive heights, plus a bottom slab of width A N. Same area, two ways of adding it up: it's integration by parts, for sums.

Summation by parts goes back to Abel; the test it gives is named for Dirichlet. Suppose the partial sums of the a n stay bounded, by some M, without converging, and the b n decrease to zero. Then the sum of a n b n converges. Sum a block by parts: each partial sum is at most M in size, and the drops in b telescope, leaving at most two M times b p, which goes to zero. That's the Cauchy criterion. With a n equal to plus and minus one, this is the alternating series test.

Now the sawtooth. Part 1 opened with the series sine x, plus sine 2 x over two, plus sine 3 x over three, and asked whether it even converges. Here a k is sine k x, which doesn't go to zero, but its partial sums stay bounded: they're imaginary parts of the sums of e to the i k x, and those just walk around a circle, for x equal to one here. The b k, one over k, decrease to zero. So Dirichlet's test applies: at x equal to one, the partial sums close in on pi minus one over two, inside Dirichlet's shrinking bound.

The same argument works at every x except the multiples of two pi, and there every term is zero anyway. So the series converges at every single point, and the partial sums settle onto the sawtooth, each at its own pace, slowest near the jumps. That's the first entry in the Fourier column of the ledger: the series converges at each point.

If the absolute values have a finite sum, the series converges: blocks can only shrink when you allow cancellation. Series that converge only thanks to cancellation, like the alternating harmonic series, are called conditionally convergent. The sawtooth's series is one of them. That matters, as the next chapter will show.

How do you multiply two series? The product of the sums is the sum of every product a i times b j, an infinite grid. The Cauchy product adds the grid along diagonals: c n collects the terms where the indices add up to n, just as you'd collect powers of x when multiplying power series. Mertens proved this gives the right answer if one of the two series converges absolutely. Adding up a doubly infinite array in a different order is the first glimpse of a question that comes back in Part 5, as Fubini's theorem.

Without absolute convergence it can fail. Take the alternating series of one over root n plus one, which converges, and multiply it by itself. Every term in the n-th diagonal has the same sign, so they pile up instead of cancelling: the Cauchy product's terms never shrink. Their size climbs toward pi, and the product series diverges.

What it establishes: Summation by parts (3.41) as two ways to slice an area; Dirichlet's test (3.42); alternating series (3.43); the sawtooth converges at every x; absolute convergence (3.45); the Cauchy product, Mertens (3.50) and the counterexample (3.49).; Computed on screen: Summation by parts checked; Σ e^(ikx) on its circle of radius 1/(2|sin(x/2)|); Σ sin(k)/k → (π − 1)/2 inside Dirichlet's bound; |cₙ| ≥ 2(n + 1)/(n + 2).

8RearrangementsQualifying exam3 min

Back to the hook, where reordering one series produced any sum we liked. Riemann proved this in the same 1854 work where he defined his integral. Now we have the tools to see why it works, and when it can't happen.

Rudin's version is even stronger than the hook. If a series converges but not absolutely, then for any two targets alpha below beta there's a rearrangement whose partial sums have lower limit alpha and upper limit beta. Split the terms into two piles: the positive ones, and the sizes of the negative ones. Both piles have infinite sums: if one pile were finite, then since the series converges the other would be too, and the series would converge absolutely. And in both piles the terms go to zero.

Now the hook's algorithm, which is Rudin's proof. Take positive terms until the sum passes the target, then negative terms until it falls below, and repeat; here on a logarithmic axis, out to four thousand terms. Because each pile is infinite, every crossing happens: there's always enough left. Every term eventually gets used. And each time the sum crosses the target, it overshoots by at most the last term used. Those terms go to zero, so the overshoots do too: the rearranged series converges to pi.

With two targets, the same idea gives any upper and lower limits. Climb past one, then fall below zero, then climb past one again, forever. On a logarithmic axis, each swing takes about seven times as many terms as the last, and the turning points close in on the two targets: the lim sup is one and the lim inf is zero.

Absolute convergence makes all this impossible. If the absolute values have a finite sum, every rearrangement converges, to the same value. Given epsilon, choose N so that all the terms past N have total size less than epsilon. A rearrangement shuffles the terms, but after finitely many steps it has used each of the first N. From then on, the original and rearranged partial sums share those terms, and differ only by terms past N, whose total size is less than epsilon.

And the Fourier thread. The sawtooth series at x equal to one converges to pi minus one over two, but only conditionally. So it, too, can be reordered to sum to anything. Here it is, steered to three. After about a million terms it's off by less than three parts in a hundred thousand, having used nearly all the positive terms and only a couple of thousand negative ones. When we write a Fourier series, the order, by frequency, is part of what we mean. Summing in a different way is an interchange of limits, and that's exactly the question the rest of the series is about.

What it establishes: Riemann's theorem (3.54): two infinite piles, the greedy walk, the overshoot bounded by the last term; two targets give any lim sup and lim inf; 3.55; the sawtooth is conditionally convergent.; Computed on screen: The overshoot envelope to 4,000 terms; a rearrangement swinging between 0 and 1 (turning points approaching both); Σ sin(k)/k reordered to 3 within 3 × 10⁻⁵ after 2 × 10⁶ terms.

9ContinuityUndergraduate4 min

Bolzano in 1817 and Cauchy in 1821 turned no jumps into a definition, using the same game we've been playing with sequences.

First, limits of functions. Here's x squared, except that someone has moved the value at 3 down to 4. The limit of f at p is q if for every epsilon there's a delta such that every x within delta of p, other than p itself, has f of x within epsilon of q. The value at p is deliberately ignored, so here the limit at 3 is nine, whatever f of 3 says. And f is continuous at p when the limit exists and equals the actual value. This f is not continuous at 3.

Continuity as a game. Take x squared at 3. The first player, epsilon, draws a band around the value 9. The second player answers with a strip around 3, of half-width delta. They win if the graph over the strip stays inside the band: green where it does, red where it escapes. A strip too wide loses at the edges. The best answer is the widest strip that works.

Tighten epsilon to a half: the strip must narrow. At a tenth, the widest strip has half-width 0.0166. The right edge binds, because the parabola is steeper there: delta is the square root of 9.1, minus 3. Whatever epsilon you pick, some delta answers it. That's continuity at 3.

Limits and continuity can also be tested with sequences: f is continuous at p exactly when f carries every sequence converging to p to a sequence converging to f of p. This is handy for showing a limit fails. Sine of one over x oscillates faster and faster near zero. Along one sequence approaching zero it's always one; along another, always minus one. So it has no limit at zero, and no choice of a value at zero makes it continuous there.

Now the reformulation that changed mathematics. A function is continuous exactly when the preimage of every open set is open. Pick an open interval V of values. The points whose values land in V form a union of open intervals: each is open because, by continuity, a point whose value is strictly inside V has neighbors whose values are too. A jump breaks this. Here a small open interval around the value at the jump pulls back to an interval that includes its left endpoint: not open.

This version never mentions a distance, only which sets are open. That's why it became the definition of continuity in topology, and in Part 8 we'll need it in spaces where no distance describes the convergence we care about.

The open-set version makes some proofs one line. A composition of continuous functions is continuous, because the preimage under g of f is the preimage under f of the preimage under g. Sums and products are continuous by the epsilon over two trick, so polynomials and rational functions are continuous wherever they're defined.

What it establishes: Limits of functions (4.1); continuity (4.5) on the function game board; sequences (4.2, 4.6) and sin(1/x); preimages of open sets (4.8); compositions (4.7), sums and products (4.9).; Computed on screen: For x² at 3: the largest δ for ε = 1, 0.5, 0.1 (0.0166 = √9.1 − 3), by bisection, asserted.

10Continuity and compactnessUndergraduate4 min

On a compact set, continuous functions behave far better than they have to anywhere else. Three of the most used theorems in analysis come from one fact.

The fact: a continuous function maps compact sets to compact sets. Here the domain is a closed interval, and its image is the set of values on the vertical axis. Cover the image with open sets. Pull each one back: by continuity, the preimages are open, and together they cover the domain. The domain is compact, so finitely many of them already cover it, and then the matching finitely many open sets cover the image. Open covers, pulled back, are exactly what continuity and compactness were designed to share.

Consequence one: on a compact set, a continuous real function attains a largest and a smallest value. The image is compact, so closed and bounded, so it contains its supremum and infimum. Here they are. Drop any hypothesis and it fails. On the half-open interval, one over x is unbounded. On the open interval, x gets arbitrarily close to one but never reaches it. And on a closed interval, a single jump can remove the top.

Consequence two: a continuous bijection from a compact space has a continuous inverse. Compactness is needed. Wrap the half-open interval from zero to two pi around the circle. It's continuous, one to one, and onto. But take points near the point one comma zero: those just above it come from near zero, and those just below come from near two pi. Close together on the circle, far apart on the line: the inverse is not continuous. The interval isn't compact, and that's the whole problem.

Consequence three needs a stronger kind of continuity. In ordinary continuity, delta may depend on the point. Uniform continuity demands one delta that works at every point at once: the second player must answer before knowing where the game is played. Picture it as a box of fixed size sliding along the graph: the graph must leave through the sides, never the top or bottom. For the square root on zero to one, a box with delta equal to epsilon squared slides all the way to zero. For one over x on the open interval, any fixed box fails once it gets close enough to zero, where the graph is too steep.

Here are the best deltas for one over x at a tolerance of a tenth, computed at seven points. They shrink to zero as x approaches zero, so no single positive delta works everywhere: one over x is continuous on the open interval, but not uniformly.

And now the theorem: on a compact space, continuous implies uniformly continuous. Each point has its own delta, for epsilon over two. The intervals of half those widths cover the space, so finitely many of them cover it. Take delta to be the smallest of those finitely many half-widths. A minimum of finitely many positive numbers is positive, and a short triangle-inequality argument shows this one delta works everywhere. With infinitely many, the infimum could be zero, which is exactly what happened to one over x.

What it establishes: Continuous images of compact sets (4.14); extreme values (4.16) and three failures; continuous inverses (4.17) and [0, 2π) → circle (4.21); uniform continuity (4.18) as a sliding box; 1/x; 4.19 via a finite subcover.; Computed on screen: √x with δ = ε² on a grid; the best δ for 1/x at seven points, matching x − 1/(1/x + ε); a finite subcover of √x's δ-intervals.

11Continuity and connectednessUndergraduate3 min

Bolzano's 1817 paper set out to prove that a continuous function can't get from below a value to above it without passing through it. The proof needs exactly what Part 1 built.

Continuous functions carry connected sets to connected sets: if the image split into two separated pieces, their preimages would split the domain. On an interval, that's the intermediate value theorem. The image of the interval is connected, so by Part 1 it's an interval, and an interval containing f of a and f of b contains everything in between: here the level c is crossed three times.

Without completeness the theorem fails. Take x squared minus 2, but only at rational points between one and two. It's continuous there, negative at one and positive at two. But it's never zero: the only place it could be is root two, and that's not a rational. The rationals aren't connected, so their image needn't be an interval.

When continuity fails, it fails in one of two ways. If the limits from the left and the right both exist, the discontinuity is of the first kind, or simple: either the two limits agree and only the value is wrong, or they disagree, and the graph jumps. Otherwise it's of the second kind, like sine of one over x, which has no one-sided limits at zero.

Monotone functions are much tamer. An increasing function has one-sided limits everywhere, so its only discontinuities are jumps. And there can only be countably many: each jump opens a gap in the values, the gaps don't overlap, and each contains a rational number, which it can claim as its own. Different jumps claim different rationals, and there are only countably many rationals. Countably many can still be a lot: Rudin builds an increasing function that jumps at every single rational. Here it is, with jumps at fractions of denominator up to forty, each sized by its denominator.

And the strangest example. Give each fraction p over q in lowest terms the value one over q, and each irrational the value zero. If this picture looks familiar, it's because it's the rational ruler we've used since Part 1, with each tick's height set to one over its denominator.

It's continuous at every irrational. Take one over root two, and epsilon equal to a tenth. Only the fractions with denominator at most ten reach the band's top edge, and there are finitely many of them. So a small enough strip avoids them all: here the nearest is seven tenths, and delta is about seven thousandths. Inside the strip every value is below epsilon. At a rational, though, the value is positive while irrationals arbitrarily close have value zero. So this function is continuous exactly at the irrationals.

Into the museum it goes. And the reverse, a function continuous exactly at the rationals, is impossible, though proving that needs Baire's theorem, in Part 8.

What it establishes: Connected images (4.22); intermediate values (4.23); x² − 2 on Q; kinds of discontinuity (4.26); monotone functions (4.29–4.31); Thomae's function (Exercise 4.18).; Computed on screen: The rationals of denominator ≤ 60 (1,103 points); δ = 0.0071 at 1/√2 for ε = 0.1 (to 7/10); a staircase with jumps at the 489 rationals of denominator ≤ 40.

12The derivativeUndergraduate3 min

The derivative, defined as a limit, the way Cauchy did in the 1820s, and looked at under a microscope.

The derivative of f at x is the limit of the difference quotient: the slope of the line through the point at x and a second point at t, as t slides toward x. The secants settle on a limiting slope, the tangent's.

Here's what the definition means geometrically. Put three graphs under a microscope and zoom in, a thousandfold. A differentiable function straightens out into a line, whose slope is the derivative. The absolute value at zero stays a corner at every scale. And the third is a function Rudin builds in chapter seven: continuous everywhere, but every zoom shows new wrinkles. It has a derivative nowhere.

Straightening has an algebraic form: f of x plus h is f of x, plus the derivative times h, plus an error that's small even compared with h. That's the version that survives in many dimensions, where the derivative becomes a linear map. One consequence: differentiable functions are continuous, since the difference f of t minus f of x is the difference quotient times t minus x, which goes to zero. The converse fails, spectacularly.

The chain rule is two zooms composed. A tiny interval around x is stretched by f prime of x, then the result is stretched by g prime at f of x: the stretch factors multiply. Rudin's proof makes this precise without a classic trap. Write f of t minus f of x as t minus x times f prime of x plus an error u that goes to zero. Do the same for g. Substitute, divide by t minus x, and let t go to x. The tempting shortcut, multiplying and dividing by f of t minus f of x, fails when that difference is zero for t arbitrarily close to x.

And the museum piece. x squared times sine of one over x, set to zero at zero. It oscillates infinitely often, but squeezed between x squared and minus x squared. At zero, the difference quotient is h times sine of one over h, which goes to zero: so f prime of zero exists, and it's zero. Everywhere else the derivative is two x sine of one over x minus cosine of one over x, and near zero that keeps swinging between about minus one and one. So the derivative exists at every point, and it's not continuous at zero.

What it establishes: The derivative (5.1); zooming to straightness, |x|, and Rudin's 7.18 function; the best linear approximation; 5.2; the chain rule (5.5); x² sin(1/x) (5.6).; Computed on screen: Difference quotients of Rudin's function at 0.3 exceeding (3ᵐ + 1)/2; h sin(1/h) → 0.

13Mean value theoremsUndergraduate3 min

If a trip averaged sixty miles an hour, at some instant the speedometer read exactly sixty. That's the mean value theorem, and its proof runs on compactness.

First, a lemma. At a local maximum the derivative is zero. Approaching from the left, f of t is at most f of x and t minus x is negative, so the difference quotients are at least zero; from the right they're at most zero. The limit has to be both.

The theorem: the chord from a to b has the same slope as the tangent at some point in between. Here's a proof you can watch. Subtract the chord from the function: a vertical shear, not a rotation, so vertical lines stay vertical. Now the two ends are level. The sheared function is continuous on a compact interval, so it has a maximum, and since the ends are level, we can take it in the interior. There, the slope is zero. Shear back: slopes all increase by the chord's slope, so the horizontal tangent becomes a tangent parallel to the chord. Rudin proves a version with two functions, which we'll need for L'Hôpital's rule.

The theorem's main job is to turn facts about the derivative into facts about the function. If the derivative is never negative, then for any two points the difference f of x two minus f of x one is x two minus x one times some derivative, so it's never negative: f increases. A zero derivative means a constant function.

Darboux noticed something surprising: a derivative always has the intermediate value property, continuous or not. To hit a value lambda, subtract lambda t from f: the result slopes down at a and up at b, so its minimum is inside, where its derivative is zero. Remember the museum piece: its derivative is discontinuous at zero, yet on every interval next to zero it takes every value between about minus one and one, again and again. So a derivative can never have a simple jump: if it's discontinuous, it's wildly so.

Finally L'Hôpital's rule, which follows from the two-function mean value theorem. Draw the curve whose coordinates are g of x and f of x; it starts at the origin, because both go to zero. The ratio f over g is the slope of the chord from the origin. The ratio of derivatives is the slope of the curve itself. The generalized mean value theorem says some point of the curve between has a tangent parallel to the chord. So if the tangent slopes approach A, the chord slopes are dragged along.

What it establishes: Local extrema (5.8); the mean value theorem by a vertical shear (5.9–5.10); monotonicity (5.11); Darboux (5.12); L'Hôpital (5.13) as chord and tangent slopes.; Computed on screen: The tangent point ξ by root-finding; f′ of x² sin(1/x) crossing every level in [−0.9, 0.9] near 0.

14Taylor's theoremUndergraduate3 min

The derivative is the best line. Higher derivatives give the best parabola, the best cubic, and so on, and Taylor's theorem says exactly how good they are.

The Taylor polynomial of degree n matches the value and the first n derivatives at a point. For the sine, adding terms makes the polynomials hug the curve over a wider and wider range. For the logarithm of one plus x, they improve inside the interval from minus one to one, and flail outside it, however many terms you take. Same story as the last power series puzzle: the series has radius one.

Taylor's theorem, in Lagrange's form: f of beta equals the degree n minus one polynomial, plus one more term with the n-th derivative evaluated at some unknown point x between alpha and beta. It's the mean value theorem, one level up, and the proof is the mean value theorem applied n times. Subtract the polynomial and a multiple M of t minus alpha to the n, choosing M so the difference g vanishes at beta. It also vanishes at alpha, along with its first n minus one derivatives. So g' has a zero x one between alpha and beta; then g'' has a zero x two between alpha and x one; and so on, n times. At the last point the n-th derivative of g is zero, which says M is the n-th derivative of f over n factorial.

The unknown point is the price, but a bound on the n-th derivative turns the theorem into an error estimate. For e to the x between zero and one, every derivative is at most e, so the error of the degree n polynomial at one is at most e over n plus one factorial. On a log scale, the actual errors sit just under the bound, all the way down.

And the payoff museum piece. e to the minus one over x squared, with value zero at zero. It's infinitely differentiable, and it's so flat at zero that every derivative there is zero. So every Taylor polynomial at zero is the zero polynomial, and the Taylor series converges everywhere, to zero, which is the wrong function at every point but one. On a log scale, near zero it lies below x to the tenth, and below any other power you choose.

Smooth isn't the same as analytic. Cauchy pointed this function out in 1823. In the complex plane this can't happen: a function with one complex derivative has all of them and equals its Taylor series, which is Part 7's surprise. And in Part 9 this flatness becomes useful, building the smooth bump functions that distribution theory runs on.

What it establishes: Taylor polynomials of sin x and log(1 + x); Taylor's theorem (5.15) by repeated mean value theorems; Lagrange's error bound for e; e^(−1/x²) (Exercise 8.1).; Computed on screen: Errors of e's Taylor polynomials under e/(n + 1)!; the first ten derivatives of e^(−1/x²) at 0 (sympy, all 0); e^(−1/x²) < x¹⁰ on (0, 0.2].

Vector-valued functions, and the second row of the ledgerAll tracks3 min

One last result, to close the part. Let a point go once around the unit circle at unit speed. It ends where it started, so the total change is zero, but the velocity always has length one, so no instant has the average velocity, which is zero. For vector-valued functions the mean value theorem fails. What survives is an inequality: the total change is at most the elapsed time times the speed at some moment. That inequality, not the equation, is the version that carries over to many dimensions and to the infinite-dimensional spaces to come.

Let's take stock. Convergence is a game where epsilon moves first. Cauchy sequences let us test convergence without knowing the limit, and they converge exactly in complete spaces, which the rationals are not. Upper and lower limits describe what's left when there's no limit. For series we have comparison, condensation, and the root and ratio tests; e is irrational; power series converge in disks. Summation by parts proved that the sawtooth series converges at every point, and Riemann showed that conditionally convergent series can be rearranged to sum to anything. Continuity became a statement about open sets, and compactness and connectedness gave the extreme value theorem, uniform continuity, and intermediate values. Finally, the derivative: the mean value theorem, Darboux's theorem, Taylor's theorem, and a smooth function its Taylor series can't see.

And the ledger gets its second row. The space: sequences and series of numbers. Complete means Cauchy sequences converge. Compactness means every sequence has a convergent subsequence. The limits we may swap: we may reorder a sum when it converges absolutely. And Fourier's series: it converges at each point, though not yet in any stronger sense, and we don't yet know to what, in general.

Next time, in Part 3, integration, and the first real function space. It starts from Rudin's main problem. In this grid, m over m plus n, go far down a column and the entries approach one; go far along a row and they approach zero. Take the limits in one order and you get one, in the other order, zero. Integrating a Fourier series term by term is exactly such an interchange, and Part 3 is about when it's allowed.

This part followed chapters three to five of Rudin's Principles of Mathematical Analysis. Thanks for watching, and see you in Part 3.

Where it goes next. Rudin's grid m/(m + n) becomes Part 3's main problem, the swap of two limits, and the sawtooth series returns there as a Fourier series. The nowhere-differentiable function is proved in Part 3, completeness drives the contraction principle in Part 4, and the fact that no function is continuous exactly at the rationals waits for Baire's theorem in Part 8.

Key results

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

The Cauchy criterion\(\displaystyle (p_n)\subset\mathbb{R}^k\ \text{converges}\iff \forall\varepsilon>0\ \exists N:\ |p_n-p_m|<\varepsilon\ \ (n,m\ge N)\)
The number e\(\displaystyle e=\sum_{n=0}^{\infty}\frac{1}{n!}=\lim_{n\to\infty}\Bigl(1+\frac1n\Bigr)^{n},\qquad\allowbreak 0<e-s_n<\frac{1}{n!\,n}\)
Radius of convergence\(\displaystyle \sum c_n z^n\ \text{converges }\allowbreak \text{for}\ |z|<R,\ \text{diverges }\allowbreak \text{for}\ |z|>R,\qquad\allowbreak \frac1R=\limsup_{n\to\infty}|c_n|^{1/n}\)
Riemann's rearrangement theorem\(\displaystyle \sum a_n\ \text{conditionally }\allowbreak \text{convergent},\ \alpha\le\beta\ \Longrightarrow\ \exists\ \text{a }\allowbreak \text{rearrangement }\allowbreak \text{with}\ \liminf s_n'=\alpha,\ \limsup s_n'=\beta\)
Pringsheim's ratio for the alternating harmonic series\(\displaystyle \frac{\#\text{positive terms}}{\#\text{negative terms}}\to e^{2(T-\ln 2)}\ \text{when }\allowbreak \text{the }\allowbreak \text{greedy }\allowbreak \text{rearrangement }\allowbreak \text{sums }\allowbreak \text{to}\ T\)
Taylor's theorem\(\displaystyle f(\beta)=\sum_{k=0}^{n-1}\frac{f^{(k)}(\alpha)}{k!}(\beta-\alpha)^k+\frac{f^{(n)}(\xi)}{n!}(\beta-\alpha)^n\ \text{for }\allowbreak \text{some}\ \xi\ \text{between}\ \alpha\ \text{and}\ \beta\)

Try it

Lab 2 · Riemann's rearrangement theorem, run as an algorithm

Reorder 1 - 1/2 + 1/3 - ... by the greedy rule (below the target take a positive term, above it a negative one), check the overshoot bound and Pringsheim's ratio, then run the same rule on the series with terms 1/k².

Figure produced by Lab 2: Riemann's rearrangement theorem, run as an algorithm
Produced by the lab below, seed 0, in 0.5 s.
python -m videos.analysis.labs 2 needs numpy, scipy, matplotlib · download lab02.py · source on GitHub
natural order, 200,000 terms            0.693145   (ln 2 = 0.693147)
greedy toward pi = 3.1416               sum 3.14138   last terms used at most 3.4e-04
  positive per negative terms           133.8618   (Pringsheim: e^(2(T - ln 2)) = 133.8729)
greedy toward -1 = -1.0000              sum -0.99995   last terms used at most 7.6e-05
  positive per negative terms           0.0338   (Pringsheim: e^(2(T - ln 2)) = 0.0338)
greedy toward a random target = 1.1848  sum 1.18481   last terms used at most 9.2e-06
  positive per negative terms           2.6734   (Pringsheim: e^(2(T - ln 2)) = 2.6733)
blocks + + -, terms 1/k                 1.03972   (1.5 ln 2 = 1.03972; natural order ln 2 = 0.69315)
blocks + + -, terms 1/k²                0.82247   (natural order pi²/12 = 0.82247)
greedy toward pi, terms 1/k²            stalls at 1.2337 < pi²/8 = 1.2337; negative terms used: 0

A conditionally convergent series has two infinite piles, so the greedy walk reaches any target with an overshoot bounded by the last term; an absolutely convergent one has finite piles and one sum.
The code (95 lines; it asserts its own result)
"""Lab 2: rearrange the alternating harmonic series to any sum, and fail to do it to an absolutely convergent one."""

from math import exp, log, pi

import numpy as np

from videos.coursekit import labs

TITLE = "Riemann's rearrangement theorem, run as an algorithm"
GOAL = ("Reorder 1 - 1/2 + 1/3 - ... by the greedy rule (below the target take a positive term, above it a negative "
        "one), check the overshoot bound and Pringsheim's ratio, then run the same rule on the series with terms 1/k².")
TASKS = [
    "Use two targets: climb above 1, then fall below 0, and repeat. Check that the partial sums have upper limit 1 and lower limit 0.",
    "Take three positive terms for every negative one, in blocks. Predict the sum from Pringsheim's ratio before computing it.",
    "Rearrange the sawtooth series, the sum of sin(k)/k, to the target 3: split its terms by sign first, then run the greedy rule.",
]


def greedy(target, n_terms, p=1.0):
    """The greedy rearrangement of sum (-1)^(k+1) / k^p toward ``target``: partial sums, the count of positive
    terms after each step, and the larger of the last positive and the last negative term used so far."""
    sums, pos, last = np.empty(n_terms), np.empty(n_terms, int), np.empty(n_terms)
    s, i_pos, i_neg, up, down = 0.0, 0, 0, 0.0, 0.0
    for i in range(n_terms):
        if s <= target:
            i_pos += 1
            up = (2 * i_pos - 1) ** -p
            s += up
        else:
            i_neg += 1
            down = (2 * i_neg) ** -p
            s -= down
        sums[i], pos[i], last[i] = s, i_pos, max(up, down)
    return sums, pos, last


def blocks(n_blocks, p, n_pos=2, n_neg=1):
    """The sum of the rearrangement that takes ``n_pos`` positive terms, then ``n_neg`` negative ones, in blocks."""
    odd = (2.0 * np.arange(1, n_pos * n_blocks + 1) - 1) ** -p
    even = (2.0 * np.arange(1, n_neg * n_blocks + 1)) ** -p
    return odd.sum() - even.sum()


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()
    n = 200_000
    k = np.arange(1, n + 1)
    natural = np.sum((-1.0) ** (k + 1) / k)
    lab.row("natural order, 200,000 terms", f"{natural:.6f}   (ln 2 = {log(2):.6f})")
    assert abs(natural - log(2)) < 1 / n

    targets = [("pi", pi), ("-1", -1.0), ("a random target", float(rng.uniform(-2, 3)))]
    runs = {}
    for name, t in targets:
        sums, pos, last = greedy(t, n)
        runs[name] = (t, sums, pos)
        crossed = np.flatnonzero(np.diff(np.sign(sums - t)) != 0)[0] + 1
        assert np.all(np.abs(sums[crossed:] - t) <= last[crossed:] + 1e-12), "the overshoot is at most the last term used on that side"
        ratio, predicted = pos[-1] / (n - pos[-1]), exp(2 * (t - log(2)))
        lab.row(f"greedy toward {name} = {t:.4f}", f"sum {sums[-1]:.5f}   last terms used at most {last[-1]:.1e}")
        lab.row("  positive per negative terms", f"{ratio:.4f}   (Pringsheim: e^(2(T - ln 2)) = {predicted:.4f})")
        assert abs(sums[-1] - t) < 1e-3 and abs(ratio / predicted - 1) < 0.03

    # A fixed pattern, two positive terms per negative one: the ratio 2 must give T = ln 2 + (1/2) ln 2.
    two_one = blocks(400_000, 1.0)
    lab.row("blocks + + -, terms 1/k", f"{two_one:.5f}   (1.5 ln 2 = {1.5 * log(2):.5f}; natural order ln 2 = {log(2):.5f})")
    assert abs(two_one - 1.5 * log(2)) < 1e-5
    # The same pattern on the absolutely convergent series: the sum does not move.
    absolute = blocks(400_000, 2.0)
    lab.row("blocks + + -, terms 1/k²", f"{absolute:.5f}   (natural order pi²/12 = {pi * pi / 12:.5f})")
    assert abs(absolute - pi * pi / 12) < 1e-5
    # And the greedy rule cannot reach pi: the positive pile is finite (pi²/8), so the walk never takes a negative term.
    sums2, pos2, _ = greedy(pi, 20_000, p=2.0)
    lab.row("greedy toward pi, terms 1/k²", f"stalls at {sums2[-1]:.4f} < pi²/8 = {pi * pi / 8:.4f}; negative terms used: {20_000 - pos2[-1]}")
    assert sums2[-1] < pi * pi / 8 < pi and pos2[-1] == 20_000
    lab.note = ("A conditionally convergent series has two infinite piles, so the greedy walk reaches any target with "
                "an overshoot bounded by the last term; an absolutely convergent one has finite piles and one sum.")

    fig, ax = labs.figure(2, size=(11, 4.2))
    show = 300
    for (name, (t, sums, pos)), color in zip(runs.items(), (labs.GOLD, labs.GREEN, labs.PURPLE)):
        ax[0].plot(np.arange(1, show + 1), sums[:show], color=color, lw=1.2, label=f"toward {name}")
        ax[0].axhline(t, color=color, lw=0.8, ls="--")
        steps = np.arange(1, n + 1)
        ax[1].loglog(steps[9:], (pos[9:] + 0.5) / (steps[9:] - pos[9:] + 0.5), color=color, lw=1.2, label=f"toward {name}")
        ax[1].axhline(exp(2 * (t - log(2))), color=color, lw=0.8, ls="--")
    ax[0].plot(np.arange(1, show + 1), np.cumsum((-1.0) ** (k[:show] + 1) / k[:show]), color=labs.MUTED, lw=1.2,
               label="natural order (ln 2)")
    ax[0].set(title="The same terms, three orders, three sums", xlabel="terms used", ylabel="partial sum", ylim=(-1.4, 5.2))
    ax[0].legend(loc="upper right", ncols=2)
    ax[1].set(title="Positive per negative terms (dashed: Pringsheim's ratio)", xlabel="terms used", ylim=(1e-2, 3e4))
    ax[1].legend(loc="upper right", ncols=3)
    lab.fig = fig
    return lab

Now change it

  1. Use two targets: climb above 1, then fall below 0, and repeat. Check that the partial sums have upper limit 1 and lower limit 0.
  2. Take three positive terms for every negative one, in blocks. Predict the sum from Pringsheim's ratio before computing it.
  3. Rearrange the sawtooth series, the sum of sin(k)/k, to the target 3: split its terms by sign first, then run the greedy rule.

Notes and sources

Sources

Fact-check notes and sources

The mathematics follows W. Rudin, Principles of Mathematical Analysis, 3rd ed. (McGraw-Hill, 1976), chapters 3–5 (and Exercise 8.1, Example 7.2, Definition 9.11, Theorem 7.18 for forward references); theorem numbers on screen are that edition's.

  • Bolzano's 1817 paper (Rein analytischer Beweis …) on the intermediate value theorem; Cauchy's Cours d'analyse (1821) and Résumé des leçons (1823), where e^(−1/x²) appears as a function not given by its Taylor series.
  • Oresme (c. 1350) for the divergence of the harmonic series; Euler (1734) for π²/6.
  • Riemann's rearrangement theorem is in his 1854 Habilitationsschrift on trigonometric series (published posthumously), the same work that introduced his integral.
  • Summation by parts goes back to Abel (1826); the test is named for Dirichlet (published posthumously in 1862 as a proof of a theorem of Abel's). The narration does not date it.
  • Mertens (1875) for the Cauchy product theorem; Darboux (1875) for the intermediate value property of derivatives; Thomae (1875) for his function; Hermite (1873): e is transcendental (Rudin points to a proof).
  • The claim that no function is continuous exactly at the rationals is a consequence of Baire's theorem (Part 8); it is not in Rudin's chapter 4.

On-screen simplifications:

  • The hulls of a spiral's tails stand in for the closures of the tails (same diameter); the screen says so.
  • Rudin's nowhere-differentiable function is rescaled vertically in the zoom panel; the panel says so.
  • The monotone function with a jump at every rational is drawn with denominators up to 40.
About this partfrom its README

Part 2 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 3 to 5 of Principles of Mathematical Analysis, in a hook, fourteen chapters and an outro:

  • Sequences. Convergence as a game (ε moves first, then N), uniqueness, the limit laws and the ε/2 trick, subsequences. Cauchy sequences: the tails' diameters, convergence checked without knowing the limit, Rᵏ and compact spaces are complete, Q is not (the convergents of √2 close in on a hole). Monotone bounded sequences. Upper and lower limits as the high- and low-water marks of the tail; a sequence listing every rational has E = [0, 1]; the special limits n^(1/n) → 1 and nᵅ/(1 + p)ⁿ → 0.
  • Series. The Cauchy criterion, Oresme's harmonic blocks, comparison, Cauchy condensation and Σ 1/nᵖ, no sharp line between convergence and divergence. The number e, its two definitions and its irrationality. Root and ratio tests (Rudin's example where only the root test decides), power series and their disks of convergence, and why the series of 1/(1 + x²) stops at |x| = 1 (the poles at ±i). Summation by parts, Dirichlet's test, and the sawtooth series Σ sin(kx)/k converging at every x. The Cauchy product, Mertens, and its failure without absolute convergence. Riemann's rearrangement theorem, proved by the hook's algorithm; absolutely convergent series are safe; the sawtooth series at x = 1 reordered to sum to 3.
  • Continuity. Limits of functions; continuity on the ε–δ game board (for x² at 3, ε = 0.1, the largest δ is 0.0166); sin(1/x) by sequences; preimages of open sets; compactness gives extreme values, continuous inverses and uniform continuity (the sliding box; 1/x's best δ shrinking to 0); connectedness gives intermediate values (and their failure over Q); the kinds of discontinuity; monotone functions jump only countably often, and Rudin's function that jumps at every rational; Thomae's function, which is Part 1's rational ruler with tick height 1/q, continuous exactly at the irrationals.
  • The derivative. Secants to tangents; zooming in until straight (and Rudin's nowhere-differentiable function, which never straightens); the chain rule with Rudin's u(t) trick; x² sin(1/x). The mean value theorem by a vertical shear; monotonicity; Darboux's theorem; L'Hôpital's rule as chord and tangent slopes of the curve (g, f). Taylor's theorem with Lagrange's remainder, its error bound for e, and e^(−1/x²), smooth but not the sum of its Taylor series. The vector-valued mean value inequality and the ledger's second row.

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
rearrange greedy rearrangements of 1 − 1/2 + ⋯ to π, −1, +∞ (10⁶ terms) within 10⁻⁵ of π and −1; overshoots bounded by the last term; Pringsheim's ratio e^(2(π − ln 2)) within 1%; the natural order → ln 2
swing a rearrangement swinging between 0 and 1; Σ sin(k)/k reordered to 3 turning points within the last term of 0 and 1, approaching them; the reordered sum within 10⁻⁴ of 3; the natural order within 10⁻⁵ of (π − 1)/2
sequences 1/n, (−1)ⁿ/n, n^(1/n), (1 + 1/n)ⁿ thresholds; n^(1/n) peaks at n = 3
cauchy tails of 1 − 1/2 + ⋯; convergents of √2; a spiral's hulls; (1 + 1/n)ⁿ diam Eₙ = 1/(N + 1); p² − 2q² = ±1 and diam = 1/(qₙqₙ₊₁) exactly; hull diameters decreasing; increasing, below 3
limsup tail sups/infs; the rationals by denominator; n^(1/n); n¹⁰/1.1ⁿ the tail sups match the closed form; the binomial bound; peak at n = 105, below 1 from n = 686
pseries Σ 1/nᵖ to 10⁶; Oresme's blocks; condensation; Σ 1/(n log n) ln N + γ, π²/6, ζ(3/2) with the tail size; blocks ≥ 1/2 exactly; ½ t_k ≤ s ≤ t_k
etail q!(e − s_q); the binomial terms of (1 + 1/n)ⁿ in (0, 1/q); 0 < e − sₙ < 1/(n!·n); the terms sum to (1 + 1/n)ⁿ (to 10⁻⁴⁰) and stay below s_n
tests Rudin 3.35(b) ratios → 0 and ∞; roots → 1/√2; the sum is 3/2
power Σ zⁿ/n at four points; the series of 1/(1 + x²) −ln 2 at z = −1; −log(1 − z) inside; divergence outside; converges at 0.9, not at 1.1
abel summation by parts; Σ e^(ikx); Σ sin(k)/k the identity on random data; the circle; Dirichlet's tail bound
product the Cauchy product of Σ (−1)ⁿ/√(n + 1) with itself |cₙ| ≥ 2(n + 1)/(n + 2)
deltas largest δ for x² at 3, 1/x on (0, 1), √x on [0, 1] √9.1 − 3; x − 1/(1/x + ε); δ = ε² works for √x
thomae Thomae's function; a monotone function jumping at every rational δ at 1/√2 is the distance to 7/10; every value inside the strip is below ε; monotone
wiggle x² sin(1/x); Rudin's nowhere-differentiable function |h sin(1/h)| ≤ h; Darboux's crossings; quotients ≥ (3ᵐ + 1)/2
taylor e^(−1/x²); Lagrange's bound for e; log(1 + x) ten derivatives 0 at 0 (sympy); errors under the bound; radius 1; below x¹⁰
Chapter notes
0:00 One series, any sum you like
2:33 1. Sequences and their limits
5:32 2. Cauchy sequences and completeness
10:13 3. Upper and lower limits
13:39 4. Series, and the comparison tests
17:00 5. The number e
19:15 6. Root, ratio and power series
22:07 7. Summation by parts, and multiplying series
25:49 8. Rearrangements
28:37 9. Continuity
31:47 10. Continuity and compactness
35:03 11. Continuity and connectedness
38:10 12. The derivative
40:43 13. Mean value theorems
43:20 14. Taylor's theorem
46:07 Vector-valued functions, and the second row of the ledger
Chapter notes
# Scene What it establishes Computed on screen
0 Hook The ledger so far; 1 − 1/2 + 1/3 − ⋯ = ln 2 in its natural order; the greedy rearrangement to π, to −1 and to +∞; the plan. The rearrangements to 10⁶ terms (within 10⁻⁵ of π and −1); Pringsheim's ratio of positive to negative terms (≈ 134 for π).
1 Sequences Convergence (3.1) on the sequence game board; (−1)ⁿ diverges; uniqueness and boundedness (3.2); limit laws and the ε/2 trick (3.3); subsequences (3.5–3.6). For pₙ = 1 + (−1)ⁿ1.5/n, the smallest N for ε = 0.5, 0.2, 0.05: 3, 7, 30.
2 Cauchy Cauchy sequences (3.8); diam Eₙ → 0 (3.9); convergent ⇒ Cauchy (3.11a); Q is incomplete; compact ⇒ complete, Rᵏ complete (3.11b–c), via nested closed tails; complete spaces (3.12); monotone bounded sequences (3.14). The tails of 1 − 1/2 + ⋯ have diameter 1/(N + 1) (N = 10 for ε = 0.1, 20 for 0.05); the convergents p/q of √2, diam Eₙ = 1/(qₙqₙ₊₁) exactly; hulls of a spiral's tails, nested; (1 + 1/n)ⁿ within 0.1 of e from n = 13 on.
3 LimSup Upper and lower limits (3.16), the tail sup and inf; 3.17; convergence ⇔ lim sup = lim inf; every rational listed gives E = [0, 1]; the special sequences (3.20). Tail sups and infs; the subsequence nearest 1/√2; n^(1/n) to 10⁶ under the bound 1 + √(2/(n − 1)); n¹⁰/1.1ⁿ peaking near 7 × 10¹⁵ at n = 105, below 1 from n = 686.
4 Series Series and the Cauchy criterion (3.22); terms → 0 (3.23); Oresme's blocks; comparison (3.25); the geometric series (3.26); condensation (3.27); Σ 1/nᵖ (3.28); Σ 1/(n log n) (3.29); Exercises 3.11–3.12. Oresme's blocks ≥ 1/2 in exact fractions; Σ 1/nᵖ for p = 1, 1.5, 2 to 10⁶ terms (14.39; ζ(3/2) still 0.002 away; π²/6); the condensation inequalities; Σ 1/(n log n) ≈ 3.42 at 10⁶.
5 NumberE e = Σ 1/n! and the tail bound 1/(n!·n); lim (1 + 1/n)ⁿ = e (3.31) by the binomial bars; e is irrational (3.32). The tail bound for n ≤ 15 (60-digit arithmetic); the binomial terms of (1 + 1/n)ⁿ for n up to 200; q!(e − s_q) ∈ (0, 1/q) for q = 1 … 15.
6 Tests Root test (3.33) as a geometric envelope; ratio test (3.34) and Rudin's example 3.35(b); 3.37; power series (3.39); 1/(1 + x²) and its poles at ±i. Ratios → 0 and → ∞ while the n-th roots → 1/√2; partial-sum paths of Σ zⁿ/n at |z| = 0.9, z = −1, z = 1, |z| = 1.1 (−ln 2 at z = −1).
7 Abel Summation by parts (3.41) as two ways to slice an area; Dirichlet's test (3.42); alternating series (3.43); the sawtooth converges at every x; absolute convergence (3.45); the Cauchy product, Mertens (3.50) and the counterexample (3.49). Summation by parts checked; Σ e^(ikx) on its circle of radius 1/(2|sin(x/2)|); Σ sin(k)/k → (π − 1)/2 inside Dirichlet's bound; |cₙ| ≥ 2(n + 1)/(n + 2).
8 Rearrangement Riemann's theorem (3.54): two infinite piles, the greedy walk, the overshoot bounded by the last term; two targets give any lim sup and lim inf; 3.55; the sawtooth is conditionally convergent. The overshoot envelope to 4,000 terms; a rearrangement swinging between 0 and 1 (turning points approaching both); Σ sin(k)/k reordered to 3 within 3 × 10⁻⁵ after 2 × 10⁶ terms.
9 Continuity Limits of functions (4.1); continuity (4.5) on the function game board; sequences (4.2, 4.6) and sin(1/x); preimages of open sets (4.8); compositions (4.7), sums and products (4.9). For x² at 3: the largest δ for ε = 1, 0.5, 0.1 (0.0166 = √9.1 − 3), by bisection, asserted.
10 Compactness Continuous images of compact sets (4.14); extreme values (4.16) and three failures; continuous inverses (4.17) and [0, 2π) → circle (4.21); uniform continuity (4.18) as a sliding box; 1/x; 4.19 via a finite subcover. √x with δ = ε² on a grid; the best δ for 1/x at seven points, matching x − 1/(1/x + ε); a finite subcover of √x's δ-intervals.
11 Connectedness Connected images (4.22); intermediate values (4.23); x² − 2 on Q; kinds of discontinuity (4.26); monotone functions (4.29–4.31); Thomae's function (Exercise 4.18). The rationals of denominator ≤ 60 (1,103 points); δ = 0.0071 at 1/√2 for ε = 0.1 (to 7/10); a staircase with jumps at the 489 rationals of denominator ≤ 40.
12 Derivative The derivative (5.1); zooming to straightness, |x|, and Rudin's 7.18 function; the best linear approximation; 5.2; the chain rule (5.5); x² sin(1/x) (5.6). Difference quotients of Rudin's function at 0.3 exceeding (3ᵐ + 1)/2; h sin(1/h) → 0.
13 MeanValue Local extrema (5.8); the mean value theorem by a vertical shear (5.9–5.10); monotonicity (5.11); Darboux (5.12); L'Hôpital (5.13) as chord and tangent slopes. The tangent point ξ by root-finding; f′ of x² sin(1/x) crossing every level in [−0.9, 0.9] near 0.
14 Taylor Taylor polynomials of sin x and log(1 + x); Taylor's theorem (5.15) by repeated mean value theorems; Lagrange's error bound for e; e^(−1/x²) (Exercise 8.1). Errors of e's Taylor polynomials under e/(n + 1)!; the first ten derivatives of e^(−1/x²) at 0 (sympy, all 0); e^(−1/x²) < x¹⁰ on (0, 0.2].
15 Outro e^(it): the mean value theorem fails for vector-valued functions, the inequality (5.19) survives; recap; the ledger's second row; Part 3's main problem (m/(m + n), Rudin 7.2); sources. —
The visual language

Part 2 adds two instruments to Part 1's (the rational ruler, ladders of derivation lines, museum cards, the ledger):

  • The ε–δ game board (explainer/analysis/gameboard.py): a yellow band of half-width ε, a teal strip of half-width δ (or a threshold N for sequences), and the graph over the strip colored green where it stays in the band and red where it escapes. The largest winning δ is found by bisection and asserted. The same board with δ fixed before the point moves is uniform continuity.
  • Log-scale plots for slow phenomena: harmonic growth, condensation, the swinging rearrangement, n^(1/n).
Concept Color
ε, tolerances, highlights yellow
δ, N, responses teal
sequences, partial sums, the hero function blue
approximants, rearranged sums magenta
winning / losing parts of the graph green / red
a hole: where a limit should be and is not red ring
the rationals grey

Build the film

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

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

Part 2 imports helpers from Part 1 (videos/analysis/analysis1/common.py): the zoomable window with its rational ruler, and the sawtooth.