An integral problem: I am working on a proof in lecture notes, but there are two steps that I couldn't understand
The first one: $$\int_1^n \frac{n-\lfloor x \rfloor}{x} dx=\int_1^n \frac{n+\frac{1}{2}+(\{x\}-\frac{1}{2})-x }{x} dx$$
Edit: Knowing that $\{x\}=x-\lfloor x\rfloor\quad$ , I am done with this part.
The second:
$$\int_1^n \frac{\{x\}-\frac{1}{2}}{x} dx=\int_1^\infty \frac{\{x\}-\frac{1}{2}}{x}dx+o(1),$$ since $$\int_1^\infty \frac{\{x\}-\frac{1}{2}}{x}dx \qquad (*) $$can be written as an alternating sum which is convergent so that its tail will converge to $0$.
I couldn't understand how they get from one equation to another and also the last part that says $(*)$ can be written as an alternating sum which is convergent so that its tail will converge to $0$
Actually in the second part, I don't know what is the meaning/use of $\{x\}$
 A: That
\begin{equation*}
\int_1^n \frac{\{x\} - \frac{1}{2}}{x} \,dx = \int_1^\infty \frac{\{x\} - \frac{1}{2}}{x} \, dx + o(1)
\end{equation*}
will follow from
\begin{equation*}
\int_n^\infty \frac{\{x\} - \frac{1}{2}}{x} \, dx = o(1).
\end{equation*}
This is equivalent to
\begin{equation*}
\lim_{n \to \infty} \int_n^\infty \frac{\{x\} - \frac{1}{2}}{x} \, dx = 0
\end{equation*}
which will follow from the fact that
\begin{equation*}
\int_1^\infty \frac{\{x\} - \frac{1}{2}}{x} \, dx
\end{equation*}
is convergent.
The idea is that we should partition the integral into an alternating sum. Recall that an alternating sum $\sum_n (-1)^n a_n$ is convergent if and only if $a_n \to 0$ as $n \to \infty$. After some thinking one realises that the partition to use is $1, 1 + \frac{1}{2}, 2, 2 + \frac{1}{2}, \ldots$. Indeed, for a natural $k$,
\begin{equation*}
\int_k^{k + \frac{1}{2}} \frac{\{x\} - \frac{1}{2}}{x} \, dx
= \int_k^{k + \frac{1}{2}} \frac{x - k - \frac{1}{2}}{x} \, dx < 0
\end{equation*}
and
\begin{equation*}
\int_{k + \frac{1}{2}}^{k + 1} \frac{\{x\} - \frac{1}{2}}{x} \, dx
= \int_{k + \frac{1}{2}}^{k + 1} \frac{x - k - \frac{1}{2}}{x} \, dx > 0.
\end{equation*}
What is left is to see that the terms of the sum converges to 0. I am lazy and will only do the positive ones. Well,
\begin{align*}
\int_{k + \frac{1}{2}}^{k + 1} \frac{x - k - \frac{1}{2}}{x} \, dx
&= \int_{k + \frac{1}{2}}^{k + 1} 1 - (k + \frac{1}{2}) \frac{1}{x} \, dx \\
&= \frac{1}{2} - (k + \frac{1}{2}) (\log(k + 1) - \log(k + \frac{1}{2})
\end{align*}
which converges to 0 as $k \to \infty$. This feels a bit cumbersome but it involved alternative sums so it was probably what was intended. 
