I have been using this formula which I determined for myself for quite some time now for use in everything from the sgn() function to the Kronecker delta to the ceiling and NINT() functions but haven't quite pinned down why it works or what its limitations may be. Can anyone elaborate as to why this works at all (not strictly how to derive it as I've done that myself, but what limitations the expression on the right may have which may prevent this from being a strict equality)? I've found this to be of much practical utility, but wouldn't want to use it if indeed it harbors some unforeseen limitation. Many thanks supposing this gets read. - Matt Miller :)
$$\lfloor x \rfloor = x - (\frac{1}{2}) + (\frac{1}{\pi})\sum_{k=1}^\infty (\frac{1}{k})sin(2k\pi x) = x - (\frac{1}{2}) - (\frac{i}{2\pi})ln(-e^{-i2\pi x}), x \ne [0,1,2…n]$$
And:
$$\lfloor x \rfloor = 1 + x - (\frac{1}{2}) - (\frac{i}{2\pi})ln(-e^{-i2\pi x}), x = [1,2...n]$$
From the comments below, it's been shown that the above fails to work at x=0 and is shifted from x to f(x) = n-1 when x is an exact integer 'n' for which I've heavily edited the original post to correct the formula.
Borrowing from @gammatester and @barakmanos I've devised a simple fix to the above formula, though this work-around doesn't exactly cooperate with all computer implementations (due in large part to the composition of functions involved) it demonstrates the point to my mind:
Given (courtesy @barakmanos):
$$f(x) = x - (\frac{1}{2})((\frac{1}{i\pi})ln(e^{i2\pi(x-(\frac{1}{2})})+1)$$
For:
$$ \lceil x \rceil = - \lfloor - x \rfloor $$
And:
$$ \lceil x \rceil = \lfloor x \rfloor, x \in \mathbb{Z}$$
And:
$$ \lceil x \rceil - \lfloor x \rfloor = 1, x \in \mathbb{R}/\mathbb{Z}$$
One obtains:
$$\bbox[5px,border:2px solid red] {\lfloor x \rfloor = f(x) - f(-f(-x)-f(x)), x \in \mathbb{R}}$$
Note: I think it's important to emphasize one should expect the correct results if the terms inside the brackets are independently evaluated first and then the composition is taken. There is a chance I may have made a mistake I'm unable to see myself, otherwise this is working for me as it's written though I've reformulated it for my own purposes in other applications (be very careful trying to simplify this expression for use in, say, a symbolic programming language).