# Measure Theory/Fourier and the Need for Swaparoo
## Fourier and the Need for Swaparoo

Note: This lesson is mostly to provide context and meaning to measure theory. Therefore, it is not stated with full and complete rigor. It is intentionally written in a kind of "discovery phase" where ideas become progressively clearer. This lesson is meant only to set us on the start of the road to measure theory, after which statements, theorems, and proofs will become more formal.

### Fourier Series in Very Brief

A shockingly large amount of modern mathematics has its roots in Fourier series. For measure theory, the ancestry could not be more direct.
Since this is not a course on Fourier series we will try to know only the absolute minimum of Fourier analysis which will still allow us to appreciate the reason why measure theory became necessary.
From a physics perspective, Fourier series gives tools to take a complicated wave form, and decompose it into simple sinusoidal waves. It is easy to go the other way, and take a few simple sinusoidal waves like
    $2\cos x$
    $-3\sin x$
    $\cos(2x)$
and then just sum them to obtain a "complex" wave
    $2\cos x-3\sin x+\cos(2x)$
But going the other way around is tougher. Imagine observing a wave (or, mathematically, just having any periodic function), and then trying to discover its representation as a combination of sinusoids.
We will not try to do this with any real depth. Still, it is worth appreciating how foundational waves are in physics. Sinusoids describe the motion of the waves that we see daily. But also waves describe sound, light, springs, and much more physical phenomena. Therefore, there was and is good reason to study Fourier series.
We define the Fourier series of a function f to be the infinite series
    $f(x)=a_{0}+\sum _{k=1}^{\infty }a_{k}\cos(kx)+\sum _{k=1}^{\infty }b_{k}\sin(kx)$
if there are coefficients $a_{0},a_{k},b_{k}$ which make this equation correct.
For now we can assume that the quantities here are all real numbers. Modern studies in Fourier series extend these ideas, but that effort won't be necessary for us.
Also, we will restrict the domain of all functions to the interval $[0,2\pi ]$. The reasons for this need not concern us, although you're likely to learn about it in a course on Fourier analysis.
* Exercise 1. Quick Coeffs
* In the expression
* $2\cos x-3\sin x+\cos(2x)$
* identify the indexed coefficients of its Fourier series. That is to say, identify
* $a_{0},a_{1},a_{2},\dots$
* and
* $b_{1},b_{2},\dots$
When we think of "finding" the Fourier series of f, we are interested in determining the coefficients $a_{0},a_{k},b_{k}$ by using our knowledge of the function $f(x)$.
Fourier (the eponymous discoverer of Fourier series) realized that one could find $a_{n}$ by computing a certain integral. Namely, $\int _{0}^{2\pi }f(x)\cos(nx)\ dx$.
Now why does computing this help at all? The following exercises try to illuminate this progressively.
* Exercise 2. Integrate Sinusoidal Products
* Show that $\int _{0}^{2\pi }\cos(kx)\sin(nx)\ dx=0$ for every choice of $k,n\in {\mathbb {N}}^{+}$.
* It will be easiest to recall the sinusoidal product formula for an arbitrary $\cos \alpha \sin \beta$.
* Then show that if $k,n\in {\mathbb {N}}$ and $k\neq n$ then $\int _{0}^{2\pi }\cos(kx)\cos(nx)\ dx=0$.
* Then show that if $k=n$ then $\int _{0}^{2\pi }\cos(kx)\cos(nx)\ dx=\pi$.
* Then show the same for sine.
Suppose that the function $f:[0,2\pi ]\to {\mathbb {R}}$ has a valid Fourier series, which is to say, there exist coefficients for which the equation
    $f(x)=a_{0}+\sum _{k=1}^{\infty }a_{k}\cos(kx)+\sum _{k=1}^{\infty }b_{k}\sin(kx)$
is true. Then if we multiply both sides by cosine and integrate, we obtain
    $\int _{0}^{2\pi }f(x)\cos(nx)\ dx=\int _{0}^{2\pi }\left(a_{0}+\sum _{k=1}^{\infty }a_{k}\cos(kx)+\sum _{k=1}^{\infty }b_{k}\sin(kx)\right)\cos(nx)\ dx$
Fourier inferred that this equals
    $\int _{0}^{2\pi }a_{0}\cos nx\ dx+\sum _{k=1}^{\infty }a_{k}\int _{0}^{2\pi }\cos(kx)\cos(nx)\ dx+\sum _{k=1}^{\infty }b_{k}\int _{0}^{2\pi }\sin(kx)\cos(nx)\ dx$
* Exercise 3. Find $a_{n}$
* Using all of the assumptions above, compute one more integral, and use the earlier exercises, to show that the above reduces to just
* $\int _{0}^{2\pi }f(x)\cos(nx)\ dx=a_{n}\pi$
* Then by merely dividing by $\pi$, obtain a formula for $a_{n}$.

### The Swaparoo

The above is beautiful, simple, and powerful ... but ultimately flawed.
The problem comes from the step at which we go from
    $\int _{0}^{2\pi }\left(a_{0}+\sum _{k=1}^{\infty }a_{k}\cos(kx)+\sum _{k=1}^{\infty }b_{k}\sin(kx)\right)\cos(nx)\ dx$
to
    $\int _{0}^{2\pi }a_{0}\cos nx\ dx+\sum _{k=1}^{\infty }a_{k}\int _{0}^{2\pi }\cos(kx)\cos(nx)\ dx+\sum _{k=1}^{\infty }b_{k}\int _{0}^{2\pi }\sin(kx)\cos(nx)\ dx$
This is a bit messy, so let's focus only on what's important, in a cleaner and more abstract setting.
In general, consider any sequence of integrable functions $\langle f_{k}\rangle$. Is the following justified?
    $\int _{a}^{b}\sum _{k=1}^{\infty }f_{k}(x)\ dx=\sum _{k=1}^{\infty }\int _{a}^{b}f_{k}(x)\ dx$
The equation is certainly true when the sum is finite. Here is how that looks:
    $\int _{a}^{b}\sum _{k=1}^{m}f_{k}(x)\ dx=\sum _{k=1}^{m}\int _{a}^{b}f_{k}(x)\ dx$
The above is valid simply because we know that integration distributes over a sum: $\int _{a}^{b}(f+g)\ dx=\int _{a}^{b}f\ dx+\int _{a}^{b}g\ dx$. Applying this $m-1$ times justifies the interchange of $\int _{a}^{b}$ and $\sum _{k=1}^{m}$ above.
But if the sum is infinite, note that the infinite sum is the same as a certain limit. Therefore if we write the finite equation which we know to be true,
    $\int _{a}^{b}\sum _{k=1}^{m}f_{k}(x)\ dx=\sum _{k=1}^{m}\int _{a}^{b}f_{k}(x)\ dx$
and then take the limit as $m\to \infty$ then the right-hand side of the equation looks like the object that we want.
    $\lim _{m\to \infty }\int _{a}^{b}\sum _{k=1}^{m}f_{k}(x)\ dx=\sum _{k=1}^{\infty }\int _{a}^{b}f(x)\ dx$
If we know that the limit were free to distribute into an integral, then we could write the thing that we actually want,
    $\int _{a}^{b}\sum _{k=1}^{\infty }f_{k}(x)\ dx=\sum _{k=1}^{\infty }\int _{a}^{b}f(x)\ dx$
So really, the heartache comes from not knowing if we are justified in swapping a limit and an integral. The fundamental problem, from which measure theory originated, was trying to make the move
    $\lim _{m\to \infty }\int _{a}^{b}g_{m}(x)\ dx=\int _{a}^{b}\lim _{m\to \infty }g_{m}(x)\ dx$
Although the original interest was in functions of the form $g_{m}(x)=\sum _{k=1}^{m}f_{k}(x)$, nothing much is lost by ignoring the issue of the sum and focusing abstractly on just any sequence of functions, $\langle g_{m}\rangle$.
* Exercise 4. Can't Swap, Don't Swap
* In this exercise, we will see that the concern about the swaparoo is not merely theoretical. It really is not valid for some sequences of functions.
* Set $g_{m}(x)={\frac {1}{1+mx}}$.
* 1. Show that for any fixed $x\in ]0,\infty )$, the limit $\lim _{m\to \infty }g_{m}(x)=0$. Infer that
* $\int _{0}^{\infty }\lim _{m\to \infty }g_{m}(x)\ dx=0$
* 2. Show that for a fixed $m\in {\mathbb {Z}}^{+}$, the integral $\int _{0}^{\infty }g_{m}(x)\ dx=\infty$. Infer that
* $\lim _{m\to \infty }\int _{0}^{\infty }g_{m}(x)\ dx=\infty$
* 3. Reflect upon what this exercise was meant to demonstrate.

### A Brief Prehistory of the Swaparoo

The invalidity of the "swaparoo" launched a program among mathematicians, starting near the end of the 19th century. They sought to find conditions that the functions $g_{m}$ could satisfy, which would then guarantee the equation
    $\lim _{m\to \infty }\int _{a}^{b}g_{m}(x)\ dx=\int _{a}^{b}\lim _{m\to \infty }g_{m}(x)\ dx$
These mathematicians found one very significant result. If the functions converge uniformly to an integrable function, and if they all share the same compact domain, then this swaparoo is valid.
This was a nice and productive result! However, it was imperfect because there were some sequences of functions for which the convergence was not uniform, and yet we still desired to know if the swaparoo is valid. The condition of uniform convergence was, after all, a sufficient but not a necessary condition.
Mathematicians later made progress in specifying further and further conditions on functions, which would ensure the validity of the swaparoo.
But the results continued to be weak and not capture classes of functions that mathematicians wanted to study. Moreover, the proofs became so long and subtle that simply managing the complexity of the forest of theorems became burdensome.

### Lebesgue's New Integral

It was in this context that the mathematician Lebesgue had an idea about how to solve these difficulties.
It will be useful to contrast it with the standard Riemann integral, so recall how that is constructed.

#### Summary of Riemann Integration

Consider a function on a closed bounded interval,
    $a,b\in {\mathbb {R}},\quad a<b,\quad f:[a,b]\to {\mathbb {R}}$.
First we partition the interval with any ${\mathcal {P}}=\{a=x_{0}<x_{1}<x_{2}<\cdots <x_{n}=b\}$.
On each interval $[x_{i},x_{i+1}]$ we use f (either at the left end-point, or the right, or anywhere else) to determine a height.
Then we compute the area of the rectangle determined by this interval and height. Then we sum all of the rectangles to get an approximation of the area under the curve. Then we take finer and finer partitions ${\mathcal {P}}$ resulting in more accurate approximations.
Then we consider some kind of limiting procedure, or perhaps take a supremum and infimum. (There are several different equivalent constructions of these integrals, and it's not important to focus on exactly which strategy we use here.)
The important summary of how this integral is constructed is:
* Partition the domain,
* use the partition to determine heights,
* use these to determine rectangle areas,
* then take a limit of the procedure as the partition goes to zero.
* Exercise 5. Do a Quick Riemann
* Let $f(x)=x^{2}+1$ on $[-1,1]$. Use the partition ${\mathcal {P}}=\{-1,0,1\}$ to compute the corresponding lower Riemann sum.

#### Lebesgue Integration

Lebesgue integration reverses part of the Riemann process.
Rather than first partitioning the domain, this time we start from partitioning the range of the function. It will be useful to represent this partition as a collection of intervals.
Using the same function and domain as in Exercise 5. Do a Quick Riemann, we may choose the partition
    ${\mathcal {P}}=\{(-\infty ,0],(0,1],(1,2],(2,\infty )\}$
(This partition is chosen arbitrarily, merely for demonstration purposes.)
Now from this partition of the range, we would like to find corresponding regions of the domain. Then we will construct rectangles that approximate the area under the curve.
To each cell of the partition of the range, there corresponds a preimage in the domain.
* $E_{1}=f^{-1}((-\infty ,0])$
* $E_{2}=f^{-1}((0,1])$
* $E_{3}=f^{-1}((1,2])$
* $E_{4}=f^{-1}((2,\infty ))$
We can compute these:
* $E_{1}=\emptyset$
* $E_{2}=\{0\}$
* $E_{3}=[-1,0)\sqcup (0,1]$
* $E_{4}=\emptyset$
The preimages are like a sides of rectangles, which approximate the area under f.
If we take each preimage and write $\lambda (E_{1}),\dots ,\lambda (E_{4})$ to denote their lengths (understood somewhat intuitively for now), then
* $\lambda (E_{1})=0$
* $\lambda (E_{2})=0$
* $\lambda (E_{3})=1+1=2$
* $\lambda (E_{4})=0$
We will use the infimum of the function on each preimage, to obtain rectangle heights. This will cause us to under-approximate the area under the function.
* $\inf _{x\in E_{1}}f(x)$ does not exist.
* $\inf _{x\in E_{2}}f(x)=1$
* $\inf _{x\in E_{3}}f(x)=1$
* $\inf _{x\in E_{4}}f(x)$ does not exist.
Where the domain set is empty, we simply discard the set.
Or if you prefer to think of it this way, we set the corresponding rectangle area to 0.
Therefore we obtain the approximation
    $\overbrace {\lambda (E_{1})} ^{{\text{width}}_{1}}\overbrace {\left(\inf _{x\in E_{1}}f(x)\right)} ^{{\text{height}}_{1}}+\lambda (E_{2})\left(\inf _{x\in E_{2}}f(x)\right)+\lambda (E_{3})\left(\inf _{x\in E_{3}}f(x)\right)+\lambda (E_{4})\left(\inf _{x\in E_{4}}f(x)\right)$
If an infimum is actually undefined then, as we said above, we set the corresponding term to zero.
Then we obtain
    $\overbrace {\lambda (E_{1})\left(\inf _{x\in E_{1}}f(x)\right)} ^{0}+\overbrace {\lambda (E_{2})\left(\inf _{x\in E_{2}}f(x)\right)} ^{0\cdot 1}+\overbrace {\lambda (E_{3})\left(\inf _{x\in E_{3}}f(x)\right)} ^{2\cdot 1}+\overbrace {\lambda (E_{4})\left(\inf _{x\in E_{4}}f(x)\right)} ^{0}$
    $=2$
Predictably, now that we have a system for constructing approximations, we then take the integral to be, in some sense, the limit as the partition widths tend to zero.
At this point, the whole idea of this new approach to integration is just a "shot in the dark". We have no reason to think that it will be any better, or really any different from Riemann integration.
* Exercise 6. Do a Quick Lebesgue
* For the same example as in Exercise 5. Do a Quick Riemann, this time use the partition $\{(-\infty ,1),[1,1.5],(1.5,2),[2,\infty )\}$ to compute an under-estimate of the area under the curve.

### Measuring Preimages

The reason why Lebesgue invented this new form of integration was with the hope that it might somehow ensure the interchange of limit and integral.
Let us summarize how one computes a single approximation in Lebesgue's way.
Every step of this procedure is straight-forward and does not require too much conversation, with the exception of step 3.
But that exception turns out to be a somewhat monumental challenge.
If we imagine that the preimage is just some set of real numbers, then we need to develop a system of measuring sets of real numbers. Whatever system we choose must be consistent with the measurement of intervals being equal to their length. That will hopefully ensure that we obtain something like rectangle areas.
For certain sets, we can make reasonable guesses about what the measure should be. Of course, if I is an interval with finite bounds $a<b$, then the measure of I should probably be its length, $b-a$.
What is a reasonable measure of $[0,1]\sqcup [3,4]$? Just add the individual lengths. So it should be $1+1=2$.
But sets of real numbers can get quite weird. What about the measure of the set of all rational numbers? It is a countable set, but it is infinite. Maybe its measure should be infinity? Maybe zero? Maybe somewhere in-between?
We have now done enough "reasonable guessing" and we need to start coming up with a rigorous system of measurement. That is the focus of the first section of this course.

### Outline of the Course

The general structure of this course will be to