Rounding a number

49 Views Asked by At

$a$ is a positive whole number. $k$ is a real number greater than one. $\operatorname{round}(x)=\left\lfloor x+\frac12\right\rfloor$.

$b(a)=\operatorname{round}(k\cdot\operatorname{round}(a/k))$.

Can $b(a)$ be:

  • greater than $a$?
  • less than $a$?
  • can $b(\dots (b(a)))$ tend to infinity?

The problem is practical: It is about rounding errors when calculating paid time period ($a$ or $b(a)$) on a Web site dependently on changes of the price (price is changed $k$ times).

2

There are 2 best solutions below

1
On

Greater than $a$? Try $a = 3$ and $k = 2$.

Less than $a$? Try $a = 14$ and $k = 10$.

The last one. Is there a fixed $k$?

0
On

Both inequalities are possible. For $1 < k < 2$:

  • For $0 < x < \frac{1}{2} (k + 1)$, we have $b(x) = 0 < x$.
  • For $\frac{1}{2}(k + 1) < x < 1$, we have $b(x) = 1 > x$.

Now, for any $k > 1$, the operation $b$ actually satisfies $b(b(x)) = b(x)$ for all $x$, that is, $b$ is idempotent. In particular, the series $b(x), b(b(x)), \ldots$ cannot escape to infinity.

Hint To see this, first observe that it follows from the definition and the fact that $u - 1 < \lfloor u \rfloor < u$, $$k r(x) - \frac{1}{2} < b(x) < k r(x) + \frac{1}{2} .$$

Dividing by $k$, adding $\frac{1}{2}$, and applying the floor function gives $$\left\lfloor r(x) + \frac{1}{2} \left(1 - \frac{1}{k} \right) \right\rfloor \leq r(b(x)) \leq \left\lfloor r(x) + \frac{1}{2} \left(1 + \frac{1}{k} \right) \right\rfloor .$$ Now, since $k > 1$, $0 < \frac{1}{2} \left(1 \pm \frac{1}{k} \right) < 1$, and since $r(x)$ is an integer, $$\left\lfloor r(x) + \frac{1}{2} \left(1 \pm \frac{1}{k} \right) \right\rfloor = \lfloor r(x) \rfloor = r(x),$$ so $r(b(x)) = r(x)$, from which the claim follows quickly.