% vim: tw=50
% 25/10/2022 11AM

\noindent
Now we can move on to the main theorem on
completeness:

\begin{flashcard}
\begin{definition*}
    Let $(X, d)$ be a metric space and $f : X \to
    X$. We say $f$ is a \emph{contraction} \cloze{if
    $\exists \lambda \in [0, 1)$ such that for all
    $x, y \in X$,
    \[ d(f(x), f(y)) \le \lambda d(x, y) \]
    }
\end{definition*}
\end{flashcard}

\begin{flashcard}[contraction-mapping-theorem]
\begin{theorem}[Contraction mapping theorem]
    \cloze{
    Let $(X, d)$ be a \cloze{complete},
    \cloze{non-empty} metric
    space and $f : X \to X$ a \fcemph{contraction}. Then
    $f$ has a \fcemph{unique} fixed point.
}
\end{theorem}
\end{flashcard}

\begin{hiddenflashcard}    
\begin{theorem}[Contraction mapping theorem]
    Let $(X, d)$ be a complete, non-empty metric
    space and $f : X \to X$ a contraction. Then
    $f$ has a unique fixed point.
\end{theorem}
\begin{proof}
    \cloze{
    Pick $x_0$ in $X$. Define $x_{n + 1} = f(x)$.
    Show that $x_n$ is Cauchy, hence $x_n \to x$.
    By continuity of $f$, $f(x_n) = x_{n + 1} \to
    x$, so $f(x) = x$.
    }
\end{proof}
\end{hiddenflashcard}

\begin{proof}
    Let $\lambda \in [0, 1)$ satisfy
    \[ \forall x, y \in X \quad d(f(x), f(y)) \le
    \lambda d(x, y) \]
    Let $x_0 \in X$. Recursively define $x_n =
    f(x_{n - 1})$ for $n \ge 1$. Let $\Delta =
    d(x_), x_1)$. Then, by induction, $d(x_n, x_{n
    + 1}) \le \lambda^n \Delta$ for all $n$. Now
    suppose $N \le m < n$. Then
    \begin{align*}
        d(x_m, x_n)
        &\le \sum_{i = m}^{n - 1}
        d(x_i, x_{i + 1}) \\
        &\le \sum_{i = m}^{n - 1} \lambda^i
        \Delta \\
        &\le \sum_{i = N}^\infty \lambda^i \Delta
        \\
        &= \frac{\lambda^N \Delta}{1 - \lambda} \\
        &\to 0
    \end{align*}
    as $N \to \infty$. So for all $\eps > 0$,
    there exists $N$ such that for all $m, n \ge
    N$, $d(x_m, x_n) < \eps$. (we take $N$ such
    that $\frac{\lambda^N \Delta}{1 - \lambda} <
    \eps$). Thus $(x_n)$ is Cauchy, so by
    completeness it converges, say $x_n \to x \in
    X$. But also $x_n = f(x_{n - 1}) \to f(x)$
    because $f$ is continuous. So by uniqueness of
    limits, $f(x) = x$. \myskip
    Suppose also $f(y) = y$ for some $y \in X$.
    Then
    \[ d(x, y) = d(f(x), f(y)) \le \lambda d(x, y) \]
    with $\lambda < 1$. So $d(x, y) = 0$, i.e. $x
    = y$.
\end{proof}

\begin{remark*}
    \begin{enumerate}[(1)]
        \item Why is $f$ continuous? We have, for
            all $x, y \in X$, $d(f(x), f(y)) \le
            d(x, y)$. So for all $\eps > 0$, $d(x,
            y) < \eps \implies d(f(x), f(y)) <
            \eps$. (so we can take $\delta = \eps$
            in the definition of continuity). In
            particular this shows that $f$ is
            uniformly continuous.
        \item We have proved more than claimed.
            Not only does $f$ have a unique fixed
            point, but start from \emph{any}
            point of the space and repeatedly
            apply $f$ then the resulting sequence
            converges to the fixed point. In fact,
            the speed of convergence is
            exponential.
    \end{enumerate}
\end{remark*}

\subsubsection*{Application}

Example. Suppose we want to numerically
approximate the solution to $\cos x = x$. Any root
must lie in $[-1, 1]$. Consider the metric space
$X = [-1, 1]$ with the usual metric. $X$ is a
closed subset of complete space $\RR$ so $X$ is
complete. Obviously $X$ is non-empty. \myskip
Think of $\cos : [-1, 1] \to [-1, 1]$. Suppose $x,
y \in [-1, 1]$. Then using MVT, there is $z \in
[x, y]$
\begin{align*}
    |\cos x - \cos y|
    &= |x - y||\cos' z| \\
    &= |x - y||-\sin z| \\
    &\le |x - y| \sin 1
\end{align*}
But $0 \le \sin 1 < 1$ so $\cos$ is a contraction
of $[-1, 1]$. So by Contraction mapping theorem,
$\cos$ has a unique fixed point in $[-1, 1]$. That
is $\cos x = x$ has a unique solution. How do we
find it numerically? Use remark 2. Calculate
$\cos$ iterated many times to 0 say, and we have
rapid (exponential) convergence to the root.
\myskip
Two major applications of contraction mapping
theorem later.

\subsection{Sequential compactness}

Recall Bolzano Weierstrass for $\RR^n$ says a
bounded sequence in $\RR^n$ has a convergent
subsequence.

\begin{flashcard}
\begin{definition*}
    Let $(X, d)$ be a metric space. We say $X$ is
    \emph{bounded} if\cloze{
    \[ \exists M \in \RR ~ \forall x, y \in X
    \quad d(x, y) \le M \]}
\end{definition*}
\end{flashcard}

\begin{remark*}
    Easy to check by triangle inequality that $X$
    bounded is equivalent to $X = \emptyset$ or
    $\exists M \in \RR, \exists x \in X$ such that
    $\forall y \in X, d(x, y) \le M$.
\end{remark*}

\noindent
So definition agrees with earlier definition for
subsets of $\RR^n$. \myskip
Recall: Let $(X, d)$ be a metric space and $Y
\subset X$. We say $Y$ is \emph{closed} in $X$ if
whenever $(x_n)$ is a sequence in $Y$ with, in
$X$, $x_n \to x \in X$ then actually $x \in Y$.

\begin{flashcard}
\begin{definition*}
    A metric space is \emph{sequentially compact}
    if \cloze{every sequence has a convergent
    subsequence.}
\end{definition*}
\end{flashcard}

\noindent
Bolzano Weierstrass for $\RR^n$ is essentially the
following:

\begin{theorem}
    Let $X \subset \RR^n$ with the Euclidean
    metric. Then $X$ is sequentially compact if
    and only if $X$ is closed and bounded.
\end{theorem}

\begin{proof}
    \begin{enumerate}[(1)]
        \item[$\Leftarrow$] Suppose $X$ is closed
            and bounded. Let $(x_n)$ be a sequence
            in $X$. Then $(x_n)$ be a sequence in
            $X$. Then $(x_n)$ is a bounded
            sequence in $\RR^n$ so by Bolzano
            Weierstrass, in $\RR^n$, $x_{n_j} \to
            x$ for some $x \in \RR^n$ and some
            subsequence $(x_{n_j})$ of $(x_n)$. As
            $X$ is closed, $x \in X$. Hence the
            subsequence $(x_{n_j})$ converges in
            $X$. So $X$ is sequentially compact.
        \item[$\Rightarrow$] Suppose $X$ is not
            closed. Then we can find a sequence
            $(x_n)$ in $X$ such that in $\RR^n$,
            $x_n \to x \in \RR^n$ with $x \not\in
            X$. Now any subsequence $x_{n_j} \to
            x$ in $\RR^n$. But $x \not\in X$ so by
            uniqueness of limits $(x_{n_j})$ does
            not converge in $X$. So $X$ is not
            sequentially compact. Suppose instead
            $X$ is not bounded. Then can find a
            sequence $(x_n)$ in $X$ with for all
            $n$, $\|x\| \ge n$, i.e. $\|x_n\| \to
            \infty$ as $n \to \infty$. Suppose we
            have a subsequence $x_{n_j} \to x \in
            X$. Then $\|x_{n_j}\| \to \|x\|$ but
            $\|x_{n_j}\| \to \infty$,
            contradiction. So, again, $X$ is not
            sequentially compact.
    \end{enumerate}
\end{proof}
