# Limit involving sum of floor functions

I'm trying to compute \begin{align} \lim_{n \to \infty} \frac{1}{n}\sum_{k = 1}^n \bigg( \bigg\lfloor \frac{2n}{k} \bigg\rfloor - 2 \bigg\lfloor \frac{n}{k} \bigg\rfloor\bigg) \end{align} Numericaly the limit does not appear to be 0 but around $0.386$. Using Hermite's Identity I reduced the sum to \begin{align} \sum_{k = 1}^n \bigg( \bigg\lfloor \frac{n}{k} + \frac{1}{2} \bigg\rfloor - \bigg\lfloor \frac{n}{k} \bigg\rfloor\bigg) \end{align} and noticed that the terms can either be 0 or 1. I know that $\lfloor x + \frac{1}{2} \rfloor = \lfloor x \rfloor$ when $\{ x\} < \frac{1}{2}$. I figured that I need to find a way to count the zero terms(or non zero terms and subtract them from n) using a function say $f(n)$, and then computing $\lim_{n \to \infty} \frac{f(n)}{n}$. This is where I get stuck since I can't easily find the fractional part of $\frac{n}{k}$. I've also tried to count numbers such that $(n \mod k) < \frac{k}{2}$ but to no avail. I also can't see any squeeze theorem solutions. Any help is appreciated. (This problem is homework, so I would prefer a hint as opposed to a full solution).

This is the Riemann sum limit for $$\int_0^1 (\lfloor 2/x \rfloor - 2 \lfloor 1/x \rfloor) \, dx = \int_1^\infty \frac{\lfloor 2x \rfloor - 2 \lfloor x \rfloor}{x^2} \, dx =\log(4) -1 \approx 0.386$$

To compute, note that

$$\int_1^\infty \frac{\lfloor 2x \rfloor - 2 \lfloor x \rfloor}{x^2} \, dx = \sum_{k=1}^\infty \left(\int_k^{k+1/2} \frac{2k - 2 k}{x^2} \, dx + \int_{k+1/2}^{k+1} \frac{2k+1 - 2k}{x^2} \, dx\right)$$

By defining the fractional part as $\{x\}=x-\lfloor x\rfloor$ we have $$\{ x \} = \frac{1}{2}-\sum_{m\geq 1}\frac{\sin(2\pi m x)}{m\pi} \tag{1}$$ and:

$$\left\lfloor\frac{2n}{k}\right\rfloor -2\left\lfloor\frac{n}{k}\right\rfloor = 2\left\{\frac{n}{k}\right\}-\left\{\frac{2n}{k}\right\}=\frac{1}{2}-2\sum_{m\geq 1}\frac{\sin(2\pi m \frac{n}{k})}{m\pi}+\sum_{m\geq 1}\frac{\sin(2\pi m \frac{2n}{k})}{m\pi}$$ or, in a more compact form: $$\left\lfloor\frac{2n}{k}\right\rfloor -2\left\lfloor\frac{n}{k}\right\rfloor = \frac{1}{2}-2\sum_{\substack{m\geq 1\\ m\text{ odd}}}\frac{\sin\left(2\pi m\frac{n}{k}\right)}{m\pi}\tag{2}$$ and by Riemann sums the wanted limit equals $$L=\lim_{n\to +\infty}\frac{1}{n}\sum_{k=1}^{n}\left(\left\lfloor\frac{2n}{k}\right\rfloor -2\left\lfloor\frac{n}{k}\right\rfloor\right)=\frac{1}{2}-2\sum_{\substack{m\geq 1\\ m \text{ odd}}}\frac{1}{m\pi}\int_{0}^{1}\sin\left(\frac{2m\pi}{z}\right)\,dz \tag{3}$$ or: $$L = \frac{1}{2}+4\sum_{j\geq 0}\text{Ci}((4j+2)\pi)=\frac{1}{2}-4\int_{0}^{+\infty}\sin(z)\sum_{j\geq 0}\frac{1}{(z+(4j+2)\pi)^2}\,dz \tag{4}$$ where $\text{Ci}$ stands for a cosine integral. By the Laplace transform we get: $$L = \frac{1}{2}-2\int_{0}^{+\infty}\frac{s}{(1+s^2)\sinh(2\pi s)}\,ds \approx \color{red}{0.38629436111989}\tag{5}$$ where $L=\color{red}{2\log 2-1}$ follows from the residue theorem.


Note that $\ds{0 < \int_{\Lambda}^{2\Lambda}{\braces{x} \over x^{2}}\,\dd x < \int_{\Lambda}^{2\Lambda}{\dd x \over x^{2}} = {1 \over 2\Lambda} \,\,\,\stackrel{\mrm{as}\ \Lambda\ \to\ \infty}{\to}\,\,\, \color{#f00}{\large 0}}$.