Evaluate: $\lim_{n\to\infty}\left({2\sqrt n}-\sum_{k=1}^n\frac1{\sqrt k}\right)$

How to find $\lim\limits_{n\to\infty}\left({2\sqrt n}-\sum\limits_{k=1}^n\frac1{\sqrt k}\right)$ ?

And generally does the limit of the integral of $f(x)$ minus the sum of $f(x)$ exist? How to prove that and find the limit?


Use $\sqrt{n} = \sum_{k=1}^n \left( \sqrt{k} - \sqrt{k-1} \right)$, then $$ \begin{eqnarray} 2 \sqrt{n} - \sum_{k=1}^n \frac{1}{\sqrt{k}} &=& \sum_{k=1}^n \left( 2 \sqrt{k} - 2 \sqrt{k-1} - \frac{1}{\sqrt{k}} \right) = \sum_{k=1}^n \frac{1}{\sqrt{k}} \left( \sqrt{k}-\sqrt{k-1} \right)^2\\ &=& \sum_{k=1}^n \frac{1}{\sqrt{k}} \left( \frac{(\sqrt{k}-\sqrt{k-1})(\sqrt{k}+\sqrt{k-1})}{(\sqrt{k}+\sqrt{k-1})} \right)^2 \\ &=& \sum_{k=1}^n \frac{1}{\sqrt{k} \left(\sqrt{k}+\sqrt{k-1}\right)^2} \end{eqnarray} $$

This shows the limit does exist and $\lim_{n \to \infty} \left( 2 \sqrt{n} - \sum_{k=1}^n \frac{1}{\sqrt{k}} \right) = \sum_{k=1}^\infty \frac{1}{\sqrt{k} \left(\sqrt{k}+\sqrt{k-1}\right)^2}$.

The value of this sums equals $-\zeta\left(\frac{1}{2} \right) \approx 1.4603545$. This value is found by other means, though: $$ 2 \sqrt{n} - \sum_{k=1}^n \frac{1}{\sqrt{k}} = 2 \sqrt{n} - \left( \zeta\left(\frac{1}{2}\right) - \zeta\left(\frac{1}{2}, n+1\right)\right) \sim -\zeta\left(\frac{1}{2}\right) - \frac{1}{2\sqrt{n}} + o\left( \frac{1}{n} \right) $$


Here is an answer that uses harmonic sums to obtain a complete asymptotic expansion the same way as was done at this MSE link.

Start with the telescoping sum $$S(x) = \sum_{k\ge 1} \left(\frac{1}{\sqrt k}-\frac{1}{\sqrt{x+k}}\right)$$ which has the property that $$S(n) = \sum_{q\ge 1}^n \frac{1}{\sqrt{q}}$$ so that $S(n)$ is the value we are looking for.

Re-write the sum as follows: $$S(x) = \sum_{k\ge 1} \frac{1}{\sqrt k} \left(1-\frac{1}{\sqrt{x/k+1}}\right).$$

The sum term is harmonic and may be evaluated by inverting its Mellin transform.

Recall the harmonic sum identity $$\mathfrak{M}\left(\sum_{k\ge 1} \lambda_k g(\mu_k x);s\right) = \left(\sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} \right) g^*(s)$$ where $g^*(s)$ is the Mellin transform of $g(x).$

In the present case we have $$\lambda_k = \frac{1}{\sqrt{k}}, \quad \mu_k = \frac{1}{k} \quad \text{and} \quad g(x) = 1 - \frac{1}{\sqrt{1+x}}.$$

It follows that $$\sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} = \sum_{k\ge 1} \frac{1}{\sqrt{k}} k^s = \zeta(1/2-s)$$ which has fundamental strip $1/2-s > 1$ or $s < -1/2.$

We need the Mellin transform $g^*(s)$ of $g(x)$ which is $$\int_0^\infty \left(1 - \frac{1}{\sqrt{1+x}}\right) x^{s-1} dx$$ which is immediately seen to be a beta function integral with value $$g^*(s) = - \frac{1}{\sqrt\pi} \Gamma(s)\Gamma(1/2-s)$$ and fundamental strip $\langle -1, 0 \rangle,$ which is perfect because it includes the abscissa of convergence of the zeta function term and unlike in the calculation that we linked to in the introduction no shift of $g^*(s)$ is required.

It follows that the Mellin transform $Q(s)$ of the harmonic sum $S(x)$ is given by $$Q(s) = - \frac{1}{\sqrt\pi} \Gamma(s)\Gamma(1/2-s) \zeta(1/2-s).$$ The Mellin inversion integral here is $$\frac{1}{2\pi i} \int_{-3/4-i\infty}^{-3/4+i\infty} Q(s)/x^s ds$$ which we evaluate by shifting it to the right for an expansion at infinity.

First treat the pole from the zeta function term at $s=-1/2$, which has $$\mathrm{Res}(Q(s)/x^s; s=-1/2) = -\frac{1}{\sqrt\pi} \Gamma(-1/2)\Gamma(1)\times -1 \times \sqrt{x} = -2\sqrt{x}.$$ For the pole at $s=0$ we get $$\mathrm{Res}(Q(s)/x^s; s=0) = -\frac{1}{\sqrt\pi} \Gamma(1/2) \zeta(1/2) = -\zeta(1/2).$$ We now do the pole at $s=1/2$ (this is due to the sign discrepancy on $B_1$ the Bernoulli number as will become clear later). We get $$\mathrm{Res}(Q(s)/x^s; s=1/2) = - \frac{1}{\sqrt\pi} \Gamma(1/2) \times -1 \times \zeta(0) \times \frac{1}{\sqrt x} = -\frac{1}{2\sqrt{x}}.$$

The remaining poles are at $s=1/2+q$ with $q\ge 1$ and contribute $$\mathrm{Res}(Q(s)/x^s; s=1/2+q) = - \frac{1}{\sqrt\pi} \Gamma(1/2+q) \times \frac{(-1)^{q+1}}{q!} \times \zeta(-q)\times \frac{1}{x^{1/2+q}} \\ = \frac{1}{\sqrt\pi} \frac{2^{1-2q} \sqrt{\pi} \Gamma(2q)}{\Gamma(q)} \times \frac{(-1)^{q+1}}{q!} \times \frac{B_{q+1}}{q+1}\times \frac{1}{x^{1/2+q}} \\= -2 \times \left(-\frac{1}{4}\right)^q \times {2q-1\choose q} \frac{B_{q+1}}{q+1} \times \frac{1}{x^{1/2+q}}.$$

Setting $x=n$ and observing that the shift to the right produces a minus sign we obtain the following asymptotic expansion: $$S(n) = \sum_{k=1}^n \frac{1}{\sqrt{k}} \sim 2\sqrt{n} + \zeta(1/2) + \frac{1}{2\sqrt{n}} + 2\times \sum_{q\ge 1} \left(-\frac{1}{4}\right)^q \times {2q-1\choose q} \frac{B_{q+1}}{q+1} \times \frac{1}{n^{1/2+q}}.$$ The zeros from the Bernoulli numbers correctly represent the cancelation of those poles from the gamma function term by the trivial zeros of the zeta function.

Actually computing the Bernoulli number terms we get the expansion $$2\sqrt{n} + \zeta(1/2) + \frac{1}{2\sqrt{n}} -1/24\,{n}^{-3/2}+{\frac {1}{384}}\,{n}^{-7/2}-{\frac {1}{1024}}\,{n}^ {-11/2}+{\frac {143}{163840}}\,{n}^{-15/2}\\-{\frac {1105}{786432}}\,{n} ^{-19/2}+{\frac {223193}{62914560}}\,{n}^{-23/2}-{\frac {1300075}{ 100663296}}\,{n}^{-{\frac {27}{2}}}+{\frac {137514723}{2147483648}}\,{ n}^{-{\frac {31}{2}}} + \cdots$$

Answering the original question we thus obtain that $$\lim_{n\to\infty} \left(2\sqrt{n} - \sum_{k=1}^n\frac{1}{\sqrt{k}}\right) = -\zeta(1/2).$$

Note that we could have gotten this expansion from Euler-Maclaurin, except from the constant. Plain Mellin-Perron would give $$\sum_{k=1}^n\frac{1}{\sqrt{k}} = \frac{1}{2\sqrt{n}} + \frac{1}{2\pi i} \int_{3/4-i\infty}^{3/4+i\infty} \zeta(s+1/2) n^s\frac{ds}{s}$$ producing the approximation $$2\sqrt{n} + \zeta(1/2) + \frac{1}{2\sqrt{n}}$$ and leaving us with a remainder integral that we must prove a bound on. So it looks like harmonic Mellin summation is the best approach here.


If (as in your case) the function $f$ decreases monotonically to zero, then the limit of (integral minus sum) exists and is at most $f(1)$. You can see that by drawing a picture: draw the graph of $f$, and little rectangles jutting up over it, so the area under the graph is the integral, and the area of the rectangles gives the sum. If you push all the little excesses (the bits of rectangle above the curve) over to the left, they don't fill up the first rectangle.


A rather brute force approach, but by the Euler-Maclaurin formula,

$$2\sqrt n-\sum_{k=1}^n\frac1{\sqrt k}=-\zeta(1/2)-\frac1{2\sqrt n}+R_n$$

where

$$|R_n|\le\frac1{8n^{3/2}}$$

And so, as $n\to\infty$, we get

$$\lim_{n\to\infty}\left(2\sqrt n-\sum_{k=1}^n\frac1{\sqrt k}\right)=-\zeta(1/2)$$