\documentclass[10pt,a4paper,twoside,draft]{article}
\input{../../math/abbreviations}
\input{../../math/format}
\theoremstyle{definition}
\newtheorem{exercise}{Exercise}

\newcommand{\news}[1][]{\subsection{#1}}
\newcommand{\pref}[1]{(\ref{#1})}

\pagestyle{myheadings}
\markboth{David Pierce, \today}{\today, Analysis notes}

\addtolength{\voffset}{-1.5cm}
 \addtolength{\textheight}{3cm}

\title{Analysis lecture notes}
\author{David Pierce}
\date{\today}

\begin{document}
\maketitle

I first write these notes while preparing to give lectures on analysis
(in METU's course Math 271, year 2002/3, fall semester).  Later I
edit.  However, some mistakes and inconsistencies may remain. 

\section{Fields}
\news[Definition of a field]
A \defn{commutative} (or \defn{abelian}) \defn{group} is a structure
\begin{equation*}
  (G,*,\hat{\ },e)
\end{equation*}
---where $*$ is a binary, $\hat{\ }$ a unary, and $e$ a nullary
   operation---satisfying: 
\begin{itemize}
  \item
$\forall x\qsep\forall y\qsep x*y=y*x$ [\defn{commutativity}],
  \item
$\forall x\qsep\forall y\qsep\forall z\qsep x*(y*z)=x*y*x$
    [\defn{associativity}], 
  \item
$\forall x\qsep e*x=x$ [\defn{identity element}],
  \item
$\forall x\qsep x*\hat x=e$ [\defn{inverses}].
\end{itemize}
A \defn{field} is a structure
\begin{equation*}
  (F,+,-,\cdot,0,1)
\end{equation*}
where $F\setminus\{0\}$ is also equipped with ${}\inv$ such that
\begin{itemize}
  \item
$(F,+,-,0)$ and $(F\setminus\{0\},\cdot,{}\inv,1)$ are commutative
    groups, and  
\item
$\forall x\qsep\forall y\qsep\forall z\qsep x\cdot(y\cdot z)=x\cdot
  y+x\cdot z$ [\defn{distributivity}].
\end{itemize}
\begin{exercise}
Prove that a field satisfies:
\begin{equation*}
  \forall x\qsep\forall y\qsep(xy=0\to x=0\lor y=0) \text{ [\defn{no
  zero-divisors}]}. 
\end{equation*}
\end{exercise}

The set $\R$ of real numbers is a field (when equipped with the usual
operations).  

\news[Functions into a field] 
We  shall be interested in functions from arbitrary sets
into $\R$.  Say $S$ is a set, and $f,g:S\to \R$ are functions.  Then
we can use the field-operations to form new functions:
\begin{itemize}
  \item
$f+g:x\mapsto f(x)+g(x)$,
\item
\&c.
\end{itemize}

\begin{exercise}
Let $A$ be the set of all functions from $S$ to $\R$.  Which
properties of fields does $A$ have?  For example, does it have no
zero-divisors? 
\end{exercise}

\news[Polynomial and rational functions] 
Let $X$ be a variable; we define
\begin{equation*}
  \R[X]
\end{equation*}
to be the set of polynomials in $X$ with coefficients in $\R$.  So a
typical element of $\R[X]$ is
\begin{equation*}
  a_0+a_1X+a_2X^2+\dots+a_nX^n,
\end{equation*}
that is, 
\begin{equation*}
 \sum_{k=0}^na_kX^k,
\end{equation*}
where $a_k\in\R$.  Any member $f$ of $\R[X]$ determines a
function from $\R$ to itself, namely
$$x\mapsto f(x):\R\to \R.$$  
In particular, $X$ is the
identity-function $x\mapsto x:\R\to \R$.  Then $\R[X]$ is the smallest set of
functions from $\R$ to itself that contains the identity-function and
is closed under the field-operations induced from $\R$.

Note that the identity-function is not the multiplicative identity $1$
or the additive identity $0$.  Also, in this definition,
multiplicative inversion is not a field-operation.  (It is an
operation on the set of \emph{non-zero} elements of a field.)

Say $f\in\R[X]$.  What can we say about the set
\begin{equation*}
  \{x\in\R:f(x)=0\}?
\end{equation*}
It is a consequence of the field-axioms that this set is finite (and
is no bigger than the \tech{degree} of $f$).  Let $1/f$ be the function
$x\mapsto f(x)\inv$.  Then $1/f$ is defined at all but finitely many
points of $\R$.

The function $1/f$ is the multiplicative inverse of $f$ (not the
functional inverse, $f\inv$, which may not even exist).  We can form
the function $g/f$ whenever
$g\in\R[X]$.  The set of all such functions is
\begin{equation*}
  \R(X),
\end{equation*}
the \emph{field} of \defn{rational} functions in $X$ over $\R$.

\news[Subfields] 
A field $(F,+,-,\cdot,0,1)$ is a \defn{sub-field} of a field
$(G,\oplus,\ominus,\odot,0',1')$ if $F\included G$, and
\begin{itemize}
  \item
$x\oplus y=x+y$ for all $x$ and $y$ in $F$,
\item
\&c.
\end{itemize}
Then $\Q$ is a sub-field of $\R$; in fact, $\Q$ is the smallest
sub-field of $\R$.  Also, $\R$ is a sub-field of $\C$; but
$\Z/p\Z$ is not a sub-field of $\Q$ (or $\R$, or $\C$).

Each element $a$ of $\R$ can be considered as the function
\begin{equation*}
  x\mapsto a:\R\to \R.
\end{equation*}
In this way, $\R$ is a sub-field of $\R(X)$.  Also, $\R(X)$ is the
smallest field that contains the identity-function and includes $\R$
as a sub-field.

\news[Ordered fields] 
An \defn{ordered} field is a field with a binary relation $\leq$
satisfying: 
\begin{itemize}
\item
  $\forall x\qsep x\leq x$,
\item
$\forall x\qsep\forall y\qsep(x\leq y\land y\leq x\to x=y)$,
\item
$\forall x\qsep\forall y\qsep\forall z\qsep(x\leq y\land y\leq z\to
  x\leq z)$,
\item
$\forall x\qsep\forall y\qsep(x\leq y\lor y\leq x)$,
\item
$\forall x\qsep\forall y\qsep\forall z\qsep(x\leq y\to x+z\leq y+z)$,
\item
$\forall x\qsep\forall y\qsep\forall z\qsep(x\leq y\land 0\leq z\to
  xz\leq yz)$.
\end{itemize}
Then $\R$ is an ordered field.  So is every subfield of $\R$, such as
$\Q$. 

In an alternative definition, a field is ordered if it has a subset
$P$ that is closed under $+$ and $\cdot$ such that the whole field is
the disjoint union
\begin{equation*}
  \{x:-x\in P\}\sqcup\{0\}\sqcup P.
\end{equation*}
Then we write $x< y$ just in case $y-x\in P$.  The set $P$ is the set
of \defn{positive} elements of the field.  
\begin{exercise}
  Prove the equivalence of the definitions.
\end{exercise}

\news[Convexity and bounds] 
A set $A$ in space is called \tech{convex} if, for all points $P$ and $Q$ in
$A$, the line segment joining $P$ and $Q$ lies within $A$.

A subset $A$ of an ordered field $K$ is \defn{convex} if $K$ satisfies
\begin{equation*}
\forall x\qsep\forall y\qsep\forall z\qsep(x\in A\land y\in A\land
  x\leq z\leq y\to z\in A).
\end{equation*}
An \defn{upper bound} for $A$ is an element $b$ of $K$ such that 
\begin{equation*}
  \forall x\qsep(x\in A\to x\leq b).
\end{equation*}
Likewise, \defn{lower bound}.  A set is \defn{bounded} if it has an
upper and a lower bound.
\begin{exercise}
  An ordered field has exactly one convex subset that has no upper or lower
  bound.  What is it?
\end{exercise}
An ordered field has \defn{intervals} of nine kinds:
\begin{center}
  \begin{tabular}{|r|r|r|}
\hline
$(-\infty,b)$ & $(-\infty,b]$ & $(-\infty,\infty)$\\ \hline
$(a,b)$ & $(a,b]$ & $(a,\infty)$\\ \hline
$[a,b)$ & $[a,b]$ & $[a,\infty)$\\ \hline
  \end{tabular}
\end{center}
where $a<b$.  Here $(-\infty,b)=\{x:x<b\}$, \&c.; a square bracket
means the corresponding end-point is contained in the interval.
\begin{exercise}
Prove that every interval is convex.
\end{exercise}

\news[Completeness]
An ordered field is \defn{complete} if every subset with an upper
bound has a \emph{least} upper bound, also called a \defn{supremum}.  If it
exists, the supremum of $A$ is denoted
\begin{equation*}
  \sup A.
\end{equation*}
\emph{We postulate that $\R$ is complete,} that is, \emph{$\R$ is a
  complete ordered field.}

An \defn{infimum} is a greatest lower bound.  The infimum of $A$, if
it exists, is denoted
\begin{equation*}
  \inf A.
\end{equation*}
\begin{exercise}
  In $\R$, every convex set with at least two members is an interval.
  (This is not true in $\Q$.)
\end{exercise}
\begin{exercise}
Here, $P$ is the set of positive elements of $\R$.
  \begin{enumerate}
\item
If $ab\in P$, what can you conclude about $a$ and $b$?
    \item
Write $P$ as an interval.
\item
Prove that $P$ is closed under $x\mapsto x\inv$.
\item
Let $f$ be a non-zero polynomial whose non-zero coefficients are
positive.  Show that $P$ is closed under $x\mapsto f(x)$.  
\item
If $f\in \R[X]$, and $P$ is closed under $x\mapsto f(x)$, can you
conclude that $f\in P[X]$?
  \end{enumerate}
\end{exercise}
\begin{exercise}
Prove that, in a complete ordered field, all sets with lower bounds
have infima. 
\end{exercise}

\news[Triangle inequalities]
On any ordered field, we define the \defn{absolute-value} function
$$x\mapsto\abs x$$ 
by the rule
\begin{equation*}
  \abs x=
  \begin{cases}
    x, &\text{ if }x\geq0;\\
-x, &\text{ if }x<0.
  \end{cases}
\end{equation*}
Then 
\begin{equation*}
  \forall x\qsep\forall y\qsep (\abs x\leq y\leftrightarrow
  -y\leq x\leq y).
\end{equation*}
Hence the \defn{triangle-inequality}:
\begin{equation*}
  \abs{x+y}\leq\abs x+\abs y
\end{equation*}
and the variants
\begin{equation*}
  \abs{\abs x-\abs y}\leq\abs{x-y}\leq\abs x+\abs y.
\end{equation*}
\begin{exercise}
  Prove the triangle-inequality (and variants).
\end{exercise}
\news[The natural numbers] 
The set $\N$ of natural numbers can be defined as the smallest subset
of $\R$ that contains $0$ and that contains $x+1$ whenever it contains
$x$.  (Any intersection of subsets with this property continues to
have this property; so $\N$ is the intersection of all subsets of $\R$ with
this property.)

Therefore, proof by \defn{induction} works in $\N$: if $A\included
\N$, and $0\in A$, and $x+1\in A$ whenever $x\in A$, then $A=\N$.

\begin{exercise}
  Prove that $\N$ is \defn{well-ordered}, that is, every non-empty
  subset of $\N$ has a least element.
\end{exercise}

The definition of $\N$ works for any ordered field.  (Why not
a non-ordered field?)  

\news[Archimedean ordered fields] 
An ordered field is called \defn{Archimedean} if
$\N$ has no upper bound in the field.

\begin{theorem*}
  $\R$ is Archimedean.
\end{theorem*}

\begin{proof}
Suppose $A$ is a subset of $\N$ with an upper bound in $\R$.  Then $A$
has a supremum.  In particular, $\sup A-1$ is not an upper bound for
$A$.  Therefore
$$\sup A-1<n$$
for some $n$ in $A$.  Hence $\sup A<n+1$, so $n+1\in\N\setminus A$.  Thus
$A\neq\N$. 

In short, every subset of $\N$ with an upper bound is a proper subset
of $\N$.  So the whole set $\N$ has no upper bound.
\end{proof}

\begin{exercise}
  Make $\R(X)$ into a non-Archimedean ordered field such that 
  \begin{equation*}
    a\leq X
  \end{equation*}
for all $a$ in $\R$.
\end{exercise}

\news[The integers] 
We can define the set $\Z$ of \defn{integers} to be the set
\begin{equation*}
  \{x\in\R:-x\in\N\}\cup\N.
\end{equation*}
Note that $0$ is in both sets.  The set $\Z$ is closed under $+$ and
$-$ and $\cdot$.

\begin{lemma*}
For every $x$ in $\R$ there is a unique integer $n$ such that
$$x-1<n\leq x.$$
\end{lemma*}

\begin{proof}
The numbers $x$ and $-x$ are not upper bounds for $\Z$; hence also $x$
is not a lower bound for $\Z$.  So let $k$ be an integer such that
$k\leq x$, and let 
$$A=\{m\in\N:k+m\leq x\}.$$
Then $0\in A$, but $A\neq\N$, so there is $m$ in $A$ such that
$m+1\notin A$.  Then $k+m+1$ is the desired integer $n$.  There cannot
be two such integers, since their difference would be a natural number
between $0$ and $1$.
\end{proof}

We can now define the \defn{greatest-integer}
function 
$$x\mapsto\floor{x}:\R\to\Z$$
so that 
$$x-1<\floor x\leq x.$$

\news[The rational numbers]  
The set $\Q$ of \defn{rational}
numbers is
\begin{equation*}
  \{x\in\R:xy\in\Z\text{ for some positive integer }y\}.
\end{equation*}
This is a field.
Rational numbers exist in any ordered field.

\begin{lemma*}
  In an Archimedean ordered field, if
  \begin{equation*}
    0\leq x\leq r
  \end{equation*}
for all positive rational numbers $r$, then $x=0$.
\end{lemma*}

\begin{proof}
For every positive $x$, there is a natural number $n$ such that
  $1/x<n$ and therefore $1/n<x$.
\end{proof}

\news[Open and closed sets] 
A subset $A$ of $\R$ is called \defn{open} if, for every $x$ in $A$,
there is a positive real number $\epsilon$ such that
\begin{equation*}
  (x-\epsilon,x+\epsilon)\included A.
\end{equation*}
A subset of $\R$ is \defn{closed} if its complement is open.
\begin{exercise}
  The intervals $(-\infty,\infty)$, $(-\infty,b)$, $(a,b)$ and
  $(a,\infty)$ are open.  The intervals $(-\infty,\infty)$,
  $(-\infty,b]$, $[a,b]$ and $[a,\infty)$ are closed.  The set $\{a\}$
  is closed.
\end{exercise}
\begin{lemma*}
  If $A$ is a closed subset of $\R$ with an upper bound, then 
  \begin{equation*}
    \sup A\in A.
  \end{equation*}
\end{lemma*}
\begin{proof}
  Suppose $b$ is an upper bound of $A$, but $b\notin A$.  Since $A$ is
  closed, the set $\R\setminus A$ is open.  Therefore
  \begin{equation*}
    (b-\epsilon,b+\epsilon)\included \R\setminus A
  \end{equation*}
for some positive $\epsilon$.  Hence $b-\epsilon$ is an upper bound
for $A$.  (The reason is that we have  
$$A\included(-\infty,b],$$ 
but also
      $$A\included\R\setminus(b-\epsilon,b+\epsilon),$$ 
so
     $$A\included(-\infty,b]\setminus(b-\epsilon,b+\epsilon)=
    (-\infty,b-\epsilon],$$
which means $b-\epsilon$ is an upper bound for $A$.)  
Thus $b$ is not $\sup A$.  That is, no
      upper bound of $A$ that is not in $A$ is $\sup A$; but $\sup A$
      is an upper bound of $A$; therefore $\sup A$ is in $A$.
\end{proof}

\news[Sequences of sets]
A \defn{sequence} is a function on $\N$.  A function $n\mapsto
a_n:\N\to S$ may also be written $(a_n:n\in\N)$ or $(a_n)_n$ or just
$(a_n)$. 
\begin{theorem*}
  Suppose $(F_n:n\in \N)$ is a sequence of non-empty bounded closed
  subsets of $\R$ such that 
  \begin{equation*}
    F_{n+1}\included F_n
  \end{equation*}
for all $n$ in $\N$.  Then
\begin{equation*}
  \bigcap_{n\in\N}F_n\neq\emptyset.
\end{equation*}
\end{theorem*}
\begin{proof}
  Since $F_n$ is bounded and empty, $\sup F_n$ exists; and $\sup
  F_n\in F_n$ by the last lemma, since $F_n$ is closed.  Then the set
  \begin{equation*}
    \{\sup F_n:n\in\N\}
  \end{equation*}
is a subset of $F_0$, so it is bounded below by any lower bound of
$F_0$.  Hence this set of suprema has an infimum, say $L$.  
 I claim that $L\in F_n$ for each $n$ in $\N$.  To prove this, since
 $F_n$ is closed, it is enough to show that
 \begin{equation*}
   F_n\cap(L-\epsilon,L+\epsilon)\neq\emptyset
 \end{equation*}
whenever $\epsilon>0$.  But by definition of $L$, for each positive
$\epsilon$, there is $m$ in $\N$ such that
\begin{equation*}
  L\leq \sup F_m<L+\epsilon.
\end{equation*}
Let $k=\max\{m,n\}$; then
\begin{equation*}
  L\leq\sup F_k\leq\sup F_m<L+\epsilon
\end{equation*}
and $\sup F_k\in F_k\included F_n$.
Therefore $\sup F_k\in F_n\cap(L-\epsilon,L+\epsilon)$.
\end{proof}
The sets $F_n$ of the Theorem can be called \defn{nested}, because
each includes the next.
\begin{example*}
  Let $F_n=\{x\in\R:\abs{x^2-2}\leq 1/n\}$.  Then each $F_n$ is non-empty,
  closed and bounded, and $F_{n+1}\included F_n$, so
  $$\bigcap_{n\in\N}F_n\neq\emptyset.$$  
In fact, the intersection is
  $\{\pm\radix 2\}$.
\end{example*}
\begin{exercise}
The Theorem puts four conditions on the sequence of nested sets $F_n$:
  each $F_n$ must
  \begin{enumerate}
    \item
 be non-empty, 
\item be closed, 
\item 
have
  an upper bound, and 
\item 
have a lower bound.  
  \end{enumerate}
Show that each of
  these conditions is necessary (that is, if any one of them is
  removed, then the theorem cannot be proved).
\end{exercise}
Note that the theorem is true in any complete ordered field.  The next
theorem gives an alternative definition for \tech{complete}.
\begin{theorem*}
  Suppose $K$ is an Archimedean ordered field, and suppose that
  $$\bigcap_{n\in\N}[a_n,b_n]\neq\emptyset$$ 
whenever
  $([a_n,b_n]:n\in\N)$ is a
  sequence of nested closed intervals of $K$.  Then $K$ is a complete
  ordered field. 
\end{theorem*}
\begin{proof}
  Let $C$ be a subset of $K$ with element $a$ and upper bound $b$.  We
  shall recursively define a nested sequence $([a_n,b_n]:n\in\N)$ in
  the following way.  First,
  \begin{equation*}
    [a_0,b_0]=[a,b].
  \end{equation*}
Then $[a_0,b_0]$ contains a member of $C$ and an upper bound of $C$.
Suppose $[a_k,b_k]$ has been defined and contains a point of $C$ and
an upper bound of
$C$.  Then one of the intervals
\begin{equation*}
  \left[a_k,\frac {a_k+b_k}2\right],\qquad\left[\frac {a_k+b_k}2,b_k\right]
\end{equation*}
has the same property (why?).  Let $[a_{k+1},b_{k+1}]$ be this interval.  If
both intervals have this property, then we can just define
$$[a_{k+1},b_{k+1}]=\left[a_k,\frac {a_k+b_k}2\right].$$

By assumption, there is some $c$ in $\bigcap_{n\in\N}[a_n,b_n]$.  Then
$c$ is an upper bound of $C$ (why?), and no upper bound of $C$ is less
than $c$ (why?).  Therefore $c=\sup C$.
\end{proof}

\begin{exercise}
  Supply the missing details in the proof of the last theorem.
\end{exercise}

\news[Different treatments of the real numbers]
We have treated $\R$ \tech{axiomatically}.  That is, we have written
down 
\begin{itemize}
  \item
 axioms for \tech{fields}, 
\item 
additional axioms for
\tech{ordered} fields, and finally 
\item 
the \tech{completeness} axiom for
fields.  
\end{itemize}
Then we have declared that $\R$ is a complete ordered field.

The alternative approach is \tech{constructive}.  Here, one starts
with $\N$---as given by axioms, namely 
\begin{itemize}
\item  
 $0\neq n+1$ for any $n$ in $\N$, 
\item
$\forall x\qsep\forall y\qsep(x+1=y+1\to x=y)$, and 
\item 
for all
subsets $A$ of $\N$, if $0\in A$, and $n+1\in A$ whenever $n\in A$,
then $A=\N$.
\end{itemize}
  Then, using $\N$, one defines $\Z$ and the Archimedean
ordered field $\Q$.
Finally, it is possible to define an ordered field-structure on the
set of all \emph{convex open subsets} of $\Q$ that have upper but not lower
bounds.  The result is a complete ordered field, and $\R$ can be
\emph{defined} to be this field.

Again, we are taking the axiomatic approach to $\R$, and not the
constructive approach.  But we shall see presently why the
constructive approach works.

A subset $A$ of an ordered field $K$ is called \defn{dense} in $K$ if every
interval of $K$ contains an element of $A$.

\begin{lemma*}
  $\Q$ is dense in $\R$.
\end{lemma*}

\begin{proof}
  It is enough to show that if $a,b\in\R$ and $a<b$, then $a<c<b$ for
  some $c$ in $\Q$.  But since $a<b$, we have $0<b-a$.  
From an earlier lemma, since $\R$ is Archimedean, we conclude that
  some positive rational number $r$ satisfies $r<b-a$.  We may assume
  (why?) that $r=2/n$ for some natural number $n$.  Then $nb-na>2$.
  Therefore
  \begin{equation*}
    na<\floor{nb}-1<\floor{nb}\leq nb
  \end{equation*}
(why?).  Finally, $a<(\floor{nb}-1)/n<b$, and $(\floor{nb}-1)/n\in\Q$.
\end{proof}

\begin{theorem*}
  There is a one-to-one correspondence between:
  \begin{itemize}
    \item
real numbers, and
\item
convex open subsets of $\Q$ that are bounded above, but not below.
  \end{itemize}
\end{theorem*}

\begin{proof}
  The correspondence is given by the function
  \begin{equation*}
    x\mapsto\{r\in\Q:r<x\}
  \end{equation*}
(why?).
\end{proof}

\begin{exercise}
  Supply the details in the proof of the last theorem.
\end{exercise}

(If $A$ is a convex subset of $\Q$ with an upper but not a lower bound,
then the pair $(A,\Q\setminus A)$ is called a \tech{cut}.  It was
Dedekind who first defined the real numbers in terms of cuts.)

\news[Topology of the real numbers]

\tech{Topology} is the study of open and closed sets as such.

\begin{theorem*}
  $\R$ and $\emptyset$ are open subsets of $\R$.  If $A$ and $B$ are
  open subsets of $\R$, then so is $A\cap B$.  If $\{U_i:i\in I\}$ is
  a family of open subsets of $\R$, then the union
  \begin{equation*}
    \bigcup_{i\in I}U_i
  \end{equation*}
is open.
\end{theorem*}

\begin{proof}
  It is trivial that $\R$ and $\emptyset$ are open.  If $A$ and $B$
  are open, and $x\in A\cap B$, then $x\in A$ and $x\in B$, so there
  are positive reals $\epsilon_A$ and $\epsilon_B$ such that
  \begin{equation*}
    (x-\epsilon_S,x+\epsilon_S)\included S
  \end{equation*}
when $S\in\{A,B\}$.  Let $\epsilon=\min\{\epsilon_A,\epsilon_B\}$; then
  \begin{equation*}
    (x-\epsilon,x+\epsilon)\included A\cap B.
  \end{equation*}
Thus $A\cap B$ is open.
Finally, if $U_i$ is open for \emph{each} $i$ in the index-set $I$,
and $x\in\bigcup_{i\in I}U_i$, then $x\in U_i$ for \emph{some} $i$ in
$I$, so $(x-\epsilon,x+\epsilon)\included U_i$, and therefore
\begin{equation*}
  (x-\epsilon,x+\epsilon)\included\bigcup_{i\in I}U_i.
\end{equation*}
Therefore $\bigcup_{i\in I}U_i$ is open.
\end{proof}

\begin{exercise}
  Prove that:
  \begin{itemize}
    \item
 $\R$ and $\emptyset$ are closed subsets of $\R$;
\item
if $A$ and $B$ are
  closed subsets of $\R$, then so is $A\cup B$;
\item
if $\{F_i:i\in I\}$ is
  a family of closed subsets of $\R$, then the intersection
  \begin{equation*}
    \bigcap_{i\in I}F_i
  \end{equation*}
is closed.
  \end{itemize}
\end{exercise}

An arbitrary \emph{intersection} of open sets may not be open:

\begin{example*}
  $\displaystyle\bigcap_{n\in\N}\left(-\frac1{n+1},\frac 1{n+1}\right)
  =\{0\}$.
\end{example*}

\begin{exercise}
  Show that the only subsets of $\R$ that are both open and closed are
  $\emptyset$ and $\R$ itself.
\end{exercise}

(The exercise shows that $\R$ is \tech{connected}.)


\news[The Cantor set]
By definition, a non-empty open subset of $\R$ includes an open
interval.  Does a non-empty closed set include a closed interval?

No.  Every set $\{x\}$ is closed; hence (by an exercise) every finite
set is closed.  The infinite set $\Z$ is closed; so is the infinite
bounded set 
$$\{0\}\cup\{\frac 1{n+1}:n\in\N\}.$$
But none of these sets includes an interval.

 We can obtain a `large' bounded closed set that includes no intervals 
in the following way.  Start with a closed interval.  Remove an open
interval, so two closed intervals remain.  Remove an open interval
from each of these, and continue.  In the end, no interval can remain.

More precisely, we define the \defn{Cantor set} as the intersection
$$\bigcap_{n\in\N}F_n,$$
where
\begin{gather*}\textstyle
  F_0 =\left[0,1\right],\\
F_1 =\left[0,\frac13\right]\cup\left[\frac23,1\right],\\
F_2 =\left[0,\frac19\right]\cup\left[\frac29,\frac13\right]\cup
\left[\frac23,\frac79\right]\cup\left[\frac89,1\right],
\end{gather*}
and so on.  

How can we make the words `and so on' precise?
We want $F_0$ to be $[0,1]$, and we want each $F_n$ to be the disjoint
union of $2^n$ intervals of 
length $1/3^n$.  If $[a,b]$ is one of these intervals, then
$$[a,\frac13(2a+b)]\text{ and }[\frac13(a+2b),b]$$
should be among the intervals that make up $F_{n+1}$.  

Then in fact we can define
$$F_n=\bigcup\left\{\left[\sum_{i<n}\frac{2e_i}{3^{1+i}},
  \sum_{i<n}\frac{2e_i}{3^{1+i}}+\frac1{3^n}\right]:
  e_0,\dots,e_{n-1}\in\{0,1\}\right\}.$$ 

\begin{exercise}
Show that, under our definition, $F_n$ meets the desired conditions.
Then show that the Cantor set is closed, but none of its subsets is an
interval. 
\end{exercise}

\news[Binary expansions]
Let $2^{\N}$ stand for the set of sequences $(a_n:n\in\N)$ such that
$a_n\in\{0,1\}$ in each case. 

  \begin{theorem*}
    For each real number $x$ in the interval $[0,2)$ there is a
    unique sequence $(a_n)$ in $2^{\N}$ such that
    \begin{equation}\label{eqn:interval}
          x\in\left[\sum_{k=0}^n\frac{a_k}{2^k}, 
\sum_{k=0}^n\frac{a_k}{2^k}+\frac1{2^{n}}\right)
    \end{equation}
for each $n$ in $\N$, and for each $n$ there is $k$ such that $k>n$
and $a_k=0$.
In fact, $x$ is the unique real number that satisfies
(\ref{eqn:interval}) in each case.  Conversely, suppose $(a_n:n\in\N)$ is
an element of $2^{\N}$ such that, for all $n$, there is $k$ such that
$k>n$ and $a_k\neq0$.  Then there is a real number $x$ satisfying
(\ref{eqn:interval}) in each case.
\end{theorem*}

  \begin{proof}
    Define $(a_n)$ recursively, as in the proof that an Archimedean
    ordered field is complete if every sequence of nested bounded
    closed intervals has non-empty intersection.  So, we first define
$$a_0=
    \begin{cases}
      0,& \text{ if $x\in[0,1)$;}\\
      1,& \text{ if $x\in[1,2)$.}
    \end{cases}$$
Then $x\in[a_0,a_0+1)$.  Suppose $a_k$ have been chosen when $k\leq n$
  so that  
$$x\in\left[a_0+\frac {a_1}{2}+\frac {a_2}{2^2}+\dots+\frac{a_n}{2^n}, 
a_0+\frac {a_1}{2}+\frac {a_2}{2^2}+\dots+\frac{a_n+1}{2^{n}}\right).$$ 
Write $b_n$ for $\sum_{k=0}^n{a_k}/{2^k}$; so
$x\in[b_n,b_n+1/2^n)$.  Then define
$$a_{n+1}=
  \begin{cases}
    0,& \text{ if $x\in[b_n,b_n+1/{2^{n+1}})$;}\\
1,& \text{ if $x\in[b_n+1/{2^{n+1}},b_n+ 1/{2^n})$.}
  \end{cases}$$
By recursion, $a_n$ is defined for all $n$ in $\N$.  Also, $x$ is
the \emph{unique} member of the intersection
$$\bigcap_{n\in\N}\left[\sum_{k=0}^n\frac{a_k}{2^k}, 
\sum_{k=0}^n\frac{a_k}{2^k}+\frac1{2^{n}}\right)$$
(why?).  The converse holds as well (why?).
  \end{proof}

  \begin{exercise}
    Complete the last proof.
  \end{exercise}

With $x$ and $a_n$ as in the theorem, we can write
$$x=\sum_{n\in\N}\frac{a_n}{2^n}.$$

\begin{example*}
  By the high-school rule for the sum of a geometric series, we have
$$\sum_{n\in\N}\frac 1{4^n}=\frac1{1-\frac14}=\frac43.$$
We haven't formally proved this rule.  However, we can show by
induction that
$$\frac43-\sum_{k=0}^n\frac1{4^k}=\frac1{3\cdot 4^n}$$
for each $n$ in $\N$.  Hence
$$\frac43\in\left[\sum_{k=0}^n\frac1{4^k}+\frac1{4\cdot 4^n},
  \sum_{k=0}^n\frac1{4^k} +\frac1{2\cdot 4^n}\right).$$
Note that $1/4^k=1/2^{2k}+0/2^{2k+1}$.  So define
$$a_j=
\begin{cases}
  1,&\text{ if $j$ is even;}\\
0,&\text{ if $j$ is odd.}
\end{cases}$$
Then
$$\frac43\in 
\left[\sum_{j=0}^{2n+1}\frac{a_j}{2^j},
  \sum_{j=0}^{2n+1}\frac{a_j}{2^j}+\frac 1{2^{2n+1}}\right)
\included
\left[\sum_{j=0}^{2n}\frac{a_j}{2^j},
  \sum_{j=0}^{2n}\frac{a_j}{2^j}+\frac 1{2^{2n}}\right).$$ 
By the theorem, we have
$$\frac43=\sum_{j\in\N}\frac{a_j}{2^j}.$$
\end{example*}

\begin{exercise}
  Give the proof by induction mentioned in the example.  More
  generally, prove
$$\frac{x}{x-1}-\sum_{k=0}^n\frac1{x^n}=\frac 1{(x-1)x^n}$$
when $x$ is not $0$ or $1$.
\end{exercise}

In general, if $b$ is an integer greater than $1$, then for each $x$
in $[0,b)$ there is a sequence $(c_n:n\in\N)$ of elements of
  $\{0,1,2,\dots,b-1\}$ such that $x$ can be written as the infinite
  sum
$$\sum_{n\in\N}\frac{c_n}{b^n}.$$
If $b=10$, then we get the usual \tech{decimal expansion} 
$$c_0.c_1c_2c_3\dots$$
of a number
in $[0,10)$.

\news[Cardinality]

The Cantor set is large in the sense that it is \tech{uncountable}.

Two sets $A$ and $B$ have the same \defn{cardinality}, or are
\defn{equipollent}, if there is a bijection from $A$ to $B$.  In this
case we write
$$A\equip B.$$
If there is an \emph{injection} from $C$ to $D$, we write
$$C\injects D;$$
if also $C$ and $D$ are \emph{not} equipollent, then we write
$$C\prec D.$$ 

\begin{theorem*}
  $A\prec \pow{A}$.
\end{theorem*}

\begin{proof}
  The map $x\mapsto\{x\}:A\to\pow A$ is an injection, so $A\injects
  \pow A$.  Suppose $f:A\to\pow A$ is an injection.  Let
$$B=\{x\in A:x\notin f(x)\}.$$
If $x\in B$, then $x\notin f(x)$, so $B\neq f(x)$.  If $x\in
A\setminus B$, then $x\in f(x)$, so $B\neq f(x)$.  Thus $B$ is not in
the range of $f$, so $f$ is not a bijection.
\end{proof}

\begin{theorem*}[Schr\"oder--Bernstein]
  $A\injects B\land B\injects A\implies A\equip B$.
\end{theorem*}

A set $A$ is called \defn{countable} if
$$A\injects\N,$$
and \defn{uncountable} if $\N\prec A$.  It is a consequence of the
\tech{Axiom of Choice} of set theory that every set is countable or
uncountable in this sense.

\begin{theorem*}
$\Z$ and  $\Q$ are countable.
\end{theorem*}

\begin{proof}
  By the Schr\"oder--Bernstein theorem, since $\N\included
  \Z\included\Q$, it is enough to show that $\Q\injects\Z\injects\N$.
  The function 
$$n\mapsto2\abs{n}+\frac{n+\abs n}{2\abs n}:\Z\to\N$$
is injective, so $\Z\injects\N$.  Let
$$p_0,p_1,p_2,\dots$$
be the list of prime numbers.  Each rational number $x$ can be written 
$$\pm\frac{p_0^{a_0}\cdot p_1^{a_1}\cdots p_{k-1}^{a_{k-1}}}
{p_0^{b_0}\cdot p_1^{b_1}\cdots p_{k-1}^{b_{k-1}}},$$
for some $k$ in $\N$, where the $a_i$ and $b_i$ are in $\N$, and
$$a_ib_i=0$$
in each case.
Then define $f(x)$ to be
$$\pm p_0^{a_0}\cdot p_1^{b_0}\cdot p_2^{a_1}\cdot p_3^{b_1}\cdots
p_{2k-2}^{a_{k-1}}\cdot p_{2k-1}^{b_{k-1}}.$$
The function $f$ is an injection from $\Q$ to $\Z$, so $\Q\injects\Z$.
\end{proof}

\begin{lemma*}
  $\pow{\N}\equip 2^{\N}$.
\end{lemma*}

\begin{proof}
If $A\included\N$, let $\chi_A$ be the function
\begin{equation*}
n\mapsto
\begin{cases}
  1, &\text{ if $n\in A$;}\\
  0, &\text{ if $n\notin A$}
\end{cases}
\end{equation*}
mapping $\N$ into $\{0,1\}$.  Then the function
$$A\mapsto\chi_A:\pow{\N}\to 2^{\N}$$
is a bijection.
\end{proof}

\begin{lemma*}
  The Cantor set is equipollent with $2^{\N}$.
\end{lemma*}

\begin{proof}
Let $f$ be the function from $2^{\N}$ to $\R$ such that
$f(e_n:n\in\N)$ is the unique element of the intersection
$$\bigcap_{n\in\N}\left[\sum_{i<n}\frac{2e_i}{3^{1+i}},
  \sum_{i<n}\frac{2e_i}{3^{1+i}}+\frac1{3^n}\right].$$ 
Then $f$ is injective, and its range is the Cantor set.
\end{proof}

Hence the Cantor set, and therefore $\R$ itself, are uncountable.

\begin{theorem*}
  $\R\equip\pow{\N}$.
\end{theorem*}

\begin{proof}
We have $2^{\N}\injects\R$ by the last lemma.  Also,
  $[0,2)\injects 2^{\N}$ by the last section.  But the function $f$ on
  $\R$ given by
$$f(x)=
  \begin{cases}
    1/(x+1),\text{ if $0\leq x$;}\\
(2x-1)/(x-1),\text{ if $x<0$}
  \end{cases}$$
is a bijection between $\R$ and $(0,2)$ (why?); so $\R\injects[0,2)$.
  All together, we
  have
$$\R\injects 2^{\N}\injects\R,$$
so $R\equip 2^{\N}$ by the Schr\"oder--Bernstein theorem.
\end{proof}

\begin{exercise}
  Answer the `why' in the last proof, \emph{without} using calculus.
\end{exercise}

\input{exercises.tex}
\input{metric.tex}
\input{limits}
\input{continuity}
\input{differentiation} 

\tableofcontents
\end{document}
