# How do I calculate an integral that contains the floor function?

I am trying to get my head around Abel's summation formula (here), but I am confused about how to deal with an integral involving the floor function.

Let $$a_1, a_2, a_3, ... , a_n, ...$$ be a sequence of real or complex numbers, and define a partial sum function $$A$$ by

$$A(t) = \sum_{1 \le n \le t} a_n$$

Further, fix real numbers $$x < y$$ and let $$\phi$$ be continuously differentiable function on $$[x, y]$$. Then

$$\sum_{1 \le n \le x} a_n \phi(n) = A(x) \phi(x) - \int_1^x A(u) \phi '(u) \, du$$

EXTRA INFO: My aim is find a formula of this form for a sum $$\sum_{1 \le n \le x} \phi(n)$$. So (back to original post):

Let the sequence $$a_n$$ be $$a_0 = 0, a_1 = 1, a_2 = 1, ...$$ . Then $$\sum_{1 \le n \le x} a_n \phi(n) = \sum_{1 \le n \le x} \phi(n)$$ and $$A(x) = \lfloor x \rfloor$$. So,

$$\sum_{1 \le n \le x} \phi(n) = \lfloor x \rfloor \phi(x) - \int_1^x \lfloor u \rfloor \phi '(u) \, du$$

But how do I calculate the integral $$\int_1^x \lfloor u \rfloor \phi '(u) \, du$$? Obviously $$\lfloor u \rfloor$$ is a constant for any given value of $$u$$, but I don't know how to tackle the indefinite integral - not even for something as simple as $$\phi(x) := x^2$$. (Note that this is just an example of $$\phi$$; I am after a more general solution.)

• One simple (but possibly inefficient) way to do it is to break up the range of integration into chunks (by linearity of integration) such that each chunk has $\lfloor u\rfloor$ as constant, and sum up the result - the results may even have a closed form summation formula Commented Sep 7, 2021 at 16:55
• You can write $\int_1^x \lfloor u \rfloor \phi '(u) \, du = \int_1^2\lfloor u \rfloor \phi '(u) \, du + \int_2^3\lfloor u \rfloor \phi '(u) \, du + \cdots + \int_{\lfloor x \rfloor}^x\lfloor u \rfloor \phi '(u) \, du$ or $\int_1^21 \cdot \phi '(u) \, du + \int_2^3 2 \cdot \phi '(u) \, du + \cdots + \int_{\lfloor x \rfloor}^x \lfloor x \rfloor \phi '(u) \, du.$ If you apply this to find $\sum_{k=0}^n k^2$ and expand everything out it amounts to re-writing the discrete sum in a different way - I don't think calculus is doing much work here, really. Commented Sep 7, 2021 at 17:16
• Thank you both for your input. However, I am not after a re-expression of the sum over $\phi$ in terms of other sums, but a solution of the form implied by the Abel summation formula - i.e., involving the integral. I have updated my OP to make this clearer. Commented Sep 8, 2021 at 14:44
• What kind of expression are you looking for? I do not think there is anything more simple than the integral itself for arbitrary $\phi$. Commented Sep 10, 2021 at 12:59
• Would the approximation by sawtooth function be an approach? Just to give a complete different idea?
– user736865
Commented Sep 12, 2021 at 17:17

There is a useful guide here which contains several applications of Abel's summation formula where $$a_n = 1$$ for $$n = 1,2,3,...$$, and the integral terms therefore contains a floor function. The feature they all have in common is their use of the identity

\begin{aligned} \int_1^x \lfloor u \rfloor \phi '(u) \, du &= \int_1^x \bigl(u - \{u\} \bigr) \phi '(u) \, du \\&= \int_1^x u \phi '(u) \, du - \int_1^x \{u\} \phi '(u) \, du \end{aligned}

where $$\{u\}$$ denotes the fractional part of $$u$$.

The function $$\int_1^x u \phi '(u) \, du$$ can often be defined and, since $$0 \le \{u\} < 1$$, in many cases we can set limits on $$\int_1^x \{u\} \phi '(u) \, du$$.

The suggestion made in several comments, and in more detail by @Sayan Dutta, that one can break up the integral containing the floor function into

$$\int_1^x \lfloor u \rfloor \phi '(u) \, du = \int_1^2 \lfloor u \rfloor \phi '(u) \, du + \int_2^3 \lfloor u \rfloor \phi '(u) \, du + ... + \int_{\lfloor x \rfloor}^x \lfloor u \rfloor \phi '(u) \, du$$

while perfectly correct, will generally lead straight back to the original sum.

The advantage of noting that $$\int_1^x \lfloor u \rfloor \phi '(u) \, du = \int_1^x u \phi '(u) \, du - \int_1^x \{u\} \phi '(u) \, du$$ is that the two integrals on the right hand side can be dealt with separately, providing two distinct terms, neither of which are not directly related to the original summation. It is this separation of terms which allows us to express the summation in a different and potentially useful form.

Example

Let $$H_x = \sum_{1 \le n \le x} \frac{1}{n}$$ be the harmonic number function. Set $$\phi(x) = \frac{1}{x}$$ and $$a_n = 1$$ for all $$n = 1,2,3,...$$.

Splitting the integral into unit steps produces

\begin{aligned} H_x &= \frac{\lfloor x \rfloor}{x} - \int_1^x \frac{\lfloor u \rfloor}{u^2} \, du \\&= \frac{\lfloor x \rfloor}{x} - \biggl( \int_1^2 \frac{\lfloor u \rfloor}{u^2} \, du + \int_2^3 \frac{\lfloor u \rfloor}{u^2} \, du + \int_{3}^4 \frac{\lfloor u \rfloor}{u^2} \, du + ... \biggr) \\&= \frac{\lfloor x \rfloor}{x} - \biggl( 1 \bigl( \frac{1}{2} - \frac{1}{1} \bigr) + 2 \bigl( \frac{1}{3} - \frac{1}{2} \bigr) + 3 \bigl( \frac{1}{4} - \frac{1}{3} \bigr) + ... \biggr) \\&= \frac{1}{1} + \frac{1}{2} + \frac{1}{3} + ... \\&= \sum_{1 \le n \le x} \frac{1}{n} \\&= H_x \end{aligned}

On the other hand, writing $$\lfloor x \rfloor = x - \{x\}$$ gives us

\begin{aligned} H_x &= \frac{\lfloor x \rfloor}{x} + \int_1^x \frac{\lfloor u \rfloor}{u^2} \, du \\&= \frac{x - \{x\}}{x} + \int_1^x \frac{u - \{u\}}{u^2} \, du \\&= 1 - \frac{\{x\}}{x} + \int_1^x \frac{1}{u} \, du - \int_1^x \frac{\{u\}}{u^2} \, du \\&= 1 - \frac{\{x\}}{x} + \log x - \int_1^x \frac{\{u\}}{u^2} \, du \\&= 1 - \frac{\{x\}}{x} + \log x - \biggl( \int_1^\infty \frac{\{u\}}{u^2} \, du - \int_x^\infty \frac{\{u\}}{u^2} \, du \biggr) \end{aligned}

Since $$\{x\} = O(1)$$ we can write $$\frac{\{x\}}{x} = \frac{O(1)}{x} = O \bigl(\frac{1}{x} \bigr)$$ and (after checking for issues of convergence)

\begin{aligned} \int_x^\infty \frac{\{u\}}{u^2} \, du &= \int_x^\infty \frac{O(1)}{u^2} \, du \\&= O(1)\int_x^\infty \frac{1}{u^2} \, du \\&= O(1) \frac{1}{x} \\&= O \bigl(\frac{1}{x} \bigr) \end{aligned}

So, now we have

$$H_x = \log x + 1 - \int_1^\infty \frac{\{u\}}{u^2} \, du + O \bigl(\frac{1}{x} \bigr)$$

Here, $$1 - \int_1^\infty \frac{\{u\}}{u^2} \, du$$ is the Euler-Mascheroni constant $$\gamma = 0.5772156649...$$. Thus

$$H_x = \log x + \gamma + O \bigl(\frac{1}{x} \bigr)$$

Assuming $$x$$ is NOT an integer \begin{align*} &\int_1^x \lfloor u \rfloor \phi '(u) \, du \\ = &\int_1^2 \lfloor u \rfloor \phi '(u) \, du + \int_2^3 \lfloor u \rfloor \phi '(u) \, du + \dots \int_{\lfloor x \rfloor-1}^{\lfloor x \rfloor} \lfloor u \rfloor \phi '(u) \, du +\int_{\lfloor x \rfloor}^x \lfloor u \rfloor \phi '(u) \, du\\ =&1\cdot \int_1^2 \phi '(u) \, du + 2\cdot \int_2^3 \phi '(u) \, du +\dots (\lfloor x \rfloor-1)\int_{\lfloor x \rfloor-1}^{\lfloor x \rfloor} \phi '(u) \, du +\lfloor x \rfloor\cdot\int_{\lfloor x \rfloor}^x \phi '(u) \, du\\ =&(\phi(2)-\phi(1))+2(\phi(3)-\phi(2))+\dots +(\lfloor x \rfloor-1)(\phi(\lfloor x \rfloor)-\phi(\lfloor x \rfloor-1))+\lfloor x \rfloor (\phi(x)-\phi(\lfloor x \rfloor))\\ =&-\phi(1)+(\phi(2)-2\cdot \phi(2))+(2\cdot \phi(3)-3\cdot \phi(3))+\dots +(\lfloor x \rfloor\phi(\lfloor x \rfloor)-(\lfloor x \rfloor-1)\phi(\lfloor x \rfloor))+\lfloor x \rfloor\phi(x)\\ =&-\phi(1)-\phi(2)-\phi(3)-\dots -\phi(\lfloor x \rfloor)+\lfloor x \rfloor\phi(x) \end{align*}

The first equality is due to linearity of integral, and the second one is due to Fundamental Theorem of Calculus.

If $$x$$ is an integer, the last term won't be counted.

Hope that helps.

• Hi @Sayan, plugging this into the summation formula gives \begin{aligned} \sum_{1 \le n \le x} \phi(n) &= \lfloor x \rfloor \phi(x) - \int_1^x \lfloor u \rfloor \phi '(u) \, du \\&= \lfloor x \rfloor \phi(x) - \biggl(-\phi(1)-\phi(2)-\phi(3)-\dots -\phi(\lfloor x \rfloor)+\lfloor x \rfloor\phi(x) \biggr) \\&= \lfloor x \rfloor \phi(x) + \biggl(\phi(1)+\phi(2)+\phi(3)+\dots +\phi(\lfloor x \rfloor)-\lfloor x \rfloor\phi(x) \biggr) \\&= \phi(1)+\phi(2)+\phi(3)+\dots +\phi(\lfloor x \rfloor) \\&= \sum_{1 \le n \le x} \phi(n) \end{aligned} True... but not a new expression. Commented Sep 10, 2021 at 11:41
• @RichardBurke-Ward wait a moment. At first I thought you only wanted to calculate that integral (my fault of course). Now, that I read the question properly, I have some questions regarding your question. In the actual formula that you have written, I think there should be a $-A(x)\phi(x)$ (in your case $-A(1)\phi(1)$) term- is there any reason to assume that to be $0$? Also, if I understand it properly, what you want is a general formula for $\sum \phi(n)$ in terms of $\phi$. If that's right, I don't see any reason to even think it's possible to find such an expression... Commented Sep 10, 2021 at 13:19
• @RichardBurke-Ward ... What this summation formula does is it converts a discreet sum into an integral (continuous sum). I don't see any reason to believe that it's possible to use this formula to find any general sum you want. Just scroll down a bit in the link you have given, and look at their treatment of the harmonic series. When you solve the integral on the RHS, what you get is the LHS back. Because there's really no hope to find an explicit formula for it. I hope I could make myself clear. Commented Sep 10, 2021 at 13:24
• @RichardBurke-Ward if you feel like I couldn't get your question properly, please feel free to say that. Commented Sep 10, 2021 at 13:31
• Hi @Sayan Dutta, thanks for the feedback. Regarding the examples (such as harmonic series) on the page I linked to, you say "When you solve the integral on the RHS, what you get is the LHS back." This is true - provided you use the technique you outlined in order to resolve the integral. I was looking for a technique which would resolve the integral more productively. What is the point of the web page (or the Abel summation method!) if all it says is $\sum_{1 \le n \le x} \phi(n) = \sum_{1 \le n \le x} \phi(n)$? In fact, why have a whole section on the case $a_n = 1$? Commented Sep 10, 2021 at 16:14