Floor of x+m over n/Proof 1

From ProofWiki
Jump to navigation Jump to search

Theorem

Let $m, n \in \Z$ such that $n > 0$.

Let $x \in \R$.


Then:

$\left\lfloor{\dfrac {x + m} n}\right\rfloor = \left\lfloor{\dfrac {\left\lfloor{x}\right\rfloor + m} n}\right\rfloor$

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


Proof

Let:

$y = x - \floor x$
$M = m + \floor x$

We now have:

$(1): \quad 0 \le y < 1$

and

$\floor y = 0$

Write:

$(2): \quad M = k n + r$

with $k \in \Z$ and $0 \le r \le n - 1$.

By $(1)$ and $(2)$:

$(3): \quad 0 \le r + y < n - 1 + 1 = n$


We have:

\(\displaystyle \floor {\dfrac {y + M} n}\) \(=\) \(\displaystyle \floor {\dfrac {y + r} n + k}\)
\(\displaystyle \) \(=\) \(\displaystyle k + \floor {\dfrac {r + y} n}\)
\(\displaystyle \) \(=\) \(\displaystyle k\) from $(3)$
\(\displaystyle \) \(=\) \(\displaystyle \floor {\dfrac M n}\)


Substituting $y$ and $M$, we obtain:

\(\displaystyle \floor {\dfrac {x - \floor x + m + \floor x} n }\) \(=\) \(\displaystyle \floor {\dfrac {x + m} n }\)
\(\displaystyle \) \(=\) \(\displaystyle \floor {\dfrac {m + \floor x} n}\)

and the result follows.

$\blacksquare$


Sources