\documentclass[../research.tex]{subfile}

\subsection{Sequences}
\label{sec:1.1}

  We denote set of positive integers as $\N$.

  \begin{prop}
    Let $a_i = (a_i^1,\dots,a_i^n)\in\R^n$ be a sequence,  $\forall n\in\N$. Then
    $a_i\to a:=(a^1,\dots,a^n)\in\R^n$, as $i\to\infty$ iff $a_i^k\to a^k$ as $i\to\infty$,
    $\forall k\in\{1,\dots,n\}$.
  \end{prop}

  \begin{proof}
    We know that
    $$\max_{k=1,\dots,n}{|a^k|}\leq\|a\|\leq\sqrt{n}\max_{k=1,\dots,n}{|a^k|}.$$

    To show this, observe that:
    $$\sqrt{\max_k{((a^k)}^2)}\leq\sqrt{(a^1)^2+\dots+(a^n)^2}\leq\sqrt{n\max_k{((a^k)^2})}$$
    $$\Rightarrow \sqrt{(\max_k{|a^k|})^2}\leq\|x\|\leq\sqrt{n(\max_k{|a^k|})^2}$$
    $$\Rightarrow \max_k{|a^k|}\leq\|x\|\leq\sqrt{n}\max_k{|a^k|}$$

    First assume that $a_i\to a$ as $i\to\infty$. Then $\forall\epsilon>0$ $\exists N\in\N$ such
    that $\|a_i-a\|<\epsilon$ whenever $i\geq N$.

    Then $\forall k=1\dots n$, $|a^k_i-a^k|\leq\max_k{|a^k_i-a^k|}\leq\|a_i-a\|<\epsilon$ whenever
    $i\geq N$, so $a^k_i\to a^k$ as $i\to\infty$.

    Conversely, assume that $a_i^k\to a^k$ as $i\to\infty$, $\forall k\in\{1,\dots,n\}$.
    Then $\forall\epsilon>0$, $\exists N^k\in\N$ such that $|a_i^k-a^k|\leq\frac{\epsilon}{\sqrt{n}}$
    whenever $i\geq N^k$, $\forall k=1,\dots,n$. Let
    $$N=\max_{k=1,\dots,n}{N^k}.$$

    Then $\max_k{|a^k_i-a^k|}<\frac{\epsilon}{\sqrt{n}}$ whenever $i\geq N$, so
    $\|a_i-a\|\leq\sqrt{n}\max_k{|a^k_i-a^k|}<\epsilon$.
  \end{proof}

  \begin{prop}
    The limit of a sequence in $\R^n$ is unique.
  \end{prop}

  \begin{proof}
    Let $(x_i)_{i\in\N}$ be a sequence with $x_i\in\R^n$.
    Suppose for a contradiction that $x_i\to a$ and $x_i\to b$ as $i\to\infty$, with $a\neq b$.

    Then $\forall\epsilon>0$, $\exists N_a,N_b\in\N$ such that $\|x_i-a\|<\frac{\epsilon}{2}$ whenever
    $i\geq N_a$, and $\|x_i-b\|<\frac{\epsilon}{2}$ whenever $i\geq N_b$. Let
    $$N=\max{\{N_a,N_b\}}.$$
    Then whenever $i\geq N$, we have:
    \begin{align*}
    \|a-b\|&=\|a-x_i+x_i-b\|\\
           &\leq\|a-x_i\|+\|x_i-b\|\\
           &<\frac{\epsilon}{2}+\frac{\epsilon}{2}=\epsilon,
    \end{align*}
    And since $\epsilon$ can be made arbitrarily small, we find that $a=b$, which is a contradiction.
  \end{proof}

  \begin{theorem}[Monotone convergence]
    An increasing and bounded above sequence is convergent. Likewise, a decreasing and bounded below
    sequence is convergent.
  \end{theorem}

  \begin{proof}
    Suppose $(a_i)$ is bounded above and increasing. Then the set $A=\{a_i:i\in\N\}$ has a supremum,
    say $a=\sup{A}$. I claim that $a_i\to a$ as $i\to\infty$. \\

    \textit{Proof of claim.}
      Fix $\eps$. Then $\exists a_N$, with $N\in\N$ such that
      $$a-\epsilon<a_N\leq a<a+\epsilon.$$
      Since $(a_i)$ is increasing, $a_i\geq a_N$ when $i\geq N$, and since it is also bounded above
      by $a$, we have
      $$a-\epsilon<a_N\leq a\leq a_i<a+\epsilon,$$
      and so
      $$|a-a_i|<\epsilon.$$
    So $a_i\to a$ as $i\to\infty$. Simililary, we can show that if $(a_i)$ is bounded below and
    decreasing, $a_i\to \inf{\{a_i:i\in\N\}}$ as $i\to\infty$.
  \end{proof}

  \begin{lemma}
    Let $(a_n)_{n\in\N}$ be a bounded sequence of real numbers. Then $(a_n)_{n\in\N}$ has a convergent
    subsequence.
  \end{lemma}
%
%  \begin{proof}
%    We say $x_i$ is a peak point of $(a_n)$ if $a_n\leq x_i, \forall n>i$.\\
%
%    Then either we have infinitely many peak points, or finitely many.
%    In the first case, we have an infinite subsequence, $(x_{i_j})_{j\in\mathbb{N}}$, of peak points
%    which is non-increasing, since $a_{i_n}\leq x_{i_j}$ whenever $n>j$. Then since $(a_i)$ is
%    bounded, so is $(x_{i_j})$, so it is convergent.\\
%
%    Now consider the case of finitely many peak points, say $x_1,\dots x_k$. Choose
%    $n_1>\text{max}\{1,\dots,k\}$. Since $a_{n_1}$ is not a peak point, $\exists n_2 > n_1$ such
%    that $a_{n_2}>a_{n_1}$. Since $a_{n_2}$ is not a peak point, $\exists n_3 > n_2$ such that
%    $a_{n_3}>a_{n_2}$. Continuing inductively, with $a_{n_i}>a_{n_{i-1}}$, we obtain a decreasing
%    subsequence $(a_{n_j})_{j\in\N}$. Then since $(a_{n_j})_{j\in\N}$ is bounded, it converges.
%  \end{proof}
%
%  We now present another proof.
%
  \begin{proof}
    Since $(a_i)$ is bounded, $\exists K\geq0$ such that $a_i\in I_0:=[-K,K]\,\forall i\in\N$.
    Then one of $[-K,0]$, $[0,K]$ contains infinitely many elements of $(a_i)$. Choose the
    leftmost one, and call it $I_1$. Repeat this inductively, such that $I_j:=[c_j,d_j]$
    contains infinitely many elements of $(a_i)$. We then inductively define
    $$i_j=\min_{i>i_{j-1}}{i:a_i\in I_j}.$$
    In other words, $a_{i_j}$ is the first element of $(a_i)$ which lies in $I_j$. Now, since
    $$I_j\subset I_{j-1}\subset\dots\subset I_1\subset I_0,$$
    The sequences $(c_j)$ and $(d_j)$ are monotically increasing and decreasing, respectively,
    and since they are bounded, they both converge, so say that
    $$c_j\to c\in[-K,K]\text{ as }j\to\infty,$$
    $$d_j\to d\in[-K,K]\text{ as }j\to\infty.$$
    Since $d_j-c_j=\text{length}(I_j)=2^{1-j}K\to0$ as $j\to\infty$, we have that $c=d$, and
    since $c_j\leq a_{i_j}\leq d_j$, we also have that $a_{i_j}\to c=d$ as $j\to\infty$.
  \end{proof}

  \begin{cor}
    Let $(a_i)_{i\in\N}$ be a bounded sequence in $\R^n$. Then $(a_i)$ has a
    convergent subsequence.
  \end{cor}
  \begin{proof}
    Since $(a_i)$ is bounded, and the component sequences $(a_i^k)$ are bounded $\forall k=1,\dots,n$.

    Then by the previous lemma, $(a_i^1),\dots,(a_i^n)$ have subsequences $(a_{i_{j_1}}^1), \dots,
    (a_{i_{j_n}}^n)$ converging to $a^1,\dots,a^n$ respectively. Let
    \begin{align*}
      J_1&=\{j_{1_1},j_{1_2},\dots\},\\
      J_2&=\{j_{2_1},j_{2_2},\dots\},\\
         &\vdots \\
      J_n&=\{j_{n_1},j_{n_2},\dots\},
    \end{align*}
    and $J=J_1\cap\dots\cap J_n$.\\

    Then each component subsequence $(a_j^k)_{j\in J}$ converges to $a^k$, so $(a_j)_{j\in J}$
    converges to $a$.
  \end{proof}

  \begin{theorem}[Bolzano-Weierstrass]
    Let $E\subset\R^n$ be compact and $(a_i)_{i\in\N}$ a sequence in $E$. Then $(a_i)$ has a
    subsequence converging to a point in $E$.
  \end{theorem}

  \begin{proof}
    Since $(a_i)$ is bounded, it has a subsequence $(a_{i_j})\to a$ as $j\to\infty$.

    And since $E$ is closed, and $a$ a limit point of $E$, $a\in E$.
  \end{proof}

\subsection{Continuous Functions}
\label{sec:1.2}

  \begin{definition}[Continuity]
    Let $A\subset\R^n$ be open. We say $f:A\to\R^m$ is \textit{continuous} on $A$ if,
    $\forall a\in A$, $\forall\epsilon>0$ $\exists\delta>0$ such that
    $\|f(x)-f(a)\|<\epsilon$, whenever $\|x-a\|<\delta$.
  \end{definition}

  Generally, we can think of continuous functions are those for which points that are `near' are mapped to
  by points that are also `near', and so showing that a function is continuous amounts to finding a positive
  relationship between the definition of `nearness' in the domain and the definition of `nearness' in
  the range (these are not generally the same). In this
  case, points $x,y\in\R^n$ are near if the distance between them, $\|x-y\|$, is small.

  In a more general topological sense, we say that two points are near, in a certain capacity,
  if they are both elements of the same open set. Thus, very vaguely, the more open sets the points
  are both elements of, the nearer they are. In Euclidean space, open sets are defined as arbitary
  unions of open balls $B_\epsilon(x)$, for $x\in\R^n$ and $\epsilon>0$. Thus, $x=y$ precisely when
  $y\in B_\epsilon(x)$ (and $x\in B_\epsilon(y)$) $\forall\epsilon>0$.

  This is the Euclidean case of
  a general property called non-seperatedness, which we use to describe
  points that both lie in every open set. Since they share every open set in common, their nearness
  is maximal, and so we can think of them as essentially being indistinguishable - i.e. the same point.
  We will revist this later, when we discuss seperatedness conditions.

  \begin{prop}
    For $f:A\to\R^m$, we write $f(x)=(f_1(x),\dots,f_m(x))$.

    Then $f$ is continuous if and only if each of the component functions
    $f_i:A\to\R$ are continuous.
  \end{prop}

  \begin{proof}
    First assume $f$ is continuous at $a\in A$. Then $\forall\epsilon>0$
    $\exists\delta>0$ such that $\|f(x)-f(a)\|<\epsilon$ whenever $\|x-a\|<\delta$. Then
    \begin{align*}
      |f_i(x)-f_i(a)|&\leq\max_i{|f_i(x)-f_i(a)|}\\
                     &\leq\|f(x)-f(a)\|\\
                     &<\epsilon\quad\forall i=1,\dots,m.
    \end{align*}

    Hence each $f_i$ is continuous at $a$. Now assume that each $f_i$ is continuous at $a\in A$.

    Then $\forall\epsilon>0$, $\exists\delta_i>0$ such that $|f_i(x)-f_i(a)|<\frac{\epsilon}{m\sqrt{m}}$
    whenever $\|x-a\|<\delta_i$, $\forall i=1,\dots,m$. Now let $\delta=\min{\{\delta_1,\dots,\delta_m\}}$

    Then when $\|x-a\|<\delta$, $\|x-a\|<\delta_i$, so $|f_i(x)-f_i(a)|<\frac{\epsilon}{m\sqrt{m}}$
    $\forall i=1,\dots,m$. Then
    \begin{align*}
    \|f_i(x)-f_i(a)\|&\leq\sqrt{m}\max_i{|f_i(x)-f_i(a)|}\\
                     &\leq\sqrt{m}\sum_{i=1}^m{|f_i(x)-f_i(a)|}\\
                     &<\epsilon
    \end{align*}
  \end{proof}

  \begin{example}
    Every linear function is continuous.
  \end{example}

  \begin{prop}
    Let $A\subset\R^n$ be open. Then $f:A\to\R^m$ is continuous at $x\in A$ if and only if
    $f(x_i)\to f(x)$ as $i\to\infty$ for any sequence $(x_i)$ converging to $x$.
  \end{prop}

  \begin{proof}
    Let $(x_i)$ be a sequence in $A$ converging to $x\in A$, and assume $f:A\to\R^m$ to be continuous
    at $x$. Then $\forall\epsilon>0$, $\exists\delta>0$ such that $\|f(x)-f(y)\|<\epsilon$
    whenever $0<\|x-y\|<\delta$.\\

    Since $x_i\to x$, $\nat$ such that $\|x_i-x\|<\delta$ whenever $i\geq N$, and hence $\|f(x_i)-f(x)\|<\epsilon$,
    so we have that $f(x_i)\to f(x)$ as $i\to\infty$.\\

    Now assume the converse holds, and for a contradiction that $f$ is not continuous. Then
    $\exists\epsilon>0$ such that $\forall\delta>0$ $\|f(x)-f(x_i)\|\geq\epsilon$ whenever
    $0<\|x-x_i\|<\delta$, and in particular whenever $0<\|x-x_i\|<\frac{1}{i}$, $\forall i\in\N$.

    Then the sequence $(x_i)$ converges to $x$, so by assumption the image sequence $(f(x_i))$
    converges to $f(x)$.\\

    Thus $\exists N\in\N$ such that $\|f(x_i)-f(x)\|<\epsilon$ whenever $i\geq N$, which is a
    contradiction. Hence, $f$ is continuous at $x$.
  \end{proof}

  \begin{theorem}[Extreme Value Theorem]
    Let $E\subset\R^n$ be compact and non-empty. Let $f:E\to\R$ be continuous.
    Then $f$ achieves its maximum and minimum values on $E$.
  \end{theorem}

  \begin{proof}
    We prove that $f$ reaches its maximum on $E$. First suppose for a contradiction that
    $f$ is unbounded above on $E$. Then $\forall M\geq 0$, and in particular
    $\forall i\in\N$, $\exists x_i\in E$ such that $f(x_i)>i$.
    In other words, $f(x_i)\to\infty$ as $i\to\infty$.

    Then since $E$ is compact, it is bounded, so the sequence $(x_i)_{i\in\N}$ is bounded.
    Then by the Bolzano-Weierstrass theorem it has a subsequence $(x_{i_j})_{j\in\N}$ convergent to $x\in E$.

    Now since $f$ is continuous on $E$, it is continuous at $x$, so $f(x_{i_j})\to f(x)$ as $j\to\infty$.
    Since $E$ is compact, it is closed, so $f(x)\in E$, and therefore $f(x)$ is finite. This is a contraction since
    $f$ was assumed to diverge to infinity for any subsequence of $(x_i)$, including $(x_{i_j})$.

    So $f$ is bounded above on $E$. Now by completeness of $\R$, $f(E)$ has a supremum, say
    $$M=\sup_{x\in E}{f(x)}.$$
    We show that that $f$ reaches its maximum on $E$, i.e. that $M\in f(E)$, or
    that $\exists p_+\in E$ such that $f(p_+)=M$. Now $\forall i\in\N$, $\exists x_i\in E$ such that
    $$M-\frac{1}{i}<f(x_i)\leq M.$$
    Then clearly $f(x_i)\to M$ as $i\to\infty$, so by the Bolzano-Weierstrass theorem $(x_i)_{i\in\N}$ has
    a subsequence $(x_{i_j})_{j\in\N}$ convergent in to some $p_+\in E$. Since $f$ is continuous at $p_+$,
    $f(x_{i_j})\to f(p_+)$ as $j\to\infty$. Hence $f(p_+)=M$, so $f$ achieves its maximum on $E$.

    Now in a similar fashion we prove that $f$ reaches its minimum on $E$. Suppose that
    $f$ is unbounded below on $E$. Then $\forall i\in\N$, $\exists x_i\in E$ such that $f(x_i)<-i$.
    So $f(x_i)\to-\infty$ as $i\to\infty$.

    Now, the sequence $(x_i)_{i\in\N}$ is bounded. Then by the Bolzano-Weierstrass theorem it has a
    subsequence $(x_{i_j})_{j\in\N}$ convergent to $x\in E$. Since $f$ is continuous at
    $x$, $f(x_{i_j})\to f(x)$ as $j\to\infty$, and so $f(x)\in E$ (so $f(x)$ is finite). This is a contraction since
    $f$ was assumed to diverge to negative infinity for any subsequence of $(x_i)$, including $(x_{i_j})$.

    So $f$ is bounded below on $E$. Now by completeness of $\R$, $f(E)$ has an infimum, say
    $$m=\inf_{x\in E}{f(x)}.$$
    We show that that $f$ reaches its minimum on $E$, i.e. that $m\in f(E)$, or
    that $\exists p_-\in E$ such that $f(p_-)=m$. Now $\forall i\in\N$, $\exists x_i\in E$ such that
    $$m\leq f(x_i)<m+\frac{1}{i}.$$
    Then clearly $f(x_i)\to m$ as $i\to\infty$, so by the Bolzano-Weierstrass theorem $(x_i)_{i\in\N}$ has
    a subsequence $(x_{i_j})_{j\in\N}$ convergent in to some $p_-\in E$. Since $f$ is continuous at $p_-$,
    $f(x_{i_j})\to f(p_-)$ as $j\to\infty$. Hence $f(p_-)=m$, so $f$ achieves its minimum on $E$.
  \end{proof}

\subsection{Uniform Continuity and Convergence}
\label{sec:1.3}

  \begin{definition}[Uniformly Continuous]
    Let $A\subset\R^n$ be open. We say $f:A\to\R^m$ is \textit{uniformly continuous} on $A$ if,
    $\forall\epsilon>0$ $\exists\delta>0$ such that $\forall x,y\in A$,
    $\|f(x)-f(y)\|<\epsilon$ whenever $\|x-y\|<\delta$.
  \end{definition}

  \textbf{Remark:} Clearly uniform continuity implies continuity.

  \begin{prop}
    Let $f:\R\to\R$ be differentiable with bounded derivative. Then $f$ is uniformly continuous.
  \end{prop}

  \begin{proof}
    Fix $\eps$. Then $\forall x,y\in\R$ with $x<y$, by the Mean Value Theorem
    $\exists c\in(x,y)$ such that $f'(c)=\frac{f(y)-f(x)}{y-x}$. By assumption
    $\exists M\geq 0$ such that $|f'(c)|=\frac{|f(y)-f(x)|}{|y-x|}\leq M$.

    Set $\delta = \frac{\epsilon}{M+1}$. Then
    \begin{align*}
      |f(y)-f(x)|&\leq M|y-x|\\
                 &<\frac{M\epsilon}{M+1}\\
                 &<\frac{M\epsilon}{M}\\
                 &=\epsilon
    \end{align*}
  \end{proof}

  \begin{prop}
    A continuous function on a compact subset $E\subset\R^n$ is uniformly continuous.
  \end{prop}

  \begin{proof}
    Let $E\subset\R^n$ be compact, and $f:E\to\R^m$ continuous. We assume for a contradiction that
    $f$ is not uniformly continuous. Then $\exists\epsilon>0$ such that $\forall i\in\N$
    $\exists x_i,y_i\in E$ with $\|x_i-y_i\|<\frac{1}{i}$ such that $\|f(x_i)-f(y_i)\|\geq\epsilon$.

    Then by the Bolzano-Weierstrass theorem, the sequence $(x_i)_{i\in\N}$ has a
    subsequences $(x_{i_j})_{j\in\N}$ converging to some $x\in E$.  Furthermore, the sequence $(y_i)_{i\in\N}$
    has a convergent subsequence $(y_{i_j})_{j\in\N}$. We now show that $y_{i_j}\to x$ as $j\to\infty$.

    Choose $\epsilon'>0$. Then $\exists N\in\N$ such that $\|x_{i_j}-x\|<\frac{\epsilon'}{2}$ whenever $i_j\geq N$.
    \begin{align*}
    \|x-y_{i_j}\|&=\|x-x_{i_j}+x_{i_j}-y_{i_j}\|\\
                 &\leq\|x-x_{i_j}\|+\|x_{i_j}-y_{i_j}\|\\
                 &<\frac{\epsilon'}{2}+\frac{1}{i_j}\\
                 &\leq\frac{\epsilon'}{2}+\frac{1}{j}\\
                 &<\frac{\epsilon'}{2}+\frac{\epsilon'}{2}\\
                 &=\epsilon'
    \end{align*}
  \end{proof}

  \begin{theorem}[Heine-Borel]
    Let $A\subset\R^n$ be closed and bounded. Then $A$ is compact.
  \end{theorem}

  \begin{definition}[Uniform convergence]
    Let $A\subset\R^n$ and $(f_i)_{i\in\N}$ be a sequence of functions $f_i:A\to\R^m.$

    We say $f_i\to f$ \textit{uniformly} to $f:A\to\R^m$ if and only if $\forall\epsilon>0$,
    $\exists N\in\N$ such that $\|f_i(x)-f(x)\|<\epsilon$ whenever $i\geq N$ and $x\in A$.
  \end{definition}

  \begin{theorem}
    Let $A\subset\R^n$ and $(f_i)_{i\in\N}$ be a sequence of functions $f_i:A\to\R^m$ which
    converges uniformly to $f:A\to\R^m$ uniformly.

    Then if $f_i$ is uniformly continuous $\forall i\in\N$, $f$ is uniformly continuous.
  \end{theorem}

  \begin{proof}
    Fix $\epsilon>0$. Then since $f_i\to f$ uniformly, $\exists N\in\N$ such that
    $\|f_i(x)-f(x)\|<\epsilon/3$ whenever $i\geq N$ and $x\in A$.

    Also since each $f_i$ is uniformly continuous, $\exists\delta>0$ such that $\|f_i(x)-f_i(y)\|$
    $\forall x,y\in A$. Then using the triangle inequality:
    \begin{align*}
      \|f(x)-f(y)\| &\leq\|f(x)-f_i(x)\|+\|f_i(x)-f(y)\| \\
                    &<\epsilon/3+\|f_i(x)-f_i(y)\|+\|f_i(y)-f(y)\| \\
                    &<\epsilon/3+\epsilon/3+\epsilon/3 \\
                    &=\epsilon
    \end{align*}
    $\forall x,y\in A$ such that $\|x-y\|<\delta$. Hence, $f$ is uniformly continuous.
  \end{proof}

  \begin{cor}
    Now assume that each $f_i$ is just continuous instead. Then $f$ is continuous.
  \end{cor}

  \begin{proof}
    Fix $a\in A$, and $\epsilon>0$. Then since $f_i\to f$ uniformly, $\exists N\in\N$ such that
    $\|f_i(x)-f(x)\|<\epsilon/3$ whenever $i\geq N$ and $x\in A$.

    Also since each $f_i$ is continuous, $\exists\delta>0$ such that $\|f_i(x)-f_i(a)\|<\epsilon/3$
    $\forall x\in A$. Then using the triangle inequality:
    \begin{align*}
      \|f(x)-f(a)\| &\leq\|f(x)-f_i(x)\|+\|f_i(x)-f(a)\| \\
                    &<\epsilon/3+\|f_i(x)-f_i(a)\|+\|f_i(a)-f(a)\| \\
                    &<\epsilon/3+\epsilon/3+\epsilon/3 \\
                    &=\epsilon
    \end{align*}
    $\forall x\in A$ such that $\|x-a\|<\delta$. Hence, $f$ is continuous.
  \end{proof}

\subsection{Integration}
\label{sec:1.4}

  \begin{definition}[Partitions]
    Let $[a,b]\subset\R$. We define a \textit{partition}, $\mathcal{P}$, of $[a,b]$ by an ordered tuple
    $$\mathcal{P}=(x_0,x_1,\dots,x_{k-1},x_k),$$
    such that $a=x_0<x_1<\dots<x_{k-1}<x_k=b$.

    We call any interval of the form $[x_j,x_{j+1}]$ a \textit{subinterval} of the partition $\mathcal{P}$.
    The length of this subinterval is $\Delta x_j=x_{j+1}-x_j$, and we define
    $$\text{mesh}(\mathcal{P}):=\max_{j=0,\dots,k-1}{\Delta x_j}.$$

    Finally, for any two partitions $\mathcal{P}$ and $\mathcal{Q}$, we say $\mathcal{Q}$ \textit{refines}
    $\mathcal{P}$ iff every point in $\mathcal{P}$ lies in $\mathcal{Q}$.
  \end{definition}

  \begin{definition}[Darboux sums]
    Let $f:[a,b]\to\R$ be bounded, and fix a partition $\mathcal{P}$ of $[a,b]$. Then we define the
    \textit{upper} and \textit{lower Darboux sums} by
    $$U(f,\mathcal{P})=\sum_{j=0}^{k-1}M_j\Delta x_j,$$
    where $M_j=\sup_{x\in[x_j,x_{j+1}]}{f(x)}$, and
    $$L(f,\mathcal{P})=\sum_{j=0}^{k-1}m_j\Delta x_j,$$
    where $m_j=\inf_{x\in[x_j,x_{j+1}]}{f(x)}$.
  \end{definition}

  \begin{lemma}
    Let $\mathcal{P}$ and $\mathcal{Q}$ be partitions of $[a,b]$, with $\mathcal{Q}$ a refinement of
    $\mathcal{P}$. Then
    $$L(f,\mathcal{P})\leq L(f,\mathcal{Q})\leq U(f,\mathcal{Q})\leq U(f,\mathcal{P}).$$
  \end{lemma}

  \begin{proof}
    Let $\mathcal{Q}=(x_0=a,x_1,\dots,x_k=b)$. Let $I_j$ be the subinterval of $\mathcal{P}$
    containing $[x_j,x_{j+1}]$, for $j=0,\dots,k-1$. Then
    $$\inf_{x\in I_j}{f(x)}\leq\inf_{x\in [x_j,x_{j+1}]}{f(x)}\leq\sup_{x\in [x_j,x_{j+1}]}{f(x)}
    \leq\sup_{x\in I_j}{f(x)}.$$
    Then by multiplying by $\Delta x_j$ and summing over $j$, we get
    $$\sum_{j=0}^{k-1}{\Delta x_j\inf_{x\in I_j}{f(x)}}\leq\sum_{j=0}^{k-1}{\Delta x_j m_j}
    \leq\sum_{j=0}^{k-1}{\Delta x_j M_j}\leq\sum_{j=0}^{k-1}{\Delta x_j\sup_{x\in I_j}{f(x)}}.$$
    We can rewrite the two outer sums as
    $$\sum_{j=0}^{k-1}{\Delta x_j\inf_{x\in I_j}{f(x)}}=\sum_{\text{subints. of }\mathcal{P}
    \text{, }I}{\bigg[\inf_{x\in I}{f(x)}}\sum_{j\text{ s.t. }I=I_j}{\Delta x_j}\bigg]=L(f,\mathcal{P}),$$
    $$\sum_{j=0}^{k-1}{\Delta x_j\sup_{x\in I_j}{f(x)}}=\sum_{\text{subints. of }\mathcal{P}
    \text{, }I}{\bigg[\sup_{x\in I}{f(x)}}\sum_{j\text{ s.t. }I=I_j}{\Delta x_j}\bigg]=U(f,\mathcal{P}).$$
    Hence,
    $$L(f,\mathcal{P})\leq L(f,\mathcal{Q})\leq U(f,\mathcal{Q})\leq U(f,\mathcal{P}).$$
  \end{proof}

  \begin{cor}
    $$L(f,\mathcal{P})\leq U(f,\mathcal{P'})$$
    for any two partitions $\mathcal{P}$ and $\mathcal{P'}$.
  \end{cor}

  \begin{proof}
    Let $\mathcal{Q}$ be a common refinement of $\mathcal{P}$ and $\mathcal{P'}$. Then
    $$L(f,\mathcal{P})\leq L(f,\mathcal{Q})\leq U(f,\mathcal{Q})\leq U(f,\mathcal{P'}).$$
  \end{proof}

  \begin{definition}[Darboux integrals]
    We define the following sets:
    \begin{align*}
      U_f&=\{U(f,\mathcal{P'}):\mathcal{P'}\text{ is a partition of }[a,b]\}, \\
      \text{and }L_f&=\{L(f,\mathcal{P}):\mathcal{P}\text{ is a partition of }[a,b]\}.
    \end{align*}
    Let $\mathcal{Q}$ be any parition of $[a,b]$. Then $U_f$ is bounded below by $L(f,\mathcal{Q})$ and $L_f$ is
    bounded above by $U(f,\mathcal{Q})$. Thus we can define \textit{upper} and \textit{lower Darboux
    integrals} by:
    $$\overline{\int_a^b}f(x)\text{d}x=\inf{U_f},$$
    $$\underline{\int_a^b}f(x)\text{d}x=\sup{L_f}.$$
    If these two are equal, then we say $f$ is \textit{integrable}, and we let
    $$\int_a^bf(x)\text{d}x=\overline{\int_a^b}f(x)\text{d}x=\underline{\int_a^b}f(x)\text{d}x.$$
  \end{definition}

  \begin{prop}
    A bounded function $f:[a,b]\to\R$ is integrable if and only if $\eps$ there exists a partition
    $\calP$ of $[a,b]$ such that
    $$U(f,\calP)-L(f,\calP)<\epsilon.$$
  \end{prop}

  \begin{proof}
    We assume that $\eps$ there exists a partition $\calP$ of $[a,b]$ such that $U(f,\calP)-
    L(f,\calP)<\epsilon.$ Then
    $$L(f,\calP)\leq\underline{\int_a^b}f(x)\text{d}x\leq\overline{\int_a^b}f(x)\text{d}x\leq U(f,\calP),$$
    so
    $$\overline{\int_a^b}f(x)\text{d}x-\underline{\int_a^b}f(x)\text{d}x\leq U(f,\calP)-L(f,\calP)<\epsilon,$$
    and so
    $$\overline{\int_a^b}f(x)\text{d}x=\underline{\int_a^b}f(x)\text{d}x$$
    so $f$ is integrable.

    Conversely, assume that $f$ is integrable. Fix $\eps$. Then since $\lowint=\sup{L_f}$ and
    $\upint=\inf{U_f}$, $\exists\calP,\calP'$ as parititions of $[a,b]$, such that
    $$\lowint\geq L(f,\calP)>\lowint-\frac{\epsilon}{2},$$
    $$\upint\leq U(f,\calP')<\upint+\frac{\epsilon}{2}.$$
    Since $f$ is integrable, this simplifies to
    $$L(f,\calP)+\frac{\epsilon}{2}>0,$$
    $$U(f,\calP')-\frac{\epsilon}{2}<0.$$
    We let $\calQ$ be the common refinement of $\calP$ and $\calP'$. Then
    $$U(f,\calQ)-L(f,\calQ)\leq U(f,\calP')-L(f,\calP)<\frac{\epsilon}{2}+\frac{\epsilon}{2}
    =\epsilon.$$
  \end{proof}

  \begin{prop}
    Every continuous function is integrable.
  \end{prop}

  \begin{proof}
    Suppose $f:[a,b]\to\R$ is continuous. Since $[a,b]$ is compact, $f$ is uniformly continuous, so
    $\forall x,y\in[a,b]$, $\eps\del$ such that $|f(x)=f(y)|<\epsilon/{b-a}$ when $|x-y|<\delta$.
    Now fix $\eps$, let $calP$ be a partition of $[a,b]$ with $k+1$ uniformly spaced points, and
    such that $\text{mesh}(\calP)<\delta$.

    Then $\forall x,y\in[x_j,x_{j+1}]$, we have $|f(x)-f(y)|<\epsilon/{b-a}$, for $j=0,1,\dots,k-1$.
    In particular $M_j-m_j<\epsilon/{b-a}$, so $\Delta x_j(M_j-m_j)<\Delta x_j\epsilon/{b-a}$. We
    then sum over $j$, noting that $\Delta x_j=b-a/k$

    \begin{align*}
      \sum_{j=0}^{k-1}\Delta x_j(M_j-m_j)&<\sum_{j=0}^{k-1}\frac{\epsilon(b-a)}{k(b-a)} \\
      \sum_{j=0}^{k-1}\Delta x_j M_j-\sum_{j=0}^{k-1}\Delta x_j m_j&<\frac{k\epsilon}{k} \\
      U(f,\calP)-L(f,\calP) &<\epsilon
    \end{align*}
    And so $f$ is integrable by the previous proposition.
  \end{proof}

  \begin{prop}[Linearity of the integral]
    Let $f:[a,b]\to\R$ and $g:[a,b]\to\R$ be integrable functions, and $\lambda\in\R$. Then $f+
    \lambda g$ is inetgrable, and
    $$\int_a^bf(x)+\lambda g(x)\text{d}x=\int_a^bf(x)\text{d}x+\lambda\int_a^bg(x)\text{d}x.$$
  \end{prop}

  \begin{proof}

  \end{proof}

  \begin{prop}[Additivity of the integral]
    Let $f:[a,b]\to\R$ be bounded, and let $c\in[a,b]$. Then $f$ is integrable on $[a,b]$ if and
    only if $f$ is integrable on both $[a,c]$ and $[c,b]$. Moreover
    $$\int_a^bf(x)\text{d}x=\int_a^cf(x)\text{d}x+\int_c^bf(x)\text{d}x.$$
  \end{prop}

  \begin{proof}
    Assume $f$ is integrable on $[a,b]$. Fix $\eps$. Then we can choose a partition $\calP=
    (x_0=a,x_1,\dots,x_{k-1},x_k=b)$ such that $U(f,\calP)-L(f,\calP)<\epsilon$. We let $\calQ$ be a
    refinement of $\calP$ containing $c$, say $\calQ=(x_0=a,\dots,x_{l-1},x_l=c,x_{l+1},\dots,x_k=b)$.
    Clearly $U(f,\calQ)-L(f,\calQ)<\epsilon$.

    We now `split' $\calQ$ into two partitions $\calQ_1=(a,x_1,\dots,c)$ and $\calQ_2=(c,x_{l+1},\dots,b)$.
    Then $U(f,\calQ)=U(f,\calQ_1)+U(f,\calQ_2)$, and $L(f,\calQ)=L(f,\calQ_1)+L(f,\calQ_2)$, so
    $$U(f,\calQ_1)-L(f,\calQ_1)+U(f,\calQ_2)-L(f,\calQ_2)<\epsilon,$$
    and so
    $$U(f,\calQ_1)-L(f,\calQ_1)<\epsilon,$$
    $$U(f,\calQ_2)-L(f,\calQ_2)<\epsilon.$$
    Hence, $f$ is integrable on $[a,c]$ and $[c,b]$.

    Conversely, assume that $f$ is integrable on $[a,c]$ and $[c,b]$. Fix $\eps$. Then there exists
    partitions $\calP_1:=(a,x_1,\dots,c)$ and $\calP_2:=(c,\dots,x_{k-1},b)$ of $[a,c]$ and $[c,b]$ respectively such that
    $$U(f,\calP_1)-L(f,\calP_1)<\frac{\epsilon}{2},$$
    $$U(f,\calP_2)-L(f,\calP_2)<\frac{\epsilon}{2}.$$
    Then
    $$U(f,\calP_1)+U(f,\calP_2)-L(f,\calP_1)-L(f,\calP_2)<\epsilon.$$
    We now `join' $\calP_1$ and $\calP_2$ at $c$ to create a partition of $[a,b]$, $\calQ:=
    (a,\dots,x_{l-1},c,x_{l+1},\dots,b)$. Then
    $$U(f,\calQ)=U(f,\calP_1)+U(f,\calP_2),$$
    $$L(f,\calQ)=L(f,\calP_1)+L(f,\calP_2),$$
    so
    $$U(f,\calQ)-L(f,\calQ)=U(f,\calP_1)-L(f,\calP_1)+U(f,\calP_2)-L(f,\calP_2)<\frac{\epsilon}{2}
    +\frac{\epsilon}{2}=\epsilon.$$
    And hence, $f$ is integrable on $[a,b]$.

    Finally, since $\int_a^bf(x)\text{d}x=\inf{U_f}=\sup{L_f}$, for all $\epsilon>0$ there exists a partition $\calP$ of
    $[a,b]$ such that when we split it into two partitions $\calQ_1$ and $\calQ_2$ of $[a,c]$ and
    $[c,b]$ respectively, as illustrated above, we get
    \begin{align*}
      \int_a^bf(x)\text{d}x &\leq U(f,\calP) \\
                            &=U(f,\calQ_1)+U(f,\calQ_2) \\
                            &<\int_a^cf(x)\text{d}x+\frac{\epsilon}{2}+\int_c^bf(x)\text{d}x
                                                                      +\frac{\epsilon}{2} \\
                            &=\int_a^cf(x)\text{d}x+\int_c^bf(x)\text{d}x+\epsilon.
    \end{align*}
    Similarly,
    \begin{align*}
      \int_a^bf(x)\text{d}x &\geq L(f,\calP) \\
                            &=L(f,\calQ_1)+L(f,\calQ_2) \\
                            &>\int_a^cf(x)\text{d}x-\frac{\epsilon}{2}+\int_c^bf(x)\text{d}x
                                                                      -\frac{\epsilon}{2} \\
                            &=\int_a^cf(x)\text{d}x+\int_c^bf(x)\text{d}x-\epsilon,
    \end{align*}
    and hence,
    $$\bigg|\int_a^bf(x)\text{d}x-\bigg(\int_a^cf(x)\text{d}x+\int_c^bf(x)\text{d}x\bigg)\bigg|
                                                                                <\epsilon,$$
    so
    $$\int_a^bf(x)\text{d}x=\int_a^cf(x)\text{d}x+\int_c^bf(x)\text{d}x.$$
  \end{proof}

  \begin{lemma}
    Let $A\subset\R^n$ and $f,g:A\to\R$ be bounded. Then
    \begin{enumerate}
      \item $\sup_{x\in A}{-f(x)}=-\inf_{x\in A}{f(x)}$
      \item $\inf_{x\in A}{-f(x)}=-\sup_{x\in A}{f(x)}$
      \item $|\sup_{x\in A}f(x)|\leq\sup_{x\in A}|f(x)|$
      \item $|\inf_{x\in A}f(x)|\leq\inf_{x\in A}|f(x)|$
      \item $\sup_{x\in A}{f(x)+g(x)}\leq\sup_{x\in A}{f(x)}+\sup_{x\in A}{g(x)}$
      \item $\inf_{x\in A}{f(x)+g(x)}\geq\inf_{x\in A}{f(x)}+\inf_{x\in A}{g(x)}$
    \end{enumerate}
  \end{lemma}

  \begin{lemma}
    Let $A\subset\R^n$, and $f:A\to\R$ be bounded. Then
    $$\sup_{x\in A}{|f(x)|}-\inf_{x\in A}{|f(x)|}\leq\sup_{x\in A}{f(x)}-\inf_{x\in A}{f(x)}.$$
  \end{lemma}

  %\begin{proof}
  %  \verb%%
%
  %  \textit{Case 1.} $$\sup_{x\in A}f(x)\leq0.$$
  %    Then $f(x)\leq0\,\forall x\in A$, so $f(x)=-|f(x)|$.
  %
  %    So $\sup_{x\in A}{f(x)}-\inf_{x\in A}{f(x)}
  %    =\sup_{x\in A}{-|f(x)|}-\inf_{x\in A}{-|f(x)|}=-\inf_{x\in A}{|f(x)|}+\sup_{x\in A}{|f(x)|}$,
  %    and hence we have equality.
%
  %  \textit{Case 2.} $$\sup_{x\in A}f(x)\geq0,\,\inf_{x\in A}f(x)\geq0.$$
  %    Then again we have equality trivially.
%
  %  \textit{Case 3.} $$\sup_{x\in A}f(x)>0,\,\inf_{x\in A}f(x)<0.$$
  %    Then $\sup_{x\in A}f(x)=|\sup_{x\in A}f(x)|\leq\sup_{x\in A}|f(x)|$,
  %    $\inf_{x\in A}f(x)=-|\inf_{x\in A}f(x)|\geq-\inf_{x\in A}{|f(x)|}$.
  %\end{proof}

  \begin{lemma}
    Let $f:[a,b]\to\R$ be an integrable function. Then $\eps,\del$ such that
    $U(f,\calP)-L(f,\calP)<\epsilon$ whenever $\text{mesh}(\calP)<\delta$.
  \end{lemma}

  %\begin{proof}
  %  Fix $\epsilon>0$. Then, since $f$ is integrable, it is bounded, so $\exists M\geq0$ such that
  %  $|f(x)|\leq M,\,\forall x\in[a,b]$. Also, $\exists$ partition $\calQ:=(x_0=a,x_1,\dots,x_{k-1},x_k=b)$
  %  such that
  %  $$U(f,\calQ)-L(f,\calQ)<\frac{\epsilon}{2}.$$
%
  %  Let $\calP:=(x_0=a,x_1,\dots,x_{l-1},x_l=b)$ be a partition of $[a,b]$ with $\text{mesh}(\calP)
  %  <\delta:=\frac{\epsilon}{5kM}$.
%
  %  Then $\forall j=0,\dots,k-1$, we define the sets
  %  $$A_j:=\{0\leq i\leq l-1:[x_i]\}$$
  %\end{proof}

  \begin{definition}[Riemann sum]
    Given an integrable function $f:[a,b]\to\R$ and a \textit{tagged partition},
    $(\calP,\tau)$ where
    $$\calP=(x_0,\dots,x_k),$$
    $$\tau=(t_0,\dots,t_{k-1})$$ with
    $t_j\in[x_j,x_{j+1}]\,\forall j\in\{0,\dots,k-1\}$, of $[a,b]$, we define a \textit{Riemann sum} by
    $$R(f,\calP,\tau)=\sum_{j=0}^{k-1}{f(t_j)\Delta x_j}.$$
  \end{definition}

  \begin{theorem}
    Let $f:[a,b]\to\R$ be an integrable function, and $\big((\calP_i,\tau_i)\big)_{i\in\N}$ be sequence of
    tagged partitions of $[a,b]$ such that $\text{mesh}(\calP_i)\to 0$ as $i\to\infty$. Then
    $$R(f,\calP_i,\tau_i)\to\int_a^bf(x)\text{d}x,$$
    as $i\to\infty$.
  \end{theorem}

  \begin{proof}
    Fix $\varepsilon>0$. Then $\del$ such that $U(f,\calQ)-L(f,\calQ)<\varepsilon$ whenever
    $\text{mesh}(\calQ)<\delta$. Since $\text{mesh}(\calP_i)\to 0$ as $i\to\infty$, $\exists N\in\N$
    such that $|\text{mesh}(\calP_i)|<\delta$ whenever $i\geq N$. So
    $$U(f,\calP_i)-L(f,\calP_i)<\varepsilon\quad\forall i\geq N.$$
    Note that since $(m_j)_i\leq (f(t_j))_i\leq (M_j)_i$, we have $L(f,\calP_i)\leq R(f,\calP_i,\tau_i)\leq U(f,\calP_i)$,
    and in particular
    $$L(f,\calP_i)-\varepsilon<R(f,\calP_i,\tau_i)<U(f,\calP_i)+\varepsilon.$$
    Then since
    $$L(f,\calP_i)\leq\int_a^bf(x)\text{d}x\leq  U(f,\calP_i),$$
    we have
    $$-\varepsilon<R(f,\calP_i,\tau_i)-\int_a^bf(x)\text{d}x<\varepsilon.$$
    Hence
    $$\bigg|R(f,\calP_i,\tau_i)-\int_a^bf(x)\text{d}x\bigg|<\varepsilon.$$
  \end{proof}

  \begin{theorem}[Fundamental theorem of Calculus]
    Let $f:[a,b]\to\R$ be continuous. We define $F:[a,b]\to\R$ by
    $$F(x)=\int_a^xf(t)\text{d}t.$$
    Then $F$ is differentiable on $(a,b)$, and $F'(x)=f(x)$ $\forall x,y\in[a,b]$.
  \end{theorem}

  \begin{proof}
    Fix $\varepsilon>0$. Then since $f$ is continuous on $[a,b]$, it is uniformly continuous so
    $\exists\delta>0$ such that $|f(y)-f(z)|<\varepsilon$ whenever $|y-z|<\delta$. Now fix
    $x\in(a,b)$. Then $\forall y\in[a,b]$ such that $0<|y-x|<\delta$, we have:
    \begin{align*}
      \bigg|\frac{F(y)-F(x)}{y-x}-f(x)\bigg|&=\bigg|\frac{1}{y-x}\bigg(\int_a^yf(t)\text{d}t-
      \int_a^xf(t)\text{d}t\bigg)-f(x)\bigg| \\
                                            &=\bigg|\frac{1}{y-x}\int_x^yf(t)\text{d}t-f(x)\bigg| \\
                                            &=\bigg|\frac{1}{y-x}\int_x^yf(t)-f(x)\text{d}t\bigg| \\
                                            &=\frac{1}{|y-x|}\bigg|\int_x^yf(t)-f(x)\text{d}t\bigg| \\
                                            &\leq\sup_{t\in[x,y]}|f(t)-f(x)| \\
                                            &=\max_{t\in[x,y]}|f(t)-f(x)|\text{ by the extreme value theorem } \\
                                            &<\varepsilon,
    \end{align*}
    Since $|t-x|<\delta$.
  \end{proof}

\subsection{Differentiation}
\label{sec:1.5}