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

\subsubsection*{Remarks}

\begin{enumerate}[(1)]
    \item Don't have a nice rephrasing of (i) in
        terms of similar concepts in the reals.
        Would want to write ``$e(f(x), b) \to 0$
        as $d(x, a) \to 0$'', but this is
        meaningless.
    \item (i) says nothing about what happens at
        the point $a$ itself. For example, let $f
        : \RR \to \RR$
        \[ f(x) = \begin{cases}
            1 & x = 0 \\
            0 & x \neq 0
        \end{cases} \]
        Then $f(x) \to 0$ as $x \to 0$ (but $f(0)
        \neq 0$ so $f$ is not continuous at 0). If
        we have that $f$ is continuous then
        \[ d(x, a) = 0 \implies x = a \implies
        f(x) = f(a) = e(f(x), f(a)) = 0 \]
        so we can drop `$0 <$' from the definition
        when we come to define continuity.
    \item Can rewrite definition (v): $f$ is
        continuous on $W$ if and only if $f
        \mid_W$ is a continuous function $f \mid_W
        : W \to Y$ thinking of $W$ as a subspace
        of $X$. That is
        \[ \forall a \in W ~ \forall \eps > 0 ~
        \exists \delta > 0 ~ \forall x \in W \quad
        d(x, a) < \delta \implies e(f(x), f(a)) <
        \eps \]
        In particular, note the subtlety that this
        \emph{only} mentions points of $W$. So,
        under this definition, for example $f :
        \RR \to \RR$,
        \[ f(x) = \begin{cases}
            1 & x \in [0, 1] \\
            0 & x \not\in [0, 1]
        \end{cases} \]
        then $f$ is continuous on $[0, 1]$, but
        $f$ is not continuous at points 0 and 1.
\end{enumerate}

\begin{flashcard}
\begin{proposition}
    Let $(X, d)$, $(Y, e)$ be metric spaces. Let
    $f : X \to Y$ and $a \in X$. Then $f$ is
    continuous at $a$ if and only if \cloze{whenever
    $(x_n)$ is a sequence in $X$ with $x_n \to a$
    then $f(x_n) \to f(a)$.}
\end{proposition}
\end{flashcard}

\begin{proof}
    \begin{enumerate}[(1)]
        \item[$\rightarrow$] Suppose $f$ is
            continuous at $a$. Let $(x_n)$ be a
            sequence in $X$ with $x_n \to a$. Let
            $\eps > 0$. As $f$ continuous at $a$
            we can find $\delta > 0$ such that
            $\forall x \in X$, $d(x, a) < \delta
            \implies e(f(x), f(a)) < \eps$. As
            $x_n \to x$ we can find $N$ such that
            $n \ge N \implies d(x_n, a) < \delta$.
            Let $n \ge N$. Then $d(x_n, a) <
            \delta$ so $e(f(x_n), f(a)) < \eps$.
            Hence $f(x_n) \to f(a)$.
        \item[$\Leftarrow$] Suppose $f$ is not
            continuous at $a$. Then there is some
            $\eps > 0$ such that $\forall \delta .
            0$, $\exists x \in X$ with $d(x, a) <
            \delta$ but $e(f(x), f(a)) \ge \eps$.
            Now take $\delta = \frac{1}{1}, \half,
            \frac{1}{3}, \dots$ we obtain a
            sequence $(x_n)$ with, for each $n$
            \[ d(x_n, a) < \frac{1}{n} \quad
            \text{and} \quad e(f(x_n), f(a)) \ge
            \eps .\]
            Hence $x_n \to a$ but $f(x_n) \not\to
            f(a)$.
    \end{enumerate}
\end{proof}

\begin{proposition}
    Let $(W, c), (X, d), (Y, e)$ be metric spaces,
    let $f : W \to X$, let $g : X \to Y$ and let
    $a \in W$. Suppose $f$ is continuous at $a$
    and $g$ is continuous at $f(a)$. Then $g \circ
    f$ is continuous at $a$.
\end{proposition}

\begin{hiddenflashcard}[composition-of-continuous-is-continuous]
Prove that composition of continuous functions (in
a metric space) is continuous. \\
\cloze{
If you are allowed to quote the fact a function is
continuous if and only if $f(x_n) \to f(x)$
whenever $x_n \to x$, then this gives a very quick
proof of this fact.
}
\end{hiddenflashcard}

\begin{proof}
    Let $(x_n)$ be a sequence in $W$ with $x_n \to
    a$. Then by proposition 6, $f(x_n) \to f(a)$
    an so also $g(f(x_n)) \to g(f(a))$. So by
    proposition 6 $g \circ f$ continuous at $a$.
\end{proof}

\subsubsection*{Examples}

\begin{enumerate}[(1)]
    \item $\RR \to \RR$ with usual metric. This is
        the same definition as when did it
        directly for $\RR$ only. So already know
        lots of continuous functions $\RR \to
        \RR$, for example polynomials, sin, exp,
        \dots
    \item Constant functions are continuous. Also
        if $X$ is any metric space and $f : X \to
        X$ by $f(x) = x$ for all $x \in X$ (the
        \emph{identity function on $X$}) then
        $f$ is continuous.
    \item Consider $\RR^n$ with the Euclidean
        metric and $\RR$ with the usual metric. \\
        The \emph{projection maps} $\pi_i : \RR^n
        \to \RR$ given by $\pi_i (x) = x_i$ are
        continuous. (Why? We've seen convergence
        in $\RR^n$ of sequences then this is the
        same as convergence in each coordinate.
        Let's denote a sequence in $\RR^n$ by
        $(x^{(m)})_{m \ge 1}$. So for example,
        $x_5^{(3)}$ is the 5th coordinate of the
        3rd term. We know $x^{(m)} \to x$ if and
        only if for each $x_i^{(m)} \to x_i$ i.e.
        for each $i$, $\pi_i(x^{(m)}) \to
        \pi_i(x)$. So by proposition 16 each
        $\pi_i$ is continuous.) Similarly, suppose
        $f_1, \dots, f_n : \RR \to \RR$. Let $f :
        \RR \to \RR^n$ be defined by $f(x) =
        (f_1(x), \dots, f_n(x))$. Then $f$ is
        continuous at a point if and only if all
        of $f_1, \dots, f_n$ are. \myskip
        Using these facts, and using example 1 and
        proposition 17 we have many continuous
        functions $\RR^n \to \RR^m$. For example
        consider $f : \RR^3 \to \RR^2$,
        \[ f(x, y, z) = (e^{-x} \sin y, 2x \cos z) \]
        is continuous. (Why? Take $W = (x, y, z)
        \in \RR^3$, we have $f_1(w) =
        e^{-\pi_1(w)} \sin \pi_2(w)$ and $f_2(w) =
        2\pi_1(w) \cos \pi_3(w)$. So $f_1, f_2$
        continuous so $f$ continuous.)
    \item Recall that if we have the Euclidean
        metric, the $l_1$ metric or the $l_\infty$
        metric on $\RR^n$ then convergent
        sequences are same in each case. So by
        proposition 16, the continuous functions
        $X \to \RR^n$ or from $\RR^n \to Y$ are
        the same with each of these three metrics.
    \item Let $(X, d)$ be a discrete metric space
        and let $(Y, e)$ be any metric space.
        Which functions $f : X \to Y$ are
        continuous? Suppose $a \in X$ and $(x_n)$
        a sequence in $X$ with $x_n \to a$. Then
        $(x_n)$ is eventually constant, i.e. for
        sufficiently large $n$, $x_n = a$ and so
        $f(x_n) = f(a)$. So $f(x_n) \to f(a)$.
        Hence \emph{every} function on a discrete
        metric space is continuous.
        \begin{hiddenflashcard}[cts-functions-on-discrete-metric-space]
            Which functions on a discrete metric
            space are continuous? \\
            \cloze{All functions.}
        \end{hiddenflashcard}
\end{enumerate}

\subsection{Completeness}

In section 1 we saw a version of general principle
of convergence held in each of the three examples
we considered. Does general principle of
convergence hold in a general metric space?

\begin{definition*}[Cauchy sequence]
    Let $(X, d)$ be a metric space and let $(x_n)$
    be a sequence in $X$. We say $(x_n)$ is
    \emph{Cauchy} if
    \[ \forall \eps > 0 ~ \exists N
    ~ \forall m, n \ge N \quad d(x_m, x_n) <
    \eps \]
\end{definition*}

\noindent
Exercise: $(x_n)$ convergent implies that $(x_n)$
Cauchy. \\
But the converse is not true in general.

\begin{example*}
    Let $X = \RR \setminus \{0\}$ with the usual
    metric and let $x_n = \frac{1}{n}$. We saw
    previously that $(x_n)$ does not converge.
    Note that $X$ is a subspace of $\RR$. In
    $\RR$, $(x_n)$ is convergent ($x_n \to 0$) so
    $(x_n)$ is Cauchy in $\RR$ so $(x_n)$ is
    Cauchy in $X$.
\end{example*}

\begin{example*}
    Take $\QQ$ with the usual metric, and take a
    sequence $x_n \to \sqrt{2}$. Then $x_n$ is
    Cauchy but not convergent (in $\QQ$).
\end{example*}

\noindent
This example with $\QQ$ is the main motivation for
the following definition.

\begin{flashcard}
\begin{definition*}
    Let $(X, d)$ be a metric space. We say $X$ is
    \emph{complete} if \cloze{every Cauchy sequence in
    $X$ converges.}
\end{definition*}
\end{flashcard}

\subsubsection*{Examples}

\begin{enumerate}[(1)]
    \item Example above says $\RR \setminus \{0\}$
        with usual metric is not complete.
        Similarly $\QQ$ with usual metric is not
        complete.
    \item General principle of convergence says
        $\RR$ with usual metric is complete. \par
        General principle of convergence for
        $\RR^n$ says $\RR^n$ with Euclidean metric
        is complete.
    \item General principle of uniform convergence
        (almost) says if $X \subset \RR$ and $B(X)
        = \{f : X \to \RR \mid \text{$f$ is
        bounded}\}$ with the uniform norm then
        $B(X)$ is complete.
\end{enumerate}
