# Measure Theory/Differentiation and Integration
## Integration and Differentiation

Now that we have exerted an enormous effort to understand this new kind of integration, we naturally want to know that it interacts with differentiation in the familiar ways. In particular, the most powerful and defining relationships between derivative and integral are the parts of the fundamental theorem of calculus.
Definition: area function
Let $f:{\mathbb {R}}\to {\mathbb {R}}$ be an integrable function. Define $F(x)=\int _{(-\infty ,x)}f$ which we call the (length-measure) area function of f. Because almost everything we do is with the length-measure integral, then we will usually omit this qualification.
In our setting, we will want something like the following results:
* If $f:{\mathbb {R}}\to {\mathbb {R}}$ is integrable and $F(x)$ is the (length-measure) area function of f, then $F'(x)=f(x)$.
* $\int _{(a,b)}f'=f(b)-f(a)$
and we will want to understand some conditions on the function f, under which its derivative and area function exist.
Of course the conditions under which these objects exist have to make up the starting point of our journey.
This section, titled Differentiating the Integral is dedicating to showing that if f is integrable then $F'(x)=f(x)$ holds a.e. In the next section, Integrating the Derivative we find conditions in which it makes sense to state $\int _{(a,b)}f'=f(b)-f(a)$.

### A Theorem for Riemann Integration

Below is a result which can be used to prove the fundamental theorem in the Riemann setting. Our strategy throughout this section will be to try to reproduce the proof in the length-measure setting.
First let $f:{\mathbb {R}}\to {\mathbb {R}}$ be a function integrable on ${\mathbb {R}}$ (which we define to mean $\lim _{n\to \infty }\int _{-n}^{n}f(x)\ dx$ is a real number).
(Notice that this is more general than the assumption that f is continuous on a compact interval, [a,b]. If we needed to consider such a function, we could define $g:{\mathbb {R}}\to {\mathbb {R}}$ by $g(x)=0$ for $x\not \in [a,b]$ and otherwise $g(x)=f(x)$. Then g is integrable on ${\mathbb {R}}$, and the results which we find for it will typically tell us what we need to know for f on [a,b].)
Then define the area function $F(x)=\int _{-\infty }^{x}f(t)\ dt$.
Further suppose that f is continuous at a point x.
We can then show $F'(x)=f(x)$. First consider the difference quotient, for a fixed x,
    $g(h)={\frac {\int _{-\infty }^{x+h}f(t)\ dt-\int _{-\infty }^{x}f(t)\ dt}{h}}={\frac {1}{h}}\int _{x}^{x+h}f(t)\ dt$
We need to show that the limit $\lim _{h\to 0}g(h)$ exists and is $f(x)$.
* Exercise 1. Finish the Riemann FTC Lemma
* Show that $\lim _{h\to 0^{+}}g(h)=f(x)$ by the following steps.
* 1. Let $\varepsilon \in {\mathbb {R}}^{+}$ and write down a relevant quantity which we would like to show is less than $\varepsilon$.
* 2. In the previous step you should have an integral minus $f(x)$. Simplify this to a single integral, using the observation that $f(x)={\frac {1}{h}}\int _{x}^{x+h}f(x)\ dt$.
* 3. Use the integral triangle inequality.
* 4. Use the continuity of f at x.

### Mimicking the Proof for Length-measure Integration

We could repeat all of the above for length-measure integration. However, this is unsatisfying because much of the power of length-measure integration comes from the fact that we typically only need to assume that f is measurable, not continuous.
Can we prove the above, but only for measurable functions? Unfortunately, no, the theorem is simply false for arbitrary measurable functions which are integrable on ${\mathbb {R}}$. If you would like to look for an example, the Dirichlet function often proves useful for questions like these.
But we shouldn't lose heart! Often when the counter-example that you have to reach for is like the Dirichlet function, it means that the result "mostly" holds. It just fails to hold on a small-measure set, which is to say, a null set.
Definition: area function
Let $f:{\mathbb {R}}\to {\mathbb {R}}$ be integrable on ${\mathbb {R}}$. Define the area function for f by the length-measure integral
    $F(x)=\int _{(-\infty ,x)}f$
Definition: diff
Let $f:{\mathbb {R}}\to {\mathbb {R}}$ and define the difference quotient for f by
    ${\text{Diff}}_{h}f(x)={\frac {f(x+h)-f(x)}{h}}$
Definition: av
Let $f:{\mathbb {R}}\to {\mathbb {R}}$ be integrable and defined the average of f at x by
    ${\text{Av}}_{h}f(x)={\text{Diff}}_{h}F(x)$
where F is the area function for f.
* Exercise 2. Av Characterization
* Show that ${\text{Av}}_{h}f(x)={\frac {1}{h}}\int _{x}^{x+h}f$.
* Also show that, in Exercise 1., we effectively showed that $\lim _{h\to 0^{+}}|g(h)-f(x)|=0$, which is the same as the limit of ${\text{Av}}_{h}|f(t)-f(x)|$.
All of the steps that you completed in Exercise 1. Finish the Riemann FTC Lemma still hold except for the last one, which depended on continuity.
For this step we still need to prove that
    $\lim _{h\to 0^{+}}{\text{Av}}_{h}|f(t)-f(x)|=0$
but instead of showing this at every x we will instead prove that this equality is correct almost everywhere on ${\mathbb {R}}$.
(Note, I am writing the dt explicitly in order to distinguish the variable of integration.)
How do we get started? Since we have seen that continuity was so useful in the proof, we might recall that every measurable function is approximately continuous!
However, there is a problem with this. The theorem which formalized this idea, resulted in a continuous function g and subset of a compact interval, $E\subseteq [a,b]$, where f and g are not too different.
The problem for us is this subset E. We cannot know if the limit that we are to evaluate will require f to be taken at points outside of E.
Therefore we need a different kind of result which relates f to some continuous function g. In particular we need a continuous g such that ${\text{Av}}_{h}|f-g|$ is guaranteed to be small.

### What if Every Integrable Function Is Almost Continuous

Let's take a minute to consider what we will do once we have this function g described above.
Let $\varepsilon \in {\mathbb {R}}^{+}$ and we would like to show, as before, that ${\text{Av}}_{h}|f(t)-f(x)|<\varepsilon$ for almost every x.
The usual dance at this point is to invoke the function g corresponding to $\varepsilon$, and do the following:
    ${\text{Av}}_{h}|f(t)-g(t)+g(t)-f(x)|\leq {\text{Av}}_{h}|f(t)-g(t)|+{\text{Av}}_{h}|g(t)-f(x)|$
where the left-hand term can now be bounded by $\varepsilon$.
But what about the right-hand term? With x fixed, there is no reason why g should be close to f at this x.
There is a trick which comes up in case like this.
Essentially, the problem is that $g(t)$ and $f(x)$ are unrelated in two different ways. They are different both because of the functions, f and g, and the nature of the variables, t and x. When this is the case, we may introduce yet another term which acts like a bridge for each difference independently.
In this case we will introduce $g(x)$ and observe that $|g(t)-f(x)|=|g(t)-g(x)+g(x)-f(x)|\leq |g(t)-g(x)|+|g-f|(x)|$. From this we obtain
    ${\text{Av}}_{h}|f(t)-f(x)|\leq \overbrace {{\text{Av}}|f(t)-g(t)|} ^{HL}+\overbrace {{\text{Av}}_{h}|g(t)-g(x)|} ^{\text{cont}}+\overbrace {{\text{Av}}_{h}|g-f|(x)} ^{\text{Markov}})$
I have labeled each term to indicate the names of concepts which will aid us in bounding each term (after we have distributed the integral). "HL" indicates the Hardy-Littlewood maximal function theorem. "cont" indicates continuity. "Markov" indicates Markov's inequality.
* Exercise 3. Simplify These Bounds
* Show that ${\text{Av}}_{h}\int _{(x,x+h)}|g(t)-g(x)|=0$ with g as above. Hint: Since g is continuous, it is continuous at x.
* Also show that ${\text{Av}}_{h}(|g-f|(x))=|g-f|(x)$. Note that x is a fixed point, and the variable for integration we take to be some dummy variable like t.
* Infer that we therefore will study how to bound ${\text{Av}}_{h}|f(t)-f(x)|$ (almost everywhere) by bounding
* ${\text{Av}}_{h}|f-g|+|g-f|(x)$
* almost everywhere.

### Markov and Hardy-Littlewood

In light of the observation above, we will prove in this section a pair of theorems to help us.
The first, Markov's inequality, will help us to bound $|g-f|(x)$. (In fact this is a little inaccurate. Rather, we will use Markov's inequality to prove that the set of points on which this cannot be bounded has measure equal to zero.)
The informal version of Markov's inequality says "An integrable function cannot be too big at too many points".
More formally, let $f:{\mathbb {R}}\to {\mathbb {R}}$ be integrable. Then
    $\lambda (\{x\in X:c<|f(x)|\})\leq {\frac {1}{c}}\int |f|$
The integral, $\int |f|$, is taken over the entire space, ${\mathbb {R}}$, as indicated by the absence of any bounds.
The second theorem that we shall prove in this section is the Hardy-Littlewood inequality, which will help us to bound ${\text{Av}}_{h}|f(t)-g(t)|$.
To state the theorem, we first need some definitions.
Definition: the maximal average function
If $f:{\mathbb {R}}\to {\mathbb {R}}$ is any measurable function and $x\in {\mathbb {R}}$ then we call any integral of the form
    ${\frac {1}{2h}}\int _{(x-h,x+h)}f$ for $t\in {\mathbb {R}}^{+}$
is called a two-sided average of f at x. Taking the supremum over all choices of h
    $\sup _{0<h}\int _{(x-h,x+h)}f$
defines a function for each x.
Finally, we define the maximal average function, $f^{*}:{\mathbb {R}}\to {\mathbb {R}}$, by applying the above to $|f|$.
    $f^{*}(x)=\sup _{0<h}{\frac {1}{2h}}\int _{(x-h,x+h)}|f|$
The Hardy-Littlewood theorem then states, informally, that a function's maximal average cannot be too big at too many points.
More formally, with f as before,
    $\lambda (\{x\in {\mathbb {R}}:c<f^{*}(x)\})\leq {\frac {3}{c}}\int |f|$
We will apply this to the function $|f-g|$ from before.
The statement of the Hardy-Littlewood theorem is for a two-sided average, ${\frac {1}{2h}}\int _{(x-h,x+h)}|f|$ although our conversation earlier considered only a one-sided interval. These can be related to each other easily. I have preferred to write the theorem in the more standard two-sided way only because it simplifies the proof, later on.

### Integrable Functions Are Almost Continuous

Notice that Markov and Hardy-Littlewood will be applied to $|f-g|(x)$ and $(f-g)^{*}$ respectively.
But they both deliver a bound in terms of $\int |f-g|$. We will still need some guarantee that this quantity can be made to go to zero with a judicious choice of g.
Therefore another important result that we'll pursue in this section, is the following.
For any integrable function $f:{\mathbb {R}}\to {\mathbb {R}}$, for each $\varepsilon \in {\mathbb {R}}^{+}$ there is a continuous function $g:{\mathbb {R}}\to {\mathbb {R}}$ such that $\int |f-g|<\varepsilon$.
One can also read this result as saying that, in this sense, every integrable function is almost continuous.