I was trying to derive a purely trigonometric version of the floor function for Pi Day, and I came up with;
$$f(x)=-\left(1-\frac{\tan^{-1}(\tan(-{\pi}x-\frac{\pi}{2}))+\frac{\pi}{2}}{\pi} - x\right)$$ image of aforementioned function written out on the Desmos Graphing Calculator
What I would like to know, is whether or not this function properly serves its purpose as always outputting the same value the floor() function would (rounding down) given the same x in floor(x),
does this work?
The formula works if $x$ is not an integer.
If $y$ is a real number, then, when $\tan y$ is defined, $z=\tan^{-1}(\tan y)$ is the real number such that:
This can be written as $$\tan^{-1}(\tan y)= y-\pi\left \lfloor \frac{y+\pi/2}{\pi}\right\rfloor$$
(Why?)
Then substitute $y=-\pi x-\pi/2.$
You'll need $\lfloor -x \rfloor = -\lfloor x\rfloor -1$ for $x$ not an integer.
The rest is just algebra.
This works for any function, not just $\tan,$ which has period $L$ and is one-to-one on some interval $(a,a+L)$ and we define $g=f^{-1}$ to be a partial inverse with range $(a,a+L).$ Just replace $\tan$ with $f,$ $\tan^{-1}$ with $g,$ $\pi$ with $L$ and $-\pi/2$ with $a.$
Then $$g(f(y))=y-L\left\lfloor \frac{y-a}{L}\right\rfloor$$
Substituting $y=-Lx+a,$ you get:
$$g(f(-Lx+a))=L(\lfloor x\rfloor+1-x)+a$$
Solving, $$\lfloor x\rfloor =\frac{g(f(-Lx-a))-a}{L}+x-1=-\left(1-\frac{g(f(-Lx+a))-a}{L}-x\right)$$
However, even if $f$ is defined at $a$ and one-to-one on $[a,a+L)$ or equivalently $(a,a+L],$ you can't get the result for integer $x$ since we used $\lfloor -x\rfloor=-\lfloor x\rfloor -1,$ which is only true for $x$ an integer, and the formula $g(f(y))$ depends on whether $g(f(a))=a$ or $g(f(a))=a+L.$