% vim: tw=50
% 04/03/2022 11AM

\begin{theorem}
    A bounded function $f : [a, b] \to \RR$ is
    Riemann integrable if and only if given $\eps
    > 0$, $\exists \mathcal{D}$ such that
    \[ S(f, \mathcal{D}) - s(f, \mathcal{D}) <
    \eps \]
\end{theorem}

\begin{proof}
    For every dissection $\mathcal{D}$ we have
    \[ 0 \le I^*(f) - I_*(f) \le S(f, \mathcal{D})
    - s(f, \mathcal{D}) \]
    If the given condition holds, then
    \[ 0 \le I^*(f) - I_*(f) \le S(f, \mathcal{D})
    - s(f, \mathcal{D}) < \eps \]
    for all $\eps > 0$ hence $I^*(f) = I_*(f)$. \\
    Conversely, if $f$ is integrable, by
    definition of $\sup$ and $\inf$ there are
    partitions $\mathcal{D}_1$ and $\mathcal{D}_2$
    such that
    \[ \int_a^b f - \frac{\eps}{2} = I_*(f) +
    \frac{\eps}{2} = \int_a^b f + \frac{\eps}{2} \]
    By Lemma 5.1 ($\mathcal{D}_1 \cup
    \mathcal{D}_2 \supseteq \mathcal{D}_1,
    \mathcal{D}_2$)
    \begin{align*}
        S(f, \mathcal{D}_1 \cup \mathcal{D}_2) -
        s(f, \mathcal{D}_1 \cup \mathcal{D}_2)
        &\le S(f, \mathcal{D}_2) - s(f,
        \mathcal{D}_1 \\
        &< \int_a^b f + \frac{\eps}{2} - \int_a^b
        f + \frac{\eps}{2} \\
        &= \eps
    \end{align*}
\end{proof}

\myskip
We now use this criterion to show that monotone
and continuous functions are \emph{integrable}.

\begin{remark*}
    Monotone and continuous functions are bounded
    (theorem 2.6 for the case of continuous
    functions).
\end{remark*}

\begin{theorem}
    Let $f : [a, b] \to \RR$ be monotone. Then $f$
    is integrable.
\end{theorem}

\begin{proof}
    Suppose $f$ is \emph{increasing} (same proof
    for $f$ decreasing). Then
    \[ \sup_{x \in [x_{j - 1}, x_j]} f(x) = f(x_j) \]
    \[ \inf_{x \in [x_{j - 1}, x_j]} f(x) = f(x_{j
    - 1}) \]
    Thus
    \[ S(f, \mathcal{D}) - s(f, \mathcal{D}) =
    \sum_{j - 1}^n (x_j - x_{j - 1})[f(x_j) -
    f(x_{j - 1})] \]
    Now choose
    \[ \mathcal{D} = \left\{ a, a + \frac{b -
    a}{n}, a + \frac{2(b - a)}{n}, \dots, b \right\} \]
    \[ x_j = a + \frac{(b - a)j}{n} \qquad 0 \le
    j \le n \]
    \[ S(f, \mathcal{D}) - s(f, \mathcal{D}) =
    \frac{(b - a)}{n} (f(b) - f(a)) \]
    Take $n$ large enough such that
    \[ \frac{(b - a)}{n} (f(b) - f(a)) < \eps \]
    and use Theorem 5.3.
\end{proof}

\subsubsection*{Continuous Functions}

First we need an auxiliary lemma.

\begin{lemma}
    $f : [a, b] \to \RR$ continuous. Then given
    $\eps > 0$, $\exists\,\, \delta > 0$ such that if
    $|x - y| < \delta \implies |f(x) - f(y)| < \eps$
    (uniform continuity). The point is that
    $\delta$ works $\forall\,\, x, y$ as long as
    $|x - y| < \delta$. (in the definition of
    continuity of $f$ at, $\delta = f(x)$).
\end{lemma}

\begin{proof}
    Suppose the claim is false. Then $\exists\,\,
    \eps > 0$ such that $\forall\,\,\delta > 0$,
    we can find $x, y \in [a, b]$ such that $|x -
    y| < \delta$, but $|f(x) - f(y)| \ge \eps$.
    Take $\delta = \frac{1}{n}$, to get $x_n, y_n
    \in [a, b]$ with $|x_n - y_n| < \frac{1}{n}$,
    but
    \[ |f(x_n) - f(y_n)| \ge \eps \]
    By Bolzano-Weierstrass, $\exists \,\, x_{n_k}
    \to c \in [a, b]$
    \[ |y_{n_k} - c| \le |y_{n_k} - x_{n_k}| +
    |x_{n_k} - c| \to 0 \]
    so $y_{n_k} \to c$. But
    \[ |f(x_{n_k} - f(y_{n_k}) \ge \eps .\]
    Let $k \to \infty$, then by continuity of $f$
    \[ |f(c) - f(c)| \ge \eps \implies 0 \ge \eps \]
    Absurd.
\end{proof}

\begin{theorem}
    Let $f : [a, b] \to \RR$ continuous. Then $f$
    is Riemann integral.
\end{theorem}

\begin{proof}
    By 5.5, given $\eps > 0$, $\exists \,\, \delta
    > 0$ such that $|x - y| < \delta \implies
    |f(x) - f(y)| < \eps$. Let
    \[ \mathcal{D} = \left\{ a + \frac{(b -
    a)j}{n} : 0 \le j \le n \right\} \]
    Choose $n$ large enough such that $\frac{b -
    a}{n} < \delta$. Then for $x, y \in [x_{j -
    1}, x_j]$
    \[ |f(x) - f(y)| < \eps ,\]
    since
    \[ |x - y| \le |x_j - x_{j - 1}| = \frac{b -
    a}{n} < \delta \]
    Observe that
    \[ \max_{x \in [x_{j - 1}, x_j]} f(x) -
    \min_{x \in [x_{j - 1}, x_j]} f(x) = f(p_j) -
    f(q_j) \]
    $o_j, q_j \in [x_{j - 1}, x_j]$ (max and min
    are achieved due to continuity). Hence
    \begin{align*}
        S(f, \mathcal{D}) - s(f, \mathcal{D})
        &= \sum_{j = 1}^n (x_j - x_{j - 1})
        [f(p_j) - f(q_j)] \\
        &< \eps(b - a)
    \end{align*}
\end{proof}
