# Explicit formula for floor(x)?

In number theory we have so-called explicit formula's in terms of the Riemann zeta zero's. For instance to count the sum of the logarithms of the primes below some given integer.

(second Chebyshev Function)

Consider the floor function : http://mathworld.wolfram.com/FloorFunction.html

Is there an explicit formula for it consisting of elementary functions?

If not, why not?

Maybe in terms of the zero's of another special function?

• I imagine it's not what you're looking for, but $-\lceil -x \rceil$ works. (There's probably also a Fourier series for $x-\lfloor x\rfloor$, which is a triangular wave) Jan 23, 2015 at 23:30
• math.stackexchange.com/questions/389063/… I like the formula with arctan and tan May 7, 2016 at 7:02
• @TheGreatDuck - the question was asked (and answered) in a previous thread May 8, 2016 at 18:17
• – lhf
May 13, 2016 at 17:03
• I consider this question far from solved. No Sum over zero's , no non-fourrier type answers. Maybe i gave the impression that we need a zeta - type function or a prime-related function. This is not NEC the case , other special functions are possible , although Some number theory connection is slightly desired ...
– mick
Aug 5, 2016 at 20:11

Note that $\lfloor x \rfloor = x - \{x\}$, where $\{x \}$ (the fractional part of $x$) is periodic with period $1$, with a jump discontinuity at integer points. Let's try to write $\{x\}=f\left(\cot \pi x\right)$, since $\cot \pi x$ has the same property. We need $f(y)\rightarrow 0$ as $y\rightarrow \infty$, $f(y)\rightarrow 1$ as $y\rightarrow -\infty$, and the correct arc-tangent-y interpolation in between. What works is $f(y)=\frac{1}{2}-\frac{1}{\pi}\tan^{-1}y$. Putting things together, $$\lfloor x \rfloor=x-\frac{1}{2} + \frac{1}{\pi}\tan^{-1}(\cot \pi x).$$

• Yes, since $\{x\}=x - \lfloor x \rfloor$. One caveat here is that we need to fill in the integer values (for both $\{x\}$ and $\lfloor x\rfloor$) by right-continuity, since $\cot k\pi$ ($k\in\mathbb{Z}$) is not defined. May 15, 2016 at 16:00

I've derived an explicit formula for $S(x)=Floor(x)$ from the explicit formula for $Q(x)$ based on the relationship between $S(x)$ and $Q(x)$. The $c(n)$ coefficient referenced in (3) below involves both a Dirichlet convolution and a Dirichlet inverse, but I believe it simplifies such that $c(n)=1$ when $n$ is a square integer ($n\in\{1,4,9,16,...\}$) and $c(n)=0$ when $n$ is not a square integer.

(1) $\quad Q(x)=\sum\limits_{n=1}^x a(n)\,,\quad a(n)=\left|\mu(n)\right|$

(2) $\quad Q_o(x)=\frac{6\,x}{\pi^2}+\sum\limits_{k=1}^K\left(\frac{x^{\frac{\rho_k}{2}}\zeta\left(\frac{\rho_k}{2}\right)}{\rho_k \zeta'\left(\rho_k\right)}+\frac{x^{\frac{\rho _{-k}}{2}}\zeta \left(\frac{\rho_{-k}}{2}\right)}{\rho_{-k}\zeta'\left(\rho_{-k}\right)}\right)+1+\sum\limits_{n=1}^N\frac{x^{-n}\,\zeta(-n)}{(-2\,n)\,\zeta'(-2\,n)}\,,\\$ $\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad K\to\infty\land N\to\infty$

(3) $\quad S_o(x)=\sum_\limits{n=1}^x c(n)\,Q_o\left(\frac{x}{n}\right)$

The following plot illustrates $S_o(x)$ (orange) evaluated at $K=N=200$. $S(x)$ is illustrated in blue as a reference but is mostly hidden under the evaluation of $S_o(x)$. The red discrete portion of the plot illustrates the evaluation of $S_o(x)$ at integer values of $x$.

• I assume these are the usual riemann zero’s used here ? Impressive. But “ Why “ this works is not Clearly explained. Do others agree ?
– mick
Apr 17, 2018 at 21:46
• @mick Yes, $\rho_k$ refers to a non-trivial zeta zero. The formula for $S_o(x)$ is based on the relationship $S(x)=\sum\limits_{n=1}^x c(n)\,Q(\frac{x}{n})$ where $c(n)=\begin{array}{cc} \{ & \begin{array}{cc} 1 & \sqrt{n}\in \mathbb{Z} \\ 0 & \text{True} \\ \end{array} \\ \end{array}$. Apr 18, 2018 at 3:29
• @mick I illustrated the $Q_o(x)$ formula in the following question: math.stackexchange.com/q/2737492. There's still some question in my mind with respect to the convergence of the $Q_o(x)$ formula. Apr 18, 2018 at 15:11

I don't think your going to find an explicit formula for the floor function and here is why,

$nextprime(n)= 1+\sum_{j=1}^{2n}\lfloor\frac{n!^j}{j!}\rfloor-\lfloor\frac{n!^j-1}{j!}\rfloor$

$prevprime(n)=n+1-\sum_{j=1}^{n}\lfloor\frac{j!^{n-1}}{(n-1)!}\rfloor-\lfloor\frac{j!^{n-1}-1}{(n-1)!}\rfloor$

Greatest prime factor of $n$ $=n+1-\sum_{j=1}^{n}\lfloor\frac{j!^n}{n}\rfloor-\lfloor\frac{j!^n-1}{n}\rfloor$

Smallest prime coprime to $n=1+\sum_{j=1}^{n}\lfloor\frac{n^j}{j!}\rfloor-\lfloor\frac{n^j-1}{j!}\rfloor$

I mean the list goes on and on. If there were an explicit formula for the floor function, any thing having to do with primes would have a solution. Let me know if you find it. (:

• But there already is an explicit formula for the number of primes below $n$ (as mentioned by the OP already), so why would it be surprising that we get other formulas for primes by nesting summations? May 13, 2016 at 17:10
• The comment from The Great Duck was "we don't want those definitions. We want an equation consisting of elementary functions." This is what I was trying to respond to. If you had a formula comprised of elementary functions, you wouldn't need nested sums. You would have a straight forward sum as shown in the equations above. This is highly unlikely. You would have to find a simple combination of "elementary" terms that would be able to truncate exactly any decimal expansion, rational, irrational, transcendental...ect. I'm not saying its impossible, just highly unlikely. May 13, 2016 at 23:29
• I think @mjqxxxx 's answer noting that $\lfloor x\rfloor = x - \frac{1}{2}+\frac{1}{\pi}\text{arctan}(\text{cot}(\pi x))$ is explicit and elementary enough, isn't it? May 14, 2016 at 2:19
• To you and me maybe but read last comment directly under post and you will see that it was asked to find a form without the trigonometric definition. A form of "elementary functions". May 14, 2016 at 8:37
• Yes, I understand. It sounded like you were looking for something too simple. In my personal opinion, you gave the bounty to the correct person, because that is as simple as it could be. It's a good answer. That question was important to me too. As you can see from most of my posts, I use the floor a lot. May 16, 2016 at 3:42

The standard way in analytic number theory to deal with sums involving the floor function is to either (a) estimate it trivially or (b) use Fourier analysis. In both cases, the idea is that $\lfloor x \rfloor = x - \{x\},$ where $\{x\}$ denotes the fractional part of $x$. Trivially, one has $0 \leq \{x\} < 1,$ and often this is sufficient for applications. Alternatively, one can use Fourier analysis, as this is essentially a sawtooth function, which has the Fourier expansion $\{x\} = \frac{1}{2} - \frac{1}{2\pi i} \sum_{\substack{m = -\infty \\ m \neq 0}}^{\infty} \frac{1}{m} e^{2\pi i mx}.$ In practice, one instead uses the partial sum $S_M \{x\} = \frac{1}{2} - \frac{1}{2\pi i} \sum_{\substack{m = -M \\ m \neq 0}}^{M} \frac{1}{m} e^{2\pi i mx},$ which satisfies $S_M \{x\} = \{x\} + O\left(\frac{1}{1 + \|x\| M}\right),$ where $\|x\|$ denotes the distance from $x$ to the nearest integer. In particular, $S_M \{x\}$ is uniformly bounded in $M$ for all $x$ and converges pointwise almost everywhere to $\{x\}$ as $M$ tends to infinity.