%MIT OpenCourseWare: https://ocw.mit.edu
%18.100A / 18.1001 Real Analysis, Fall 2020
%License: Creative Commons BY-NC-SA 
%For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

Last time, we asked three questions about interchanging limits:
\begin{question}
Hence, we ask three questions about interchanging limits:
\begin{enumerate}
\item If $f_n:S\to \RR$, $f_n$ continuous and $f_n\to f$ pointwise or uniform, then is $f$ continuous?
\item If $f_n:[a,b]\to \RR$, $f_n$ differentiable, and $f_n\to f$ with $f_n'\to g$, then is $f$ differentiable and does $g=f'$?
\item If $f_n:[a,b]\to \RR$, with $f_n$ and $f$ continuous such that $f_n\to f$, then does 
\[
\int_a^b f_n = \int_a^b f?
\]
\end{enumerate}
\end{question}
The answer to the above questions are all \textbf{no}, if the convergence is pointwise as seen by the following counterexamples:
\begin{enumerate}
    \item Let $f_n(x) = x^n$ on $[0,1]$ is continuous $\forall n$. As we noted earlier, $f_n(x) \to f(x) =  \begin{cases} 0 & x\in [0,1) \\
    1 & x=1
    \end{cases}$. Notice that $f$ is not continuous.
    
    \item Let $f_n(x) = \frac{x^{n+1}}{n+1}$ on $[0,1]$. Then, $f_n\to 0$ pointwise on $[0,1]$. However, 
    \[
    f_n'(x) \to g(x) = \begin{cases}
    0 &x\in[0,1) \\
    1 & x=1
    \end{cases}.
    \]
    Thus, $g(x) \neq (0)' = 0$ at $x=1$.
    
    \item Consider the functions
    \[
    f_n(x) =\begin{cases}
    4n^2x & x\in \left[0,\frac{1}{2n}\right] \\
    4n-4n^2x & x\in \left[\frac{1}{2n}, \frac{1}{n}\right] \\
    0 & x\in \left[\frac{1}{n}, 1\right]
    \end{cases}
    \]
    as described in the previous lecture. Then, $f_n(x)\to 0$ pointwise on [0,1] as we showed last time. However,
    \[
    \int_0^1 f_n = \frac{1}{2}(\text{base})(\text{height}) = \frac{1}{2n}\cdot 2n = 1\not\to 0 = \int_0^1 0.
    \]
\end{enumerate}

We now prove that the answer to the three questions above is \textbf{yes} if convergence is uniform.
\begin{theorem}
If $f_n:S\to \RR$ is continuous for all $n$, $f:S\to \RR$, and $f_n\to f$ uniformly, then $f$ is continuous.
\end{theorem}
\textbf{Proof}: Let $c\in S$ and let $\epsilon>0$. Since $f_n\to f$ uniformly, $\exists M\in \NN$ such that $\forall n\geq M$, $\forall y\in S$,
\[
|f_n(y) - f(y)| < \frac{\epsilon}{3}.
\]
Since $f_M:S\to \RR$ is continuous, $\exists \delta_0>0$ such that $\forall |x-c|<\delta_0$,
\[
|f_M(x)-f_M(c)|< \frac{\epsilon}{3}.
\]
Choose $\delta = \delta_0$. If $|x-c|<\delta$, then 
\begin{align*}
    |f(x)-f(c)| &\leq |f(x) + f_M(x)| + |f_M(c) - f(c)| + |f_M(x)-f_M(c)| \\
    &< \frac{\epsilon}{3} + \frac{\epsilon}{3} + \frac{\epsilon}{3} = \epsilon.
\end{align*}\qed 

\begin{theorem}
If $f_n:[a,b]\to \RR$ is continuous for all $n$, $f:[a,b]\to \RR$ and $f_n\to f$ uniformly, then 
\[
\int_a^b f_n\to \int_a^b f.
\]
\end{theorem}
\textbf{Proof}: Let $\epsilon>0$. Since $f_n\to f$ uniform, $\exists M_0\in \NN$ such that $\forall n\geq M_0,\forall x\in[a,b]$,
\[
|f_n(x) -f(x)| < \frac{\epsilon}{b-a}.
\]
Then, for all $n\geq M = M_0$, we have 
\[
\left|\int_a^b f_n - \int_a^b f\right| \leq \int_a^b |f_n-f|<\int_a^b \frac{\epsilon}{b-a} = \epsilon.
\]\qed

\begin{remark}
Notationally, this states that 
\[
\lim_{n\to \infty} \int_a^b f_n = \int_a^b \lim_{n\to \infty} f_n = \int_a^b f.
\]
\end{remark}

\begin{theorem}
If $f_n:[a,b]\to \RR$ is continuously differentiable, $f:[a,b]\to \RR$, $g:[a,b]\to \RR$, and 
\begin{align*}
    f_n &\to f \text{~~pointwise}, \\
    f_n' &\to g \text{~~uniformly},
\end{align*}
then $f$ is continuously differentiable and $g = f'$.
\end{theorem}
\textbf{Proof}: By the FTC, $\forall n\forall x\in[a,b]$,
\[
f_n(x) - f_n(a) = \int_a^x f_n'.
\]
Thus, by the previous two theorems,
\begin{align*}
    f(x) - f(a) &= \lim_{n\to \infty} (f_n(x) - f_n(a)) \\
    &= \lim_{n\to \infty}\int_a^x f_n' \\
    &= \int_a^x g.
\end{align*}
Therefore, $f(x) = f(a) +\int_a^x g$. Thus, by the FTC, $f$ is differentiable and $f' = (\int_a^x g)' = g.$ \qed 

We now return back to our study of power series, answering some questions we asked at the beginning of Lecture 23.

\begin{theorem}
Let $\sum_{j=0}^\infty a_j(x-x_0)^j$ be a power series of radius of convergence $p\in (0,\infty]$. Then, $\forall r\in (0,p)$, $\sum_{j=0}^\infty a_j(x-x_0)^j$ converges uniformly on $[x_0-r,x_0+r]$.
\end{theorem}
\textbf{Proof}: Let $r\in [0,p)$. Then, $\forall j \in \NN \cup\{0\}$, $\forall x\in [x_0-r,x_0+r]$,
\[
|a_j(x-x_0)^j| \leq |a_j|r^j =:M_j.
\]
Now, 
\[
\lim_{}j\to \infty M_j^{1/j} = \lim_{j\to \infty} |a_j|^{1/j} r = \begin{cases} 
\frac{r}{p} &p< \infty \\
0 &p=\infty
\end{cases}
\]
since $p^{-1} = \lim_{j\to \infty} |a_j|^{1/j}$. Since $r<p$, we have 
\[
\lim_{j\to \infty}M_j^{1/j} < 1 \implies \sum_{j=0}^\infty M_j \text{~~converges.}
\]
By the Weierstrass M-test, it follows that $\sum_{j=0}^\infty a_j(x-x_0)^j$ converges uniformly on $[x_0-r, x_0+r]$. \qed 

\begin{theorem}
Let $\sum_{j=0}^\infty a_j(x-x_0)^j$ be a power series with radius of convergence $p\in (0,\infty]$. Then, 
\begin{enumerate}
    \item $\forall c\in (x_0-p, x_0+p)$, $\sum_{j=0}^\infty a_j(x-x_0)^j$ is differentiable at $c$ and 
    \[
    \frac{\mathrm d}{\mathrm dx} \sum_{j=0}^\infty a_j(x-x_0)^j = \sum_{j=0}^\infty ja_j(x-x_0)^{j-1}.
    \]
    \item $\forall a,b$ such that $x_0-p<a<b<x_0 + p$,
    \[
    \int_a^b \sum_{j=0}^\infty a_J(x-x_0)^j\,\mathrm dx = \sum_{j=0}^\infty a_j\left(\frac{(b-x_0)^{j+1}}{j+1} - \frac{(a-x_0)^{j+1}}{j+1}\right).
    \]
\end{enumerate}
\end{theorem}

\begin{remark}
Since 
\[
\lim_{j\to \infty}((j+1)|a_{j+1}|)^{1/j} = \lim_{j\to \infty} \left(((j+1)|a_{j+1}|^{1/(j+1)}\right)^{(j+1)/j} = \lim_{k\to \infty} |a_k|^{1/k} = p,
\]
1. implies $\sum a_j(x-x_0)^j$ is infinitely differentiable and 
\[
k!a_k = \left(\frac{\mathrm d^k}{\mathrm dx^k} \sum a_j(x-x_0)^j\right)\bigr|_{x=x_0}.
\]
\end{remark}

\noindent\underline{\textbf{Weierstrass Approximation Theorem}}

\begin{remark}
This theorem essentially states: "Every continuous function on $[a,b]$ is almost a polynomial."
\end{remark}

\begin{theorem}[Weierstrass Approximation Theorem]
If $f\in C([a,b])$, there exists a sequence of polynomials $\{P_n\}$ such that 
\[
P_n\to f \text{~~uniformly on~~} [a,b].
\]
\end{theorem}

The idea of the proof is to choose a suitable sequence of polynomials $\{Q_n\}_n$ such that $Q_n$ behaves like a `Dirac delta function' as $n
to \infty$. Then, the sequence of polynomials $P_n(x) = \int_0^1 Q_n(x-t)f(t)\,\mathrm dt$ converges to $f(x)$ as $n\to \infty$. We will prove this momentarily, but first we need to do the ground work.

Notice that we only need to consider $a = 0$ and $b=1$, with $f(0) = f(1) = 0$. If we prove this case, then for a general $\Tilde{f}\in C([0,1])$, $\exists$ a sequence of polynomials
\[
P_n(x) \to \Tilde{f}(x) - \Tilde{f}(0) - x(\Tilde{f}(1) -  \Tilde{f}(0)) \text{~~uniformly.}
\]
Hence, 
\[
\Tilde{P}_n(x)= P_n(x) + \Tilde{f}(0) + x(\Tilde{f}(1) - \Tilde{f}(0))\to \Tilde{f}(x) \text{~~uniformly.}
\]

\begin{theorem}
Let $c_n:= (\int_{-1}^1 (1-x^2)^n \,\mathrm dx)^{-1}>0$, and let 
\[
Q_n(x) = c_n(1-x^2)^n.
\]
Then,
\begin{enumerate}
\item $\forall n$, $\int_{-1}^1 Q_n = 1$.
\item $\forall n$, $Q_n(x) \geq 0$ on $[-1,1]$, and 
\item $\forall \delta\in (0,1)$, $Q_n\to 0$ uniformly on $\delta \leq |x|\leq 1$.
\end{enumerate}
\end{theorem}
Before we prove this, here is a picture of $Q_n$:
\begin{figure}[h]
    \centering
    \includegraphics{pics/fig13.PNG}
\end{figure}

\noindent \textbf{Proof}: 
\begin{enumerate}
    \item[2.] Immediately clear.
    \item[1.] $\int_{-1}^1 Q_n = c_n \int_{-1}^1 (1-x^2)^{n}\,\mathrm dx = 1$ by definition of $c_n$.
    \item[3.] We first estimate $c_n$. We have for all $n\in\NN$ and $\forall x\in[-1,1]$,
    \[
    (1-x^2)^n \geq 1-nx^2.
    \]
    We proved this way earlier in the course by induction, but it also follows from the calculus we have proven as 
    \[
    g(x) = (1-x^2)^n - (1-nx^2)
    \]
    satisfies $g(0) = 0$, and
    \[
    g'(x) = n\cdot 2x(1-(1-x^2)^{n-1})\geq 0
    \]
    in [0,1]. Thus, $g(x)\geq 0$ by the MVT.
    
    Then,
    \begin{align*}
        \frac{1}{c_n} &= \int_{-1}^1 (1-x^2)^n\,\mathrm dx \\
        &= 2\int_0^1 (1-x^2)^n \,\mathrm dx \\
        &> 2\int_0^{1/\sqrt{n}}(1-x^2)^n \,\mathrm dx \\
        &\geq 2\int_0^{1/\sqrt{n}} (1-nx^2)\,\mathrm dx \\
        &= 2\left(\frac{1}{\sqrt n} - \frac{n}{3}\cdot n^{-3/2}\right) \\
        &= \frac{4}{3} \sqrt{n} >\sqrt{n}.
    \end{align*}
    Therefore, $c_n< \sqrt{n}$.
    
    Let $\delta>0$. We note $\lim_{n\to \infty} \sqrt{n}(1-\delta^2)^n = 0$. Then, 
    \begin{align*}
        \lim_{n\to \infty} (\sqrt{n}(1-\delta^2)^n)^{1/n} &= \lim_{n\to \infty}(n^{1/n})^{1/2}(1-\delta^2)\\
        &= 1-\delta^2<1.
    \end{align*}
    Therefore, 
    \[
    \lim_{n\to \infty} \sqrt{n}(1-\delta^2)^n = 0.
    \]
    Let $\epsilon>0$, and choose $M\in \NN$ such that for all $n\geq M$,
    \[
    \sqrt{n}(1-\delta^2)^n <\epsilon.
    \]
    Then, $\forall n\geq M$ and $\forall \delta\leq |x|\leq 1$, 
    \[
    |c_n(1-x^2)^n| < \sqrt{n}(1-x^2)^n \leq \sqrt{n}(1-\delta^2)^n <\epsilon.
    \]
\end{enumerate}\qed 

We now prove the Weierstrass Approximation Theorem.

\noindent\textbf{Proof}: Suppose $f\in C([0,1])$, $f(0) = f(1) = 0$. We extend $f$ to an element of $C(\RR)$ by setting $f(x) = 0$ for all $x\notin [0,1]$. We furthermore define 
\begin{align*}
    P_n(x) &= \int_0^1 f(t)Q_{n}(t-x)\,\mathrm dt \\
    &= \int_0^1 f(t) c_n(1-(t-x)^2)^n \,\mathrm dt.
\end{align*}
Note that $P_n(x)$ is in fact a polynomial.

Furthermore, observe that for $x\in [0,1]$,
\begin{align*}
    P_n(x) &= \int_0^1 f(t) Q_n(t-x)\,\mathrm dt \\
    &= \int_{-x}^{1-x} f(x+t)Q_n(t) \,\mathrm dt \\
    &= \int_{-1}^1 f(x+t)Q_n(t)\,\mathrm dt.
\end{align*}
The second equality is true by a change of variable, and the last equality is true as $f(x+t) = 0$ for $t\notin [-x,1-x]$.

We now prove $P_n\to f$ uniformly on $[0,1]$. Let $\epsilon>0$. Since $f$ is uniformly continuous on $[0,1]$, $\exists \delta>0$ such that $\forall |x-y|\leq \delta$, $|f(x)-f(y)|<\frac{\epsilon}{2}$. Let $C = \sup\{f(x) \mid x\in [0,1]\}$, which exists by the Min/Max theorem i.e. the EVT. Choose $M\in \NN$ such that $\forall n\geq M$, 
\[
\sqrt{n}(1-\delta^2)^n < \frac{\epsilon}{8C}.
\]
Thus, $\forall n\geq M,\forall x\in [0,1]$, by the previous theorem, 
\begin{align*}
    |P_n(x) - f(x)| &= \left|\int_{-1}^1 (f(x-t)-f(t))Q_n(t)\,\mathrm dt \right| \\
    &\leq \int_{-1}^1 |f(x-t)-f(x)|Q_{n}(t)\,\mathrm dt \\
    &\leq \int_{|t|\leq \delta} |f(x-t)-f(x)|Q_n(t)\,\mathrm dt + \int_{\delta \leq |t|\leq 1} |f(x-t)-f(x)|Q_n(t)\,\mathrm dt \\
    &\leq \frac{\epsilon}{2}\int_{|t|\leq \delta} Q_n(t) \,\mathrm dt + \sqrt{n}(1-\delta^2)^n \int_{\|\delta|\leq |t|\leq 1} 2C \\
    &< \frac{\epsilon}{2} + 4C\sqrt{n}(1-\delta^2)^n \\
    &< \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon.
\end{align*} \qed 

In the last minute of the course, Casey Rodriguez stated: "This was quite an experience; teaching to an empty room. I hope you did get something out of this class. Unfortunately I wasn't able to meet a lot of you, and that's one of the best parts of teaching...."