Simplifying sum of floor functions

6.8k Views Asked by At

Consider $$S = \sum_{i=0}^{x-2}{\lfloor{a(x-i)}\rfloor}$$
where $x \in \mathbb{N}$, $x \geq 2$, and $a = \frac{p}{10}$, with $p \in \{1, 2, \ldots , 9\}$, is rational.

How can one go about finding a closed form of such summation, if it exists?

Attempt
First I consider the sum for first few values of $x$ expanded out: $$ \begin{array}{cc} x & S \\ \hline 2 & {\lfloor 2a \rfloor} \\ 3 & {\lfloor 3a \rfloor} + {\lfloor 2a \rfloor} \\ 4 & {\lfloor 4a \rfloor} + {\lfloor 3a \rfloor} + {\lfloor 2a \rfloor} \\ 5 & \ldots \\ \end{array} $$ So we can express $S$ as a recursive sum $S(x) = {\lfloor ax \rfloor} + S(x-1)$ with base case $S(2) = {\lfloor 2a \rfloor}$.
But then all I've done is just switched from one type of problem into another.

-- edit --
On a further thought, the constraint $x \geq 2$ isn't really relevant to the problem so we may consider removing it:
$$S = \sum_{i=0}^{x}{\lfloor{a(x-i)}\rfloor}$$
where $x \in \mathbb{N}_{0}$, and $a$ is as above.

3

There are 3 best solutions below

10
On BEST ANSWER

For convenience, I rewrite the sum equivalently as

$$S=\sum_{k=0}^n\lfloor ak\rfloor.$$

First assume $a=\dfrac pq$ to be rational and the fraction be irreducible. For instance, with $a=\dfrac 37$, the $7$ first terms are

$$0,0,0,1,1,2,2$$ and the same sequence repeats with an increment of $3$,

$$0,0,0,1,1,2,2,\ 3,3,3,4,4,5,5,\ 6,6,6,7,7,8,8\cdots$$

So a sum of $n$ terms will include $m:=\lfloor\dfrac n7\rfloor$ whole sequences, with sum $$(0+0+0+1+1+2+2)m+7\cdot3\frac{(m-1)m}2=6+7\cdot3\frac{(m-1)m}2,$$ and there remains a partial sequence of length $l:=n-7\lfloor\dfrac n7\rfloor$, with a sum equal to the sum of the $l$ first term of the base sequence plus $l\cdot3m$.

More generally,

$$S=\left(S_{p,q}+pq\frac{\left(\lfloor\frac nq\rfloor-1\right)}2\right)\lfloor\frac nq\rfloor+S_{p,q,n-q\lfloor\frac nq\rfloor}+p(n-q\lfloor\frac nq\rfloor)\lfloor\frac nq\rfloor,$$

where $S_{p,q,l}$ is the sum of the $l$ first terms of the base sequence, and $S_{p,q}=S_{p,q,q}$.

I have no idea if there are closed formulas for $S_{p,q,l}$ or $S_{p,q}$. They depend on the sequence of remainders of $pk$ divided by $q$, and approximately $S_{p,q,l}=\dfrac{l(l-1)p}{2q}$.

For irrational $a$, one can take a rational approximation of $a$ with a denominator larger than $n$, so that for all terms $\lfloor ak\rfloor=\lfloor\dfrac{pk}q\rfloor$. But this is not very helpful, as there will be no complete sequence.


Update:

In the base sequence, we are summing the integer parts of $\dfrac{kp}q$, which are the differences $\dfrac{kp-(kp\bmod q)}{q}$. So the total sum is that of all fractions minus the sum of the remainders over $q$. As all remainders from $0$ to $q-1$ appear exactly once, we have

$$S_{p,q}=\frac pq\frac{(q-1)q}2-\frac{(q-1)q}{2q}=\frac{(p-1)(q-1)}2.$$

When $n$ is a multiple of $q$,

$$S=\left(\frac{(p-1)(q-1)}2+p\frac{n-q}{2}\right)\frac nq.$$

0
On

I know this should be a comment but I don't have enough reputation for that.

I recommend you the book "Concrete Mathematics" by Knuth and Patashnik. It deals a lot with sums and integer functions like ceiling and floor. There is an example pretty close to your question from page 77 (Chapter 3.2 Floor/Ceiling Applications).

$$N(\alpha,n)=\sum_{k>0}[\lfloor k\alpha\rfloor \leq n]$$ $$=\sum_{k>0}[\lfloor k\alpha\rfloor < n+1]$$ $$=\sum_{k>0}[k\alpha < n+1]$$ $$=\sum_{k}[0<k < (n+1)/\alpha]$$ $$=\lceil(n+1)/\alpha\rceil-1$$

The brackets in the first summand are Iverson brackets, they evaluate to 1 if the content is true or 0 otherwise. $N(\alpha,n)$ are the number of elements in $Spectrum(\alpha)$ that are $\leq$ n

I don't know if it will help you or not, but hopefully it will point you in the right direction.

0
On

A similar sum can be evaluated using simple combinatorics or Pick´s theorem:

$$\sum_{i=1}^n\left\lfloor \frac{p}{n} i\right\rfloor = \frac{pn+p-n + gcd(p,n)}{2}$$