# Is $\lfloor x\rfloor$ defined in terms of $|x|$ and branch selection?

Is $\lfloor x\rfloor$ defined in terms of repeated square root branch selection:

$$\lfloor x\rfloor = \frac{1}{2}\left(\sum_{n=-\infty}^\infty\frac{+\sqrt{(x-n)^2}}{x-n} \right) - \frac1{2}$$

Or the arctangent's logarithmic branch selection:

$$\lfloor x\rfloor = x - \frac1{2}-\frac1{\pi}\tan^{-1}\left(\tan\left(\pi(x - \frac1{2})\right)\right)$$

Or both, or something else?

-
Should the index of summation be $n$? – robjohn Sep 10 '11 at 18:20
No, it's defined as the greatest integer less than or equal to its argument. But sure, there's this... – J. M. Sep 10 '11 at 18:23
The series is divergent (and one term is undefined when $x$ is an integer). – Did Sep 10 '11 at 18:50

First of all, I emphasize that neither is a definition of the floor function found in any standard text or paper. This obfuscation seems like an attempt to create an "algebraic" formula to express $\lfloor x \rfloor$. Let me play along anyway.

Since Yuval already explained the second formula, I will restrict to the first. However, I will modify it slightly to make the expression even meaningful. First, let us replace $$\frac{\sqrt{x^2}}{x} = \frac{|x|}{x},$$ by $$\mathrm{sgn} \ x = \begin{cases} 1 & x \geq 0, \\ -1 & x < 0. \end{cases}$$ Notice that $\mathrm{sgn}\ 0$ is arbitrarily defined as $1$. Further, we will modify the right hand by grouping the positive and negative terms together. That is, we want to prove that the expression: $$\frac{1}{2}\sum_{n=1}^{\infty} (\mathrm{sgn} (x-n) + \mathrm{sgn} (x+n)) + \frac{1}{2}\mathrm{sgn} (x) - \frac{1}{2}. \tag{1}$$ sums to $\lfloor x \rfloor$ for all $x \in \mathbb R$. (Convince yourself that I have included all the terms in the above formula.) The reason for pairing up the terms like this is that the original series had obvious convergence issues; in contrast, for any real $x$ all but finitely many terms of the modified series vanish.

First of all, suppose $x \geq 0$, and define $r := \lfloor x \rfloor \geq 0$. Since for any integer $k$, we have $k \leq x$ iff $k \leq \lfloor x \rfloor = r$, the $n$th summand of the series $\mathrm{sgn}(x-n) + \mathrm{sgn}(x+n)$ vanishes for $n \geq r+1$. On the other hand, for $1 \leq n \leq r$, the two terms double up to $2$. Plugging in these values, $(1)$ simplifies to: $$\frac{1}{2} \sum_{n=1}^{r} 2 + \frac{1}{2} - \frac{1}{2} = r = \lfloor x \rfloor,$$ and so we are done. (Note that $\mathrm{sgn} x = 1$.)

Now consider the case $x < 0$. The trick in this case is to define $r := \lceil -x \rceil \geq 0$. I leave it as an exercise to verify that $\lfloor x \rfloor = -r$, in all cases whether or not $x$ is an integer. In this case, the $n$th summand cancels for $n \geq r$, since $x+n \geq x + r = x + \lceil -x \rceil \geq x -x = 0$, whereas $x-n$ is clearly negative. On the other hand, for $1 \leq n \leq r-1$, we have $x + n < 0$ (following a similar argument as above). So in this range the two terms double up to $-2$. Substituting these values, $(1)$ simplifies to $$\frac{1}{2}\sum_{n=1}^{r-1} (-2) + \frac{-1}{2} - \frac{1}{2} = -(r-1) -1 = -r,$$ which is what we want to show. (Note that $\mathrm{sgn} \ x$ is $-1$.)

-

The first formula is similar to the well-known formula for the expectation of a variable taking natural numbers as values: $$\mathbb{E}X = \sum_{n \geq 1} \Pr[X \geq n].$$ Since $$\frac{\sqrt{(x-n)^2}}{x-n} = \begin{cases} 1 & x > n, \\ -1 & x < n, \end{cases}$$ we can write the formula (after correcting it) as $$\frac{1}{2} \sum_n \left(1 + \frac{|x-n|}{x-n}\right) = \sum_n [x > n].$$ If we know that $x > 0$ is non-integral and we let the summation to be on the range $1$ to $\infty$, then everything works. So the correct formula is $$\lfloor x \rfloor = \frac{1}{2} \sum_{n=1}^\infty \left(1+\frac{|x-n|}{x-n}\right), \quad x \in \mathbb{R}_+ \setminus \mathbb{N}.$$

The second formula is a fancy way to write $$\lfloor x \rfloor = x - (x),$$ where $(x)$ is the fractional part. To find the fractional part, we take some monotone increasing periodic function, apply it and "reverse" it, to find the location within the period. If $f$ is a monotone increasing periodic function such that $f^{-1}$ maps to the period $(a,b)$, then $$(x) = \frac{f^{-1}(f(a + (b-a)x))-a}{b-a}.$$ For example, if $f = \tan$ then $[a,b] = [-\pi/2,\pi/2]$ (given the usual choice of period for $\arctan$), and so $$(x) = \frac{\arctan(\tan(\pi(x-1/2))+\pi/2}{\pi} = \frac{1}{\pi} \arctan(\tan(\pi(x-1/2)) + \frac{1}{2}.$$

But why would you define $\lfloor x \rfloor$ this way? Both "definitions" have the drawback that they don't work at the discontinuities (note that a monotone periodic function must have discontinuities for obvious reasons). More importantly, they are far more obscure than the usual, textual definition, which is also easier to work with. Gone are the days when "function" implicitly meant "formula".

-