I have established the following function for calculating $floor$:
$$f(x)=x-\frac{1}{2}-\frac{\arcsin(\sin(\pi(x-\frac{1}{2})))}{\pi}$$
It works correctly for all real values in the range $[2N+0,2N+1)$, for every integer $N$.
It works incorrectly for almost all real values in the range $[2N+1,2N+2)$, for every integer $N$.
I believe that I can work it out by changing the domain of $x$, though I can't quite figure out how...
Any ideas?
Please see a few examples below:
- $f(2.0)=2.0 = \lfloor 2.0 \rfloor$
- $f(2.1)=2.0 = \lfloor 2.1 \rfloor$
- $f(2.2)=2.0 = \lfloor 2.2 \rfloor$
- $f(2.3)=2.0 = \lfloor 2.3 \rfloor$
- $f(2.4)=2.0 = \lfloor 2.4 \rfloor$
- $f(2.5)=2.0 = \lfloor 2.5 \rfloor$
- $f(2.6)=2.0 = \lfloor 2.6 \rfloor$
- $f(2.7)=2.0 = \lfloor 2.7 \rfloor$
- $f(2.8)=2.0 = \lfloor 2.8 \rfloor$
- $f(2.9)=2.0 = \lfloor 2.9 \rfloor$
- $f(3.0)=2.0 \neq \lfloor 3.0 \rfloor$
- $f(3.1)=2.2 \neq \lfloor 3.1 \rfloor$
- $f(3.2)=2.4 \neq \lfloor 3.2 \rfloor$
- $f(3.3)=2.6 \neq \lfloor 3.3 \rfloor$
- $f(3.4)=2.8 \neq \lfloor 3.4 \rfloor$
- $f(3.5)=3.0 = \lfloor 3.5 \rfloor$
- $f(3.6)=3.2 \neq \lfloor 3.6 \rfloor$
- $f(3.7)=3.4 \neq \lfloor 3.7 \rfloor$
- $f(3.8)=3.6 \neq \lfloor 3.8 \rfloor$
- $f(3.9)=3.8 \neq \lfloor 3.9 \rfloor$
- $f(4.0)=4.0 = \lfloor 4.0 \rfloor$
The problem with sine is that it is not monotone on its period. I would therefore use tangent instead. Try $x-\arctan(\tan(x))$. This should be locally flat. By rescaling the variables you should be able to get the floor. Of course, there are points where this is undefined, but it works for almost all points :-)