TITLE: Can we integrate over a summation index?
QUESTION [5 upvotes]: So I am reading this paper https://arxiv.org/pdf/math/0008177.pdf by Jeffrey Lagarias and in the proof of Lemma 3.1 he says
\begin{equation}
\int_{1}^{n} \frac{\lfloor t \rfloor}{t^2}dt = \sum_{1 \le r \le n} \int_{r}^{n} \frac{1}{t^2} dt.
\end{equation}
In the paper he uses $\infty$ as the upper integration bound, but I think it should be n, and r as the lower end, in order for the next steps in the paper to make sense. The left side is equal to $\int_{1}^{n} \sum_{1 \le r \le t} \frac{1}{t^2} dt$, but I cannot see how
\begin{equation}
\int_{1}^{n} \sum_{1 \le r \le t} \frac{1}{t^2} dt = \sum_{1 \le r \le n} \int_{r}^{n} \frac{1}{t^2} dt
\end{equation}
would hold. Yes it is a finite sum, but we are integrating over t, so we shouldn't be able to just move it out of the sum, right?
Then I thought it might help that $\lfloor t \rfloor$ is a step function, but we multiply it with $\frac{1}{t^2}$, so I can't see how I can use that either. I tried using integration by parts but I got a completely different result than whats in the paper. WolframAlpha tells me it exceeds computation time. What am I missing here?
I apologise if this is a stupid question, it's been a long time since my Analysis courses!

REPLY [5 votes]: You have
$$
\int_{1}^{n} \frac{\lfloor t \rfloor}{t^2}dt
= \sum_{k=1}^{n-1} k \int_{k}^{k+1} \frac{dt}{t^2}
$$
because $\lfloor t \rfloor = k$ on each interval $[k, k+1)$. Now write $k$ as a sum
$$
\ldots = \sum_{k=1}^{n-1} \sum_{r=1}^{k} \int_{k}^{k+1} \frac{dt}{t^2} \, .
$$
and change the order of summation:
$$
 \ldots = \sum_{r=1}^{n-1} \sum_{k=r}^{n-1} \int_{k}^{k+1} \frac{dt}{t^2}
= \sum_{r=1}^{n-1} \int_{r}^{n} \frac{dt}{t^2} \, .
$$
That is your right-hand side because the term with $r=n$ is zero.

It may be instructive to write the transformation explicitly for small values of $n$, e.g. $n=4$:
$$
\int_{1}^{4} \frac{\lfloor t \rfloor}{t^2}dt
= \int_1^2 \frac{dt}{t^2} + 2 \int_2^3 \frac{dt}{t^2} + 3 \int_3^4  \frac{dt}{t^2} \\
= \left( \int_1^2 \frac{dt}{t^2} + \int_2^3 \frac{dt}{t^2} + \int_3^4  \frac{dt}{t^2}\right)
+ \left( \int_2^3 \frac{dt}{t^2} + \int_3^4  \frac{dt}{t^2}\right)
+ \left(\int_3^4  \frac{dt}{t^2}\right) \\
= \int_1^4 \frac{dt}{t^2} + \int_2^4 \frac{dt}{t^2} + \int_3^4 \frac{dt}{t^2} \, .
 $$

Here is another way to look at it (perhaps more in line with your question  “Can we integrate over a summation index?”). A sum can be written as an integral with respect to the counting measure $\mu$ on the integers. Then your equation becomes an application of Fubini's theorem:
$$
\int_{1}^{n} \frac{\lfloor t \rfloor}{t^2}dt = \int_{1}^{n} \sum_{1 \le r \le t} \frac{1}{t^2} dt = \int_{1}^{n} \int_1^t \frac{1}{t^2} \, d\mu(r) \, dt \\
= \int_1^n \int_r^n \frac{1}{t^2}  \, dt\, d\mu(r)
= \sum_{n=1}^r \int_r^n \frac{1}{t^2}  \, dt \, .
$$