\documentclass{article}

\input{../../preamble}

\externaldocument[C:1:07:]{Chapter_1_07}[Chapter_1_07.pdf]

\newcommand{\lean}[1]{\leanref
  {./Chapter\_1\_11.html\#Apostol.Chapter\_1\_11.#1}
  {Apostol.Chapter\_1\_11.#1}}

\begin{document}

\header{Exercises 1.11}{Tom M. Apostol}

\section*{Exercise 4}%
\label{sec:exercise-4}

Prove that the greatest-integer function has the properties indicated:

\subsection*{\verified{Exercise 4a}}%
\label{sub:exercise-4a}

$\floor{x + n} = \floor{x} + n$ for every integer $n$.

\begin{proof}

  \lean{exercise\_4a}

  \divider

  Let $x$ be a real number and $n$ an integer.
  Let $m = \floor{x + n}$.
  By definition of the floor function, $m$ is the unique integer such that
    $m \leq x + n < m + 1$.
  Then $m - n \leq x < (m - n) + 1$.
  That is, $m - n = \floor{x}$.
  Rearranging terms we see that $m = \floor{x} + n$ as expected.

\end{proof}

\subsection*{\verified{Exercise 4b}}%
\label{sub:exercise-4b}

$\floor{-x} =
  \begin{cases}
    -\floor{x} & \text{if } x \text{ is an integer}, \\
    -\floor{x} - 1 & \text{otherwise}.
  \end{cases}$

\begin{proof}

  \ \vspace{6pt}

  \lean{exercise\_4b\_1}

  \lean{exercise\_4b\_2}

  \divider

  There are two cases to consider:

  \paragraph{Case 1}%

    Suppose $x$ is an integer.
    Then $x = \floor{x}$ and $-x = \floor{-x}$.
    It immediately follows that $$\floor{-x} = -x = -\floor{x}.$$

  \paragraph{Case 2}%

    Suppose $x$ is not an integer.
    Let $m = \floor{-x}$.
    By definition of the floor function, $m$ is the unique integer such that
      $m \leq -x < m + 1$.
    Equivalently, $-m - 1 < x \leq -m$.
    Since $x$ is not an integer, it follows $-m - 1 \leq x < -m$.
    Then, by definition of the floor function, $\floor{x} = -m - 1$.
    Solving for $m$ yields $$\floor{-x} = m = -\floor{x} - 1.$$

  \paragraph{Conclusion}%

    The above two cases are exhaustive. Thus
      $$\floor{-x} =
        \begin{cases}
          -\floor{x} & \text{if } x \text{ is an integer}, \\
          -\floor{x} - 1 & \text{otherwise}.
        \end{cases}$$

\end{proof}

\subsection*{\verified{Exercise 4c}}%
\label{sub:exercise-4c}

$\floor{x + y} = \floor{x} + \floor{y}$ or $\floor{x} + \floor{y} + 1$.

\begin{proof}

  \lean{exercise\_4c}

  \divider

  Rewrite $x$ and $y$ as the sum of their floor and fractional components:
    $x = \floor{x} + \{x\}$ and $y = \floor{y} + \{y\}$.
  Now
    \begin{align}
      \floor{x + y}
        & = \floor{\floor{x} + \{x\} + \floor{y} + \{y\}} \nonumber \\
        & = \floor{\floor{x} + \floor{y} + \{x\} + \{y\}} \nonumber \\
        & = \floor{x} + \floor{y} + \floor{\{x\} + \{y\}}
        & \text{\nameref{sub:exercise-4a}} \label{sub:exercise-4c-eq1}
    \end{align}
  There are two cases to consider:

  \paragraph{Case 1}%

    Suppose $\{x\} + \{y\} < 1$.
    Then $\floor{\{x\} + \{y\}} = 0$.
    Substituting this value into \eqref{sub:exercise-4c-eq1} yields
      $$\floor{x + y} = \floor{x} + \floor{y}.$$

  \paragraph{Case 2}%

    Suppose $\{x\} + \{y\} \geq 1$.
    Because $\{x\}$ and $\{y\}$ are both less than $1$, $\{x\} + \{y\} < 2$.
    Thus $\floor{\{x\} + \{y\}} = 1$.
    Substituting this value into \eqref{sub:exercise-4c-eq1} yields
      $$\floor{x + y} = \floor{x} + \floor{y} + 1.$$

  \paragraph{Conclusion}%

    Since the above two cases are exhaustive, it follows
      $\floor{x + y} = \floor{x} + \floor{y}$ or $\floor{x} + \floor{y} + 1$.

\end{proof}

\subsection*{\partial{Exercise 4d}}%
\label{sub:exercise-4d}

$\floor{2x} = \floor{x} + \floor{x + \frac{1}{2}}.$

\begin{proof}

  \lean{exercise\_4d}

  \divider

  This is immediately proven by applying Hermite's Identity as shown in
    \nameref{sec:exercise-5}.

\end{proof}

\subsection*{\partial{Exercise 4e}}%
\label{sub:exercise-4e}

$\floor{3x} = \floor{x} + \floor{x + \frac{1}{3}} + \floor{x + \frac{2}{3}}.$

\begin{proof}

  \lean{exercise\_4e}

  \divider

  This is immediately proven by applying Hermite's Identity as shown in
    \nameref{sec:exercise-5}.

\end{proof}

\section*{\partial{Exercise 5}}%
\label{sec:exercise-5}

The formulas in Exercises 4(d) and 4(e) suggest a generalization for
  $\floor{nx}$.
State and prove such a generalization.

\note{The stated generalization is known as "Hermite's Identity."}

\begin{proof}

  \lean{exercise\_5}

  \divider

  We prove that for all natural numbers $n$ and real numbers $x$, the following
    identity holds:
    \begin{equation}
      \label{sec:exercise-5-eq1}
      \floor{nx} = \sum_{i=0}^{n-1} \floor{x + \frac{i}{n}}
    \end{equation}
  By definition of the floor function, $x = \floor{x} + r$ for some
    $r \in \ico{0}{1}$.
  Define $S$ as the partition of non-overlapping subintervals
    $$\ico{0}{\frac{1}{n}}, \ico{\frac{1}{n}}{\frac{2}{n}}, \ldots,
      \ico{\frac{n-1}{n}}{1}.$$
  By construction, $\cup\; S = \ico{0}{1}$.
  Therefore there exists some $j \in \mathbb{N}$ such that
    \begin{equation}
      \label{sec:exercise-5-eq2}
      r \in \ico{\frac{j}{n}}{\frac{j+1}{n}}.
    \end{equation}
  With these definitions established, we now show the left- and right-hand sides
    of \eqref{sec:exercise-5-eq1} evaluate to the same number.

  \paragraph{Left-Hand Side}%

    Consider the left-hand side of identity \eqref{sec:exercise-5-eq1}.
    By \eqref{sec:exercise-5-eq2}, $nr \in \ico{j}{j + 1}$.
    Therefore $\floor{nr} = j$.
    Thus
      \begin{align}
        \floor{nx}
          & = \floor{n(\floor{x} + r)} \nonumber \\
          & = \floor{n\floor{x} + nr} \nonumber \\
          & = \floor{n\floor{x}} + \floor{nr}. \nonumber
            & \text{\nameref{sub:exercise-4a}} \\
          & = \floor{n\floor{x}} + j \nonumber \\
          & = n\floor{x} + j. \label{sec:exercise-5-eq3}
      \end{align}

  \paragraph{Right-Hand Side}%

    Now consider the right-hand side of identity \eqref{sec:exercise-5-eq1}.
    We note each summand, by construction, is the floor of $x$ added to a
      nonnegative number less than one.
    Therefore each summand contributes either $\floor{x}$ or $\floor{x} + 1$ to
      the total.
    Letting $z$ denote the number of summands that contribute $\floor{x} + 1$,
      we have
      \begin{equation}
        \label{sec:exercise-5-eq4}
        \sum_{i=0}^{n-1} \floor{x + \frac{i}{n}} = n\floor{x} + z.
      \end{equation}
    The value of $z$ corresponds to the number of indices $i$ that satisfy
      $$\frac{i}{n} \geq 1 - r.$$
    By \eqref{sec:exercise-5-eq2}, it follows
      \begin{align*}
        1 - r
          & \in \ioc{1 - \frac{j+1}{n}}{1-\frac{j}{n}} \\
          & = \ioc{\frac{n - j - 1}{n}}{\frac{n - j}{n}}.
      \end{align*}
    Thus we can determine the value of $z$ by instead counting the number of
      indices $i$ that satisfy $$\frac{i}{n} \geq \frac{n - j}{n}.$$
    Rearranging terms, we see that $i \geq n - j$ holds for
      $z = (n - 1) - (n - j) + 1 = j$ of the $n$ summands.
    Substituting the value of $z$ into \eqref{sec:exercise-5-eq4} yields
      \begin{equation}
        \label{sec:exercise-5-eq5}
        \sum_{i=0}^{n-1} \floor{x + \frac{i}{n}} = n\floor{x} + j.
      \end{equation}

  \paragraph{Conclusion}%

    Since \eqref{sec:exercise-5-eq3} and \eqref{sec:exercise-5-eq5} agree with
    one another, it follows identity \eqref{sec:exercise-5-eq1} holds.

\end{proof}

\section*{\unverified{Exercise 6}}%
\label{sec:exercise-6}

Recall that a lattice point $(x, y)$ in the plane is one whose coordinates are
  integers.
Let $f$ be a nonnegative function whose domain is the interval $[a, b]$, where
  $a$ and $b$ are integers, $a < b$.
Let $S$ denote the set of points $(x, y)$ satisfying $a \leq x \leq b$,
  $0 < y \leq f(x)$.
Prove that the number of lattice points in $S$ is equal to the sum
  $$\sum_{n=a}^b \floor{f(n)}.$$

\begin{proof}

  Let $i = a, \ldots, b$ and define $S_i = \mathbb{N} \cap \ioc{0}{f(i)}$.
  By construction, the number of lattice points in $S$ is
    \begin{equation}
      \label{sec:exercise-6-eq1}
      \sum_{n = a}^b \abs{S_n}.
    \end{equation}
  All that remains is to show $\abs{S_i} = \floor{f(i)}$.
  There are two cases to consider:

  \paragraph{Case 1}%

    Suppose $f(i)$ is an integer.
    Then the number of integers in $\ioc{0}{f(i)}$ is $f(i) = \floor{f(i)}$.

  \paragraph{Case 2}%

    Suppose $f(i)$ is not an integer.
    Then the number of integers in $\ioc{0}{f(i)}$ is the same as that of
      $\ioc{0}{\floor{f(i)}}$.
    Once again, that number is $\floor{f(i)}$.

  \paragraph{Conclusion}%

    By cases 1 and 2, $\abs{S_i} = \floor{f(i)}$.
    Substituting this identity into \eqref{sec:exercise-6-eq1} finishes the
      proof.

\end{proof}

\section*{Exercise 7}%
\label{sec:exercise-7}

If $a$ and $b$ are positive integers with no common factor, we have the formula
  $$\sum_{n=1}^{b-1} \floor{\frac{na}{b}} = \frac{(a - 1)(b - 1)}{2}.$$
When $b = 1$, the sum on the left is understood to be $0$.

\note{When $b = 1$, the proofs of (a) and (b) are trivial. We continue under the
  assumption $b > 1$.}

\subsection*{\unverified{Exercise 7a}}%
\label{sub:exercise-7a}

Derive this result by a geometric argument, counting lattice points in a right
  triangle.

\begin{proof}

  Let $f \colon [1, b - 1] \rightarrow \mathbb{R}$ be given by $f(x) = ax / b$.
  Let $S$ denote the set of points $(x, y)$ satisfying $1 \leq x \leq b - 1$,
    $0 < y \leq f(x)$.
  By \nameref{sec:exercise-6}, the number of lattice points of $S$ is equal to
    the sum
    \begin{equation}
      \label{sub:exercise-7a-eq1}
      \sum_{n=1}^{b-1} \floor{f(n)} = \sum_{n=1}^{b-1} \floor{\frac{na}{b}}.
    \end{equation}
  Define $T$ to be the triangle of width $w = b$ and height $h = f(b) = a$
    as $$T = \{ (x, y) : 0 < x < b, 0 < y \leq f(x) \}.$$
  By construction, $T$ does not introduce any additional lattice points.
  Thus $S$ and $T$ have the same number of lattice points.
  Let $H_L$ denote the number of boundary points on $T$'s hypotenuse.
  We prove that (i) $H_L = 2$ and (ii) that $T$ has $\frac{(a - 1)(b - 1)}{2}$
    lattice points.

  \paragraph{(i)}%
  \label{par:exercise-7a-i}

    Consider the line $L$ overlapping the hypotenuse of $T$.
    By construction, $T$'s hypotenuse has endpoints $(0, 0)$ and $(b, a)$.
    By hypothesis, $a$ and $b$ are positive, excluding the possibility of $L$
      being vertical.
    Define the slope of $L$ as $$m = \frac{a}{b}.$$
    $H_L$ coincides with the number of indices $i = 0, \ldots, b$ such that
      $(i, i * m)$ is a lattice point.
    But $a$ and $b$ are coprime by hypothesis and $i \leq b$.
    Thus $i * m$ is an integer if and only if $i = 0$ or $i = b$.
    Thus $H_L = 2$.

  \paragraph{(ii)}%

    Next we count the number of lattice points in $T$.
    Let $R$ be the overlapping retangle of width $w$ and height $h$, situated
      with bottom-left corner at $(0, 0)$.
    Let $I_R$ denote the number of interior lattice points of $R$.
    Let $I_T$ and $B_T$ denote the interior and boundary lattice points of $T$
      respectively.
    By \nameref{C:1:07:sub:exercise-4b-eq2},
      \begin{align}
        I_T
          & = \frac{1}{2}(I_R - (H_L - 2)) \nonumber \\
          & = \frac{1}{2}(I_R - (2 - 2))
            & \text{\nameref{par:exercise-7a-i}} \nonumber \\
            & = \frac{1}{2}I_R. & \label{sub:exercise-7a-eq2}
      \end{align}
    Furthermore, since both the adjacent and opposite side of $T$ are not
      included in $T$ and there exist no lattice points on $T$'s hypotenuse
      besides the endpoints, it follows
      \begin{equation}
        \label{sub:exercise-7a-eq3}
        B_T = 0.
      \end{equation}
    Thus the number of lattice points of $T$ equals
      \begin{align}
        I_T + B_T
          & = I_T & \eqref{sub:exercise-7a-eq3} \nonumber \\
          & = \frac{1}{2}I_R & \eqref{sub:exercise-7a-eq2} \nonumber \\
          & = \frac{(b - 1)(a - 1)}{2}.
            & \text{\nameref{C:1:07:sub:exercise-4a}}
              \label{sub:exercise-7a-eq4}
      \end{align}

  \paragraph{Conclusion}%

    By \eqref{sub:exercise-7a-eq1} the number of lattice points of $S$ is equal
      to the sum $$\sum_{n=1}^{b-1} \floor{\frac{na}{b}}.$$
    But the number of lattice points of $S$ is the same as that of $T$.
    By \eqref{sub:exercise-7a-eq4}, the number of lattice points in $T$ is equal
      to $$\frac{(b - 1)(a - 1)}{2}.$$
    Thus $$\sum_{n=1}^{b-1} \floor{\frac{na}{b}} = \frac{(a - 1)(b - 1)}{2}.$$

\end{proof}

\subsection*{\partial{Exercise 7b}}%
\label{sub:exercise-7b}

Derive the result analytically as follows:
By changing the index of summation, note that
  $\sum_{n=1}^{b-1} \floor{na / b} = \sum_{n=1}^{b-1} \floor{a(b - n) / b}$.
Now apply Exercises 4(a) and (b) to the bracket on the right.

\begin{proof}

  \lean{exercise\_7b}

  \divider

  Let $n = 1, \ldots, b - 1$.
  By hypothesis, $a$ and $b$ are coprime.
  Furthermore, $n < b$ for all values of $n$.
  Thus $an / b$ is not an integer.
  By \nameref{sub:exercise-4b},
    \begin{equation}
      \label{sub:exercise-7b-eq1}
      \floor{-\frac{an}{b}} = -\floor{\frac{an}{b}} - 1.
    \end{equation}
  Consider the following:
    \begin{align*}
      \sum_{n=1}^{b-1} \floor{\frac{na}{b}}
        & = \sum_{n=1}^{b-1} \floor{\frac{a(b - n)}{b}} \\
        & = \sum_{n=1}^{b-1} \floor{\frac{ab - an}{b}} \\
        & = \sum_{n=1}^{b-1} \floor{-\frac{an}{b} + a} \\
        & = \sum_{n=1}^{b-1} \floor{-\frac{an}{b}} + a.
          & \text{\nameref{sub:exercise-4a}} \\
        & = \sum_{n=1}^{b-1} -\floor{\frac{an}{b}} - 1 + a
          & \eqref{sub:exercise-7b-eq1} \\
        & = -\sum_{n=1}^{b-1} \floor{\frac{an}{b}} - \sum_{n=1}^{b-1} 1 +
          \sum_{n=1}^{b-1} a \\
        & = -\sum_{n=1}^{b-1} \floor{\frac{an}{b}} - (b - 1) + a(b - 1).
    \end{align*}
  Rearranging the above yields
    $$2\sum_{n=1}^{b-1} \floor{\frac{an}{b}} = (a - 1)(b - 1).$$
  Dividing both sides of the above identity concludes the proof.

\end{proof}

\section*{\partial{Exercise 8}}%
\label{sec:exercise-8}

Let $S$ be a set of points on the real line.
The \textit{characteristic function} of $S$ is, by definition, the function
  $\mathcal{X}_S$ such that $\mathcal{X}_S(x) = 1$ for every $x$ in $S$, and
  $\mathcal{X}_S(x) = 0$ for those $x$ not in $S$.
Let $f$ be a step function which takes the constant value $c_k$ on the $k$th
  open subinterval $I_k$ of some partition of an interval $[a, b]$.
Prove that for each $x$ in the union $I_1 \cup I_2 \cup \cdots \cup I_n$ we have
  $$f(x) = \sum_{k=1}^n c_k\mathcal{X}_{I_k}(x).$$
This property is described by saying that every step function is a linear
  combination of characteristic functions of intervals.

\begin{proof}

  Let $x \in I_1 \cup I_2 \cup \cdots \cup I_n$ and $N = \{1, \ldots, n\}$.
  Let $k \in N$ such that $x \in I_k$.
  Consider an arbitrary $j \in N - \{k\}$.
  By definition of a partition, $I_j \cap I_k = \emptyset$.
  That is, $I_j$ and $I_k$ are disjoint for all $j \in N - \{k\}$.
  Therefore, by definition of the characteristic function,
    $\mathcal{X}_{I_k}(x) = 1$ and $\mathcal{X}_{I_j}(x) = 0$ for all
    $j \in N - \{k\}$.
  Thus
    \begin{align*}
      f(x)
        & = c_k \\
        & = (c_k)(1) + \sum\nolimits_{j \in N - \{k\}} (c_j)(0) \\
        & = c_k\mathcal{X}_{I_k}(x) +
          \sum\nolimits_{j \in N - \{k\}} c_j\mathcal{X}_{I_j}(x) \\
        & = \sum_{k=1}^n c_k\mathcal{X}_{I_k}(x).
    \end{align*}

\end{proof}

\end{document}
