Does $\left\lfloor\frac{x^2+x}{i}\right\rfloor – \left\lfloor\frac{x^2}{i}\right\rfloor = \left\lfloor\frac{x}{i}\right\rfloor$

ceiling-and-floor-functionsproof-verification

Does $\left\lfloor\dfrac{x^2+x}{i}\right\rfloor – \left\lfloor\dfrac{x^2}{i}\right\rfloor = \left\lfloor\dfrac{x}{i}\right\rfloor$?

where $i \le x^2$ and $x$ are any positive integer.

Intuitively, this doesn't seem correct to me but here's my argument which appears valid:

(1) There exists an integer $a$ such that: $x \equiv a \pmod i$ where $0 \le a < i$

(2) $\left\lfloor\dfrac{x^2+x}{i}\right\rfloor – \left\lfloor\dfrac{x^2}{i}\right\rfloor = \dfrac{x^2 + x – a^2 – a}{i} – \dfrac{x^2 – a^2}{i} = \dfrac{x-a}{i} = \left\lfloor\dfrac{x}{i}\right\rfloor$

Is my argument wrong? Is my intuition wrong?

Best Answer

Consider x = 7 and i = 5. you get

$\left\lfloor\dfrac{49+7}{5}\right\rfloor = 11$

$\left\lfloor\dfrac{49}{5}\right\rfloor = 9$

$\left\lfloor\dfrac{7}{5}\right\rfloor = 1$

as you see the equation doesn't hold.

Your intuition is right and the argument is wrong. The same argument should follow the following logic

$\dfrac{x}{i} = k + \dfrac{a}{i}$ where $k$ is highest possible positive integer without making term a negative

$\dfrac{x^2}{i} = l + \dfrac{a^2}{i}$

$\left\lfloor\dfrac{x^2+x}{ i}\right\rfloor = k + l + \left\lfloor\dfrac{a+a^2}{i}\right\rfloor$

$\left\lfloor\dfrac{x^2}{i}\right\rfloor = l + \left\lfloor\dfrac{a^2}{i}\right\rfloor$

$\left\lfloor\dfrac{x}{i}\right\rfloor = k + \left\lfloor\dfrac{a}{i}\right\rfloor$

as you see the floor terms are not necessarily equal. There could be cases when $a+a^2$ is higher than $i$ when both $a$ and $a^2$ are less than $i$.

Hope it helps

Related Question