Sum of Floors not greater than Floor of Sum
Jump to navigation
Jump to search
Theorem
Let $\floor x$ denote the floor function.
Then:
- $\floor x + \floor y \le \floor {x + y}$
The equality holds:
- $\floor x + \floor y = \floor {x + y}$
- $x \bmod 1 + y \bmod 1 < 1$
where $x \bmod 1$ denotes the modulo operation.
Proof
From the definition of the modulo operation, we have that:
- $x = \floor x + \paren {x \bmod 1}$
from which:
\(\ds \floor {x + y}\) | \(=\) | \(\ds \floor {\floor x + \paren {x \bmod 1} + \floor y + \paren {y \bmod 1} }\) | ||||||||||||
\(\ds \) | \(=\) | \(\ds \floor x + \floor y + \floor {\paren {x \bmod 1} + \paren {y \bmod 1} }\) | Floor of Number plus Integer |
Hence the inequality.
The equality holds if and only if:
- $\floor {\paren {x \bmod 1} + \paren {y \bmod 1} } = 0$
that is, if and only if:
- $x \bmod 1 + y \bmod 1 < 1$
$\blacksquare$
Sources
- 1997: Donald E. Knuth: The Art of Computer Programming: Volume 1: Fundamental Algorithms (3rd ed.) ... (previous) ... (next): $\S 1.2.4$: Integer Functions and Elementary Number Theory: Exercise $7$