\documentclass[a4paper,11pt]{article}
\usepackage{a4wide,mymaths}
\begin{document}
\newtheorem{defn}{Definition}[section]
\newtheorem{prop}[defn]{Proposition}
\newtheorem{corr}[defn]{Corrolary}
\newtheorem{thrm}[defn]{Theorem}
\title{Continuity}
\maketitle
\section{Real numbers}
The real numbers consist of: a set $\mathbf{R}$, together with two binary
operations, formally functions $\mathbf{R}\times \mathbf{R} \rightarrow
\mathbf{R}$, written $(a,b) \mapsto a+b$ and $(a,b) \mapsto ab$; two
distinguished elements (i.e. elements of $\mathbf{R}$ with definite names) 0
and 1; and a binary relation written $a<b$. This set-up obeys the usual
axioms (associativity etc.).

\section{The real numbers as a complete ordered field}
\begin{defn} A system satisfying the usual axioms of addition and
multiplication for numbers is called an \emph{(algebraic) field}. \end{defn}
\begin{defn} A system satisfying the usual axioms of addition and
multiplication for numbers, and the usual axioms for ordering, is called an
\emph{ordered field}. \end{defn}

\noindent \textbf{Completeness axiom}: \textit{Every non-empty bounded subset
$S$ of $\mathbf{R}$ has a least upper bound $\sup S$ in $\mathbf{R}$.}

\medskip \noindent
Suppose now that $\mathbf{F}$ is (just known to be) an
ordered field. Then the Completeness axiom makes sense in $\mathbf{F}$, by
the following definitions:

\begin{defn}
For $x,y \in \mathbf{F}$ we define $x \le y$ to mean (either $x<y$ or $x=y$).
\end{defn}

\begin{defn}
If $S \subseteq \mathbf{F}$ is a subset then $U \in \mathbf{F}$ is called an
\emph{upper bound} for $S$ if $s \le U \: \forall s \in S$.
\end{defn}

\begin{defn}
If $S \subseteq \mathbf{F} \: (S \neq \emptyset)$ has an upper bound then
we say that $S$ is \emph{bounded above}. 
\end{defn}

Then the Completeness axiom makes sense in $\mathbf{F}$, though it may or may
not be true in $\mathbf{F}$. We assume it is true for $\mathbf{R}$, so we
take $\mathbf{R}$ to be a complete ordered field.

\begin{defn}
A \emph{least upper bound} $\ell$ for a nonempty subset $S$ of any ordered
field $\mathbf{F}$ is an element of $\mathbf{F}$ such that:
\begin{enumerate}
\item $\ell$ is an upper bound for $S$, and
\item If $u$ is any upper bound for $S$ then $\ell \le u$.
\end{enumerate}
\end{defn}

\noindent Traditionally we write $\sup S$ for the least upper bound of $S
\subseteq \mathbf{R}$.

\noindent We'll assume $\mathbf{R}$ contains subsets $\mathbf{N}, \mathbf{Z},
\mathbf{Q}$ with all the usual properties.

\begin{prop}
If $S \subseteq \mathbf{R}$ has a least upper bound, then it has at most one.
\end{prop}

\noindent \textbf{Proof}: Suppose $\ell$ and $\ell'$ are both least
upper bounds for $S
\subseteq \mathbf{R}$. View $\ell$ as \emph{an} upper bound and $\ell'$ as
\emph{least} such, and see from (2) that $\ell' \le \ell$. Now interchange
the r\^{o}les of $\ell$ and $\ell'$, and get $\ell \le \ell'$. So
$\ell=\ell'$.


\noindent Since by the axiom any non-empty $S \subseteq \mathbf{R}$ which is
bounded above has a least upper bound, we now see that it is unique. Call it
$\sup S$ (supremum or l.u.b.).

\subsection{Remark}
If $F \subseteq \mathbf{R}$ is finite (non-empty) then F contains a
\emph{greatest} member, and this is $\sup F$.

\subsection{Remark}
More generally (even if $S$ isn't finite) it may be that $S$ contains a
greatest element; call it $x_\mathrm{max}$. Check:
\begin{enumerate}
\item For any $x \in S$, $x \le x_\mathrm{max}$, by definition of greatest
element.
\item if $U$ is any bound for $S$, then (since $x_\mathrm{max} \in S$), we
get $x_\mathrm{max} \le U$.
\end{enumerate}

\subsubsection*{Examples}
\begin{enumerate}
\item In $[0,1]$, $x_\mathrm{max}=1$.
\item In $(0,1)$, there's no greatest element.
\item In $\{1-\frac{1}{n}: n \in \mathbf{N}_+\} = \{0, \frac{1}{2},
\frac{2}{3}, \cdots\}$, there's no greatest element.
\end{enumerate}

\noindent NB: Not all subsets of $\mathbf{R}$ are intervals.

\subsection{Remark}
If $S \subseteq \mathbf{R}$ is non-empty and bounded above but has no
greatest element, than $\sup S$ is a kind of substitute for the greatest
element $x_\mathrm{max}$.

\begin{prop}[The Archimedian Property].
\begin{enumerate}
\renewcommand{\labelenumi}{(\alph{enumi})}
\item For any $x \in \mathbf{R}$, $\exists n \in \mathbf{N}$ such that $n>x$.
\item For any $x>0$ in $\mathbf{R}$, $\exists n \in \mathbf{N}$ such that
$\frac{1}{n}<x$.
\end{enumerate}
\end{prop}

\noindent \textbf{Proof}
{
\renewcommand{\labelenumi}{(\alph{enumi})}
\begin{enumerate}
\item Suppose there is some $x \in \mathbf{R}$ for which (a) fails, so $n \le x \: \forall n \in \mathbf{N}$.\\
So $\mathbf{N}$ is non-empty and bounded above. By the completeness axiom,
$\mathbf{N}$ has a supremum, say $\ell$.\\
For any $n \in \mathbf{N}$, we have $n+1 \in \mathbf{N}$, so $n+1 \le \ell$. Hence $n < \ell-1$.\\
But this is true for any $n \in \mathbf{N}$, so $\ell-1$ is another upper
bound for $\mathbf{N}$, so $\ell$ is not the least such. This contradicts the
choice of $\ell$, so (a) must be true.
\item If $x>0$ then $\frac{1}{x}>0$, so by (a) $\exists n \in \mathbf{N}$
with $n>\frac{1}{x}$, so $\frac{1}{n} < x$.
\end{enumerate}
}

\subsection{Remark}
For some subsets of $\mathbf{R}$, even when there's no greatest element, we
can see that a supremum exists without having to use the completeness axiom.

\subsubsection*{Example}
To prove that $\sup (0,1) = 1$: let $S=(0,1)$.
\begin{enumerate}
\item $x \in S \Rightarrow x<1$, by definition of $(0,1)$.
\item Let $U$ be any upper bound for $S$. We need to show that $1 \le U$.
Suppose for a contradiction that $U<1$. So $1-U>0$. So by 1.8(b), $\exists n
\in \mathbf{N}$ such that $1-U>\frac{1}{n}$. So $1-\frac{1}{n}>U$. But
$1-\frac{1}{n} \in (0,1)$ (NB: we can w.l.o.g.\footnote{without loss of
generality} assume that $n>1$). So $U$ is not an upper bound for $S$.
\end{enumerate}

\subsection{Remark}
We now look at an example where we \emph{do} need the axiom.

Consider $S = \{x \in \mathbf{R}: x^2<2\}$. Then $S \ne \emptyset$ (e.g. $1
\in S$) and $S$ is bounded above, e.g. by 2, since if $x>2$ then $x^2>4$, so
$x \notin S$.

By completeness, $S$ has a supremum, say $\ell$. We'll show that $\ell^2 =
2$, i.e. $\ell = \sqrt{2}$.

\subsubsection*{Proof (by contradiction)}
\begin{enumerate}
\item Suppose $\ell ^2<2$. We'll show that $\ell$ is not an upper bound for
$S$, by showing that $\exists n \in \mathbf{N}$ with $\ell + \frac{1}{n} \in
S$.
\begin{eqnarray*}
&&\mbox{We want } \left(\ell + \frac{1}{n}\right)^2<2 \mbox{, i.e. }
\ell ^2+\frac{2\ell}{n}+\frac{1}{n^2}<2. \\
&&\mbox{Equivalently } \frac{2\ell}{n}+\frac{1}{n^2}<2-\ell ^2
\mbox{ (NB: }2-\ell ^2>0\mbox{ by assumption).} \\
&&\mbox{Well, }\frac{2\ell}{n}+\frac{1}{n^2} \le
\frac{2\ell}{n}+\frac{n}{n^2}\mbox{, so
enough to get $n$ such that } \frac{2\ell+1}{n} < 2-\ell ^2.\\
&&\mbox{But by 1.8(a), }\exists n \in \mathbf{N}
\mbox{ with }n>\frac{2\ell+1}{2-\ell ^2}.\\
\end{eqnarray*}

\item Suppose $\ell ^2>2$. We'll show that $\ell$ isn't ``least'' by finding
$n$ such that $\ell - \frac{1}{n}$ is an upper bound of $S$.
\begin{eqnarray*}
&&\mbox{Enough to see }\left(\ell - \frac{1}{n}\right)^2>2
\mbox{ for then if }x \in S\mbox{, we have:}\\
&&x^2 < 2 < \left(\ell - \frac{1}{n}\right)^2\mbox{ and we get }
x < \ell - \frac{1}{n}.\\
&&\mbox{(NB: }\ell - \frac{1}{n}>0\mbox{ since }1 \in S\mbox{, so }
\ell \ge 1)\\
&&\mbox{We want }\ell ^2 - \frac{2\ell}{n}+\frac{1}{n^2}>2
\mbox{. Enough to get }\ell ^2 - \frac{2\ell}{n}>2\\
&&\mbox{, or equivalently }
\frac{2\ell}{n}<\ell ^2-2\mbox{. Just choose }
n>\frac{2\ell}{\ell ^2-2}.\\
\end{eqnarray*}
\end{enumerate}

\subsubsection*{Remark}
If $S=\emptyset$, then vacuously any real number is an upper bound.

\begin{prop} Let S be a non-empty subset of $\mathbf{R}$ which is bounded
above. The $\ell = \sup S$ iff:
\begin{enumerate}
\item $\ell$ is an upper bound for $S$.
\item given any (real) $\epsilon > 0$, $\exists s \in S$ with
$s > \ell - \epsilon$.
\end{enumerate}
\end{prop}

\noindent \textbf{Proof} Suppose first $\ell = \sup S$. Then (1) is
true by definition. Now for any $\epsilon > 0$, since $\ell$ is the
least upper bound, $\ell - \epsilon$ is not an upper bound for $S$. So
$\exists s \in S$ such that $s > \ell - \epsilon$.

Conversely, supppose (1) and (2) hold. Then by (1) $\ell$ is an upper
bound. We want to see that it's the least such. So let $U$ be any 
upper bound for $S$. We want $U \ge \ell$. Suppose for a contradiction
$U<\ell$. Put $\epsilon = \ell - U$ in (2). So $\exists s \in S$ with
$s > \ell - \epsilon = \ell - (\ell - U) = U$. So $U$ is not an upper 
bound.

\begin{prop} Suppose $S,T \subseteq \mathbf{R}$, non-empty and 
bounded above. Then $S \cup T$ is bounded above and $\sup (S \cup T) =
\max(\sup S, \sup T)$.
\end{prop}

\noindent \textbf{Proof}: exercise.

\begin{prop} Suppose $S, T$ as in 2.10. Let $S+T = \{ x+y \in 
\mathbf{R}: \: x \in S, y \in T\}.$ Then $S+T$ is bounded and 
$\sup(S+T) = \sup S + \sup T$.
\end{prop}

\noindent \textbf{Proof} For any $x \in S, \: y \in T$ we have 
$x \le \sup S, \: y \le \sup T \Rightarrow \sup S + \sup T$ is an 
upper bound for $S+T$.

Let $\epsilon > 0$. BY 2.9, $\exists s \in S$ such that
$s > \sup S - \frac{\epsilon}{2}$ and $\exists t \in T$ such that
$t > \sup T - \frac{\epsilon}{2}$. Then $s+t \in S+T$, and $s+t >
\sup S + \sup T - \epsilon$. So by 2.9, $\sup S + \sup T = \sup (S+T)$.

\smallskip

\noindent \textbf{Warning:} Given $\ell = \sup S$ and $\epsilon > 0$,
it's not necessarily true that $\ell - \epsilon \in S$. All you can be sure
of is that $\exists s \in S$ with $s > \ell - \epsilon$.

Example: $S = \{1 - \frac{1}{n}: \: n \in \mathbf{N}_+\}.$ Then 
$\sup S = 1$, and $\epsilon = 3/10 > 0, \; \ell - \epsilon = 7/10$, not
in $S$, but for example $9/10 \in S$.

\begin{defn} Given $S \subseteq \mathbf{R}$, non-empty and bounded below,
a greatest lower bound $G$ for $S$ is a number such that:
\begin{enumerate}
\item $g$ is a lower bound of $S$.
\item $g$ is the greatest such.
\end{enumerate}
Written $g = \inf S$ (infimum).
\end{defn}

\begin{prop} If $S$ is non-empty, $S \subseteq \mathbf{R}$, and bounded
below, then $\exists \inf S$.
\end{prop}

\noindent \textbf{Proof} follows from Completeness Axiom by a trick: 
let $S^* = \{x \in \re: \: -x \in S\}$. Easy to check: $x$ is a lower 
bound for $S$ iff $-x$ is an upper bound for $S^*$.

Outline: Since $S$ is bounded below, $S^*$ is bounded above and 
non-empty, so by Completeness $\sup S^*$ exists. Not hard to check that
$-\sup S^*$ is a greatest lower bound for $S$.

\section{Revision on limits of functions}

\begin{defn} Suppose a real-valued function $f$ is defined at least 
`near' $a$, i.e. $\exists (b,c)$ with $a \in (b,c)$ and $f$ defined at 
least on $(b,c)\backslash\{a\}$. Then $\lim_{x\rightarrow a} f(x) = \ell$
means: Given any $\epsilon > 0$, $\exists \delta>0$ such that 
whenever $0 < |x-a| < \delta$, we have $|f(x) - \ell| < \epsilon$.
\end{defn}

N.B. For $\lim_{x \rightarrow a} f(x)$ to exist, it's not necessary for 
$f$ to be defined at $a$, and if $f(a)$ is defined it need not be 
equal to $\lim_{x \rightarrow a} f(x)$.

\subsubsection*{Example}
Suppose $f:[0,1] \rightarrow \re$ is defined by \[f(x) =
\left\{ \begin{array}{r@{\quad:\quad}l}
x & x \neq 1/2\\ 666 & x = 1/2 \end{array} \right.\]
Then $\lim_{x \rightarrow 1/2} f(x) = 1/2 \neq f(1/2)$. (Or:
don't define $f(1/2)$.

\subsubsection*{Example}
\[\mbox{Let } f(x) = \left\{ \begin{array}{r@{\quad:\quad}l}
\sin(1/x) & x \neq 0 \\ 0 & x = 0 \end{array} \right.\]
Want to show that $\lim_{x \rightarrow 0}f(x)$ does not exist.

Three levels:

\begin{enumerate}
\item (intuitive) The graph osciallates too much near 0 for 
$\lim_{x \rightarrow 0}f(x)$ to exist.
\item (towards proof) Take any potential limit $\ell$. Then near 0,
there are points where the graph is at $+1$ and points where it's at
$-1$. These can't both be arbitrarily close to $\ell$.
\item Let $\ell \in \re$ and take $\epsilon = 1/2$, say. Want to show
that 3.1 doesn't work for this $f, \epsilon, \ell$.

Take any $\delta > 0$. Let $N \in \zahl$, $N > 1/\delta$ and consider \[
x_1 = \frac{1}{(2N+\frac{1}{2})\pi}, \;
x_2 = \frac{1}{(2N+\frac{3}{2})\pi}. \]
We see $f(x_1) = 1$, $f(x_2) = -1$, and $0 < |x_1-0| < \delta$.
Now if $0 < |f(x)-\ell| < 1/2$ whenever $0 < |x-0| < \delta$,
we'd have $|1-\ell < 1/2$, $|-1-\ell < 1/2$ so \\
$2 = |1-(-1)| = |1-\ell + -1-\ell| \le |1-\ell| + |-1-\ell| < 1$.
Contradiction.
\end{enumerate}

\subsubsection*{One-sided limits}
If $f$ is defined at least on $(a,b) \; (b>a)$ we say $\lim_{x \to a+}
f(x) = \ell$ or $f(x) \to \ell$ as $x \to a+$ if given any $\epsilon>0,\;
\exists \delta>0$ such that $|f(x)-\ell|<\epsilon$ whenever $a<x<x+\delta$.

Similarly for $\lim_{x \to b-}f(x),\; \lim_{x \to \infty}f(x),\;
\lim_{x \to -\infty}f(x)$.

\begin{defn} Suppose $f:(b,c) \to \re$ and $a \in (b,c)$. We say $f$ is
continuous at $a$ if $f(x) \to f(a)$ as $x \to a$. \end{defn}

\noindent \textbf{Variants}: $f:[a,b] \to \re$ is (right-hand)
continuous at $a$ is $f(x) \to f(a)$ as $x \to a+$. Similarly for 
left-hand continuity at $b$.

\begin{prop} $f:(b,c) \to \re$ is continuous at $a \in (b,c)$ iff given 
any $\epsilon>0,\; \exists \delta>0$ such that $|f(x)-f(a)|<\epsilon$
whenever $|x-a|<\delta$. \end{prop}

\thingy{Proof} follows from definitions 3.1 and 3.2.

\thingy{Note} Difference from 3.1: no ``$0 < |x-a|$ this time. When 
$x=a,\; f(x) = f(a)$ so $|f(x) - f(a)| = 0 < \epsilon$, i.e. this time
we're looking at $f(x) \to f(a)$ as $x \to a$, not $f(x) \to \ell$ as
$x \to a$.

There are two ways of thinking about continuity of $f$ at $a$:
\begin{enumerate}
\item Approximation: think of $f$ as a black box which accepts real number
inputs and gives you real number outputs. Then if you vary input $x$ only
slightly from $a$, output $f(x)$ also varies only slightly from $f(a)$.
\item Geometrically: graph doesn't jump around too much: given any horizontal
strip centred on height $f(a)$ you can find a vertical strip centred on $a$,
narrow enough so that all of the graph in the vertical strip is also inside
the horizontal strip. For some reason he called this the ``principle of
inertia''.
\end{enumerate}

\begin{defn} $f:[a,b] \to \re$ is said to be continuous if it's continuous at
every point in $[a,b]$ (RH continuous at $a$, LH continuous at $b$).
\end{defn}

\thingy{Note} if $f:[a,b] \to \re$ is continuous and $I$ is any interval
$I \subseteq [a,b]$, then $f|_I:I \to \re$ is also continuous (obvious if
you ask me). For $c \in I$, any $\epsilon>0$, by continuity of $f$ at $c$,
$\exists \delta>0$ such that $|f(x)-f(c)|<\eps$ whenever $|x-c|<\delta$
and $x \in [a,b]$ so certainly true $\forall x$ with $|x-c|<\delta$ and
$x \in I$.

\smallskip \noindent Continuous functions behave well under addition
and multiplication.

\begin{prop} Suppose $f,g:(b,c) \to \re$ and $a \in (b,c)$ and $f,g$
continuous at $a$. Then so are the following functions:
\begin{enumerate}
\item $x \mapsto kf(x)$ ($k$ constant)
\item $x \mapsto f(x) + g(x)$ (``$f+g$'')
\item $x \mapsto f(x)g(x)$
\item provided $g(a) \neq 0,\; x \mapsto 1/g(x)$
\end{enumerate}
\end{prop}
\noindent \textbf{Proof:} Given definition 3.2, follows imediately from
Algebra of Limits.

\begin{corr} Any polynomial $p(x),\; x \mapsto a_0 + a_1x + \ldots +
a_nx^n$, $a_i$ constant, is continuous at any point in $\re$ and so is
any rational function $x \mapsto \frac{p(x)}{q(x)}$ where $p$ and $q$
are polynomials, except at (finite set of) points where $q(x)=0$.
\end{corr}

\thingy{Proof} A sequence of easy inductions. But first,
\begin{enumerate}
\item Any constant function $x \mapsto k$ is continuous, since for any 
$\eps>0$ take any $\delta>0$ and we have $|k-k|=0<\eps$ whenever
$|x-a|<\delta$.
\item The function $x \mapsto x$ is continous, since for any $\eps>0$, 
take $\delta=\eps$. Then $|x-a|<\delta \implies |f(x) - f(a)| = |x-a|
<\eps$.
\end{enumerate}

First induction: $\forall n \in \nat,\; x \mapsto x^n$ is continuous.
Anchor is (2) above. Induction step follows from $x \mapsto x$ and
$x \mapsto x^n$ continuous $\implies x \mapsto x^{n+1}$ continuous.

Then by one more application of `product', $x \mapsto a_nx^n$ is 
continuous. Finally $x \mapsto a_0 + a_1x + \ldots + a_nx^n$ is 
continuous by easy induction on adding two continous functions.

Also, $p(x)/q(x)$ follows by ``quotient'' part of Algebra of Limits.

\thingy{Remark} Continuity of $f$ at $a$ can be split into four bits:
\begin{enumerate}
\item $\lim_{x \to a+}$ exists.
\item $\lim_{x \to a+}=f(a)$
\item $\lim_{x \to a-}$ exists.
\item $\lim_{x \to a-}=f(a)$
\end{enumerate}

\subsubsection*{Examples}
\[ f(x) = \splitfunc{0}{x \le 0}{1}{x>0} ,\:a=0.\:
\mbox{1, 3, 4 true but 2 fails at 0.}\]
\[ f(x) = \splitfunc{0}{x<0}{1}{x \ge 0} ,\:a=0.\:
\mbox{1, 2, 3 hold but 4 fails at 0.}\]
These two functions have a \emph{simple jump discontinuity}.
\[ f(x) = \splitfunc{\sin(1/x)}{x>0}{0}{x \le 0} ,\:a=0.\:
\mbox{3, 4 true, 1 fails so 2 meaningless.}\]
Similarly we can get 1 and 2 to hold and 3 to fail so 4 is meaningless.

\begin{prop} The composition $f \circ g$ of continuous functions is
continuous. \end{prop}

\begin{prop} If $f$ is differentiable at $a \in \re$, it's continuous
at $a$.
\[ \frac{f(x)-f(a)}{x-a} \to f'(a) \mbox{ as } x \to a \implies
\underbrace{f(x)-f(a)}_{\mbox{hence also }\to 0}
- \underbrace{(x-a)f'(a)}_{\mbox{must tend to 0}}
\to 0 \mbox{ as } x \to a \]
\end{prop}

\section{Results about sequences proved using Completeness, and needed to
study Continuity}
\begin{prop} Any monotone bounded sequence converges. \end{prop}

\thingy{Proof} First consider $(a_n)$ increasing, bounded above. Let
$S = \{a_n : n \in \nat\}$. Certainly non-empty, and bounded above. So the
least upper bound $\sup S$ exists --- call it $\ell$. We'll show $(a_n)$
converges to $\ell$.

Let $\eps > 0$. The $\ell - \eps$ is not an upper bound for $S$. So 
$\exists N$ such that $a_N < \ell - \eps$. By an easy induction using the
fact $a_{n+1} \ge a_n \forall n$, get $a_n > \ell - \eps \forall n \ge N$.
But also $a_n \le \ell \forall n$. So $\forall n \ge N$ we have $\ell - 
\eps < a_n \le \ell$, so $|a_n - \ell| < \eps$.

Finally, if $(a_n)$ is decreasing and bounded below, then $(-a_n)$ is
increasing and bounded above, so $-a_n \to \ell$, say, as $n \to \infty$, so
it's easily seen that $a_n \to -\ell$ as $n \to \infty$.

\begin{thrm}[Bolzano-Weierstrass] Any bounded sequence of real numbers has at
least one convergent subsequence.\end{thrm}

\thingy{Proof I} It is enough to show that $(a_n)$ has a monotonic
subsequence. For then that subsequence is monotonic and bounded so 4.1
applies. We can show \ldots

\begin{thrm} Any sequence of real numbers has a monotonic subsequence.
\end{thrm}
Local definition: for a sequence $(a_n)$, $n$ is a scenic viewpoint if 
$\forall m \ge n,\: a_n \ge m$.

\thingy{Proof} The sequence $(a_n)$ has infinitely many scenic viewpoints, or
it doesn't.

\thingy{Case 1} Suppose that there are infinitely many scenic viewpoints. Put
them in order: $n_1<n_2<n_3<\ldots$. Consider $a_{n_r}$: since $n_r$ is a
scenic viewpoint, $a_m \le a_{n_r} \forall m \ge n_r$, in particular 
$a_{n_{r+1}} \le a_{n_r}$. This is true $\forall r$ so $(a_{n_r})$ is
decreasing.

\thingy{Case 2} There are not infinitely many scenic viewpoints. Let $n_0$ be
the largest scenic viewpoint, if any exist, otherwise let $n_0=0$. Let 
$n_1 = n_0 + 1$. Then $n_1$ is not a scenic viewpoints so $\exists m>n_1$
such that $a_m > a_{n_1}$. Choose any such $m$ and call it $n_2$.
Inductively: suppose $n_1<n_2<\ldots<n_r$ chosen so that $a_{n_1}<
a_{n_2}<\ldots<a_{n_r}$. Then $n_r$ is not a scenic viewpoint, so we can
choose $n_{r+1}>n_r$ with $a_{n_{r+1}}>a_{n_r}$. This way, inductively, we
get a (strictly) increasing subsequence of $(a_n)$.

\thingy{Proof II (Bisection method)}

Definition: call an interval $I$ \emph{crowded} if $a_n \in I$ for infinitely
many $I$.

Step 1. $(a_n)$ is bounded so  $\exists K
\in \re$ such that $a_n \in [-K,K] \forall n$.
So either \dag $[-K,0]$ is crowded or $[0,K]$ is crowded. If \dag 
holds, put $x_0 = -K,\: y_0 = 0$. If \dag fails, put $x_0 = 0, y_0 = K$.
Then $[x_0, y_0]$ is crowded.

\smallskip Suppose inductively we've already chosen $x_0\le x_1 \le 
\ldots \le x_r \le y_r \le y_{r-1} \le \ldots \le y_0$ such that
$[x_r, y_r]$ is crowded and $y_i - x_i = K/2^i$ for $i = 0,1,\ldots,r$.

Bisect $[x_r,y_r]$. Either \ddag the left-hand half or the right-hand half
is crowded. If \ddag holds, put $x_{r+1} = x_r,\: y_{r+1} = (x_r+y_r)/2$.
Otherwise put $x_{r+1} = (x_r+y_r)/2,\: y_{r+1} = y_r$. Then clearly the 
assumption hold for $n+1$.

\smallskip Not $(x_r)$ in increasing and bounded above (by any $y_s$) so 
$x_r \to x$ as $r \to \infty$ and similarly $y_r \to y$ as $r \to \infty$
and at any stage $r$ we have $x_r \le x \le y \le y_r$ ($y_s \ge x$
for any $s$ since $x_r \le y_s$ (fixed) $\forall r$). Put $y_r - x_r =
K/2^r$ --- true $\forall r$ so by sandwiching, $y=x$.

Now need to see that a subsequence of $(a_n)$ converges to $x$. Every
$[x_r,y_r]$ is crowded so $a_{n_r} \in [x_r,y_r]$ for some $n_r$. But this
is not yet an orderly subsequence ($n_{r+1} > n_r \forall r$). Suppose 
we already have $n_1<n_2<\ldots<n_r$ such that $a_r \in [x_i,y_i]
\forall i \le r$. Since $[x_{r+1},y_{r+1}]$ is crowded, we can choose
$n_{r+1}>n_r$ such that $a_{n_{r+1}} \in [x_{r+1},y_{r+1}]$. Now we see
$x_r \le a_{n_r} \le y_r \forall r$, so $a_{n_r} \to x$ as $r \to
\infty$, by sandwiching.

There's another version of B-W --- see e.g. Spivak \emph{Calculus} 
p. 386 ex. 21.

\section{Results about continuous functions $f:[a,b] \to \re$}

\begin{thrm} Any continuous function $f:[a,b]\to\re$ is bounded and 
attains its bounds.\end{thrm}
We now rephrase the second part of this assertion thrice.

Suppose $f:[a,b]\to\re$ is bounded, so $\exists K$ such that 
$|f(x)|\le K \forall x \in [a,b]$. Equivalently, $f([a,b]) =
\{y \in\re$ such that, for some $x\in [a,b], f(x)=y\} \subseteq
[-K,K].$

So image $f([a,b])$ is (non-empty) bounded above and below, so has a
$\sup$ and an $\inf$; (ii) says that they are taken on as values of $f$. 
Equivabloodylently, $\exists c,d \in [a,b]$ s.t. $f(c) \le f(x) \le f(d)
\forall x \in [a,b]$.

\thingy{Remark} It's crucial that [a,b] is closed and bounded.

\subsubsection*{Examples}
\begin{itemize}
\item Define $f:(0,1)\to\re$ by $f(x)=1/x$. $f$ continuous, not bounded.
\item Define $g:(0,1)\to\re$ by $g(x)=x$. Continuous, bounded but
bounds not attained.
\item Define $g:[1,\infty)\to\re$ by $g(x) = x$. Not bounded.
\item Define $f:[1,\infty)\to\re$ by $=1/x$. Bounded but infimum not
attained.
\end{itemize}

\thingy{Recall} If $(a_n)$ converges to $\ell$ and $a_n \ge L \forall n$,
then $\ell \ge L$ (also, $a_n>L \implies \ell \ge L$, not $\ell>L$).
Similarly, $a_n \le L \forall n \implies \ell \le L$.

\subsubsection{Proof}
\thingy{(i)} Suppose $f$ not bounded. Then for any $n\in\nat,\:
\exists a_n\in [a,b]$ with $|f(a_n)|>n$. Consider $(a_n)$ --- bounded,
so by Bolzano-Weierstrass, has a convergent subsequence $a_{n_r}$
converging to some $\ell\in\re$ \dag.

Now $a \le a_{n_r} \le b \forall r$, so $a \le \ell \le b$, i.e. 
$\ell \in [a,b]$ \ddag. Use continuity of $f$ at $\ell$: get
$f(a_{n_r})\to f(\ell)$ as $r\to\infty$. All we need of this is:
$(f(a_{n_r}))$ converges, hence (from result last term) is bounded.
But $|f(a_{n_r})|>n_r \forall r$. Contradiction, so $f$ bounded.

\dag is where we use $[a,b]$ bounded. \ddag is where we use $[a,b]$ 
closed.

{\newcommand{\allx}{\forall x \in [a,b]}
\thingy{(ii)} Let $g, \ell$ be the inf and sup of $f([a,b])$. Suppose
e.g. $\ell$ is not attained on $[a,b]$. We know $f(x)\le\ell \allx
$ and by our supposition $f(x)<\ell \allx$.
\textbf{KEY:} Let $h(x) = 1/(\ell-f(x)),\:x \in [a,b]$. By (3.5), $h$
is continuous on $[a,b]$. By (1), $h$ is bounded on $[a,b]$.
Say $1/(\ell-f(x)) \le U \implies \ell-f(x)
\ge 1/U \implies f(x) \le \ell-1/U \allx$. i.e. $\ell - 1/U$ is an 
upper bound for $f([a,b])$ --- contradicts leastness of $\ell$. 
Proof that $\inf f([a,b])$ is attained on $[a,b]$ is similar. }

\begin{thrm}[Special case of IVT] Suppose $f:[a,b]\to\re$ is 
continuous, and $f(a)<0$ and $f(b)>0$. Then $\exists c \in (a,b)$ with
$f(c) = 0$. \end{thrm}

\thingy{Note} not true for $\rat$: try $f:[0,2]\to\re,\:f(x)=x^2-2$.

\subsubsection*{Proof I}
Consider $s = \{x \in [a,b]: f(x) \le 0\}$. Note $s \neq 0\:(a \in S)$
and bounded above (e.g. by $b$). So by Completeness, $\exists\sup S$.
Let $c = \sup S$. We'll show $f(c)=0$ by contradicting the other 
possibilities.
\begin{enumerate}

\item Suppose $f(c)>0$. We'll show this contradicts $c$ being \emph{least}
upper bound of $S$. By continuity of $f$ at $c$, $\exists\delta>0$ such
that whenever $x \in [a,b]$ and $|x-c|<\delta$, we have 
$|f(x)-f(c)|<f(c)/2$ (note $f(c)/2>0$).

For all such $x$, $-(f(x)-f(c))<f(c)/2$, so $f(x)>f(c)-f(c)/2>0$. Now
$c \neq 0$ (we're supposing $f(c)>0$, and we know $f(a)<0$). We may
as well assume $\delta<c-a$, so $c-\delta>a$. So $\forall x \in
(c-\delta,c]$< we have $f(x)>0$. By definition of $S$, $f(x)>0 \forall
x>c$ (in $[a,b]$). So $c-\delta$ is an upper bound for $S$, contradicting
leastness of $c$.

\item Suppose $f(c)<0$. We'll contradict ``$c$ is \emph{an} upper bound
for $S$''. By continuity of $f$ at $c$, $\exists\delta>0$ such that
whenever $x \in [a,b]$ and $|x-c|<\delta$, we have
$|f(x)-f(c)|<-f(c)/2$ (note $-f(c)/2>0$).

So for all such $x$ we have $f(x)-f(c)<-f(c)/2$ so $f(x)<f(c)-f(c)/2<0$.
Now $c \neq b$ ($f(c)<0,\:f(b)>0$). So certainly $\exists x \in [a,b]$
with $c<x<x+\delta$, and for any one such, $f(x)<0$, so contradicting
``$c$ an upper bound for $S$''.

\end{enumerate}
So $f(c)=0$.

\subsubsection*{Proof II}

Proceed similarly to Bolzano-Weierstrass proof, but choose $a = x_0 \le 
x_1 \le \ldots \le x_r \le y_r \le y_{r-1} \le \ldots \le y_0 \le b$
as follows:

If $f((a+b)/2) \le 0$, put $x_1 = (a+b)/2,\:y_1=b$.

If $f((a+b)/2)>0$, put $x_1 = a,\:y_1=(a+b)/2$.

Continue inductively --- get $a \le x_1 \le \ldots \le x_r \le y_r
\le y_{r-1} \le \ldots \le y_1 \le b$. such that $y_r-x_r=(b-a)/2^r$
and $f(x_r)\le 0$, $f(y_r)\ge 0$. As in Bolzano-Weierstrass, 
$(x_r), (y_r)$ converge to a common limit $c$ and $f(c)\le 0$ by
continuity of $f$ at $c$, and $f(c) \ge 0\: (f(x_r)\le 0 \forall r)$
so $f(c)=0$.

\end{document}


