<s>[INST] How to prove that $\sum_{m\leqslant x}\sum_{n\leqslant x}\Big\{\frac{x}{m+n}\Big\}=\Big(2\log2-\frac{\pi^2}{12}\Big)x^2+O(x\log x)$? Prove that $$\sum_{m\leqslant x}\sum_{n\leqslant x}\Big\{\frac{x}{m+n}\Big\}=\Big(2\log2-\frac{\pi^2}{12}\Big)x^2+O(x\log x),$$
where $\{x\}$ is the fractional part of the real number $x$.
I know
$$\sum_{n\leqslant x} \Big\{\frac{x}{n} \Big\}=(1-\gamma)x+O\big(x^{1/2}\big),$$
where $\gamma$ is Euler's constant. But I don't know whether it is useful. Can you help me?
 [/INST] Write $\{x\} = x - \lfloor x\rfloor$,s so that
\[\sum_{m \leq x} \sum_{n \leq x} \left\{ \frac{x}{m + n}\right\} = \sum_{m \leq x} \sum_{n \leq x} \frac{x}{m + n} - \sum_{m \leq x} \sum_{n \leq x} \left\lfloor \frac{x}{m + n}\right\rfloor.\]
Then note that
\[\sum_{m \leq x} \sum_{n \leq x} \left\lfloor \frac{x}{m + n}\right\rfloor = \sum_{m \leq x} \sum_{n \leq x} \sum_{\ell \leq \frac{x}{m + n}} 1 = \sum_{\ell \leq \frac{x}{2}} \sum_{n \leq \frac{x}{\ell} - 1} \sum_{m \leq \frac{x}{\ell} - n} 1.\]
The sum over $m$ is $\lfloor x/\ell\rfloor - n$. The ensuing sum over $n$ is
\[\left\lfloor \frac{x}{\ell}\right\rfloor \left(\left\lfloor \frac{x}{\ell}\right\rfloor - 1\right) - \sum_{n \leq \frac{x}{\ell} - 1} n.\]
Via partial summation,
\[\sum_{n \leq \frac{x}{\ell} - 1} n = \left(\frac{x}{\ell} - 1\right) \left(\left\lfloor \frac{x}{\ell} \right\rfloor - 1\right) - \int_{1}^{\frac{x}{\ell} - 1} \lfloor t\rfloor \, dt,\]
and this integral is equal to $\frac{1}{2} \left(\frac{x}{\ell} - 1\right)^2 + O(\frac{x}{\ell})$. So the sum over $n$ and $m$ simplifies to
\[\frac{x^2}{2 \ell^2} + O\left(\frac{x}{\ell}\right).\]
The ensuing sum over $\ell$ is
\[\frac{x^2}{2} \sum_{\ell = 1}^{\infty} \frac{1}{\ell^2} - \frac{x^2}{2} \sum_{\ell > \frac{x}{2}} \frac{1}{\ell^2} + O(x \log x).\]
The first sum over $\ell$ is $\zeta(2) = \pi^2/6$. The second is $O(1/x)$. So this simplifies to
\[\frac{\pi^2 x^2}{12} + O(x \log x).\]
Now we deal with
\[\sum_{m \leq x} \sum_{n \leq x} \frac{x}{m + n} = x \sum_{m \leq x} \sum_{n \leq x} \frac{1}{m + n}.\]
We deal with the sum over $n$ via partial summation: it is equal to
\[\frac{\lfloor x\rfloor}{m + x} + \int_{1}^{x} \frac{\lfloor t \rfloor}{(m + t)^2} \, dt = \log \frac{m + x}{m + 1} + O\left(\frac{1}{m}\right),\]
where we have used the fact that $\lfloor x \rfloor = x - \{x\} = x + O(1)$, the fact that the antiderivative of $t/(m + t)^2$ is $m/(m + t) + \log(m + t)$, and the fact that the antiderivative of $1/(m + t)^2$ is $-1/(m + t)$.
So it remains to evaluate
\[\sum_{m \leq x} \log \frac{m + x}{m + 1} = \lfloor x\rfloor \log \frac{2x}{x + 1} + (x + 1) \int_{1}^{x} \frac{\lfloor t\rfloor}{(t + x)(t + 1)} \, dt.\]
The antiderivative of $\frac{t}{(t + x)(t + 1)}$ is $\frac{x}{x - 1} \log \frac{t + x}{t + 1}$, and so after some simplification, we arrive at $(2\log 2) x + O(\log x)$.
</s>