# Does the floor function commute with any other functions?

Basically what I'm asking is if there are any functions $$f: \mathbb{R}\rightarrow \mathbb{R}$$ such that \begin{align}\text{floor}(f(x)) = f(\text{floor}(x)),\text{ or } f \circ \text{floor} = \text{floor} \circ f. \end{align} I am, of course, aware of trivial examples like $$f(x) = x$$, but I'm wondering if there's a whole class of functions?

For example, for $$g(x) = x^b$$, any function $$f(x) = x^a$$ will commute with $$g$$ in the way stated above; that is, $$g\circ f = f\circ g$$ for all $$x \in \mathbb{R}.$$

• A slightly less dull answer is $f(x) = x + n$ where $n$ is an integer. – badjohn Jun 18 '20 at 9:31
• Well, there are examples like $f(x)=x-\frac 12\times \{x\}$, where (as usual) $\{x\}$ denotes the fractional part of $x$, $x-\lfloor x\rfloor$. – lulu Jun 18 '20 at 9:33
• Hmm, wouldn't any funtion where for all $n\le x < n+1$ then $[f(n)] \le f(x) < [f(n)] + 1$ do. Seems there's lots of variable. – fleablood Jul 18 '20 at 22:49

In order for $$f(\lfloor x\rfloor)=\lfloor f(x)\rfloor$$ to hold for all $$x$$, we must have $$f(k)\in\mathbb{Z}$$ for all $$k\in\mathbb{Z}$$, with $$f(k)\le f(x)\lt f(k)+1$$ for $$k\le x\lt k+1$$. Beyond that the function can behave any way it likes.
Remark: The prime counting function, $$\pi(x)$$, is a nice example of a function that commutes with the floor function. If you want a continuous example, the (strictly) increasing function
$$f(x)=x+{1\over\pi}\sin(\pi x)$$
fits the bill, since $$f(k)=k$$ for all $$k\in\mathbb{Z}$$. (It's increasing since $$f'(x)=1+\cos(\pi x)\ge0$$ for all $$x$$.)