Proving nearest integer function identity

63 Views Asked by At

While trying to express the nearest integer function in terms of the modulo or floor function to make some lunar ephemeris equations more compact, I noticed (using GeoGebra) that $$\lfloor x\rceil=1+\lfloor x-1/2\rfloor$$ Is it true? If so, how would one prove it?

1

There are 1 best solutions below

0
On BEST ANSWER

There are four cases. (There may be fewer cases; I've made no attempt to determine if these cases can be handled together.)

  • $x$ is an integer. Then $1+\lfloor x-1/2 \rfloor = 1 + (x-1) = x$, as expected.
  • $x$ is one-half more than an integer, $n$. Then $1 + \lfloor (n+1/2) - 1/2 \rfloor = 1 + \lfloor n \rfloor = n+1$, which may or not be the behaviour you expect.
  • $n$ is an integer and $x \in (n,n+1/2)$. Then \begin{align*} n &< x < n+1/2 \\ n - 1/2 &< x -1/2 < n \\ \lfloor n - 1/2 \rfloor &\leq \lfloor x -1/2 \rfloor < \lfloor n \rfloor \\ n-1 &\leq \lfloor x -1/2 \rfloor < n \\ 1 + (n-1) &\leq 1 + \lfloor x -1/2 \rfloor < 1 + n \\ n &\leq 1 + \lfloor x -1/2 \rfloor < n + 1 \text{,} \end{align*} and since the expression in the middle is an integer, it must be $n$, as expected.
  • A similar argument for integer $n$ and $x \in (n-1/2, n)$: \begin{align*} n - 1/2 &< x < n \\ n - 1 &< x - 1/2 < n - 1/2 \\ \lfloor n - 1 \rfloor &\leq \lfloor x -1/2 \rfloor \leq \lfloor n - 1/2 \rfloor \\ n-1 &\leq \lfloor x -1/2 \rfloor \leq n-1 \\ 1 + (n-1) &\leq 1 + \lfloor x -1/2 \rfloor \leq 1 + (n-1) \\ n &\leq 1 + \lfloor x -1/2 \rfloor \leq n \text{,} \end{align*} so we obtain $n$, as expected.