The Abel’s summation by parts formula is one of the most important and ubiquitous results in analytic number theory which is frequently employed to estimate the partial sums of an arithmetic functions weighted by some smooth function.
Theorem. (Abel’s summation by parts formula) Let $a : \mathbb{N} \to \mathbb{C}$ be an arithmetic function, let $0 < x < y$ be real numbers and let $f : [x, y] \to \mathbb{C}$ be a continuously differentiable function. Then we have
\[
\sum_{x < n \leq y} a(n)f(n) = A(y)f(y) -A(x)f(x) -\int_{x}^{y} A(u) f'(u) \, du,
\] where $A(u) = \sum_{n \leq u} a(n)$.
Proof. Let $m = \lfloor x \rfloor$ and $M = \lfloor y \rfloor$. We can rewrite the weighted sum as
\[
\sum_{x < n \leq y} a(n) f(n) = \sum_{n = m + 1}^{M} a(n) f(n).
\] By definition $a(n) = A(n) -A(n-1)$ so we can replace $a(n)$ to get
\[
\begin{align}
\sum_{n = m + 1}^{M} a(n) f(n) &= \sum_{n = m + 1}^{M} (A(n) -A(n-1)) f(n) \\
&= \sum_{n = m + 1}^{M} A(n) f(n) -\sum_{n = m}^{M -1} A(n)f(n+1) \\
&= A(M)f(M) -A(m) f(m + 1) -\sum_{n = m + 1}^{M -1} A(n)(f(n+1) -f(n)) \label{sum by parts 1} \tag{1}
\end{align} \] Since $f(n+1) -f(n) = \int_{n}^{n+1}f'(u) \, du$ and $A(u) = A(n)$ for all $u \in [n, n+1)$, we get
\[\begin{align}
\sum_{m + 1}^{M -1} A(n)(f(n+1) -f(n)) &= \sum_{m+1}^{M-1} A(n) \int_{n}^{n+1} f'(u) \, du \\
&= \sum_{m+1}^{M-1} \int_{n}^{n+1} A(u) f'(u) \, du \\
&= \int_{m + 1}^{M} A(u) f'(u) \, du. \tag{2}
\end{align} \] Substituting (2) into (1), we get
\[
\sum_{n = m + 1}^{M} a(n)f(n) = A(M) f(M) -A(m)f(m + 1) -\int_{m + 1}^{M} A(u) f'(u) \, du. \tag{3}
\] Using Fundamental Theorem of Calculus and observing that $A(u) = A(x)$ for $u \in [x, m +1)$, we get
\[
\begin{align}
\int_{x}^{m + 1} A(u)f'(u) \, du &= A(x)f(m + 1) -A(x)f(x) \\
&= A(m)f(m + 1) -A(x)f(x). \tag{4}
\end{align} \] Doing a similar calculation for $\int_{M}^{y}A(u)f'(u) \, du$ yields
\[
\int_{M}^{y} A(u)f'(u) \, du = A(y)f(y) -A(M)f(M). \tag{5}
\] Using (4) and (5), one can easily turn (3) into the required form.
Corollary. Let $a : \mathbb{N} \to \mathbb{C}$ be an arithmetic function and let $f : [1, x] \to \mathbb{C}$ be a continuously differentiable function where $x \geq 1$. Then we have
\[
\sum_{n \leq x} a(n)f(n) = A(x)f(x) -\int_{1}^{x} A(u) f'(u) \, du.\]
We now estimate harmonic sums.
Theorem. If $x \geq 1$, then we have
\[
\sum_{n \leq x} \frac{1}{n} = \log x + \gamma + O\left(\frac{1}{x}\right), \tag{6}
\]where $\gamma$ is the Euler-Mascheroni constant.
Proof. Taking $a(n) = 1$ and $f(x) = 1/x$ in the summation by parts formula, we get
\[
\sum_{n \leq x} \frac{1}{n} = \frac{\lfloor x \rfloor}{x} + \int_{1}^{x} \frac{\lfloor u \rfloor}{u^2} \, du.
\] Substituting $\lfloor x \rfloor = x -\{x\}$ in, we get
\[
\begin{align} \sum_{n \leq x} \frac{1}{n} &= 1 -\frac{\{x\}}{x} + \int_{1}^{x} \frac{du}{u}-\int_{1}^{x} \frac{\{u\}}{u^2} \, du \\
&= 1 + O\left( \frac{1}{x} \right) + \log x -\int_{1}^{x} \frac{\{u\}}{u^2} \, du \\
&= 1 + O\left( \frac{1}{x} \right) + \log x -\int_{1}^{\infty} \frac{\{u\}}{u^2} \, du + \int_{x}^{\infty} \frac{\{u\}}{u^2} \, du. \end{align}\]
Taking $C = 1 -\int_{1}^{\infty} \{u\}u^{-2} \, du$, we obtain
\[
\sum_{n \leq x} \frac{1}{n} = \log x + C + O\left( \frac{1}{x} \right) + \int_{x}^{\infty} \frac{\{u\}}{u^2} \, du.\] We can bound the improper integral as
\[
\int_{x}^{\infty} \frac{\{u\}}{u^2} \, du \leq \int_{x}^{\infty} \frac{du}{u^2} = \frac{1}{x}
\] and so
\[
\int_{x}^{\infty} \frac{\{u\}}{u^2} \, du = O\left( \frac{1}{x} \right).
\] It thus follows that
\[
\sum_{n \leq x} \frac{1}{n} = \log x + C + O\left( \frac{1}{x} \right).
\] It can be easily seen by taking limit as $x$ approaches $\infty$ that $C = \gamma$.
Note that in the above proof we obtained the following integral expression for $\gamma$
\[
\gamma = 1 -\int_{1}^{\infty} \frac{\{u\}}{u^2} \, du.
\]
Theorem. If $x \geq 1$, then for any $s \in \mathbb{C}$ with $s \neq 1$ and $\sigma = \text{Re}(s) > 0$ we have
\[
\sum_{n \leq x} \frac{1}{n^{s}} = \frac{x^{1-s}}{1-s} + \frac{s}{s-1} -s \int_{1}^{\infty} \frac{{u}}{u^{s + 1}} \, du + O(x^{-\sigma}),
\] where the implicit constant depends on $s$.
Proof. We apply the Abel’s summation by parts formula with $a(n) = 1$ and $f(x) = x^{-s}$. For $x \geq 1$ we then get
\[
\sum_{n \leq x} \frac{1}{n^s} = \frac{\lfloor x \rfloor}{x^{s}} + s \int_{1}^{x} \frac{\lfloor u \rfloor}{u^{s+1}} \, du
\] Substituting $\lfloor x \rfloor = x -\{x\}$, we obtain
\[ \begin{align}
\sum_{n \leq x} \frac{1}{n^{s}} &= x^{1-s} -\frac{{x}}{x^{s}} + s\int_{1}^{x} \frac{du}{u^{s}} -s \int_{1}^{x} \frac{{u}}{u^{s+1}} \, du \\
&= x^{1-s} + s \left( \frac{x^{1-s}}{1-s} -\frac{1}{1-s} \right) -s \int_{1}^{x} \frac{{u}}{u^{s+1}} \, du + O(x^{-\sigma}) \\
&= \frac{x^{1-s}}{1-s} + \frac{s}{s -1} -s\int_{1}^{\infty} \frac{{u}}{u^{s+1}} \, du + s \int_{x}^{\infty} \frac{{u}}{u^{s+1}} \, du + O(x^{-\sigma}).
\end{align} \] Finally note that
\[
\left|\int_{x}^{\infty} \frac{\{u\}}{u^{s + 1}} \, du \right| \leq \int_{x}^{\infty} \frac{du}{u^{\sigma+1}} = \frac{x^{-\sigma}}{\sigma}. \]
This leads to the desired estimate.
As a corollary we obtain that if $x \geq 1$ and $\sigma > 1$, then we have
\[
\sum_{n > x} \frac{1}{n^s} = O(x^{1-\sigma}),
\] where the implicit constant depends on $s$.
Theorem. (estimate of power sums) If $x \geq 1$, then for any $s \in \mathbb{C}$ with $\sigma > 0$ we have
\[ \sum_{n \leq x} n^s = \frac{x^{1 + s}}{1 + s} + O(x^{\sigma}),
\] where the implicit constant depends on $s$.
Proof. Applying the Abel summation by parts formula with $a(n) = 1$ and $f(x) = x^s$, we get
\[
\sum_{n \leq x} n^s = \lfloor x \rfloor x^s -s \int_{1}^{x} \lfloor u \rfloor u^{s -1} \, du.
\] Substituting $\lfloor x \rfloor = x -\{x\}$, we obtain
\[
\begin{align}
\sum_{n \leq x} n^s &= x^{s + 1} -\{x\}x^{s} -s \int_{1}^{x} u^s \, du + s \int_{1}^{x} \{u\} u^{s -1} \, du \\
&= x^{s + 1} + O(x^{\sigma}) -s \left( \frac{x^{1 + s}}{1 + s} -\frac{1}{1 + s} \right) + s \int_{1}^{x} \{u\} u^{s -1} \, du. \tag{7}
\end{align} \] Now note that
\[
\left| s\int_{1}^{x} \{u\} u^{s -1} \, du \right| \leq |s| \int_{1}^{x} u^{\sigma -1} \, du = \frac{|s|}{\sigma}( x^{\sigma} -1) = O_{s}(x^{\sigma}).
\] Hence (7) simplifies to
\[
\sum_{n \leq x} n^s = \frac{x^{1 + s}}{1 + s} + \frac{s}{1 + s} + O(x^{\sigma})
\] Observe that the error term $O(x^\sigma)$ absorbs the constant $s/(1 + s)$ and thus we get the desired result.