Quotient of Modulo Operation with Modulus

From ProofWiki
Jump to navigation Jump to search

Theorem

Let $x, y \in \R$ be real numbers.

Let $x \bmod y$ denote the modulo operation:

$x \bmod y := \begin{cases} x - y \left \lfloor {\dfrac x y}\right \rfloor & : y \ne 0 \\ x & : y = 0 \end{cases}$

where $\left \lfloor {\dfrac x y}\right \rfloor$ denotes the floor of $\dfrac x y$.


Let $y \ne 0$.


Then:

$0 \le \dfrac x y - \left \lfloor {\dfrac x y}\right \rfloor = \dfrac {x \bmod y} y < 1$


Proof

From Real Number minus Floor:

$\dfrac x y - \left \lfloor {\dfrac x y}\right \rfloor \in \left[{0 \,.\,.\, 1}\right)$

Thus by definition of half-open real interval:

$0 \le \dfrac x y - \left \lfloor {\dfrac x y}\right \rfloor < 1$


Then:

\(\displaystyle x \bmod y\) \(=\) \(\displaystyle x - y \left \lfloor {\frac x y}\right \rfloor\) Definition of Modulo Operation
\(\displaystyle \leadsto \ \ \) \(\displaystyle \frac {x \bmod y} y\) \(=\) \(\displaystyle \frac {x - y \left \lfloor {\dfrac x y}\right \rfloor} y\)
\(\displaystyle \) \(=\) \(\displaystyle \frac x y - \frac y y \left \lfloor {\dfrac x y}\right \rfloor\)
\(\displaystyle \) \(=\) \(\displaystyle \frac x y - \left \lfloor {\dfrac x y}\right \rfloor\)

Hence the result.

$\blacksquare$


Sources