# How to calculate sum of floor functions.

Let $$f(x)$$ is real valued function.

How to calulate or at least find lower and upper bound of sum: $$\sum_{1\le n \le x}\left\lfloor f(n) \right\rfloor$$? For example when $$f(n)=\frac{x}{n}$$

Here are my ideas:

1. Is it possible to rewrite the sum so that it will depend only from for example $$f(x)$$? Like in this case: Find a formula for $\sum\limits_{k=1}^n \lfloor \sqrt{k} \rfloor$
2. Because $$\left\lfloor y \right\rfloor=y-\{y\}$$ and $$\{y\}$$ can be expressed as a Fourier series so it is sufficent to evaluate the following: $$\sum_{1\le n \le x}\{ f(n) \}$$. It is (only) mentioned here : https://www.encyclopediaofmath.org/index.php/Trigonometric_sums,_method_of
3. Because $$g(y)=\left\lfloor f(y) \right\rfloor$$ is integrable so maybe schould i use a integral?

I hope that you have also some ideas.

As we have $$f(x)-1 < \lfloor f(x) \rfloor \le f(x)$$

We get the trivial bounds $$\sum_{i=0}^n f(x)-1 < \sum_{i=0}^n \lfloor f(x) \rfloor\le \sum_{i=0}^n f(x)$$

As for your first idea - the method is useful, but has its limits. For example, for the approach to work, your function needs to be monotone and its inverse has to be "easy" (if you can't write it down using standard calculus, chances are slim you can do the sum manipulation).

We can express any continuous function using, analogue to finite vector spaces, by using certain special countably infinite bases, as linear combinations of the elements of the base.

For example, a base for periodic functions $$f:\mathbb R\to \mathbb R$$ with periodicity $$T$$ would be: $$[sin(2\pi T\cdot 1x),cos(2\pi T\cdot 1x),sin(2\pi T\cdot 2x),cos(2\pi T\cdot 2x),...]$$

Using this base, we now fit e.g. $$f(x) = x$$ over the interval $$[0,1]$$ (and therefore with $$T = 1$$).
As our resulting function therefore is periodic, we now get $$\lfloor x\rfloor = x-f(x)$$

Unluckily, this approach has its problems as well. For one, looking for a closed expression of the infinite series is, whether you use a periodic base or a non-periodic base, extremely difficult - we have a good understanding of which coefficient sequences lead to closed forms for continuous functions, but not so much for non-continuous functions.
That we are looking for an alternative formulation only makes this even more difficult (as opposed to just deducing that the closed formula is equivalent to $$\lfloor f(x) \rfloor$$).

If you want to use this series as approximation, you should threat carefully as well. Generally, as you model a non-continuous function by a sum of continuous ones, any approximation will behave not-nice near integer values.

For example, the approximation $$x- \frac 1 2 + \frac 1 \pi \sum_{k=1}^p \frac{\sin(2\pi k x)}k$$ (which turns into $$\lfloor x \rfloor$$ at $$p\to \infty$$

has the problem that, while it generally models the function for growing $$p$$ better and better, if you look at $$x+0.05$$ for any $$x\in\mathbb N$$, it will become worse and worse for growing $$p$$.

• You clearly spent a lot of time typing this up, and the author of the question does not seem to be willing to respond to it, so instead you got one upvote from me :) Jun 20 '19 at 19:50

Since $$\left\lfloor f(n) \right\rfloor\leq f(n)$$ for all $$n$$ and $$\left\lfloor f(n) \right\rfloor\geq f(n)-1$$ for all $$n$$, the obvious upper and lower bounds are

$$\sum_{1\le n \le x} (f(n)-1)\leq \sum_{1\le n \le x}\left\lfloor f(n) \right\rfloor\leq \sum_{1\le n \le x}f(n)$$