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

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

\renewcommand{\theequation}{\roman{equation}}
\pagestyle{myheadings}
\markboth{David Pierce, \today}{\today, Analysis II notes}

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

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

\begin{document}
\pagenumbering{roman}
%\renewcommand{\thepage}{\roman{page}}
%\renewcommand{\labelpage}{(\thepage)}
\maketitle
%\thispagestyle{empty}
These notes are for Math 272 at METU.  I intend to edit them and add
   to them from time to time; the latest version is in the course
   directory,
   \url{<http://www.math.metu.edu.tr/~dpierce/courses/272/>}.  The
   catalog description of the 
   course is: 
   \begin{quote}
     Riemann--Stieltjes Integral. Infinite series and
   products. Sequences of functions. Inverse Function Theorem.
   Multiple Integrals.
\end{quote}  
These topics are covered in \cite[chs 7, 8, 9, 12, 13 and
   14]{MR49:9123}.  This book will be my main
   reference, although \cite{MR52:14179} may also be useful.  I shall
   also cover functions of bounded variation 
   (in \cite[ch.~6]{MR49:9123}), a topic left over from Math
   271.  My proof of Theorem \ref{thm:sf:diff} below is based on that
   of \cite[ch.~1, \S~1, Proposition~6]{MR87h:30001}; my
   \S\S~\ref{sect:diff} and \ref{sect:int} are influenced by
   \cite[chs~2 and 3]{MR35:309}.

I prepare
the notes, first of all, for my own use.
They are only an outline of what is to be discussed
in class.  In particular, for the student, reading
these notes is probably not an adequate substitute for coming to
class.  Your own notes, taken properly in class, will be richer and
more complete than these notes.

The parts of these notes labelled
`proof' are generally only sketches of proofs.  I leave it to the
reader both:
\begin{itemize}
  \item
to recognize where details are missing, and
\item
to supply those details.
\end{itemize}
I might give the details in class, especially if I am asked to.  I
myself might ask for the details on an exam. 

Some proofs are omitted entirely and are thus left to be given in
class or to be done as exercises.  These proofs too
might be asked for on an exam.

I do intend to write my proofs (or proof-sketches) in complete
sentences, with the
usual sorts of punctuation (commas, semicolons, full stops/periods).
Like any other writing (in English and Turkish and many other
languages), the proofs are to be read left to right, top to bottom.
Students should follow this example in writing their own complete
proofs. 

Every time a new class of functions (for example) is introduced, one
should ask:  What are some examples of functions that belong to this
class?  Which functions do \emph{not} belong to this class?

Likewise, when a theorem is introduced, one should ask:  What sorts of
functions does the theorem apply to?  What does the theorem \emph{not}
tell us?  For example, if the theorem is an implication (an if-then
statement), then can we prove the converse, or is there a
counter-example?  

Examples and counter-examples could be requested on
an exam.

In studying the \emph{proof} of a theorem, one should ask:  What
previous lemmas and theorems does the proof rely on?  Is the proof in
the style of earlier proofs; does it use familiar techniques; or does
it introduce a new approach?  Will a similar proof work to prove
something else?  Is there an alternative proof?

\bibliographystyle{plain}
\bibliography{../../math/references}

\tableofcontents

\newpage
\pagenumbering{arabic}

%\setcounter{page}{1}

%\renewcommand{\thepage}{\arabic{page}}
%\renewcommand{\labelpage}{\thepage}
\section{Variation}

Here are some conventions, definitions and notations to be used
throughout this section:

Let $I$ be a compact interval of $\R$; so $I$ is $[a,b]$ for some
numbers $a$ and $b$.
Let $f$ be a real-valued function on $I$.  A \defn{partition} of $I$
is a subset that: 
\begin{itemize}
  \item
is finite, and
\item
contains the endpoints $a$ and $b$.
\end{itemize}
Let $P$ be a partition of $I$.  We may also write $P$ as
\begin{equation*}
  \{x_0,x_1,\dots,x_n\}
\end{equation*}
for some positive integer $n$, where
\begin{equation*}
  a=x_0<x_1<\dots<x_n=b.
\end{equation*}
If $0<k\leq n$, then for $x_k-x_{k-1}$ we may write 
\begin{equation*}
  \chng x_k,
\end{equation*}
and for $f(x_k)-f(x_{k-1})$ we may write 
\begin{equation*}
  \chng f_k.
\end{equation*}
For $\sum_{k=1}^n\abs{\chng f_k}$ we may write 
\begin{equation*}
  \sum(P).
\end{equation*}
The set of partitions of $I$ can be denoted
\begin{equation*}
  \partit I.
\end{equation*}
(This is \emph{not} the power-set of $I$!)  Suppose there is a number
$M$ such that for \emph{all} $P$ in
$\partit I$ we have $\sum(P)\leq M$.  Then $f$ is said to be
\defn{of bounded variation} on $I$.  In this case, the supremum of the
set $\{\sum(P):P\in\partit I\}$ exists; this supremum is called the
\defn{total variation} of $f$ on $I$, and can be denoted
\begin{equation*}
  V_f I
\end{equation*}
or just $V_f$.  Note that total
  variation is always non-negative.  We may say that $f$ itself is
  \defn{bounded on $I$ by
  $A$} if $\abs{f(x)}\leq A$ for all $x$ in $I$.  

What sorts of functions are of bounded variation?  How bad can a
function be while still being of bounded variation?

\begin{theorem}\label{thm:bv:monot}
  Suppose $f$ is monotone on $I$.  Then $f$ is of bounded variation on $I$,
  and in fact 
  \begin{equation*}
      V_f I=\abs{f(b)-f(a)}.
  \end{equation*}
In particular, constant functions $x\mapsto a$ and the
identity-function $x\mapsto x$ are of bounded variation on any compact
interval. 
\end{theorem}

Recall that monotonicity does not imply continuity.  So, functions of
bounded variation need not be continuous.

The converse of Theorem \ref{thm:bv:monot} fails: consider $x\mapsto
x^2:[-1,1]\to \R$.

\begin{theorem}
  If $f$ is of bounded variation on $I$, then $f$ is bounded on $I$,
  and in fact
  \begin{equation*}
    \abs{f(x)}\leq V_f+\abs{f(a)}
  \end{equation*}
 for all $x$ in $I$.
\end{theorem}

\begin{proof}
  Suppose $f$ is of bounded variation.  If $x\in I$, let $P_x$ be the
  partition $\{a,x,b\}$ of $I$.  Then
  \begin{equation*}
    \abs{f(x)}-\abs{f(a)}\leq \abs{f(x)-f(a)}\leq \abs{f(x)-f(a)}+
    \abs{f(b)-f(x)} =\sum(P_x)\leq V_f,
  \end{equation*}
which yields the claim.
\end{proof}

The converse fails: consider $x\mapsto
\begin{cases}
  x\sin\frac 1x,& \text{ if }x\in(0,1];\\
  0            ,& \text{ if }x=0.
\end{cases}$

\begin{theorem}
  Suppose $f$ and $g$ are of bounded variation on $I$.  Then so are
  $f+g$ and $f-g$, and in fact
  \begin{equation*}
    V_{f\pm g}\leq V_f+V_g.
  \end{equation*}
Moreover, $f\cdot g$ is also of bounded variation on $I$, and if $A$
bounds $f$ and $B$ bounds $g$ on $I$, then 
\begin{equation*}
  V_{f\cdot g}\leq B\cdot V_f+ A\cdot V_g.
\end{equation*}
\end{theorem}

Consequently, all polynomial functions are of bounded variation on
compact intervals.

\begin{lemma}\label{lem:bv:finer}
  If $P$ and $Q$ are partitions of $I$ such that $P\included Q$, then
  \begin{equation*}
      \sum(P)\leq\sum(Q).
  \end{equation*}
\end{lemma}

\begin{theorem}\label{thm:bv:unions}
  Suppose $x\in(a,b)$.  Then $f$ is of bounded variation on $[a,b]$ if
  and only if it is of bounded variation on both $[a,x]$ and $[x,b]$.
  In either case, 
  \begin{equation*}
    V_f[a,b]=V_f[a,x]+V_f[x,b].
  \end{equation*}
\end{theorem}

\begin{proof}
  Say $f$ is of bounded variation on $[a,b]$.  Let $Q$ be a
  partition of $[a,x]$, and $R$ be a partition of $[x,b]$.  Then
  $Q\cup R$ is a partition of
  $[a,b]$.  Hence 
  \begin{equation*}
      \sum(Q)+\sum(R)=\sum(Q\cup R)\leq V_f[a,b].
  \end{equation*}
  Therefore
  $f$ is of bounded variation on $[a,x]$ and on $[x,b]$, and
  \begin{equation}\label{eqn:var1}
      V_f[a,x]+V_f[x,b]\leq V_f[a,b].
\end{equation}
Conversely, say $f$ is of bounded variation both on $[a,x]$ and on
$[x,b]$.  If $P$ is a partition of $[a,b]$, then so is $P\cup\{x\}$,
and the latter is $Q\cup R$ for some partitions $Q$ and $R$ of $[a,x]$
and $[x,b]$ respectively.  Hence (by Lemma \ref{lem:bv:finer})
\begin{equation*}
  \sum(P)\leq \sum(P\cup\{x\})= \sum(Q)+\sum(R)\leq V_f[a,x]+V_f[x,b].
\end{equation*}
Therefore $f$ is of bounded variation on $[a,b]$,
and 
\begin{equation}\label{eqn:var2}
  V_f[a,b]\leq V_f[a,x]+V_f[x,b].
\end{equation}
Either of the foregoing hypotheses now yields the other and hence
yields both \pref{eqn:var1} and \pref{eqn:var2}.
\end{proof}

Theorem \ref{thm:bv:unions} (with Theorem \ref{thm:bv:monot}) gives another
proof that polynomial functions are of bounded variation on compact
intervals. 

\begin{theorem}\label{thm:bv:bdd-suff}
  Suppose that $f$ is continuous on $[a,b]$ and differentiable on
  $(a,b)$ and that $f'$ is bounded on $(a,b)$.  Then $f$ is of bounded
  variation on $[a,b]$. 
\end{theorem}

\begin{proof}
  For every partition $\{x_0,\dots,x_n\}$ in $\partit[a,b]$, for every
  $k$ in $\{1,\dots,n\}$, by the Mean-Value Theorem there is $t_k$ in
  $(x_{k-1},x_k)$ such that 
  \begin{equation*}
    \frac{\chng f_k}{\chng x_k}=f'(t_k).
  \end{equation*}
Hence, if $A$ is an upper bound of $\{f'(x):x\in(a,b)\}$, then
\begin{equation*}
  \sum_{k=1}^n\abs{\chng f_k}=\sum_{k=1}^n\abs{f'(t_k)}\chng x_k
  \leq\sum_{k=1}^n A\chng x_k=A(b-a),
\end{equation*}
so $f$ is of bounded variation by definition.
\end{proof}

Hence for example the function 
\begin{equation*}
  x\mapsto
\begin{cases}
  x\sin\log x,&\text{ if }x\in(0,1];\\
0,&\text{ if }x=0
\end{cases}
\end{equation*} 
is of bounded variation.
The converse of Theorem \ref{thm:bv:bdd-suff} fails: consider
$x\mapsto\radix x:[0,1]\to\R$. 

\begin{theorem}
  Suppose $f$ is of bounded variation on $I$.  Then the functions
  $x\mapsto V_f[a,x]$ and $x\mapsto V_f[a,x]-f(x)$ are increasing on
  $I$. 
\end{theorem}

\begin{proof}
Suppose $a\leq x\leq y\leq b$.  By Theorem \ref{thm:bv:unions}, we have
\begin{equation*}
  V_f[a,x]\leq V_f[a,y].
\end{equation*}
Hence $x\mapsto V_f[a,x]$ is increasing.  We also have
\begin{equation*}
  V_f[a,x]+ f(y)-f(x) \leq V_f[a,x]+ \abs{f(y)-f(x)} \leq V_f[a,x]+
  V_f[x,y]=V_f[a,y],
\end{equation*}
whence $V_f[a,x]-f(x)\leq V_f[a,y]-f(y)$.  Therefore $x\mapsto
V_f[a,x]-f(x)$ is increasing.
\end{proof}

In the proof, note that if, for example, $x=y$, then $[x,y]$ is not in
fact an interval, although we can still understand the total variation
$V_f[x,y]$ to be $0$.

\begin{theorem}\label{thm:bv:diff}
  A function is of bounded variation if and only if it is the
  difference of two increasing functions.
\end{theorem}

\begin{lemma}
  Suppose $f$ is of bounded variation on $[a,b]$, and $c\in[a,b]$.
  Then $f$ is continuous at $c$ if and only if $x\mapsto V_f[a,x]$ is
  continuous at $c$.
\end{lemma}

\begin{proof}[Proof (not given in class)]
  Let $V$ be the increasing function $x\mapsto V_f[a,x]$.  If $a\leq
  x\leq y\leq b$, then
  \begin{equation*}
    0\leq\abs{f(y)-f(x)}\leq V_f[x,y]=V(y)-V(x).
  \end{equation*}
Hence continuity of $V$ implies that of $f$.

Suppose conversely that $f$ is continuous at $c$.  Let $\epsilon>0$.
It is enough to find positive numbers $\delta_{\ell}$ and
$\delta_{\mathrm r}$ such that, for all $x$ in $[a,b]$,
we have the two implications
\begin{gather*}
  c-\delta_{\ell}<x\leq c\implies V(c)-V(x)<\epsilon,\\
  c\leq x< c+\delta_{\mathrm r}\implies V(x)-V(c)<\epsilon.
\end{gather*}
Now, by continuity of $f$ at $c$, we can pick a positive $\delta$ so that,
for all $x$ in $[a,b]$, 
\begin{equation*}
  c-\delta<x<c+\delta'\implies\abs{f(c)-f(x)}<\frac{\epsilon}2.
\end{equation*}
There is a partition $P$ of
$[a,c]$ such that, for all finer partitions
$\{u_0,\dots,u_m\}$, we have
\begin{equation*}
V(c)\leq\sum_{k=1}^m\abs{\chng f_k}+{\epsilon}/2.
\end{equation*}
Let $y$ be the greatest element of $P\setminus\{c\}$, and let 
\begin{equation*}
  \delta_{\ell}=\min(c-y,\delta).
\end{equation*}
Suppose $c-\delta_{\ell}<x<c$.  We may assume $u_{m-1}=x$; hence
\begin{equation*}
  V(c)\leq \sum_{k=1}^{m-1}\abs{\chng f_k}+\epsilon\leq
  V(x) + \epsilon.
\end{equation*}
Thus we have the first implication above; the second is obtained
similarly. 
\end{proof}

\begin{theorem}
  A continuous function is of bounded variation if and only if it is
  the difference of two continuous increasing functions.
\end{theorem}

\section{The Riemann--Stieltjes Integral}

Let us continue to use the notation of the previous section, letting
also $g$ be a real-valued function on $I$.
If $g$ is in fact differentiable, and if one writes $g'(x)$ as
$\dee g/\dee x$, then one might write $g'(x)\dee x$ as  $\dee g$, and
$\int_a^b f(x)g'(x)\dee x$ as $\int_a^b f\dee g$.  If $f$ is also
differentiable, then the rule of integration by parts is
\begin{equation}\label{eqn:rs:parts}
  \int_a^b f\dee g= f(b)g(b)-f(a)g(a)-\int_a^b g\dee f.
\end{equation}
We shall show that this equation is meaningful and true even if $f$
and $g$ are not differentiable.

If $P,Q\in\partit I$, and $P\included Q$, let us say that $Q$ is
\defn{finer} than $P$ (also, $P$ is \defn{coarser} than $Q$).

\begin{theorem}\label{thm:rs:E}
There is at most one number $A$ such that, for every positive
$\epsilon$, there is a 
partition $P$ of $I$ such that, for all partitions $\{u_0,\dots,u_m\}$
of $I$ that are finer than $P$, and for all $t_k$ in $[u_{k-1},u_k]$
(where $k\in\{1,2,\dots,m\}$),
\begin{equation*}
  \abs{\sum_{k=1}^m f(t_k)\chng g_k-A}<\epsilon.
\end{equation*}
\end{theorem}

The sum in the theorem is a \defn{Riemann--Stieltjes sum} of $f$ with
respect to $g$ for the partition $P$.
If the number $A$ exists, it is denoted
\begin{equation*}
  \int_a^bf\dee g.
\end{equation*}
This is a \defn{Riemann--Stieltjes integral}, and in particular it is the
Riemann integral of $f$ on $I$ \emph{with respect to} $g$.  The set of
all functions $f$ on $I$ whose Riemann integrals with
respect to $g$ exist is denoted
\begin{equation*}
  R(g).
\end{equation*}
If $g$ is differentiable, with constant derivative $1$, then
$\int_a^bf\dee g$ is just $\int_a^b f$, the ordinary Riemann
integral. 

\begin{theorem}\label{thm:rs:parts}
  If $f\in R(g)$, then $g\in R(f)$, and also equation
  \pref{eqn:rs:parts} holds. 
\end{theorem}

\begin{proof}
  Let $\{x_0,\dots,x_n\}$ be a partition $P$ as in Theorem
  \ref{thm:rs:E}.  Choose some $t_k$ in $[x_{k-1},x_k]$.  Then
  \begin{gather*}
   f(b)g(b)-f(a)g(a)- \sum_{k=1}^n g(t_k)\chng f_k=\\
 \sum_{k=1}^nf(x_k)g(x_k)-\sum_{k=1}^nf(x_{k-1})g(x_{k-1}) - \sum_{k=1}^n
    g(t_k)f(x_k) + \sum_{k=1}^n g(t_k)f(x_{k-1})=\\
\sum_{k=1}^nf(x_k)(g(x_k)-g(t_k))
 +\sum_{k=1}^nf(x_{k-1})(g(t_{k})-g(x_{k-1})).
  \end{gather*}
This is a Riemann--Stieltjes sum for $f$ with respect to $g$
corresponding to the partition
$\{x_0,t_1,x_1,\dots,x_{n-1},t_n,x_n\}$.  This partition is finer than
$P$, so the sum is within $\epsilon$ of $\int_a^bf\dee g$.  Therefore
the Riemann--Stieltjes sum $\sum_{k=1}^n g(t_k)\chng f_k$ is within
$\epsilon$ of $f(b)g(b)-f(a)g(a)-\int_a^bf\dee g$.
\end{proof}

\begin{theorem}\label{thm:rs:vector}
  $R(g)$ is a vector-space, that is, it contains the $0$-function and
  is also closed under the taking of linear combinations.  In fact, if
  $f_i\in R(g)$ and $a_i\in\R$ (where $i<n$), then
  \begin{equation*}
    \int_a^b\sum_{i<n} a_if_i\dee g=\sum_{i<n} a_i\int_a^bf_i\dee g.
  \end{equation*}
Hence also 
\begin{equation*}
  \bigcap_{i<n}R(f_i)\included R\big(\sum_{i<n}a_if_i\big),
\end{equation*}
and if $g\in\bigcap_{i<n}R(f_i)$, then
\begin{equation*}
  \int_a^b g\dee\sum_{i<n}a_if_i=\sum_{i<n}a_i\int_a^b g\dee f_i.
\end{equation*}
\end{theorem}

If $\int_a^bf\dee g$ exists, then we may define 
\begin{equation*}
  \int_b^af\dee g=-\int_a^b f\dee g.
\end{equation*}
Also, $\int_a^af\dee g=0$.
\begin{theorem}
  If $x\in I$, and any two of the three integrals
  \begin{equation*}
    \int_a^x f\dee g,\qquad \int_x^b f\dee g,\qquad \int_b^a f\dee g
  \end{equation*}
exist, then they all exist, and their sum is $0$.
\end{theorem}

\begin{theorem}
  Let $h$ be an increasing bijection from an interval $[c,d]$ onto
  $[a,b]$.  If $f\in R(g)$, then $f\circ h\in R(g\circ h)$, and
  \begin{equation*}
    \int_c^d f\circ h\dee(g\circ h)=\int_{h(c)}^{h(d)}f\dee g.
  \end{equation*}
\end{theorem}

\begin{proof}
  Pick $P$ as in Theorem \ref{thm:rs:E}.  This determines a partition
  $h\inv(P)$ of $[c,d]$.  A Riemann--Stieltjes sum of $f\circ h$ on
  $[c,d]$ with respect to $g\circ h$ for a partition
  finer than $h\inv(P)$ can be understood as a Riemann--Stieltjes sum
  of $f$ on $[a,b]$ with respect to $g$ for a partition
  finer than $P$; hence it is within $\epsilon$ of $\int_a^bf\dee g$.
\end{proof}

\begin{theorem}\label{thm:rs:g'}
  If $f$ is bounded on $I$, and $f\in R(g)$, and $g$ has a continuous
  derivative on $I$, then $fg'$ is Riemann-integrable on $I$, and
  \begin{equation*}
    \int_a^bfg'=\int_a^bf\dee g.
  \end{equation*}
\end{theorem}

\begin{proof}
  For any partition $\{x_0,\dots,x_n\}$ of $I$, by the Mean-Value
  Theorem, there are $u_k$ in $(x_{k-1},x_k)$ such that $\chng
  g_k=g'(u_k)\chng x_k$.  Hence, for any $t_k$ in $[x_{k-1},x_k]$, the
  Riemann--Stieltjes sum
  \begin{equation*}
    \sum_{k=1}^nf(t_k)\chng g_k
  \end{equation*}
is precisely 
\begin{equation*}
\sum_{k=1}^nf(t_k)g'(u_k)\chng x_k. 
  \end{equation*}
We have
\begin{equation*}
  \abs{\sum_{k=1}^nf(t_k)g'(u_k)\chng x_k-\sum_{k=1}^nf(t_k)g'(t_k)\chng x_k}
=  \sum_{k=1}^nf(t_k)\abs{g'(u_k)-g'(t_k)}\chng x_k.
\end{equation*}
Since $f$ is bounded on $I$, and $g'$---being continuous on a compact
interval---is uniformly continuous on $I$, we conclude that,
in the last equation, the right member can be made smaller than
$\epsilon/2$, provided that the partition $\{x_0,\dots,x_n\}$ is
sufficiently fine.  This
partition can also be fine enough that the sum $\sum_{k=1}^nf(t_k)\chng
g_k$ is within $\epsilon/2$ of $\int_a^bf\dee g$.  In this case, we
have
\begin{equation*}
  \abs{\int_a^bf\dee g-\sum_{k=1}^nf(t_k)g'(t_k)\chng x_k}<\epsilon,
\end{equation*}
which establishes the claim.
\end{proof}

\begin{lemma}
  Suppose $u\in(a,b]$, and $f$ is continuous from the left at $u$,
  that is, for every positive $\epsilon$, there is a positive $\delta$
  such that for all $t$ in $I$,
  \begin{equation*}
    u-\delta<t\leq u\implies\abs{f(u)-f(t)}<\epsilon.
  \end{equation*}
Let $g$ be defined so that
\begin{math}
  g(x)=
  \begin{cases}
    0,&\text{ if }a\leq x<u;\\
1,&\text{ if }u\leq x\leq b.
  \end{cases}
\end{math}
Then $f\in R(g)$ and 
\begin{equation*}
  \int_a^bf\dee g=f(u).
\end{equation*}
\end{lemma}

\begin{proof}
  Suppose $s\in (a,u)$.  For every partition that is finer
  than $\{a,s,u,b\}$, every Riemann--Stieltjes sum for $f$ with
  respect to $g$ is
  \begin{equation*}
    f(t)(g(u)-g(s)),
  \end{equation*}
that is, $f(t)$, for some $t$ in $[s,u]$.  With $\epsilon$ and
$\delta$ as in the statement, if we choose $s$ in $(u-\delta,u)$, then
$\abs{f(u)-f(t)} <\epsilon$.
\end{proof}

\begin{theorem}\label{thm:rs:sum}
  Every finite sum can be expressed as a Riemann--Stieltjes integral.
  In fact, if $f$ is continuous on $[a,b]$, and $a<x_1<\dots<x_n=b$,
  then
  \begin{equation*}
    \sum_{k=1}^nf(x_k)=\int_a^bf\dee g
  \end{equation*}
for some function $g$.
\end{theorem}

\begin{proof}
  Let $g=\max\{k:x_k\leq x\}$.
\end{proof}

In the theorem and its proof, if $x_k=k$ for each $k$, then $g$ is the
greatest-integer function, $x\mapsto\floor{x}$.  Hence:

\begin{theorem}[Euler's summation-formula]
  If $f$ is continuously differentiable on $[0,n]$, then
  \begin{align*}
    \sum_{k=1}^nf(k)&=\int_0^nf+\int_0^n(x-\floor x)f'(x)\dee x;\\
    \sum_{k=0}^nf(k)&=\int_0^nf+\int_0^n\left(x-\floor
    x-\frac12\right)f'(x)\dee x +\frac12(f(n)+f(0)).\\
  \end{align*}
\end{theorem}

\begin{proof}
  Just calculate:
  \begin{multline*}
    \sum_{k=1}^nf(k)=
\int_0^nf(x)\dee\floor x=
\int_0^nf-\int_0^nf(x)\dee(x-\floor x)=\\
 \int_0^nf- \int_0^n(x-\floor x)\dee f(x)=
\int_0^nf+\int_0^n(x-\floor x)f'(x)\dee x,
  \end{multline*}
by Theorems \ref{thm:rs:sum}, \ref{thm:rs:vector}, \ref{thm:rs:parts}
and \ref{thm:rs:g'} respectively.  Note however that, to have the second
equation, we must know that $\int_a^bf$ does in fact exist.  Since $f$
is continuous, its Riemann-integrability will be a consequence of
Theorem \ref{thm:rs:cont}.  For the second equation, add $f(0)$ to
both sides, and use 
\begin{equation*}
  \int_0^nf'=f(n)-f(0),
\end{equation*}
which will be Theorem \ref{thm:rs:2}.
\end{proof}

As noted in the last proof, we need to be able to say \emph{which}
functions are Riemann-integrable with 
respect to a given function.  Towards this end, we make some
definitions---but we must assume that $f$ is bounded:
\begin{align*}
  \mn kf&=\inf\{f(x):x\in[x_{k-1},x_k]\},& \ls Pfg& 
=\sum_{k=1}^n\mn kf\chng g_k,\\
  \mx kf&=\sup\{f(x):x\in[x_{k-1},x_k]\},& \us Pfg& 
=\sum_{k=1}^n\mx kf\chng g_k.
\end{align*}

\begin{lemma}\label{lem:rs:order}
  Assume $g$ is increasing.  For all partitions $P$ and $Q$ of $I$,
  \begin{equation*}
    \ls Pfg \leq \ls {P\cup Q}fg \leq \us {P\cup Q}fg \leq \us Qfg.
  \end{equation*}
\end{lemma}

If $g$ is increasing, then by the lemma we can define
\begin{equation*}
  \underline{\int_a^b}f\dee g= \sup\{\ls Pfg:P\in\partit I\},\quad
   \overline{\int_a^b}f\dee g= \inf\{\us Pfg:P\in\partit I\}.
\end{equation*}
Moreover:
\begin{lemma}\label{lem:rs:more-order}
  Assume $g$ is increasing.  Then
  \begin{equation*}
\ls Pfg\leq    \underline{\int_a^b}f\dee g\leq
\overline{\int_a^b}f\dee g \leq \us Pfg
  \end{equation*}
for all partitions $P$ of $I$.
\end{lemma}

Suppose $g$ is increasing.  Let us say that $f$ satisfies
\defn{Riemann's condition} with respect to $g$ on $I$ if for each
positive $\epsilon$ there is a partition $P$ of $I$ such that
\begin{equation*}
  \us Pfg-\ls Pfg<\epsilon.
\end{equation*}

\begin{lemma}\label{lem:rs:rc}
  Assume $g$ is increasing.  Then the following conditions are equivant:
  \begin{enumerate}\setcounter{enumi}{-1}
\item\label{cond:rs:rc}
$f$ satisfies Riemann's condition with respect to $g$ on $I$.
\item\label{cond:rs:ul}
$\underline{\int_a^b}f\dee g= \overline{\int_a^b}f\dee g$.
\item\label{cond:rs:fing}
$f\in R(g)$.
  \end{enumerate}
\end{lemma}

\begin{proof}
If condition \pref{cond:rs:rc} holds, then $\overline{\int_a^b}f\dee
g- \underline{\int_a^b}f\dee g<\epsilon$ for all positive $\epsilon$,
so condition \pref{cond:rs:ul} holds.

Suppose $\epsilon>0$.  By Lemma \ref{lem:rs:order}, we can let $P$ be
a partition 
of $I$ such that $\ls Pfg$ is within $\epsilon$
of $\underline{\int_a^b}f\dee g$, \emph{and} $\us Pfg$ is within
$\epsilon$ of $\overline{\int_a^b}f\dee g$.
But if $P=\{x_0,\dots,x_n\}$, for any $t_k$ in $[x_{k-1},x_k]$, we have
  \begin{equation*}
    \ls Pfg\leq\sum_{i=1}^n f(t_k)\chng g_k\leq\us Pfg;
  \end{equation*}
if condition \pref{cond:rs:ul} holds, then by Lemma
\ref{lem:rs:more-order}, the sum $\sum_{i=1}^n
f(t_k)\chng g_k$ must be within $\epsilon$ of the common value of
$\underline{\int_a^b}f\dee g$ and $\overline{\int_a^b}f\dee g$.  Hence
this common value is $\int_a^bf\dee g$, and condition
\pref{cond:rs:fing} holds.

Finally, suppose \pref{cond:rs:fing} holds.  We can choose $P$ so that
\begin{equation*}
  \abs{\sum_{i=1}^n f(t_k)\chng g_k-\int_a^bf\dee g}<\frac\epsilon 4
\end{equation*}
for all $t_k$ in $[x_{k-1},x_k]$.  But also, since $g$ is increasing,
we can choose 
the $t_k$ so that, in addition, 
\begin{equation*}
  \abs{\sum_{i=1}^n f(t_k)\chng g_k-\ls Pfg} <\frac{\epsilon}4.
\end{equation*}
Then $\abs{\ls Pfg-\int_a^b f\dee g}<\epsilon/2$.  Likewise, 
$\abs{\us Pfg-\int_a^b f\dee g}<\epsilon/2$.  So condition
\pref{cond:rs:rc} holds. 
\end{proof}

\begin{theorem}
  Assume $g$ is increasing.  If $f_0,f_1\in R(g)$, and $f_0\leq f_1$
  (that is, $f_0(x)\leq f_1(x)$ for all $x$ in $I$), then
  \begin{equation*}
    \int_a^b f_0\dee g\leq \int_a^b f_1\dee g.
  \end{equation*}
\end{theorem}

\begin{lemma}
  Assume $g$ is increasing.  If $f\in R(g)$, then $\abs f\in R(g)$ and
  \begin{equation*}
    \abs{\int_a^bf\dee g}\leq\int_a^b\abs f\dee g.
  \end{equation*}
\end{lemma}

\begin{proof}
  Since
  $\big\lvert\abs{f(x)}-\abs{f(y)}\big\rvert\leq\abs{f(x)-f(y)}$, we
  have 
  \begin{equation*}
    \mx k{\abs f}-\mn k{\abs f}\leq \mx kf -\mn kf,
  \end{equation*}
hence
$\us P{\abs f}g-\ls P{\abs f}g\leq \us Pfg-\ls Pfg$.  Now use Lemma
\ref{lem:rs:rc}.  
\end{proof}

\begin{lemma}
  Assume $g$ is increasing.  If $f\in R(g)$, then $f^2\in R(g)$.
\end{lemma}

\begin{proof}
  Suppose $M$ bounds $\abs f$.  Then
  \begin{multline*}
    \mx k{f^2}-\mn k{f^2}=\\
(\mx k{\abs f}+\mn k{\abs f}) 
(\mx k{\abs f}-\mn k{\abs f})\leq\\
2M(\mx k{\abs f}-\mn k{\abs f}).
  \end{multline*}
Now use Lemma \ref{lem:rs:rc}.
\end{proof}

If $g$ is merely of bounded variation, then $g$ is the difference
$g_0-g_1$ of increasing functions, by Theorem \ref{thm:bv:diff}, and
$R(g_0)\cap R(g_1)\included R(g)$, by Theorem \ref{thm:rs:vector}.
But what about the reverse inclusion?

\begin{lemma}
  Assume $g$ is of bounded variation.  Let $V$ be the function
  $x\mapsto V_g[a,x]$.  If $f$ is bounded, and $f\in R(g)$, then $f\in
  R(V)$. 
\end{lemma}

\begin{proof}[Proof (not given in class)]
Since $V$ is increasing, we can use Lemma
  \ref{lem:rs:rc}.  We have
  \begin{multline*}
    \us PfV-\ls PfV= \sum_{k=1}^n(\mx kf-\mn kf)\chng V_k =\\
\sum_{k=1}^n(\mx kf-\mn kf)(\chng V_k-\abs{\chng g_k})+ 
\sum_{k=1}^n(\mx kf-\mn kf)\abs{\chng g_k},
  \end{multline*}
and we can make each of the last summations less than $\epsilon/2$.
Indeed, if $\abs f\leq M$, then
\begin{equation*}
\sum_{k=1}^n(\mx kf-\mn kf)(\chng V_k-\abs{\chng g_k})\leq
2M(V(b)-\sum_{k=1}^n\abs{\chng g_k}),  
\end{equation*}
which is less than $\epsilon/2$ if $P$ is fine enough.  We can also
choose $t_k$ and $t_k'$ in $[x_{k-1},x_k]$ so that
\begin{equation*}
  \mx kf-\mn kf<\abs{f(t_k)-f(t_k')}+\frac{\epsilon}{4V(b)}.
\end{equation*}
We may assume also that $f(t_k)-f(t_k')$ has the same sign as $\chng
g_k$.  Then
\begin{equation*}
  \sum_{k=1}^n(\mx kf-\mn kf)\abs{\chng g_k}< 
  \sum_{k=1}^n(f(t_k)-f(t_k')){\chng g_k}+ \frac{\epsilon}4.
\end{equation*}
If $P$ is fine enough, then $\sum_{k=1}^n(f(t_k)-f(t_k')){\chng
  g_k}<\epsilon/4$. 
\end{proof}

\begin{theorem}
  Assume $g$ is of bounded variation.  Then there are increasing
  functions $g_0$ and $g_1$ such that $g=g_0-g_1$ and every bounded
  function in $R(g)$ is also in $R(g)=R(g_0)\cap R(g_1)$.
\end{theorem}

\begin{theorem}\label{thm:rs:cont}
  If $g$ is of bounded variation, then $R(g)$ contains all continuous
  functions. 
\end{theorem}

\begin{proof}
  It is enough to prove the theorem in case $g$ is increasing and
  $g(a)<g(b)$.  Suppose $f$ is continuous (on $I$); then $f$ is
  uniformly continuous.  Let $\epsilon>0$.  Then there is a positive
  $\delta$ such that for all $x$ and $y$ (in $I$),
  \begin{equation*}
    \abs{x-y}<\delta\implies \abs{f(x)-f(y)}<\frac{\epsilon}{g(b)-b(a)}.
  \end{equation*}
Let $P$ be a partition fine enough that $\chng x_k<\delta$ in each
case.  Since $f$ is continuous, we have
\begin{equation*}
\mx kf-\mn kf=\abs{f(t_k)-f(t_k')}<  \frac{\epsilon}{g(b)-b(a)}
\end{equation*}
for some $t_k$ and $t_k'$ in $[x_{k-1},x_k]$, for each $k$; this means
\begin{equation*}
  \us Pfg-\ls Pfg<\sum_{k=1}^n \frac{\epsilon}{g(b)-g(a)}\chng
  g_k=\epsilon. 
\end{equation*}
Thus, Riemann's condition is met.
\end{proof}

\begin{corollary}
  All functions of bounded variation are Riemann-integrable.
\end{corollary}

\begin{lemma}[Mean-Value Theorem for Integrals]
  Suppose $f$ is continuous, and $g$ is increasing.  Then
  \begin{equation*}
    \int_a^bf\dee g=f(t)(g(b)-g(a))=f(t)\int_a^b\dee g
  \end{equation*}
for some $t$ in $(a,b)$.
\end{lemma}

\begin{proof}
The second equation is clear from the definition of the
Riemann--Stieltjes integral, or from Theorem \ref{thm:rs:parts}.
For the first equation, work with the partition $\{a,b\}$ of $I$.
We have
  \begin{equation*}
    \mn 1f(g(b)-g(a))\leq\int_a^bf\dee g\leq\mx 1f(g(b)-g(a)),
  \end{equation*}
so $(\int_a^bf\dee g)/(g(b)-g(a))$ is between $\mn 1f$ and $\mx 1f$.  Now
use the interme\-diate-value theorem for continuous functions.
\end{proof}

\begin{theorem}[First Fundamental, of Calculus]
  If $g$ is increasing, then the function
  \begin{equation*}
    x\mapsto\int_a^xf\dee g
  \end{equation*}
is well-defined on $I$, and is differentiable, with derivative
$f(u)g'(u)$, at every point $u$ of 
$I$ where $f$ is continuous and $g$ is differentiable.
\end{theorem}

\begin{proof}
  If $u$ is such a point, and $u+h\in I$, then
  \begin{equation*}
    \frac{\int_a^{u+h}f\dee g-\int_a^uf\dee g}h=
    \frac{\int_u^{u+h}f\dee g}h= f(t)\frac{g(u+h)-g(u)}h
  \end{equation*}
for some $t$ between $u$ and $u+h$ inclusive.
\end{proof}

\begin{theorem}[Second Fundamental, of Calculus]\label{thm:rs:2}
For any function $g$ that is continuous on $I$ and differentiable on
$(a,b)$, 
\begin{equation*}
  \int_a^b g'=g'(b)-g'(a),
\end{equation*}
provided the integral exists.
\end{theorem}

\begin{proof}
  For any partition $\{x_0,\dots,x_n\}$ of $I$, we can pick $t_k$ in
  $(x_{k-1},x_k)$ such that $g'(t_k)\chng x_k=\chng g'_k$, whence the
  Riemann sum $\sum_{k=1}^ng'(t_k)\chng x_k$ is just $g'(b)-g'(a)$.
\end{proof}

\section{Infinite series and products}

An infinite sequence is a function with domain $\{n\in\Z:k\leq n\}$
for some $k$ in $\Z$.  Usually the domain is $\N$ (the set
$\{0,1,2,\dots\}$ of natural numbers) or $\Zp$ (the set
$\{1,2,3,\dots\}$ of positive integers).

Informally, a sequence $(a_n)$ has a real number $b$ as a limit,
provided that $a_n$ is close to $b$ whenever $n$ is
sufficiently large.  We can understand `sufficiently large' to mean
`close to $\infty$'.  Then we can allow the limit $b$ to be $\infty$
or $-\infty$ as well.

To be more precise:  Recall that a neighborhood of a real number $x$
is a set of real numbers that has, as a subset, an open interval that
contains $x$.  We can define a \defn{neighborhood of $\infty$} to be a
set of real numbers that has, as a subset, an interval of the form
$(a,\infty)$.  Similarly, neighborhoods of $-\infty$ have subsets
$(\infty,a)$. 

Now we can say that the sequence $(a_n)$ of real numbers has the
\defn{limit} $b$ (where $b\in\{-\infty\}\cup\R\cup\{\infty\}$) if, for
every neighborhood $U$ of $b$, there is a neighborhood $U'$ of
$\infty$ such that, for all $n$ in the domain of the sequence,
\begin{equation*}
  n\in U'\implies b_n\in U.
\end{equation*}
In this case, we write
\begin{equation*}
  \lim_{n\to\infty}a_n=b.
\end{equation*}
If $b$ is \defn{finite} (that is, $b\in\R$), then the sequence is said
to \defn{converge to $b$}.  If $b$ is infinite, then the sequence
\defn{diverges to $b$}.  If the sequence has no limit, then the
sequence simply \defn{diverges}.

The \defn{extended real number system}, $\R^*$, consists of the
elements of the set
\begin{equation*}
  \{-\infty\}\cup\R\cup\{\infty\}.
\end{equation*}
This can be ordered in the obvious way, so that $-\infty<x<\infty$ for
all $x$ in $\R$.  Defining open and closed intervals of $\R^*$ is
somewhat easier than for $\R$.  If $a,b\in\R^*$, then
\begin{equation*}
  (a,b)=\{x\in\R^*:a<x<b\};\qquad
[a,b]=\{x\in\R^*:a\leq x\leq b\}.
\end{equation*}
An \defn{open} interval of $\R^*$ is an interval $(a,b)$; a
\defn{closed}, $[a,b]$.
Note that $\R$ is an open, but not a closed,
interval of $\R^*$.  

Let $f$ be the function from $[-1,1]$ to $\R^*$
given by
\begin{equation*}
  f(x)=
  \begin{cases}
    -\infty,&\text{ if }x=-1;\\
\frac{x}{1-x^2},&\text{ if }-1<x<1;\\
\infty,&\text{ if }x=1.
  \end{cases}
\end{equation*}
Then $f$ is a bijective, order-preserving function.  This means that
both $f\inv$ and $f$ send open sets to open sets; that is, both $f$
and $f\inv$ are continuous.  However, we cannot extend the
\emph{usual} metric on $\R$ so as to make $\R^*$ into a metric space;
$\R^*$ is simply a \defn{topological space}.

If a subset $A$ of $\R$ has no upper bound in $\R$, then we may write
\begin{equation*}
  \sup A=\infty;
\end{equation*}
if no lower bound, then $\inf A=-\infty$.  Also,
$\sup\emptyset=\inf\R=-\infty$, and $\inf\emptyset=\sup\R=\infty$.
Thus, every subset of $\R$ has a supremum and in infimum in $\R^*$.

Every monotone sequence has a limit in $\R^*$.

A sequence $(a_n)$ has the \defn{limit superior} $b$ in $\R$ if for
all positive $\epsilon$:
\begin{equation*}
\Exists M\Forall n  (M<n\implies a_n<b+\epsilon);
\end{equation*}
and
\begin{equation*}
\Forall M  \Exists n (M<n \mathrel{\&} b-\epsilon<a_n).
\end{equation*}
In this case, we write
\begin{equation*}
  \limsup_{n\to\infty}a_n=b.
\end{equation*}

\begin{theorem}
  The following are equivalent:
  \begin{enumerate}
    \item
$\limsup_{n\to\infty}a_n=b$.
\item
$\lim_{n\to\infty}\sup\{a_m:n<m\}=b$.
\item
$(a_n)$ has a subsequence converging to $b$, but not a subsequence
  converging to a greater limit.
  \end{enumerate}
\end{theorem}

If $\{a_n\}$ has no upper bound, then
\begin{equation*}
  \limsup_{n\to\infty}a_n=\infty;
\end{equation*}
if there \emph{is} an upper bound,
but no finite limit superior, then 
\begin{equation*}
  \limsup_{n\to\infty}a_n=-\infty.
\end{equation*}
  So every sequence has a limit
superior in $\R^*$.  The \defn{limit inferior} is defined similarly;
in fact,
\begin{equation*}
  \liminf_{n\to\infty}a_n=-\limsup_{n\to\infty}-a_n.
\end{equation*}

\begin{examples}
\makebox{}
  \begin{center}
    \begin{tabular}{c|c|c}
$a_n$ & $\displaystyle\limsup_{n\to\infty}a_n$ &  $\displaystyle\liminf_{n\to\infty}a_n$\\
      \hline\hline
$(-1)^n$ & $1$ & $-1$\\ \hline
$\displaystyle\frac{n+1}n(1+(-1)^n)$ & $2$ & $0$\\ \hline
$n(1+(-1)^n)$ & $\infty$ & $0$\\ \hline
$\log n$ & $\infty$ & $\infty$
    \end{tabular}
  \end{center}
\end{examples}

For a sequence $(a_p,a_{p+1},\dots)$, the sequence of its
\defn{partial sums} is
\begin{equation*}
  \left(\sum_{i=p}^na_i:n=p,p+1,\dots\right).
\end{equation*}
Considered with respect to its sequence of partial sums, a sequence is
a \defn{series}; the series \defn{converges} to a limit $b$ if the
sequence of partial sums does; in this case, we write
\begin{equation*}
  \sum_{i=p}^\infty a_i=b.
\end{equation*}
A sequence $(a_n)$, as a series, can be written
\begin{equation*}
  \sum a_n.
\end{equation*}

\begin{theorem}\label{thm:s:linear}
The set of convergent series is a vector-space: if $\sum a_n$ and
$\sum b_n$ converge, and $c,d\in\R$, then $\sum(ca_n+db_n)$ converges,
and
\begin{equation*}
  \sum_{k=p}^{\infty}(ca_n+db_n)= c\sum_{k=p}^{\infty}a_n+
  d\sum_{k=p}^{\infty} b_n. 
\end{equation*}
\end{theorem}

\begin{lemma}[Cauchy condition]
  The series $\sum a_n$ converges if and only if, for every positive
  $\epsilon$, there is $M$ such that, for all $k$ in $\N$,
  \begin{equation*}
    n>M\implies\abs{\sum_{m=n}^{n+k}a_m}<\epsilon. 
  \end{equation*}
\end{lemma}

\begin{theorem}
  If $\sum a_n$ converges, then $\lim_{n\to\infty}a_n=0$.
\end{theorem}

\begin{proof}
  Use the Cauchy condition when $k=1$.
\end{proof}

It is clear that, if $\sum a_n$ converges, then so does
$\sum(a_{2n}+a_{2n+1})$. 

\begin{lemma}\label{lem:s:brackets}
If $\sum(a_{2n}+a_{2n+1})$ converges, and $\lim_{n\to\infty}a_n=0$,
then $\sum a_n$ converges.
\end{lemma}

\begin{proof}
  Let $\sum_{k=p}^{\infty}(a_{2k}+a_{2k+1})=b$.  Let $M$ be such that 
  \begin{equation*}
    n>M\implies \abs{\sum_{k=p}^{p+n}(a_{2k}+a_{2k+1})-b},
    \abs{a_{2(p+n)+1}}<\frac{\epsilon}2. 
  \end{equation*}
Then also $n>M\implies\abs{\sum_{k=p}^{2(p+n)}a_k-b},
\abs{\sum_{k=p}^{2(p+n)+1}a_k-b}<\epsilon$.  
\end{proof}

A series $\sum a_n$ is \defn{alternating} if $(-1)^na_n\geq0$ for each
$n$, or  $(-1)^na_n\leq0$ for each
$n$.

\begin{theorem}
  An alternating series $\sum a_n$ converges if $\lim_{n\to\infty}a_n=0$.
\end{theorem}

\begin{proof}
  Assume $(-1)^na_n\geq0$ in each case.  Then $a_{2n}-a_{2n+1}\geq0$,
  and
  \begin{equation*}
    \sum_{k=0}^n(a_{2k}-a_{2k+1})=a_0-
    \sum_{k=0}^{n-1}(a_{2k+1}-a_{2k+2})-a_{2n+1}, 
  \end{equation*}
so partial sums of $\sum (a_{2n}-a_{2n+1})$ are bounded.  Therefore
the latter series converges.  Now use Lemma \ref{lem:s:brackets}.
\end{proof}

\begin{example}
  $\sum(-1)^n/n$ converges.
\end{example}

\begin{theorem}
  If $\abs x<1$, then 
  \begin{equation*}
      \sum_{k=0}^{\infty}x^k=\frac 1{1-x}.
  \end{equation*}
\end{theorem}

\begin{proof}
  $\sum_{k=0}^n x^k=(1-x^{n+1})/(1-x)$.  If $\abs x<1$, then the
  partial sums converge to $1/(1-x)$. 
\end{proof}

\begin{lemma}[Comparison Test]
  If $0\leq a_n\leq cb_n$ when $n$ is large enough, for some non-zero
  $c$, and $\sum b_n$ converges, then $\sum a_n$ converges.
\end{lemma}

\begin{theorem}[Limit Comparison Test]
If $\lim_{n\to\infty}a_n/b_n$ is finite and non-zero, then
\begin{equation*}
  \sum a_n\text{ converges }\Iff\sum b_n\text{ converges.}
\end{equation*}
\end{theorem}

\begin{theorem}[Integral Test]
If $f$ is monotone on $[0,\infty)$, then
  \begin{equation*}
    \sum f(n)\text{ converges }\Iff \lim_{x\to\infty}\int_0^xf\text{
    is finite.}
  \end{equation*}
\end{theorem}

\begin{proof}
Assume $f$ is decreasing.  If $f(x)<0$ for some $x$, then each member
of the equivalence fails.  Suppose $f(x)\geq0$ for all $x$.  Since
$f(k+1)\leq f(x)\leq f(k)$ when $k\leq x\leq k+1$, we have
\begin{equation*}
  \sum_{k=1}^{n}f(k)\leq\int_0^n f\leq\sum_{k=0}^{n-1}f(k).
\end{equation*}
If $\int_0^{\infty}f$ exists, then so does $\sum_{k=1}^{\infty}a_k$; if
  not, not.
\end{proof}

\begin{examples}\label{examp:s:int}
  We have
  \begin{equation*}
    \int_1^x\frac{\dee t}{t^s}=
    \begin{cases}
      \log x,&\text{ if }s=1;\\
\displaystyle\frac{1}{s-1}\left(1-\displaystyle\frac
1{x^{s-1}}\right),&\text{ if }s\neq 1.
    \end{cases}
  \end{equation*}
Hence $\sum 1/n^s$ converges if and only if $s>1$.
\end{examples}

A series $\sum a_n$ is \defn{absolutely convergent} if $\sum\abs{a_n}$
converges.  Absolute convergence implies convergence, by the Cauchy
criterion. 

\begin{theorem}[Ratio Test]
  Let 
  \begin{equation*}
    r=\liminf_{n\to\infty}\abs{\frac{a_{n+1}}{a_n}}\quad\text{ and }\quad
  R=\limsup_{n\to\infty}\abs{\frac{a_{n+1}}{a_n}}.
  \end{equation*}
Then
  \begin{itemize}
\item
    $R<1\implies \sum a_n$ converges absolutely;
\item
$1<r\implies\sum a_n$ diverges.
  \end{itemize}
In case $r\leq 1\leq R$, no conclusion is possible.
\end{theorem}

\begin{proof}
  Suppose $R<x<1$.  Then, for some $M$,
  \begin{equation*}
    n\geq M\implies\abs{\frac {a_{n+1}}{a_n}}<x,
  \end{equation*}
so $n\geq M\implies\abs{a_{n+1}}<\abs{a_M}x^{n-M}$.  By the Comparison
Test, $\sum a_n$ converges.

Suppose $1<r$.  Then, for some $M$,
\begin{equation*}
  n\geq M\implies\abs{\frac {a_{n+1}}{a_n}}>1,
\end{equation*}
which means $a_n$ cannot converge to $0$.

Finally,
$\lim_{n\to\infty}\displaystyle\frac{1/(n+1)}{1/n}=1
=\displaystyle\frac{1/(n+1)^2}{1/n^2}$.
\end{proof}

\begin{theorem}[Root Test]
  Let $\rho=\limsup_{n\to\infty}\sqrt[n]{\abs{a_n}}$.  Then
  \begin{itemize}
    \item
$\rho<1\implies\sum a_n$ converges absolutely;
\item
$1<\rho\implies\sum a_n$ diverges.
  \end{itemize}
In case $\rho=1$, no conclusion is possible.
\end{theorem}

\begin{proof}
  If $\rho<x<1$, and $n$ is large enough, then
  \begin{equation*}
    \sqrt[n]{\abs{a_n}}<x,
  \end{equation*}
whence $\abs{a_n}<x^n$.

If $1<\rho$, then $a_n$ does not converge to $0$.

Finally, $\lim_{n\to\infty}n^{1/n}=\exp \lim_{n\to\infty}\log
n/n=e^0=1$; hence $\lim_{n\to\infty}(n^2)^{1/n}=1$.
\end{proof}

\begin{theorem}
  If $\sum a_n$ is absolutely convergent, and $f:\N\to\N$ is a
  bijection, then $\sum a_{f(n)}$ converges, and
  \begin{equation*}
    \sum_{k=0}^{\infty}\abs{a_{f(k)}}=
    \sum_{k=0}^{\infty}\abs{a_{k}}. 
  \end{equation*}
\end{theorem}

\begin{proof}
  $\sum_{k=0}^n\abs{a_{f(k)}}\leq\sum_{k=0}^{\infty}\abs{a_k}$, so
  $\sum a_{f(n)}$ converges absolutely.  

We have
\begin{equation*}
  \abs{\sum_{k=0}^na_{f(k)}-\sum_{k=0}^{\infty}a_k}\leq
  \abs{\sum_{k=0}^na_{f(k)}-\sum_{k=0}^{m}a_k} +
  \abs{\sum_{k=m+1}^{\infty}a_k}.  
\end{equation*}
Let $\epsilon>0$.  Let $m$ be large enough that
$\abs{\sum_{k=m+1}^{\infty}{a_k}}\leq
\sum_{k=m+1}^{\infty}\abs{a_k}\leq\epsilon/2$.  Then $n$ can be large
enough that
\begin{equation*}
  \{0,1,\dots,m\}\included\{f(0),f(1),\dots,f(n)\}.
\end{equation*}
Then  $\abs{\sum_{k=0}^na_{f(k)}-\sum_{k=0}^{m}a_k}<\epsilon/2$, so
\begin{math}
  \abs{\sum_{k=0}^na_{f(k)}-\sum_{k=0}^{\infty}a_k}<\epsilon
\end{math}.
\end{proof}

\begin{theorem}
  If $\sum a_n$ is convergent, but not absolutely convergent, and
  $-\infty\leq b\leq c\leq\infty$, then there is a bijection
  $f:\N\to\N$ such that
  \begin{equation*}
    \liminf_{n\to\infty}\sum_{k=0}^na_{f(k)}=b\quad\text{ and }\quad
    \limsup_{n\to\infty}\sum_{k=0}^na_{f(k)}=c. 
  \end{equation*}
\end{theorem}

\begin{proof}
For any $x$ in $\R$, we have 
\begin{equation*}
  x=\max(0,x)+\min(0,x)
\quad\text{ and }\quad
\abs{x}= \max(0,x)-\min(0,x).
\end{equation*}
Hence (by Theorem \ref{thm:s:linear}), if
  $\sum a_n$ and one of $\sum\max(0,a_n)$ and $\sum\min(0,a_n)$
  converge, then $\sum a_n$ converges absolutely.

Suppose $\sum a_n$ converges, but not absolutely, and  $-\infty<
b\leq c<\infty$.  Then
both $\sum\max(0,a_n)$ and $\sum\min(0,a_n)$ diverge, to $\infty$ and
$-\infty$ respectively.  So it is possible to find a strictly increasing
sequence $(g(n):n\in\N)$ and a bijection $f:\N\to\N$ such that:
\begin{itemize}
  \item
$g(0)=0$;
\item
$f$ is increasing on $\{k\in\N:(\exists n\in\N)\;g(2n)\leq
  k<g(2n+1)\}$ and on its complement;
\item
$a_{f(k)}\geq0\Iff(\exists n\in\N)\; g(2n)\leq k<g(2n+1)$;
\item
$\sum_{k=0}^{g(2n+1)-2}a_{f(k)}\leq c<
  \sum_{k=0}^{g(2n+1)-1}a_{f(k)}$;
\item
$\sum_{k=0}^{g(2n+2)-1}a_{f(k)}< b\leq
  \sum_{k=0}^{g(2n+2)-2}a_{f(k)}$.
\end{itemize}
Since $\lim_{n\to\infty}a_{f(n)}=0$, we have
  \begin{equation*}
    \liminf_{n\to\infty}\sum_{k=0}^na_{f(k)}=b\quad\text{ and }\quad
    \limsup_{n\to\infty}\sum_{k=0}^na_{f(k)}=c. 
  \end{equation*}
If possibly one or both of $b$ and $c$ are infinite, then we modify
the construction of $f$ by choosing sequences $(b_n)$ and $(c_n)$ that
have limits $b$ and $c$ respectively and that satisfy $b_n<c_n$.  Then
we require
\begin{equation*}
  \sum_{k=0}^{g(2n+1)-2}a_{f(k)}\leq c_n<
  \sum_{k=0}^{g(2n+1)-1}a_{f(k)}
\end{equation*}
and $\sum_{k=0}^{g(2n+1)-1}a_{f(k)}< b_n \leq
  \sum_{k=0}^{g(2n+1)-2}a_{f(k)}$.
\end{proof}

Suppose $(p,q)\mapsto a_{p\,q}$ is a function from $\N\times\N$ to
$\R$ (that is, a \defn{double sequence}).  Then we say
\begin{equation*}
  \lim_{(p,q)\to\infty}a_{p\,q}=b
\end{equation*}
if for all positive $\epsilon$ there is $M$ such that
\begin{equation*}
  p,q>M\implies\abs{a_{p\,q}-b}<\epsilon.
\end{equation*}

\begin{theorem}
  Suppose 
  \begin{equation*}
      \lim_{(p,q)\to\infty}a_{p\,q}=b.
  \end{equation*}
  If
  $\lim_{q\to\infty}a_{p\,q}$ exists for each $p$ in
  $\N$, then 
  \begin{equation*}
      \lim_{p\to\infty}\lim_{q\to\infty}a_{p\,q}=b.
  \end{equation*}
\end{theorem}

\begin{proof}
  Let $N$ be such that
  \begin{equation*}
    p,q>N\implies\abs{a_{p\,q}-b}<\frac{\epsilon}2.
  \end{equation*}
Suppose $p>N$ and $\lim_{q\to\infty}a_{p\,q}=c_p$.  There is $M$ such
that 
\begin{equation*}
  q>M\implies\abs{a_{p\,q}-c_p}<\frac{\epsilon}2.
\end{equation*}
Hence, if $q>\max(M,N)$, then $\abs{c_p-b}\leq\abs{c_p-a_{p\,q}}+
\abs{a_{p\,q}-b}<\epsilon$.
\end{proof}

\begin{example}
We have
\begin{equation*}
  \lim_{p\to\infty}\lim_{q\to\infty}\frac{pq}{p^2+q^2}=
\lim_{p\to\infty}0=0;
\end{equation*}
 but $pq/(p^2+q^2)=1/2$ if $p=q$; so the double
sequence
\begin{equation*}
  (p,q)\mapsto \frac {pq}{p^2+q^2}
\end{equation*}
has no limit.
\end{example}

Suppose $(a_n:n\in\N)$ is a sequence of real numbers.
We shall say that $\prod a_n$ \defn{converges} if, for some $p$ in
$\N$, the sequence of products $\prod_{k=p}^na_k$ converges to a
\emph{finite} and \emph{non-zero} limit $b$.  In this case, we write
\begin{equation*}
  \prod_{k=p}^{\infty}a_n=b\quad\text{ and }\quad
  \prod_{k=0}^{\infty}a_k= b\cdot\prod_{k=0}^{p-1}a_k.
\end{equation*}
(If $p=0$, then $\prod_{k=0}^{p-1}a_k=1$.)  
The definition has two immediate consequences:
\begin{itemize}
  \item
If $\prod a_n$
converges, then $a_n\neq0$ for all but finitely many $n$.
\item
$\prod a_n$ converges if and only if $\prod 1/a_n$ converges.
\end{itemize}

\begin{examples}
  $\prod_{k=1}^n(1+ 1/k)=\prod_{k=1}^n((k+ 1)/k)=n+1$, and
  \begin{equation*}
      \prod_{k=2}^{n+1}\left(1-\frac 1k\right)= \prod_{k=2}^{n+1}\frac{k-1}k=
      \frac 1{n+1};
  \end{equation*}
 so
  $\prod(1\pm 1/n)$ diverges in each case.
\end{examples}

\begin{theorem}[Cauchy condition for products]
The product $\prod a_n$ converges if and only if, for every positive
$\epsilon$, there is $M$ such that, for all $n$ and $k$ in $\N$,
\begin{equation*}
  n>M\implies\abs{\prod_{\ell=n}^{n+k}a_{\ell}-1}<\epsilon.
\end{equation*}
\end{theorem}

\begin{proof}
  Suppose $\prod a_n$ converges.  Then for some $p$ there is a
  positive $\delta$ such that
  \begin{equation*}
    \abs{\prod_{\ell=p}^{p+n}a_{\ell}}>\delta
  \end{equation*}
for all $n$ in $\N$.  Also, there is $M$ such that
\begin{equation*}
  n>M\implies\abs{\prod_{\ell=p}^{p+n+k+1}a_{\ell}-
  \prod_{\ell=p}^{p+n}a_{\ell}}<\epsilon\delta
\end{equation*}
for all $k$ in $\N$.  Division yields
\begin{equation*}
  n>M\implies\abs{\prod_{\ell=p+n+1}^{p+n+k+1}a_{\ell}-
1}<\epsilon.
\end{equation*}
Suppose conversely that for all positive $\epsilon$ there is $M$ such
that
\begin{equation*}
  n>M\implies\abs{\prod_{\ell=n}^{n+k}a_{\ell}-
1}<\epsilon.
\end{equation*}
for all $k$ in $\N$.  Then, in particular, there is $p$ such that
\begin{equation*}
  \frac12<\prod_{\ell=p}^{p+k}a_{\ell} <\frac32 
\end{equation*}
for all $k$ in $\N$.
Hence if $\lim_{n\to\infty}\prod_{\ell=p}^{p+n}a_{\ell}$ exists, then
it is not zero, so $\prod a_n$ converges.  We can show that this limit
exists by the Cauchy criterion.  Indeed, we have
\begin{equation*}
  \abs{\prod_{\ell=p}^{p+n+k+1}a_{\ell}-\prod_{\ell=p}^{p+n}a_{\ell}}= 
\abs{\prod_{\ell=p+n+1}^{p+n+k+1}a_{\ell}- 1} \cdot
\abs{\prod_{\ell=p}^{p+n}a_{\ell}}< \frac 32\epsilon 
\end{equation*}
if $n>M$.
\end{proof}

\begin{theorem}
  If $(a_n)$ is a sequence of \emph{positive} terms, then
  \begin{equation*}
    \prod(1+a_n)\text{ converges }\Iff\sum a_n\text{ converges.}
  \end{equation*}
\end{theorem}

\begin{proof}
If $1<x$, then, by the Mean-Value Theorem, $1\leq e^t=(e^x-1)/x$ for
some $t$ in $(1,x)$, so $1+x\leq e^x$.  Hence
\begin{equation*}
  \sum_{k=0}^na_k<1+  \sum_{k=0}^na_k\leq\prod_{k=0}^n(1+a_k) \leq
  \prod_{k=0}^n \exp{a_k}=\exp\sum_{k=0}^na_k.
\end{equation*}
Thus, the increasing sequence of partial sums is bounded if and only
if the increasing sequence of partial products is bounded.
\end{proof}

The \defn{Riemann Zeta-function} is defined on the interval
$(1,\infty)$ by the formula
\begin{equation*}
  \zeta(s)=\sum_{n=1}^{\infty}\frac 1{n^s}.
\end{equation*}
(See Examples \ref{examp:s:int}.)

\begin{theorem}[Euler product]
  Let the set of prime numbers be the range of the increasing sequence
  $(p_n:n\in\N)$.  Then
the Riemann Zeta-function is given by
\begin{equation*}
  \zeta(s)=\prod_{k=0}^{\infty}\frac 1{1-p_k^{-s}}=
  \prod_{k=0}^{\infty}\sum_{n=0}^{\infty}\frac 1{p_k^{ns}}.
\end{equation*}
\end{theorem}

\begin{proof}
  Every partial product $\prod_{k=0}^{m}\frac 1{1-p_k^{-s}}$ is the
  limit of the products
  \begin{equation*}
    \prod_{k=0}^{m} \sum_{\ell=0}^{n}\frac 1{p_k^{\ell s}},
  \end{equation*}
which can be written as the sums $\sum_a 1/a^s$, where $a$ ranges over
the positive integers whose only prime factors are among the $p_k$
such that $k\leq m$, and which are divisible by any one of these $p_k$
at most $n$ times.  Hence
\begin{equation*}
  \abs{\zeta(s)- \prod_{k=0}^{m}\frac 1{1-p_k^{-s}}}\leq\sum_b\frac
  1{b^s}\leq\sum_{n=p_m}^{\infty}\frac 1{n^s},
\end{equation*}
where $b$ ranges over those positive integers divisible by a prime
greater than $p_m$.  Since
$\lim_{n\to\infty}\sum_{n=p_m}^{\infty}1/{n^s}=0$, the claim
follows. 
\end{proof}

\section{Sequences of functions}

Suppose $I$ is a sub-interval of $\R$, and
$(f_n:n\in\N)$ is a sequence of functions from $I$ to $\R$.  If $f$ is
another such sequence, then $(f_n)$ \defn{converges pointwise} to $f$
if, for all $x$ in $I$,
\begin{equation*}
  \lim_{n\to\infty}f_n(x)=f(x).
\end{equation*}
Nice properties need not be preserved under the taking of pointwise
limits:

\begin{examples}
  \begin{enumerate}\setcounter{enumi}{-1}
\item
The sequence of continuous functions $x\mapsto x^n:[0,1]\to\R$
converges pointwise to the non-continuous function
\begin{equation*}
  x\mapsto
  \begin{cases}
    0,&\text{ if }0\leq x<1;\\
1,&\text{ if }x=1.
  \end{cases}
\end{equation*}
\item
The sequence of integrable functions $x\mapsto n^2x^n(1-x):[0,1]\to\R$
converges pointwise to $0$, but
\begin{equation*}
  \int_0^1n^2x^n(1-x)\dee
  x=\left.n^2\left(\frac{x^{n+1}}{n+1}-\frac{x^{n+2}}{n+2}\right)
  \right|_0^1 = \frac{n^2}{(n+1)(n+2)},
\end{equation*}
so the sequence of integrals converges to $1$.
\item
The sequence of differentiable functions $x\mapsto (\sin n^2x)/n$
converges to $0$, but the sequence of derivatives $x\mapsto 2n\cos nx$
does not converge.
  \end{enumerate}
\end{examples}

The sequence $(f_n)$ \defn{converges uniformly} to $f$ if for every
positive $\epsilon$ there is $M$ such that for all $x$ in $I$ and all
$n$ in $\Z$,
\begin{equation*}
  n>M\implies \abs{f_n(x)-f(x)}<\epsilon.
\end{equation*}
We showed in Math 271 that the uniform limit of continuous functions
is continuous.

Let $B(I)$ be the set of bounded real-valued functions on $I$.  This
becomes a metric space when we define
\begin{equation*}
  d(f,g)=\sup\{\abs{f(x)-g(x)}:x\in I\}.
\end{equation*}
Then a sequence of functions in $B(I)$ converges uniformly if and
only if it converges in the metric $d$.

\begin{lemma}[Cauchy condition for uniform convergence]
  A sequence $(f_n)$ of functions on $I$ converges uniformly if and
  only if for all positive $\epsilon$ there is $M$ such that for all
  $x$ in $I$, all $n$ in $\Z$ and all $k$ in $\N$,
  \begin{equation*}
    n>M\implies\abs{f_{n+k}(x)-f_n(x)}<\epsilon.
  \end{equation*}
\end{lemma}

\begin{proof}
  Suppose $(f_n)$ converges uniformly to $f$.  If $\epsilon>0$, let
  $M$ be such that
  \begin{equation}\label{eqn:sf:Cauchy}
    n>M\implies \abs{f_n(x)-f(x)}<\frac{\epsilon}2.
  \end{equation}
If $n>M$, then also $\abs{f_{n+k}(x)-f(x)}<\epsilon/2$, so
$\abs{f_{n+k}(x)-f(x)}<\epsilon$. 

Conversely, if $(f_n)$ satisfies the Cauchy condition, then each
sequence $(f_n(x))$ of real numbers is Cauchy, so it has a limit, say
$f(x)$.  Hence, for all $n$, we have
\begin{equation*}
  \lim_{k\to\infty}\abs{f_n(x)-f_{n+k}(x)}=\abs{f_n(x)-f(x)}.
\end{equation*}
   If $\epsilon>0$, let $M$ be such that \pref{eqn:sf:Cauchy}
holds.  Then
\begin{equation*}
  n>M\implies\abs{f_n(x)-f(x)}\leq\frac{\epsilon}2<\epsilon.
\end{equation*}
So $(f_n)$ converges uniformly to $f$.
\end{proof}

A \emph{series} $\sum f_n$ of functions converges uniformly if
the sequence of partial sums $\sum_{k=0}^{n}f_k$ converges uniformly.

\begin{lemma}[Cauchy condition for uniform convergence of series]
  A series $\sum f_n$ of functions converges uniformly if and only if,
  for all positive $\epsilon$, there is $M$ such that for all $x$ in
  $I$, for all $n$ in $\Z$ and all $k$ in $\N$,
  \begin{equation*}
    n>M\implies\abs{\sum_{\ell=n}^{n+k}f_{\ell}(x)}<\epsilon.
  \end{equation*}
\end{lemma}

\begin{theorem}[Weierstra\ss{} $M$-test]
Suppose the sequences $(f_n)$ of functions and $(M_n)$ of numbers are
such that, for each $x$ in $I$,
\begin{equation*}
  \abs{f_n(x)}\leq M_n.
\end{equation*}
If $\sum M_n$ converges, then $\sum f_n$ converges uniformly.
\end{theorem}

\begin{proof}
  If $\sum M_n$ converges, then it satisfies the Cauchy criterion for
  series; so $\sum f_n$ satisfies the Cauchy criterion for series of
  functions; so $\sum f_n$ converges uniformly.
\end{proof}

\begin{theorem}
  Suppose each $f_n$ is continuous, and $\sum f_n$ converges uniformly to
  $f$.  Then $f$ is continuous; in particular,
  \begin{equation*}
    \lim_{y\to x}\sum_{n=0}^{\infty}f_n(y)=
    \sum_{n=0}^{\infty}\lim_{y\to x}f_n(y).
  \end{equation*}
\end{theorem}

\begin{theorem}[A space-filling curve]
There is a continuous surjective function from $[0,1]$ to
$[0,1]\times[0,1]$. 
\end{theorem}

\begin{proof}
  Let $\phi$ be a continuous function on $\R$ such that, for all $n$
  in $\Z$, 
  \begin{equation*}
    \phi(x)=
    \begin{cases}
0,&\text{ if }k-1/6\leq x\leq k+1/6;\\
1,&\text{ if }k+1/3\leq x\leq k+2/3.
    \end{cases}
  \end{equation*}
Then $\phi$ is periodic, with period $1$; that is,
$\phi(x)=\phi(x-\floor x)$.
For each $e$ in $\{0,1\}$, let $f_e$ be the function given by
\begin{equation*}
  f_e(x)=\sum_{k=0}^{\infty}\frac{\phi(3^{2k+e}x)}{2^{k+1}}.
\end{equation*}
The series converge uniformly, by the $M$-test with $M_k=1/2^{k+1}$.
Since $\phi$ is continuous, so are the $f_e$.  Our function will be
\begin{equation*}
  x\mapsto (f_0(x),f_1(x)).
\end{equation*}
Any point of $[0,1]\times[0,1]$ can be written, in binary notation, as
\begin{equation*}
  \left(\sum_{k=1}^{\infty}\frac{a_k}{2^k},
  \sum_{k=1}^{\infty}\frac{b_k}{2^k}\right), 
\end{equation*}
where $a_k$ and $b_k$ are in $\{0,1\}$.  Now define
\begin{equation*}
  c_n=
  \begin{cases}
    a_k,&\text{ if }2k-1=n;\\
b_k,&\text{ if }2k=n;
  \end{cases}
\end{equation*}
and let 
\begin{equation*}
  c=\sum_{n=1}^{\infty}\frac{c_n}{3^n}.
\end{equation*}
Then 
\begin{equation*}
  3^kc-\floor{3^kc}=
  \frac{c_{k+1}}{3}+\sum_{n=1}^{\infty}\frac{c_{n+k+1}}{3^{n+1}},
\end{equation*}
so $\phi(3^kc)=c_{k+1}$.
\end{proof}

\begin{theorem}
  Let $g$ be of bounded variation on $[a,b]$.  If $f_n\in R(g)$, and
  $(f_n)$ converges uniformly to $f$ on $[a,b]$, then $f\in R(g)$, and
  $(\int_a^xf_n\dee g)$ converges uniformly to $\int_a^xf\dee g$.
\end{theorem}

\begin{proof}
We may assume $g$ is increasing and $g(b)\neq g(a)$.  There is $M$
such that, for all $x$ in $[a,b]$, 
\begin{equation*}
  n\geq M\implies\abs{f_n(x)-f(x)}<\frac{\epsilon}{3(g(b)-g(a))}.
\end{equation*}
We use this first to prove
$f\in R(g)$.  For any partition $P$ of $[a,b]$, we have
\begin{equation*}
  \abs{\us P{f-f_M}g},\abs{\ls P{f-f_M}g}<\frac{\epsilon}3.
\end{equation*}
Suppose in particular that $P$ is fine enough that
\begin{equation*}
  \us P{f_M}g-\ls P{f_M}g<\frac{\epsilon}3.
\end{equation*}
Because $\sup\{f(x):x\in[a,b]\}\leq\sup\{f(x)-f_M(x):x\in[a,b]\}+
\sup\{f_M(x):x\in[a,b]\}$, and likewise for the infima, we have
\begin{multline*}
  \us Pfg-\ls Pfg\leq\\ \us P{f-f_M}g+\us P{f_M}g - (\ls P{f-f_M}g +\ls
  P{f_M}g) \leq \epsilon.
\end{multline*}
So Riemann's condition is satisfied, and $f\in R(g)$.  We have also
\begin{multline*}
  \abs{\int_a^xf_n\dee g-\int_a^xf\dee g}=\abs{\int_a^x(f_n-f)\dee g}
  \leq \\
\int_a^x\abs{f_n-f}\dee g\leq \int_a^b\abs{f_n-f}\dee
  g\leq\frac{\epsilon}3,
\end{multline*}
so the convergence of the sequence of integrals is uniform.
\end{proof}
Under the conditions of the theorem, we have
\begin{equation*}
  \lim_{n\to\infty}\int_a^xf_n\dee
  g=\int_a^x(\lim_{n\to\infty}f_n)\dee g.
\end{equation*}
If also $\sum f_n$ converges uniformly, then
\begin{equation*}
  \sum_{n=0}^{\infty}\int_a^xf_n\dee
  g=\int_a^x(\sum_{n=0}^{\infty}f_n)\dee g.
\end{equation*}

A \defn{power series} is a function
\begin{equation*}
  z\mapsto\sum_{n=0}^{\infty}c_n(z-a)^n.
\end{equation*}
At $a$, this function has the value $c_0$, by definition.  The
function may, but need not, be well-defined at other points.  Nice
results are obtained if the coefficients $c_n$ and the point $a$ (as
well as the argument $z$) are allowed to be \tech{complex numbers}.

\begin{theorem}
  The vector-space $\R^2$ becomes a field when equipped with the
  multiplication given by
  \begin{equation*}
    (a,b)(c,d)=(ac-bd,ad+bc).
  \end{equation*}
In this field, the multiplicative identity is $(1,0)$, and
\begin{equation*}
  (a,b)\inv=\frac1{a^2+b^2}(a,-b).
\end{equation*}
\end{theorem}
The field in the theorem is denoted $\C$; its elements are
\defn{complex numbers}.  For the complex numbers $(1,0)$ and $(0,1)$,
we may write
\begin{equation*}
  1 \quad\text{ and }\quad i
\end{equation*}
respectively;
then the complex number $(a,b)$---that is, $a(1,0)+b(0,1)$---can be
written $a+bi$.  Note that $i^2=-1$.

\begin{theorem}
  If $z,w\in\C$, then $\abs{zw}=\abs z\abs w$.
\end{theorem}
If $z\in\C$, then $\abs z$ is called the \defn{absolute value} or
\defn{modulus} of $z$.  We have the triangle inequality,
$\abs{z+w}\leq\abs z+\abs w$.
Much of what we have done with sequences of \emph{real} numbers
applies to \emph{complex} numbers as well.  In particular,
\begin{itemize}
  \item
the \emph{definition} of absolute convergence is meaningful for series
of complex numbers;
\item
the \emph{tests} for absolute convergence work for such series (since
absolute convergence is still convergence of a certain series of real
numbers); 
\item
the \emph{proof} that absolute convergence implies convergence is
still valid for such series.
\end{itemize}
Let $\rho=\limsup_{n\to\infty}\sqrt[n]{\abs{c_n}}$.  Then
\begin{multline*}
  \limsup_{n\to\infty}\sqrt[n]{\abs{c_n(z-a)^n}}=
  \limsup_{n\to\infty}\sqrt[n]{\abs{c_n}\abs{(z-a)^n}} = \\
  \limsup_{n\to\infty}(\abs{z-a}\sqrt[n]{\abs{c_n}})=\abs{z-a}\rho.
\end{multline*}
If $\rho>0$, then the series $\sum c_n(z-a)^n$:
\begin{itemize}
  \item
converges absolutely, if $\abs{z-a}<1/\rho$;
\item
diverges, if $\abs{z-a}>1/\rho$.
\end{itemize}
The number $1/\rho$ (if it exists) is the \defn{radius of convergence}
of the series; the ball $B(a;1/\rho)$ is the \defn{disc of
  convergence}.  (If $\rho=0$, then the radius of convergence is
$\infty$; if $\rho=\infty$, then the radius of convergence is $0$.)

\begin{theorem}
  Every power series is continuous on its disc of convergence.
\end{theorem}

\begin{proof}
  Let $R$ be the radius of convergence of $\sum c_n(z-a)^n$, and
  suppose $w\in B(a;R)$.  Let $\delta=(R-\abs{w-a})/2$, and let
  $F=\{z\in\C:\abs{z-w}\leq\delta\}$.  Then $F$ is a neighborhood of
  $w$, so it is enough to show that the series is continuous on $F$.
  For \emph{this}, since $z\mapsto c_n(z-a)^n$ is continous, it is
  enough to show that the series converges uniformly on $F$.  But $F$
  is compact, so some point $b$ of $F$ is furthest from $a$; that is,
  if $z\in F$, then
  \begin{equation*}
    \abs{c_n(z-a)^n}=\abs{c_n}\abs{z-a}^n\leq\abs{c_n}\abs{b-a}^n.
  \end{equation*}
Since $\abs{b-a}<R$, we know $\sum\abs{c_n}\abs{b-a}^n$ converges;
hence, by the $M$-test, the series converges uniformly on $F$.
\end{proof}

Since $\C$ is a field, the definition of the derivative of a function
from $\R$ to $\R$ is meaningful for functions from $\C$ to $\C$.
We shall show that any power series is \emph{differentiable} on its
disc of convergence, with derivative the sum of the derivatives of the
terms. 

\begin{lemma}\label{lem:sf:diff}
  $\sum_{n=0}^{\infty}c_n(z-a)^n$ and
  $\sum_{n=1}^{\infty}nc_n(z-a)^{n-1}$ have the same radius of convergence.
\end{lemma}

\begin{proof}
  The second series is convergent if and only if
  $\sum_{n=1}^{\infty}nc_n(z-a)^{n}$ is convergent.  Since
  $\lim_{n\to\infty}\sqrt[n]{n}=1$, this series has the same radius of
  convergence as the first.
\end{proof}

\begin{lemma}\label{lem:sf:neq}
  $\abs{z^n-w^n}\leq n\abs{z-w}(\abs{w}+\abs{z-w})^{n-1}$ if $n>0$.
\end{lemma}

\begin{proof}
  The claim is trivial if $w=0$.  Assume $w\neq 0$, and let $t=(z-w)/w$.
  Then we have to prove
  \begin{equation*}
    \abs{(1+t)^n-1}\leq n\abs{t}(1+\abs{t})^{n-1}.
  \end{equation*}
If $t$ is a non-negative real number, then the inequality holds, since
then 
\begin{equation*}
  (1+t)^n-1=n\int_0^t(1+x)^{n-1}\dee x\leq nt(1+t)^{n-1}.
\end{equation*}
For arbitrary $t$ in $\C$, we have
\begin{equation*}
  \abs{(1+t)^n-1}=\abs{\sum_{k=1}^n\binom nkt^k}\leq
  \sum_{k=1}^n\binom nk\abs t^k=(1+\abs t)^n-1, 
\end{equation*}
which, combined with the previous inequality, yields the claim.
\end{proof}

Note that, by interchanging $z$ and $w$, we can write the inequality
of the lemma as  
\begin{equation*}
  \abs{z^n-w^n}\leq
n\abs{z-w}(\abs{z}+\abs{z-w})^{n-1}.
\end{equation*}

\begin{theorem}\label{thm:sf:diff}
  If $\sum_{n=0}^{\infty}c_n(z-a)^n$ has a positive radius of
  convergence, then the function is differentiable on its disc of
  convergence, and its derivative is $\sum_{n=1}^{\infty}nc_n(z-a)^{n-1}$.
\end{theorem}

\begin{proof}
Write $f(z)$ for $\sum_{n=0}^{\infty}c_n(z-a)^n$.  Let $\zeta$ be an
element of the disc of convergence; we shall compute $f'(\zeta)$.  For
all elements $w$ of this disc distinct from $\zeta$,
\begin{equation*}
  \frac{f(\zeta)-f(w)}{\zeta-w}=
  \sum_{n=1}^{\infty}c_n\frac{(\zeta-a)^n-(w-a)^n}{\zeta-w}.
\end{equation*}
We want to make the difference between this and
$\sum_{n=1}^{\infty}nc_n(\zeta-a)^{n-1}$ small.  To do this, we break
this difference into two pieces, and make each piece small.
For any positive integer $M$,
\begin{multline*}
  \abs{\frac{f(\zeta)-f(w)}{\zeta-w}-
  \sum_{n=1}^{\infty}nc_n(\zeta-a)^{n-1}} \leq\\ 
  \sum_{n=1}^M \abs{c_n}\abs{\frac{(\zeta-a)^n-(w-a)^n}{\zeta-w}-
  n(\zeta-a)^{n-1}}  +\\
  \sum_{n=M+1}^{\infty}c_n
  \left(\abs{\frac{(\zeta-a)^n-(w-a)^n}{\zeta-w}}+
  n\abs{\zeta-a}^{n-1}\right)\leq   \\
  \sum_{n=1}^M \abs{c_n}\abs{\frac{(\zeta-a)^n-
  (w-a)^n}{\zeta-w}-n(\zeta-a)^{n-1}}   +\\
  \sum_{n=M+1}^{\infty}n\abs{c_n}
  \left((\abs{\zeta-a}+\abs{\zeta-w})^{n-1}+\abs{\zeta-a}^{n-1}\right)
\end{multline*}
by Lemma \ref{lem:sf:neq}.
Let $R$ be the radius of convergence of $f$, and let $\delta_0=
(R-\abs{\zeta-a})/2$.  Suppose $0<\abs{\zeta-w}<\delta_0$.  Then
\begin{multline*}
  \abs{\frac{f(\zeta)-f(w)}{\zeta-w}-
  \sum_{n=1}^{\infty}nc_n(\zeta-a)^{n-1}} \leq\\ 
  \sum_{n=1}^M \abs{c_n}\abs{\frac{(\zeta-a)^n-
(w-a)^n}{\zeta-w}-n(\zeta-a)^{n-1}}  +\\
 2 \sum_{n=M+1}^{\infty}nc_n
  (\abs{\zeta-a}+\delta_0)^{n-1}.
\end{multline*}
Say $\epsilon>0$.
By Lemma \ref{lem:sf:diff}, we can choose $M$ large enough that
\begin{equation*}
  2\sum_{n=M+1}^{\infty}nc_n
  (\abs{\zeta-a}+\delta_0)^{n-1}<\epsilon/2.
\end{equation*}
But for each positive $n$, the derivative of $z\mapsto (z-a)^n$ is $z\mapsto
n(z-a)^{n-1}$; hence, for the chosen $M$, we can find $\delta_1$ such
that, if $0<\abs{\zeta-w}<\delta_1$, then
\begin{equation*}
    \sum_{n=1}^M
    \abs{c_n}\abs{\frac{(\zeta-a)^n-(w-a)^n}{\zeta-w}-n(\zeta-a)^{n-1}}<
    \frac{\epsilon}2.   
\end{equation*}
Therefore, if $0<\abs{\zeta-w}<\min\{\delta_0,\delta_1\}$, then
\begin{equation*}
\abs{\frac{f(\zeta)-f(w)}{\zeta-w}-\sum_{n=1}^{\infty}nc_n(\zeta-a)^{n-1}}
\leq\epsilon;  
\end{equation*}
this proves the claim.
\end{proof}

\begin{corollary}
If $f(z)=\sum_{n=0}^{\infty}c_n(z-a)^n$, and $R$ is the radius of
convergence of the series, then $f$ is infinitely differentiable on
$B(a;R)$, and
\begin{equation*}
  c_n=\frac{f^{(n)}(a)}{n!}.
\end{equation*}
\end{corollary}
 
\begin{proof}
Repeated application of the theorem yields
  \begin{equation*}
  f^{(k)}(z)=\sum_{n=k}^{\infty}n(n-1)\dots(n-k+1)c_n(z-a)^{n-k}=
  \sum_{n=k}^{\infty}\frac{n!}{(n-k)!}c_n(z-a)^{n-k},
\end{equation*}
hence $f^{(k)}(a)=k!c_k$.
\end{proof}

For which functions $f$, defined on a neighborhood of $a$, can we conclude
\begin{equation}\label{eqn:sf:Taylor}
  f(z)=\sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(z-a)^n
\end{equation}
on some neighborhood of $a$?  If $a\in \C$, then it is enough for $f$
to be once-differentiable (but we won't prove this).  If $a\in\R$,
then it is not even enough to
know that $f$ is infinitely differentiable:

\begin{example}
  Let $f(x)=
  \begin{cases}
    \exp(-x^{-2}),&\text{ if }x\neq0;\\
0,&\text{ if }x=0.
  \end{cases}$
Then $f^{(n)}(0)=0$ for all $n$; so Equation \pref{eqn:sf:Taylor}
fails when $a=0$.
\end{example}

We can come up with a condition under which a function $f$ satisfies
Equation~\pref{eqn:sf:Taylor}: 

\begin{lemma}[Generalized Mean-Value Theorem]
  Let $F$ and $G$ be real-valued functions continuous on $[a,b]$ and
  differentiable on $(a,b)$.  Then
  \begin{equation*}
    F'(c)[G(b)-G(a)]=G'(c)[F(b)-F(a)]
  \end{equation*}
for some $c$ in $(a,b)$.
\end{lemma}

\begin{proof}
  Apply Rolle's Theorem to $x\mapsto F(x)[G(b)-G(a)]-G(x)[F(b)-F(a)]$. 
\end{proof}

\begin{theorem}
  Suppose $f^{(n-1)}$ and $g^{(n-1)}$ are continuous on $[a,b]$ and
  differentiable on $(a,b)$.  Then for any distinct $c$ and $x$ in
  $[a,b]$ there is $y$, strictly between them, such that
  \begin{equation*}
   f^{(n)}(y)\left[g(x)-\sum_{k=0}^{n-1}\frac{g^{(k)}(c)}{k!}(x-c)^k\right]
=  g^{(n)}(y)\left[f(x)-\sum_{k=0}^{n-1}\frac{f^{(k)}(c)}{k!}(x-c)^k\right].  
  \end{equation*}
\end{theorem}

\begin{proof}
  Use the Generalized Mean-Value Theorem, with $[c,x]$ (or $[x,c]$) in
  place of $[a,b]$, with $F$ as the function
  \begin{equation*}
    t\mapsto \sum_{k=0}^{n-1}\frac{f^{(k)}(t)}{k!}(x-t)^k,
  \end{equation*}
and with $G$ as a similar function in terms of $g$.  In particular,
$G(x)=g(x)$, so
\begin{equation*}
  G(x)-G(c)=g(x)-\sum_{k=0}^{n-1}\frac{g^{(k)}(c)}{k!}(x-c)^k;
\end{equation*}
also, 
\begin{equation*}
  F'(t)=f'(t)+ \sum_{k=1}^{n-1}
  \left[\frac{f^{(k+1)}(t)}{k!}(x-t)^k -
  \frac{f^{(k)}(t)}{(k-1)!}(x-t)^{k-1}\right],
\end{equation*}
a telescoping sum, so $F'(t)=f^{(n)}(t)(x-t)^{n-1}/(n-1)!$. 
\end{proof}

\begin{corollary}[Taylor's Theorem]
  Suppose $f^{(n-1)}$ is continuous on $[a,b]$ and
  differentiable on $(a,b)$.  Then for any distinct $c$ and $x$ in
  $[a,b]$ there is $y$, strictly between them, such that
  \begin{equation*}
 f(x)= \sum_{k=0}^{n-1}\frac{f^{(k)}(c)}{k!}(x-c)^k+
 \frac{f^{(n)}(y)}{k!}(x-c)^n.  
  \end{equation*}
\end{corollary}

\begin{proof}
  In the theorem, let $g$ be $t\mapsto (t-c)^n$.  We have
  \begin{equation*}
    g^{(k)}(t)=\frac{n!}{(n-k)!}(t-c)^{n-k},
  \end{equation*}
so the theorem gives
\begin{equation*}
   f^{(n)}(y)(x-c)^n
=  n!\left[f(x)-\sum_{k=0}^{n-1}\frac{f^{(k)}(c)}{k!}(x-c)^k\right],
  \end{equation*}
whence the claim.
\end{proof}

\begin{lemma}
  Suppose $f$ has derivatives of all orders on  some neighborhood of
  $c$, and for some $M$, each $f^{(n)}$ is bounded by $M^n$ on that
  neighborhood; then on that neighborhood, Equation
  \pref{eqn:sf:Taylor} holds.
\end{lemma}

\begin{proof}
For any positive $a$, we have $\lim_{n\to\infty}(a^n/n!)=0$, since
$\sum(a^n/n!)$ converges by the ratio test.
\end{proof}

\section{Differentiation in several dimensions}\label{sect:diff}
Suppose in this section that $f$ is a function from $\R^n$ to $\R^m$,
and $\tuple a$ is a point of $\R^n$.
We want to investigate the possibilities for differentiating $f$ at
$\tuple a$ .
We can write $f$ as
$(f_0,\dots,f_{m-1})$, where each $f_i$ is a function from $\R^n$ to
$\R$; so if $n=1$, then we can form $(f_0',\dots,f_{m-1}')$. 

In the general case, we can take \tech{partial derivatives}:  Define a 
function $\delta:\N\times\N\to\{0,1\}$ by
\begin{equation*}
  \delta_{i\,j}=
  \begin{cases}
    1,&\text{ if }i=j;\\
0,&\text{ if }i\neq j.
  \end{cases}
\end{equation*}
Let $\tuple e_i$ be the element
$(\delta_{i\,0},\dots,\delta_{i\,n-1})$ of $\R^n$.  Let $D_if$ be the
function defined by
\begin{equation*}
  D_if(\tuple a)=\lim_{h\to 0}\frac{f(\tuple a+h\tuple e_i)-f(\tuple
  a)} {h};
\end{equation*}
this function (where it is well-defined) is the \defn{partial derivative of
  $f$ with respect to the $i$th coordinate}.  Note that $D_if_j(\tuple
  a)$ is the ordinary derivative at $0$ of the function
  \begin{equation*}
    x\mapsto f_j(\tuple a+x\tuple e_i).
  \end{equation*}

\begin{example}\label{ex:d:partial}
  Let $f:\R^2\to\R$ be given by
  \begin{equation*}
    f(x,y)=
    \begin{cases}
      xy/(x^2+y^2),&\text{ if }(x,y)\neq(0,0);\\
0,&\text{ if }(x,y)=(0,0).
    \end{cases}
  \end{equation*}
Then $D_0f(0,0)=0=D_1f(0,0)$, but $f$ is not continuous at $(0,0)$.
\end{example}

For a stronger property than having partial derivatives, we define the
generalization called the \defn{directional derivative}:  If $\tuple
u\in\R^n$, then
\begin{equation*}
  f'(\tuple a;\tuple u)=\lim_{h\to0}\frac{f(\tuple a+h\tuple
  u)-f(\tuple a)}{h}.
\end{equation*}
Thus $f'(\tuple a;\tuple e_i)=D_if(\tuple a)$.  In Example
\ref{ex:d:partial}, not all directional derivatives at $(0,0)$ exist.

\begin{example}
  Let $f:\R^2\to\R$ be given by
  \begin{equation*}
    f(x,y)=
    \begin{cases}
      xy^2/(x^2+y^4),&\text{ if }x\neq0;\\
0,&\text{ if }x=0.
    \end{cases}
  \end{equation*}
Then all directional derivatives at $0$ exist, since
\begin{equation*}
  \frac{f(hu,hv)-f(0,0)}h=\frac{uv^2}{u^2+h^2v^4},
\end{equation*}
which has a limit as $h$ goes to $0$, whether or not $u=0$.  However,
$f(y^2,y)= 1/2$, unless $y=0$; so $f$ is not continuous at $(0,0)$. 
\end{example}

If $n=1$, then $f$ is differentiable at $a$ if and only if there is a
number, called $f'(a)$, such that
\begin{equation*}
  \lim_{h\to0}\frac{f(a+h)-f(a)-f'(a)\cdot h}h=0.
\end{equation*}
The function $h\mapsto f'(a)\cdot h:\R\to \R$ is \tech{linear}; call it
$\lambda$.  (A function $T:\R^n\to \R^m$ is \defn{linear} if
$T(a\tuple u+b\tuple v)=aT(\tuple u)+bT(\tuple v)$ in all cases.)
Then the function $x\mapsto f(a)+\lambda(x-a)$ is an approximation to
$f$ near $a$.

The function $f:\R^n\to\R^m$ is said to be \defn{differentiable at
  $\tuple a$} if there is a linear function $\lambda:\R^n\to\R^m$ such
  that
  \begin{equation*}
    \lim_{\tuple h\to\tuple 0}\frac{\abs{f(\tuple a+\tuple h)-f(\tuple
    a)-\lambda(\tuple h)}}{\abs{\tuple h}}=0.
  \end{equation*}
In this case, $\lambda$ is the \defn{total derivative of $f$ at
  $\tuple a$} and is denoted $Df(\tuple a)$.  Note well that this is a
  \emph{function}; however, we have to check that it is unique: 

  \begin{theorem}
    If $Df(\tuple a)$ exists, then $Df(\tuple a)(\tuple u)=f'(\tuple
    a;\tuple u)$ for all $\tuple u$ in $\R^n$; so the total derivative
    is uniquely determined by the directional derivatives.
  \end{theorem}

  \begin{proof}
    If $Df(\tuple a)$ exists, and $\tuple u\neq0$, then
    \begin{equation*}
      0=\lim_{h\to 0}
\frac{\abs{f(\tuple a+h\tuple u)-f(\tuple
    a)-Df(\tuple a)(h\tuple u)}}{\abs{h\tuple u}}=0;
    \end{equation*}
but $Df(\tuple a)(h\tuple u)=hDf(\tuple a)(\tuple u)$; hence the claim.
  \end{proof}

  \begin{corollary}\label{cor:d:tasp}
    $Df(\tuple a)(\tuple u)=\sum_{i<n}u_iD_if(\tuple a)$ for all
    $\tuple u$.
  \end{corollary}

  \begin{proof}
    It's true when $\tuple u=\tuple e_i$; hence it is true in general,
    by linearity.
  \end{proof}

  \begin{lemma}\label{lem:d:l}
    For any linear function $T:\R^n\to\R^m$ there is a number $M$ such
    that 
    \begin{equation*}
      \abs{T(\tuple h)}\leq M\abs{\tuple h}
    \end{equation*}
for all $\tuple h$ in $\R^n$.  Hence $T$ is continuous at $\tuple 0$.
  \end{lemma}

  \begin{proof}
    $\abs{T(\tuple x)}= \abs{\sum_{i<n}x_iT(\tuple e_i)}\leq
    \sum_{i<n}\abs{x_i}\abs{T(\tuple e_i)}\leq \abs{\tuple
    x}\sum_{i<n}\abs{T(\tuple e_i)}$.
  \end{proof}


  \begin{theorem}
    Differentiability implies continuity.
  \end{theorem}

  \begin{proof}
    If $Df(\tuple a)$ exists, then 
    \begin{equation*}
          \lim_{\tuple h\to\tuple
    0}(f(\tuple a+\tuple h)-f(\tuple a)-Df(\tuple a)(\tuple h))=0;
    \end{equation*}
    but also $\lim_{\tuple h\to\tuple
    0}Df(\tuple a)(\tuple h)=0$, by Lemma \ref{lem:d:l}; hence
    \begin{equation*}
          \lim_{\tuple h\to\tuple
    0}f(\tuple a+\tuple h)=f(\tuple a),
    \end{equation*}
whence the claim.
  \end{proof}

The sum of products in Corollary \ref{cor:d:tasp} can be written as a
matrix product:
\begin{equation*}
  Df(\tuple a)(\tuple u)=
  \begin{bmatrix}
    D_0f(\tuple a) &
\cdots &
D_{n-1}(\tuple a)
  \end{bmatrix}
  \begin{bmatrix}
    u_0 \\ \vdots \\ u_{n-1}.
  \end{bmatrix}
\end{equation*}
As $\tuple u$, so can each partial derivative $D_if(\tuple a)$ be
written as a column-vector.
Thus $Df(\tuple a)(\tuple u)$ is the matrix product $\tuple u\cdot
f'(\tuple a)$, where
\begin{equation*}
  f'(\tuple a)=
  \begin{bmatrix}
    D_0f_0(\tuple a) & \cdots & D_{n-1}f_0(\tuple a)\\
\vdots & \ddots & \vdots \\
D_0f_{m-1}(\tuple a) & \cdots & D_{n-1}f_{m-1}(\tuple a)
  \end{bmatrix}.
\end{equation*}
This matrix $f'(\tuple a)$ is the \defn{Jacobian matrix of $f$ at
  $\tuple a$}.

\begin{theorem}[Chain-Rule]
  If the functions $f:\R^n\to\R^m$ and $g:\R^m\to \R^p$ are
  differentiable at $\tuple a$ and $f(\tuple a)$ respectively, then
  $g\circ f$ is differentiable at $\tuple a$, and
  \begin{equation*}
    D(g\circ f)(\tuple a)=Dg(f(\tuple a))\circ Df(\tuple a),
  \end{equation*}
whence $(g\circ f)'(\tuple a)=g'(f(\tuple a))\cdot f'(\tuple a)$.
\end{theorem}

\begin{proof}
  We have to prove
  \begin{equation*}
    \lim_{\tuple h\to\tuple 0} \frac{g(f(\tuple a+\tuple
    h))-g(f(\tuple a))-Dg(f(\tuple a))(Df(\tuple a)(\tuple
    h))}{\abs{\tuple h}}=0. 
  \end{equation*}
The numerator of the fraction can be written as the sum of
\begin{equation*}
  g(f(\tuple a+\tuple
    h))-g(f(\tuple a))-Dg(f(\tuple a))(f(\tuple a+\tuple h)-f(\tuple a))
\end{equation*}
and
\begin{equation*}
  Dg(f(\tuple a))(f(\tuple a+\tuple h)-f(\tuple a)-Df(\tuple a)(\tuple
  h)). 
\end{equation*}
Write these summands respectively as
\begin{equation*}
  \psi(f(\tuple a+\tuple h))\quad\text{ and }\quad Dg(f(\tuple
  a))(\phi(\tuple h)).  
\end{equation*}
We shall show:
\begin{enumerate}\setcounter{enumi}{-1}
  \item\label{cond:d:first}
$\displaystyle\lim_{\tuple h\to\tuple
    0}\displaystyle\frac{\abs{\psi(f(\tuple a+\tuple h))}}{\abs{\tuple
    h}} =0$; 
\item\label{cond:d:second}
$\displaystyle\lim_{\tuple h\to\tuple
    0}\displaystyle\frac{\abs{Dg(f(\tuple a))(\phi(\tuple
    h))}}{\abs{\tuple h}} =0$.
\end{enumerate}
By Lemma \ref{lem:d:l}, there is $M$ such that, for all $\tuple h$,
\begin{equation*}
  \abs{Dg(f(\tuple a))(\phi(\tuple h))}\leq M\abs{\phi(\tuple h)};
\end{equation*}
since $\lim_{\tuple h\to\tuple 0}\abs{\phi(\tuple h)}/\abs{\tuple
  h}=0$, this proves \pref{cond:d:second}.  For \pref{cond:d:first},
  note that
  \begin{equation*}
    \lim_{\tuple k\to\tuple
    0}\frac{\abs{\psi(f(\tuple a)+\tuple k)}}{\abs{\tuple
    k}} =0;
  \end{equation*}
also,
 if $f(\tuple a+\tuple h)=f(\tuple a)$, then $\psi(f(\tuple
  a+\tuple h))=\tuple 0$.  If $f(\tuple a+\tuple h)\neq f(\tuple a)$,
  then we have
  \begin{equation*}
    \frac{\abs{\psi(f(\tuple a+\tuple h))}}{\abs{\tuple
    h}}= \frac{\abs{\psi(f(\tuple a+\tuple h))}}{\abs{f(\tuple
    a+\tuple h)-f(\tuple a)}}\cdot \frac{\abs{f(\tuple
    a+\tuple h)-f(\tuple a)}}{\abs{\tuple h}}.
  \end{equation*}
The second factor here is
\begin{equation*}
  \frac{\abs{\phi(\tuple h)+Df(\tuple a)(\tuple h)}}{\tuple h};
\end{equation*}
hence there is $N$ such that
\begin{equation*}
  \frac{\abs{f(\tuple
    a+\tuple h)-f(\tuple a)}}{\abs{\tuple
    h}}\leq\frac{\abs{\phi(\tuple h)}}{\tuple h}+N.
\end{equation*}
Suppose $\epsilon>0$.  There are positive numbers $\delta_0$,
$\delta_1$ and $\delta_2$ such that
\begin{align*}
  0<\abs{\tuple h}<\delta_0& \implies\frac{\abs{\phi(\tuple
  h)}}{\abs{\tuple h}}<1;\\
0<\abs{\tuple k}<\delta_1& \implies \frac{\abs{\psi(f(\tuple a)
  +\tuple k)}}{\abs{\tuple k}} <\frac{\epsilon}{N+1};\\
0<\abs{\tuple h}<\delta_2& \implies \abs{f(\tuple a+\tuple h)-f(\tuple
 a)}< \delta_2.
\end{align*}
Let $\delta=\min\{\delta_0,\delta_2\}$; then
\begin{equation*}
  \frac{\abs{\psi(f(\tuple a+\tuple h))}}{\abs{\tuple
    h}}<\epsilon
\end{equation*}
whenever $0<\abs{\tuple h}<\delta$.
\end{proof}

\begin{lemma}
  If the partial derivatives $D_if$ are defined on a neighborhood of
  $\tuple a$ and are continuous at $\tuple a$, then
  $f$ is differentiable at $\tuple a$, that is, the total derivative
  $Df(\tuple a)$ exists.
\end{lemma}

\begin{proof}
We may assume $m=1$.  The $D_if$ must be defined on an open
\emph{interval} $I$ that contains $\tuple a$.  (Note then that $I$ is
$I_0\times\dots\times I_{n-1}$ for some open intervals $I_i$ of $\R$
such that $a_i\in I_i$.)
We shall show that $Df(\tuple a)$ exists by showing that
\begin{equation*}
\lim_{\tuple h\to\tuple 0}\frac{\abs{f(\tuple a+\tuple h)-f(\tuple a)-
    \sum_{i<n}D_if(\tuple a)\cdot h_i}}{\abs{\tuple h}}=0. 
\end{equation*}
Suppose $\tuple h\in I\setminus\{\tuple a\}$.  We have
\begin{multline*}
  f(\tuple a+\tuple h)-f(\tuple a)\\
  \begin{aligned}
&=f(\tuple a+h_0\tuple e_0)-f(\tuple a)\\
&+f(\tuple a+h_0\tuple e_0+ h_1\tuple e_1)-f(\tuple a+h_0\tuple e_0)\\
&+\dotsb\\
&+ f(\tuple a+ h_0\tuple e_0+\dots+ h_{n-1}\tuple e_{n-1})- f(\tuple
a+ h_0\tuple e_0+\dots+ h_{n-2}\tuple e_{n-2})
  \end{aligned}\\
=\sum_{i<n}(f(\tuple a+\sum_{j<i+1}h_j\tuple e_j)- f(\tuple
a+\sum_{j<i} h_j\tuple e_j))
=\sum_{i<n} D_if(\tuple b_i)\cdot h_i,
\end{multline*}
where $\tuple b_i=\tuple a+\sum_{j<i}h_j\tuple e_j+c_i\tuple e_i$ for
some $c_i$ between $0$ and $h_i$, by the Mean-Value Theorem as applied
to the function
\begin{equation*}
  x\mapsto f(\tuple a+\sum_{i<j}h_j\tuple e_j+x\tuple e_i).
\end{equation*}
In particular, $\tuple b_i\in I$.  We now have
\begin{align*}
  0&\leq\frac{\abs{f(\tuple a+\tuple h)-f(\tuple
  a)-\sum_{i<n}D_if(\tuple a)\cdot h_i}}{\abs{\tuple h}}\\
&=\frac{\abs{\sum_{i<n}(D_if(\tuple b_i)-D_if(\tuple a))\cdot
  h_i}}{\abs{\tuple h}}\\
&\leq \sum_{i<n}\frac{\abs{D_if(\tuple b_i)-D_if(\tuple
  a)}\cdot\abs{h_i}} {\abs{\tuple h}}\\
&\leq\sum_{i<n}\abs{D_if(\tuple b_i)-D_if(\tuple
  a)}.
\end{align*}
If $\epsilon>0$, then, by the continuity of the $D_if$ at $\tuple a$,
there is a ball $B(\tuple a;\delta)$ around $\tuple a$ such that, if
$\tuple x$ is in this ball, then 
\begin{equation*}
  \abs{D_if(\tuple x)-D_if(\tuple a)}\leq\frac{\epsilon}n.
\end{equation*}
If $\tuple h$ is $B(\tuple a;\delta)$, then so are the $\tuple b_i$,
which means
\begin{equation*}
  \frac{\abs{f(\tuple a+\tuple h)-f(\tuple
  a)-\sum_{i<n}D_if(\tuple a)\cdot h_i}}{\abs{\tuple h}}<\epsilon.
\end{equation*}
The claim now follows.
\end{proof}

The sufficient condition for differentiability of $f$ at $\tuple a$ given by
the theorem is that $f$ be \defn{continuously differentiable at
  $\tuple a$}. 

To the Chain-Rule, we can now state a:

\begin{corollary}
  If $f$ is continuously differentiable at $\tuple a$, and the
  function $g:\R^m\to \R$ is differentiable at $f(\tuple a)$, then 
$g\circ f$ is differentiable at $\tuple a$, and
  \begin{equation*}
    D_i(g\circ f)(\tuple a)=\sum_{j<m}D_jg(f(\tuple a))\cdot
    D_if_j(\tuple a)
  \end{equation*}
for each $i$ less than $n$.
\end{corollary}

\begin{proof}
  By the Chain-Rule,
  \begin{multline*}
    \begin{bmatrix}
      D_0(g\circ f)(\tuple a) & \cdots & D_{n-1}(g\circ f)(\tuple a)
    \end{bmatrix}
= (g\circ f)'(\tuple a)= g'(f(\tuple a))\cdot f'(\tuple a)\\
=
\begin{bmatrix}
  D_0g(f(\tuple a))& \cdots & D_{m-1}g(f(\tuple a))
\end{bmatrix}
\cdot
\begin{bmatrix}
    D_0f_0(\tuple a) & \cdots & D_{n-1}f_0(\tuple a)\\
\vdots & \ddots & \vdots \\
D_0f_{m-1}(\tuple a) & \cdots & D_{n-1}f_{m-1}(\tuple a)  
\end{bmatrix}.
  \end{multline*}
Consideration of the $i$-th entry of the first and last members of the
equation yields the result.
\end{proof}

\begin{theorem}[Inverse Function]
Suppose $m=n$, and $f$ is continuously differentiable on a
neighborhood of $\tuple a$, and $Df(\tuple a)$ is invertible, that is,
$\det(f'(\tuple a))\neq 0$.  Then there are neighborhoods $V$ of
$\tuple a$ and $W$ of $f(\tuple a)$ such that $f$ is a bijection from
$V$ to $W$ with a differentiable inverse $f\inv$ satisfying
\begin{equation}\label{eqn:d:ift}
  D(f\inv)(f(\tuple x))=Df(\tuple x)\inv
\end{equation}
for all $\tuple x$ in $V$, equivalently,
\begin{equation*}
  (f\inv)'(f(\tuple x))=(f'(\tuple x))\inv.
\end{equation*}
\end{theorem}

\begin{proof}
\textlist
For any function $f:\R^n\to\R^n$, let $\Phi(f)$ be the statement,
\begin{quote}
  If $f$ is continuously differentiable near $\tuple a$, then $\tuple
  a$ and $f(\tuple a)$ have neighborhoods $V$ and $W$ respectively
  such that $f$ is a bijection from $V$ to $W$ with differentiable
  inverse. 
\end{quote}
Now, any linear function on $\R^n$ is its own derivative everywhere.
In particular, let $\id$ be the identity on $\R^n$.  Then
\begin{equation*}
  D(\id)(\tuple x)=\id
\end{equation*}
for all $\tuple x$ in $\R^n$.  If $\Phi(f)$, then $f\inv\circ f=\id$
on $V$, so
\begin{equation*}
  Df\inv(f(\tuple x))\circ Df(\tuple x)=\id,
\end{equation*}
whence \pref{eqn:d:ift}.  It remains for us to show simply that
$\Phi(f)$ whenever $Df(\tuple a)$ is invertible.

\next
If $\Phi(f)$, and $T:\R^n\to\R^n$ is invertible and linear, then
$\Phi(T\circ f)$.  In particular, if $Df(\tuple a)$ is invertible, and
$\Phi(Df(\tuple a)\inv\circ f)$, then $\Phi(f)$.  But
\begin{equation*}
  D(Df(\tuple a)\inv\circ f)(\tuple a)=\id,
\end{equation*}
by the Chain-Rule.  So it is enough for us to show that $\Phi(f)$
whenever 
\begin{equation}\label{eqn:d:der}
  Df(\tuple a)=\id.
\end{equation}

\next
Let us now assume that $f$ is continuously differentiable near $\tuple
a$, and that \pref{eqn:d:der} holds.
  Then
\begin{equation*}
  \lim_{\tuple h\to\tuple 0}\frac{\abs{f(\tuple a+\tuple h)-f(\tuple
  a)-\tuple h}}{\abs{\tuple h}}=0.
\end{equation*}
But we also have
\begin{equation*}
  \frac{\abs{f(\tuple a+\tuple h)-f(\tuple
  a)-\tuple h}}{\abs{\tuple h}}\geq \abs{\frac{\abs{f(\tuple a+\tuple
  h)-f(\tuple a)}}{\abs{\tuple h}} -1}.
\end{equation*}
Therefore
\begin{equation*}
  \lim_{\tuple h\to\tuple 0} \frac{\abs{f(\tuple a+\tuple
  h)-f(\tuple a)}}{\abs{\tuple h}}=1,
\end{equation*}
which means in particular that, $\tuple a$ has a neighborhood $U$ such
that 
\begin{equation}\label{eqn:d:inj}
  f(\tuple x)=f(\tuple a)\implies \tuple x=\tuple a
\end{equation}
for all $\tuple x$ in $U$.

\next
We can make certain additional assumptions about $U$.
We may assume that $U$ is a closed ball,
\begin{equation*}
U=  \{\tuple x\in\R^n:\abs{\tuple x-\tuple a}\leq r\}.
\end{equation*}
  Since $f$ is
continuously differentiable near $\tuple a$, the function
$\tuple x\mapsto\det(f'(\tuple x))$ is continuous near $\tuple a$, and
therefore we may assume that $Df(\tuple x)$ is invertible for all
$\tuple x$ in $U$; we may also assume
\begin{equation}\label{eqn:d:bound}
  \abs{D_if_j(\tuple x)-D_if_j(\tuple a)}\leq \frac 1{2n^2}
\end{equation}
for each $i$ and $j$.  

By \pref{eqn:d:der}, $D_if_j(\tuple
a)=\delta_{i\,j}$.  Let $g$ be the function $\tuple x\mapsto  f(\tuple
x)-\tuple x$;
then
\begin{equation}\label{eqn:d:g}
  D_ig_j(\tuple a)= D_if_j(\tuple x)- \delta_{i\,j}= D_if_j(\tuple
  x)-D_if_j(\tuple a). 
\end{equation}
For all $\tuple
x$ and $\tuple u$ in $U$, we have
\begin{multline*}
  \abs{\tuple u-\tuple x}-\abs{f(\tuple u)-f(\tuple
  x)} \leq\abs{g(\tuple u)-g(\tuple x)}
 \leq \sum_{i<n}\abs{g_i(\tuple
  u)-g_i(\tuple x)}\\
 \leq \sum_{i<n}\sum_{j<n}\abs{g(\sum_{k=0}^j u_k\tuple e_k+
  \sum_{k=j+1}^{n-1} x_k\tuple e_k)- g(\sum_{k=0}^{j-1} u_k\tuple e_k+
  \sum_{k=j}^{n-1} x_k\tuple e_k)}\\
 \leq \sum_{i<n}\sum_{j<n}\frac1{2n^2}\cdot\abs{u_j-x_j}
\leq \sum_{i,j<n}\frac1{2n^2}\cdot\abs{\tuple u-\tuple x}
\leq \frac12\cdot\abs{\tuple u-\tuple x}
\end{multline*}
by the Mean-Value Theorem, \pref{eqn:d:bound} and \pref{eqn:d:g}, and
therefore 
\begin{equation}\label{eqn:d:cont}
  \abs{\tuple u-\tuple x}\leq 2\cdot\abs{f(\tuple u)-f(\tuple x)}.
\end{equation}
Hence $f$ is injective on $U$, and $f\inv$ is well-defined and
continuous on $f(U)$.  

It remains to prove that $f(U)$ is in fact a
neighborhood of $f(\tuple a)$ and that $f\inv$ is differentiable on
some neighborhood of $f(\tuple a)$.

\next
The \defn{boundary} of $U$ can be denoted $\partial U$ and is the
compact set 
\begin{equation*}
  \{\tuple x\in U:\abs{\tuple  x-\tuple a}=r\}.
\end{equation*}
Note then that
\begin{equation*}
  U\setminus\partial U=B(\tuple a;r).
\end{equation*}
The continuous function $\tuple x\to\abs{f(\tuple x)-f(\tuple
  a)}:\partial U\to\R$ must attain a minimum value $d$, which must be
  positive, by \pref{eqn:d:inj}.  Now define
  \begin{equation*}
W=B(f(\tuple a);d/2),
  \end{equation*}
the open ball with center $f(\tuple a)$ and radius $d/2$.
If $\tuple y\in W$, and $\tuple u\in\partial U$, then
\begin{equation*}
  d\leq\abs{f(\tuple u)-f(\tuple a)}\leq \abs{f(\tuple u)-\tuple y} +
  \abs{\tuple y-f(\tuple a)};
\end{equation*}
since also $\abs{\tuple y-f(\tuple a)}<d/2$, we have
\begin{equation}\label{eqn:d:ineq}
  \abs{\tuple y-f(\tuple a)}<\abs{f(\tuple u)-\tuple y}.
\end{equation}

\next
We shall now show that 
\begin{equation*}
  W\included f(U\setminus\partial U).
\end{equation*}
Then we can define
\begin{equation*}
  V= (U\setminus\partial U)\cap f\inv(W),
\end{equation*}
so that $V$ is an open neighborhood of $\tuple a$, and $f$ is a
continuous bijection between this and the open neighborhood $W$ of
$f(\tuple a)$. 

Let $\tuple y\in W$; we shall find $\tuple x$ in
$U\setminus\partial U$ such that $f(\tuple x)=\tuple y$.  Let $h$ be
the continuously differentiable function 
\begin{equation*}
  \tuple u\mapsto\abs{\tuple
  y-f(\tuple u)}^2:U\to \R.
\end{equation*}
  By \pref{eqn:d:ineq}, we have
\begin{equation*}
  \tuple u\in\partial U\implies h(\tuple a)<h(\tuple u).
\end{equation*}
Since $U$ is compact, $h$ attains a minimum at some $\tuple x$, which
must therefore be in $U\setminus\partial U$.  Then $Dh(\tuple x)$ is
the zero-function.  Now, 
$h$ is the composition of $\tuple u\mapsto \tuple y-f(\tuple u)$ and $\tuple
z\mapsto\sum_{i<n}z_i^2$. 
By the Chain-Rule, we find
\begin{equation*}
  2
  \begin{bmatrix}
    y_0-f_0(\tuple x) & \cdots & y_{n-1}-f_{n-1}(\tuple x)
  \end{bmatrix}
\cdot
f'(\tuple x)=
\begin{bmatrix}
  0 & \cdots & 0
\end{bmatrix}
.
\end{equation*}
The invertibility of $f'(\tuple x)$ yields $f(\tuple x)=\tuple y$, as
desired.  

\next
It remains to show that if $\tuple x\in V$, then $D(f\inv)(f(\tuple
x))$ exists.  It will be enough to show
\begin{equation*}
  \lim_{\tuple k\to\tuple 0}\frac{\abs{f\inv(f(\tuple x)+\tuple k) -
  \tuple x - Df(\tuple x)\inv(\tuple k)}} {\abs{\tuple k}}=0.
\end{equation*}
By Lemma \ref{lem:d:l}, it will therefore be enough to show
\begin{equation}\label{eqn:d:end}
  \lim_{\tuple k\to\tuple 0}\frac{\abs{Df(\tuple x)(f\inv(f(\tuple
  x)+\tuple k) - 
  \tuple x - Df(\tuple x)\inv(\tuple k))}} {\abs{\tuple k}}=0.
\end{equation}
We re-write this, first defining
\begin{equation*}
  h(\tuple k)=f\inv(f(\tuple
x)+\tuple k) - \tuple x,
\end{equation*}
so that
\begin{equation*}
  \tuple k=f(\tuple x+ h(\tuple k))-f(\tuple x).
\end{equation*}
Then
\begin{multline*}
\frac{\abs{Df(\tuple x) (f\inv(f(\tuple x)+\tuple k) - 
  \tuple x - Df(\tuple x)\inv(\tuple k))}} {\abs{\tuple k}}\\
 =\frac{\abs{Df(\tuple x)(h(\tuple k)-Df(\tuple x)\inv(\tuple k))}}
  {\abs{\tuple k}}
=\frac{\abs{\tuple k-Df(\tuple x)(h(\tuple k))}}{\abs{\tuple k}}\\
=\frac{\abs{f(\tuple x+h(\tuple k))-f(\tuple x)
-Df(\tuple x)(h(\tuple k))}}{\abs{\tuple k}}\\
=\frac{\abs{f(\tuple x+h(\tuple k))-f(\tuple x)
-Df(\tuple x)(h(\tuple k))}}{\abs{h(\tuple k)}}\cdot
\frac{\abs{h(\tuple k)}}{\abs{\tuple k}}.
\end{multline*}
By \pref{eqn:d:bound}, the second factor here is bounded by $2$; and
the first factor has limit $0$ at $\tuple 0$, since $\lim_{\tuple
  k\to\tuple 0}h(\tuple k)=\tuple 0$.  Therefore \pref{eqn:d:end},
which completes the proof.
\end{proof}

\begin{corollary}[Implicit Function Theorem]
Suppose $\tuple a\in\R^n$ and $\tuple b\in\R^m$ and
$f:\R^n\times\R^m\to\R^m$ is continuously differentiable in a
neighborhood of $(\tuple a,\tuple b)$.  Let
\begin{equation*}
  f'(\tuple a,\tuple b)=
  \begin{bmatrix}
    A & B
  \end{bmatrix},
\end{equation*}
where $B$ is a \emph{square} matrix.  If $f(\tuple a,\tuple b)=0$, and
$\det B\neq0$, then there is a function $g:\R^n\to\R^m$ such that
$g(\tuple a)=\tuple b$, and $f(\tuple x,g(\tuple x))=0$ for all
$\tuple x$ in a neighborhood of $\tuple a$, and $g$ is differentiable
on this neighborhood.
\end{corollary}

\begin{proof}
  Let $F$ be the function
  \begin{equation*}
    (\tuple x,\tuple y)\mapsto (\tuple x,f(\tuple x,\tuple
    y)):\R^n\times \R^m\to \R^n\times \R^m.
  \end{equation*}
Then
\begin{equation*}
  F'(\tuple a,\tuple b)=
  \begin{bmatrix}
    I & 0\\
A & B
  \end{bmatrix},
\end{equation*}
so $\det(F'(\tuple a,\tuple b))=\det B\neq0$.  Hence $(\tuple a,\tuple
b)$ and $(\tuple a,\tuple 0)$ have neighborhoods $U\times V$ and $W$
respectively such that $F$ is a bijection from $U\times V$ to $W$ with
a differentiable inverse.  We can write this inverse as
\begin{equation*}
  (\tuple x,\tuple y)\mapsto(\tuple x,h(\tuple x,\tuple y)),
\end{equation*}
where $h$ is the appropriate function from $W$ to $V$.  Then
\begin{equation*}
  (\tuple x,\tuple y)=F(\tuple x,h(\tuple x,\tuple y))=(\tuple
  x,f(\tuple x,h(\tuple x,\tuple y))),
\end{equation*}
which means
\begin{equation*}
  \tuple y=f(\tuple x,h(\tuple x,\tuple y)),
\end{equation*}
when $(\tuple x,\tuple y)\in W$.  Hence, in particular,
\begin{equation*}
  \tuple 0=f(\tuple x,h(\tuple x,\tuple 0)).
\end{equation*}
So we may let $g$ be $\tuple x\mapsto h(\tuple x,\tuple 0)$.
\end{proof}

\section{Integration in several dimensions}\label{sect:int}

A \defn{compact interval} of $\R^n$ is a subset
\begin{equation*}
  I_0\times \dots I_{n-1},
\end{equation*}
where each $I_j$ is a closed, bounded interval of $\R$.  Every compact
interval $I$ has a \defn{measure}, denoted $\mu(I)$ and defined
recursively by:
\begin{itemize}
  \item
$\mu([a,b])=b-a$;
\item
$\mu(I\times I')=\mu(I)\cdot\mu(I')$.
\end{itemize}

Let $I$ be the compact interval $I_0\times \dots I_{n-1}$.  A
\defn{partition} of $I$ is a product
\begin{equation*}
  P_0\times \dots\times P_{n-1},
\end{equation*}
where each $P_j$ is a partition of $I_j$.  Let the partition of $I$ be
$P$.  If each $P_j$ has $m_j+1$
elements, then $P$ determines $m_0\dotsb m_{n-1}$ sub-intervals of $I$
in an obvious way.  Let $J$ range over the set of these
sub-intervals.  If $t_J\in J$ for each $J$, and $f$ is a function from
$I$ to $\R$, then $f$ has a \defn{Riemann sum}
\begin{equation*}
  \sum_J f(t_J)\cdot\mu(J)
\end{equation*}
for the partition $P$.  Then $f$ is \defn{Riemann-integrable on $I$}
if there is a number $A$ such that, for all positive numbers
$\epsilon$, there is a partition of $I$ such that, for all finer
partitions of $I$ into sub-intervals $J$, for all choices of $t_J$ in
$J$,
\begin{equation*}
  \abs{\sum_{J}f(t_J)\cdot\mu(J)-A}<\epsilon.
\end{equation*}
In this case, $A$ is unique and can be denoted
\begin{equation*}
  \int_If.
\end{equation*}
As in the special case where $I\pincluded \R$, so in the general case,
integrability is equivalent to a condition known as \defn{Riemann's
  Condition}.  

Suppose $S$ is a bounded subset of $\R^n$, and $f$ is a real-valued
function on $S$.  Define the \defn{characteristic function} of $S$ to
be $\chi_S:\R^n\to\R$, where
\begin{equation*}
  \chi_S(\tuple x)=
  \begin{cases}
    1,&\text{ if }\tuple x\in S;\\
0,&\text{ if }\tuple x\notin S.
  \end{cases}
\end{equation*}
Then $f\cdot\chi_S$ is a well-defined function on $\R^n$, with value
$0$ on $\R^n\setminus S$.
If $I$ and $I'$ are two compact intervals including $S$, and
$\int_If\cdot\chi_S$ exists, then so does $\int_{I'}f\cdot\chi_S$, and
the two intervals are equal; we can then define this common value to
be the integral
\begin{equation*}
  \int_Sf.
\end{equation*}
We may ask two questions:
\begin{itemize}
  \item
How can we tell whether integrals $\int_Sf$ exist?
\item
If they exist, how can they be computed?
\end{itemize}

The set $S$ has \defn{measure zero} if for all positive $\epsilon$
there is a countable set $\{I_j:j\in\N\}$ of intervals such that
\begin{equation*}
  S\included\bigcup_{j\in\N}I_j\quad\text{ and
  }\quad\sum_{j=0}^{\infty}\mu(I_j)\leq\epsilon. 
\end{equation*}
Let us say that $\tuple x$ is a \defn{discontinuity} of $f$ if $f$ is
not continuous at $\tuple x$.

\begin{theorem}[Lebesgue Criterion]
  Let $f$ be a bounded real-valued function on a compact interval $I$
  of $\R$.  Then $\int_If$ exists if and only if the set of
  discontinuities of $f$ has measure zero.
\end{theorem}

\begin{example}
  $\Q$ has measure zero.  Indeed, $\Q$ can be written as
  $\{x_j:j\in\N\}$.  If $\epsilon>0$, let
  \begin{equation*}
    I_j=\left[x_j-\frac{\epsilon}{2^{j+2}},
    x_j+\frac{\epsilon}{2^{j+2}}\right].  
  \end{equation*}
Then 
\begin{equation*}
  \sum_{j=0}^{\infty}\mu(I_j)=
\sum_{j=0}^{\infty}\frac{\epsilon}{2^{j+1}}= \epsilon, 
\end{equation*}
and $x_j\in I_j$.  Let
$f:\R\to \R$ be given by
\begin{equation*}
  f(x)=
  \begin{cases}
    0,&\text{ if }x\notin\Q;\\
1/\abs n,&\text{ if }x=m/n\text{ in lowest terms.}
  \end{cases}
\end{equation*}
Then the set of discontinuities of $f$ is precisely $\Q$, so $f$ is
integrable on every compact interval, and each of the integrals is $0$.
\end{example}

The \defn{boundary} of a subset $S$ of $\R^n$ is the set $\partial
S$ of points $\tuple x$ of $\R^n$ such that every ball with center
$\tuple x$ contains points of both $S$ and $\R^n\setminus S$.  If $S$
is bounded, then $S$ is said to be \defn{Jordan-measurable} if
$\partial S$ has measure zero.

\begin{theorem}
  Let $S$ be a bounded, Jordan-measurable subset of $\R^n$, and let
  $f$ be a real-valued function on $S$.  Then $\int_Sf$ exists if and
  only if the set of discontinuities of $f$ on $S$ has measure zero.
\end{theorem}
\end{document}



