%MIT OpenCourseWare: https://ocw.mit.edu
%18.S097 Introduction to Metric Spaces, Independent Activities Period (IAP) 2022
%License: Creative Commons BY-NC-SA 
%For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

\subsection*{The Fixed Point Theorem}

In this section of the notes, we focus on examples and theorems that are useful to know with very useful applications. Some of the most insightful examples, involve "Lipschitz" functions.

\begin{definition}[Lipschitz]
Let $(X,d_X)$ and $(Y, d_Y)$ be metric spaces. A function $f: X\to Y$ is called \textbf{Lipschitz} or $K$-Lipschitz if there exists a $K\in \RR$ such that 
\[
d_Y(f(x),f(y)) \leq Kd_X(x,y)\hspace{.5cm} \text{for all }x,y\in X.
\]
\end{definition}

These functions are sometimes called \textit{Lipschitz continuous functions}. Why? Well, consider a $K$-Lipschitz function for some $K>0$, and let $\epsilon >0$. Then, choose $\delta = \frac{\epsilon}{K}$. Hence, when $d_X(p,q) < \delta$, we have that 
\[
d_Y(f(p),f(q)) \leq Kd_X(p,q) < \epsilon.
\]
Therefore, $f$ is continuous. The same is immediately true when $K\leq 0$, simply choose $\delta = 1$ and use positive definiteness of $d_Y$.

Lipschitz functions are a key motivator for \textit{uniformly continuous functions}.

\begin{definition}[Uniform continuity]
Let $(X,d_X)$ and $(Y,d_Y)$ be metric spaces. Then, $f:X\to Y$ is \textbf{uniformly continuous} if for every $\epsilon>0$ there exists a $\delta >0$ such that whenever $d_X(x,y) < \delta$, we have $d_Y(f(x),f(y)) < \epsilon$.
\end{definition}

\begin{remark}
You may be wondering what the difference is between uniform continuity and regular continuity. Well notice that in the definition of uniform continuity, $\delta$ \textit{only} depends on $\epsilon$ and $f.$ I.e., $\delta$ does not depend on $x$. We say a function is continuous if it is continuous at every $x\in X$, and thus $\delta$ depends on $x$. This is the difference between uniform continuity and regular continuity. 
\end{remark}

Notice that a uniformly continuous function is continuous, but the other direction is not necessarily true.

\begin{theorem}
Let $(X,d_X)$ and $(Y,d_Y)$ be metric spaces. Suppose $f:X\to Y$ is continuous and $X$ is compact. Then, $f$ is uniformly continuous.
\end{theorem}
\textbf{Proof}: Let $\epsilon>0$. For each $c\in X$, choose $\delta_c$ such that 
\[
d_X(x,c) < \delta_c \implies d_Y(f(x),f(c)) < \epsilon/2.
\]
We know that such a $\delta_c$ exists as $f$ is continuous. Furthermore, the balls $B(c, \delta_c)$ cover $X$ and the space $X$ is compact. Then, by the Lebesgue Number Lemma, there exists a $\delta>0$ such that for all $x\in X$, there is a $c\in X$ such that $B(x,\delta) \subset B(c,\delta_c)$. 

If $x,y\in X$ and $d_X(x,y) < \delta$, choose a $c\in X$ such that $B(x,\delta) \subset B(c,\delta_c)$. Then, $y\in B(c,\delta_c)$ by assumption. Therefore, by the triangle inequality, 
\[
d_Y(f(x),f(y)) \leq d_Y(f(x), f(c)) + d_Y(f(c), f(y)) < \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon.
\]
\qed 

We discuss one more application of uniform continuity, and then we will move onto another useful application of Lipschitz functions. 
\begin{proposition}
If $f:[a,b]\times [c,d]\to \RR$ is a continuous function, then $g:[c,d] \to \RR$ defined by 
\[
g(y) = \int_a^b f(x,y) \,\mathrm dx
\]
is continuous.
\end{proposition}
\textbf{Proof}: Let $\epsilon >0$. Fix $y\in [c,d]$ and let $\{y_n\}$ be a sequence in $[c,d]$ such that $y_n\to y$. As we have shown in Lecture 2, $g$ is continuous if and only if $g(y_n) \to g(y)$. This is what we will show. Firstly, note that as $f$ is continuous on $[a,b]\times [c,d]$ which is compact, $f$ is uniformly continuous. I.e., there exists a $\delta >0$ such that given $y'\in [c,d]$ and $|y'-y| < \delta$, then $|f(x,y') - f(x,y)|< \epsilon$ for all $x\in [a,b]$.

Let $h_n(x) = f(x,y_n)$ and $h(x) = f(x,y)$. We have thus shown that $h_n \to h$ uniformly as $n\to \infty$. Uniform convergence implies we can swap limits and integrals, obtaining
\[
\lim_{n\to \infty}g(y_n) = \lim_{n\to \infty}\int_a^b f(x,y_n)\,\mathrm dx = \int_a^b \lim_{n\to \infty} f(x,y_n)\,\mathrm dx = \int_a^b f(x,y)\,\mathrm dx = g(y).
\]
Therefore, $g$ is continuous. \qed 

We now return back to the usefulness of Lipschitz functions.
\begin{definition}[Contraction]
Let $(X,d_X)$ and $(Y,d_Y)$ be metric spaces. A mapping $f: X\to Y$ is said to be a \textbf{contraction} if it is a $k-$Lipschitz map for some $0 \leq k< 1$. In other words, there exists a $k< 1$ such that 
\[
d_Y(f(x),f(y)) \leq k d_X(x,y) \hspace{.5cm} \text{for all }x,y\in X.
\]
\end{definition}

\begin{definition}[Fixed point]
If $f: X\to X$ is a map, $x\in X$ is called a \textbf{fixed point} if $f(x) = x$.
\end{definition}

We thus have a useful theorem that follows from these simple definitions.
\begin{theorem}{Banach Fixed Point Theorem}
Let $(X,d)$ be a nonempty complete metric space, and $f:X\to X$ be a contraction. Then, $f$ has a unique fixed point.
\end{theorem}
Note: This is sometimes called the contraction mapping principle. 

\noindent \textbf{Proof}: Try to picture this!

We want to show that there exists an $x\in X$ such that $f(x) = x$, and then we want to show $x$ is unique. How can we find such an $x$ though?

Pick some random $x_0\in X$, and define a sequence $\{x_n\}$ such that $f(x_n) = x_{n+1}$. Then, by definition, we have that 
\[
d(x_{n+1}, x_n) = d(f(x_n), f(x_{n-1})) \leq k d(x_{n}, x_{n-1}) \leq \dots \leq k^n d(x_1, x_0).
\]
We will show that $\{x_n\}$ is a Cauchy sequence.

\begin{question}
What good does this do? What property of the theorem will we use here?
\end{question}

Suppose $m\geq n$. Then, 
\begin{align*}
    d(x_m,x_n) &\leq \sum_{i=n}^{m-1} d(x_{i+1}, x_i) \\
    &\leq \sum_{i=n}^{m-1} k^i d(x_1,x_0) \\
    &= k^n d(x_1, x_0) \sum_{i=0}^{m-n-1}k^i \\
    &\leq k^n d(x_1, x_0)\sum_{i=0}^\infty k^i\\
    &= \frac{k^n}{1-k} d(x_1, x_0). 
\end{align*}
Given $0 \leq k < 1$, as $n\to \infty$, $d(x_m, x_n) \to 0.$ Therefore, $\{x_n\}$ is a Cauchy sequence, and thus there exists an $x$ such that $x_n \to x$. We claim that $x$ is a fixed point: 
\[
x = f(\lim_{n\to \infty}x_n) = \lim_{n\to \infty} f(x_n) = \lim_{n\to \infty} x_{n+1} = x.
\]
We also claim that $x$ is unique. Suppose that $y$ is also a fixed point of $f$. Then, 
\[
d(x,y) = d(f(x), f(y)) \leq k d(x,y)\implies (1-k)d(x,y) \leq 0.
\]
Given $0\leq k < 1$, it follows that $d(x,y) = 0 \implies x=y$. \qed 

As stated in Lebl's book: "The proof is constructive. Not only do we know a unique fixed point exists. We also know how
to find it" (7.6.1 page 268). We use this fact to consider an interesting application of the fixed point theorem: differential equations.

Often, we wonder when a differential equation has a solution. In 18.03, we tried to produce formulas to precisely solve differential equations. But as we approach more and more complex differential equations (complex in the sense of difficulty, not inherently complex valued), we need a different approach. Analysis and metric spaces, and especially the Banach fixed point theorem can be a very useful tool for such questions. Especially since, as we have shown, $C^0([a,b])$ is a complete metric space under the uniform metric/norm.

\begin{remark}
Using the contraction mapping principle to solve differential equation is a central topic in 18.152. 
\end{remark}

Consider the simple ordinary differential equation 
\[
\begin{cases}
\frac{\mathrm df}{\mathrm dx} = F(x,f(x)) \\
f(x_0) = y_0.
\end{cases}.
\]
We want to solve this initial value problem (IVP), finding a function $f(x)$ such that $f'(x) = F(x,f(x))$ where $F$ is a general function. For instance, consider the IVP: 
\[
\begin{cases}
\frac{\mathrm dy}{\mathrm dx} =  y'= y \\
y(0) = 1.
\end{cases}.
\]
We can solve this IVP with the solution $y = e^x$ as $(e^x)' = e^x$ and $e^0 = 1$. A more complicated example to consider is $y' = -2xy$, $y(0) = 1$. You can check that $y(x) = e^{x^2}$ is a solution. 

One can ask how long a solution exists for. For instance, consider $y' = y^2$, $y(0) = 1$. This has solution $y(x) = \frac{1}{1-x}$. While $y^2$ is a nice function (i.e. existing for all $x$ and $y$), the solution blows up at $x=1$. So how can we use the contraction mapping theorem to approach this problem?

Consider the following equation: 
\[
f(x) = y_0 + \int_0^x F(t,f(t))\,\mathrm dt.
\]
Notice that $f(0) = y_0$, and $f'(x) = F(x, f(x))$ by the Fundamental Theorem of Calculus. Using this equation as a motivator, we can prove the following theorem: 
\begin{theorem}[Picard's Theorem]
Let $I,J\subset \RR$ be closed and bounded intervals, let $I^\circ, J^\circ$ be their interiors, and let $(x_0,y_0) \in I^\circ \times J^\circ.$ Suppose $F:I\times J \to \RR$ is continuous and Lipschitz in the second variable. I.e., there exists an $L \in \RR$ such that 
\[
|F(x,y) - F(x,z)| \leq L|y-z|
\]
for all $x\in I$ and $y,z\in J$. Then, there exists an $h>0$ and a unique differentiable function $f:[x_0-h,x_0+h]\to J\subset \RR$ such that
\[
f'(x) = F(x,f(x)) \hspace{.25cm}\text{and}\hspace{.25cm} f(x_0) = y_0.
\]
\end{theorem}
By "interiors", I mean that if $I = [0,1]$, then $I^\circ = (0,1)$. There is a more general definition of the interior of a set, but we move on for now. Also note that we may assume without loss of generality that $x_0 = 0.$

\noindent \textbf{Proof}: We will prove this by constructing the convergent sequence used in the Banach fixed point theorem, and then I will outline another approach that creates a contraction that satisfies the properties we want.

The first method is called Picard iteration. To solve $f'(t) = F(x,t)$ with $f(0) = 0$, we first start with a guess. Consider the simple function $f_0(t) = y_0$. Then, it is clear that $f_0(0) = y_0$, but clearly this only solves the equation if $F(x,f_0(t)) = 0$. We thus need to keep improving our guesses. Consider a function $f_1$ such that 
\[
f_1'(t) = F(t,f_0(t)), ~~f_1(0) = y_0.
\]

We can solve this ODE using an integral, obtaining
\[
f_1(x) - f_1(0) = \int_{0}^{x} F(t,f_0(t))\,\mathrm dt \implies f_1(x) = y_0 + \int_{0}^{x} F(t,f_0(t))\,\mathrm dt.
\]
Now \textit{this} is a function we can keep on reiterating. Consider 
\[
f_{n+1}(x) = y_0 + \int_{0}^x F(t,f_{n}(t))\,\mathrm dt.
\]
We thus want to show that this sequence of functions converges as $k\to \infty$ and that the limit 
\[
f(x) = \lim_{k\to \infty} f_k(x)
\]
is a solution to the ODE.

We first check that $f_k$ is well-defined for all $k$. Pick $\alpha>0$ such that $[-\alpha, \alpha] \subset I$ and $[y_0-\alpha, y_0 + \alpha] \subset J$. Given $F(x,y)$ is continuous over the compact set $I\times J$, there exists an $M$ such that $|F(x,y)|\leq M$ for all $(x,y)\in I\times J.$ Hence, define 
\[
h = \min\left\{\alpha, \frac{\alpha}{M+ L\alpha}\right\}.
\]
Notice that $[-h,h] \subset I$. We prove that $f_k$ is well-defined inductively. Assuming that $f_{k-1}([-h,h]) \subset [y_0 - \alpha, y_0 + \alpha]$, it follows that $F(t,f_{k-1}(t))$ is well defined for all $t\in [-h,h]$. Therefore, $f_k(x) = y_0 + \int_{0}^x F(t,f_{k-1}(t)) \,\mathrm dt$ is well defined for all $x\in [-h,h]$. We thus need to show that $f_k([-h,h]) \subset [y_0 - \alpha, y_0 + \alpha]$. Given $x\in [-h,h]$, we have 
\[
|f_k(x) - y_0| = \left|\int_{0}^x F(t,f_{k-1}(t))\,\mathrm dt \right| \leq M |x| \leq Mh \leq \frac{M\alpha}{M+L\alpha} \leq \alpha.
\]
Therefore, $f_k$ is well-defined for all $k$ on the interval $[-h,h] \subset I$. Now we want to show that $f_k$ converge to some function $f$. We can do this by showing $\{f_k\}$ is a Cauchy sequence (just like we did for the proof of the Banach fixed point theorem!):
\begin{align*}
    |f_m(x) - f_x(x)| &= \left|\int_0^x F(t,f_{m-1}(t)) - F(t,f_{n-1}(t)) \,\mathrm dx\right| \\
    &\leq \int_0^x |F(t,f_{m-1}(t)) - F(t,f_{n-1}(t))|\,\mathrm dt \\
    &\leq L\int_0^t|f_{m-1}(t) - f_{n-1}(t)| \\
    &\leq L\lVert f_{m-1} - f_{n-1}\rVert |x| \\
    &\leq \frac{L\alpha}{M+ L\alpha} \lVert f_{m-1} - f_{n-1}\rVert.
\end{align*}
Let $C = \frac{L\alpha}{M+L \alpha}\leq 1$. Therefore, taking the supremum of the left-hand side, we get 
\[
\lVert f_{m} - f_{n}\rVert \leq C\lVert f_{m-1} - f_{n-1}\rVert.
\]
By induction, through a similar proof used in the Banach fixed point theorem, it follows that $\{f_n\}$ is a Cauchy sequence, and thus $f_n \to f\in C^0([-h,h])$. 

We want to show that $f$ satisfies the ODE. Note that $f([-h,h]) \subset [y_0 - \alpha, y_0 + \alpha]$. Firstly, notice that 
\[
|F(t,f_n(t)) - F(t, f(t))| \leq L|f_n(t) - f(t)| \leq L \lVert f_n - f\rVert.
\]
Therefore, given $f_n \to f$ uniformly, $F(t,f_n(t)) \to F(t,f(t))$ uniformly for $t\in [-h,h]$. Thus, 
\begin{align*}
    y_0 + \int_0^x F(t,f(t)) \,\mathrm dt &= y_0 + \int_0^x F(t, \lim_{n\to \infty} f_n(t)) \,\mathrm dt \\
    &= y_0 + \int_0^x \lim_{n\to \infty} F(t,f_n(t)) \,\mathrm dt \\
    &= \lim_{n\to \infty} y_0 + \int_0^x F(t,f_n(t)) \\
    &= \lim_{n\to \infty}f_{n+1}(x) \\
    &= f(x).
\end{align*}
By the FTC, it is then clear that $f$ is differentiable, $f'(x) = F(x,f(x))$, and $f(0) = y_0.$ \qed 

To prove this by proving the premises of the Banach fixed point theorem, you can consider the space
\[
Y = \{f\in C([-h,h]) \mid f([-h,h]) \subset J\},
\]
and show the following: 
\begin{enumerate}
    \item $Y$ is a closed subset of continuous functions. 
    \item A closed subset of a complete metric space is a complete metric space.
    \item Consider $T:Y\to C([-h,h])$ given by 
    \[
    T(f)(x) = y_0 + \int_0^x F(t,f(t))\,\mathrm dt,
    \]
    and show that $T$ is a contraction from $Y\to Y$.
    \item Then $T$ has a unique fixed point by the fixed point theorem, which solves the ODE.
\end{enumerate}
\qed 

\begin{remark}
This will be an optional problem on PSET 4.
\end{remark}

We can consider one more (harder to motivate) example of the Banach fixed point theorem.
\begin{example}
Let $\lambda \in \RR$, $f,g\in C^0([a,b])$, and $k \in C^0([a,b]\times [a,b])$. Then, consider the operator $T: C^0([a,b])\to C^0([a,b])$
\[
T(f)(x) = g(x) + \lambda \int_a^b k(x,y) f(y)\,\mathrm dy.
\]
For which $\lambda$ is $T$ a contraction?
\end{example}
By the Proposition 5, we know that $T(f)$ is continuous. Given that $k$ is continuous on a compact set, $k$ is bounded. Thus, there exists a $c$ such that 
\[
|k(x,y)| \leq c ~\forall x,y \in [a,b].
\]
Then, we have 
\begin{align*}
d(T(f_1), T(f_2)) &= \sup_{x\in [a,b]} |T(f_1)(x) - T(f_2)(x)| \\
&= |\lambda| \sup_{x\in [a,b]} \left|\int_a^b k(x,y) (f_1(y)-f_2(y))\,\mathrm dy\right|  \\
&\leq |\lambda| \sup_{x\in [a,b]} \int_a^b |k(x,y)| |f_1(y)-f_2(y)|\,\mathrm dy  \\
&\leq |\lambda|\sup_{x\in [a,b]}|f_1(x) - f_2(x)|
\sup_{x\in [a,b]} \int_a^b |k(x,y)|\,\mathrm dy \\
&\leq c|\lambda|(b-a) d(f_1, f_2).
\end{align*}
Therefore, if $|\lambda| < \frac{1}{c(b-a)}$, it follows that $T$ is a contraction on a complete metric space. Therefore, by the Banach fixed point theorem, there exists a unique $f\in C^0([a,b])$ such that 
\[
T(f)(x) = f(x) = g(x) + \lambda \int_a^b k(x,y)f(y)\,\mathrm dy.
\]