TITLE: Can the difference between these integrals and certain related sums be expressed in a simpler way?
QUESTION [5 upvotes]: Suppose I have either of the following expressions:
$$\newcommand{\rd}{\mathrm{d}}
\int\nolimits_1^n\int\nolimits_1^\frac{n}{x} \,\rd y\, \rd x - \sum_{x=2}^n\sum_{y=2}^\frac{n}{x}1
$$
$$
\int\nolimits_1^n\int\nolimits_1^\frac{n}{x} \log y \,\rd y\, \rd x - \sum_{x=2}^n\sum_{y=2}^\frac{n}{x}\log y
$$
Are there any simpler forms I could convert either of these into?  Or any other ways of expressing these that might yield insight or let me work with them in other interesting ways?
I already know there are several different ways of rewriting just the integrals on the left in isolation ($ n \log n - n + 1 $ at the simplest for the first one, for example), but I'm really looking for expressions that capture the difference between the continuous and the discrete here, kind of the way Euler-Maclaurin summation does.

REPLY [5 votes]: The double sum $S_n$ in your first expression is
$$
S_n=\sum\limits_{i=2}^n\sum\limits_k\left[2\leqslant k\leqslant\left\lfloor n/i\right\rfloor\right]=\sum\limits_{i=2}^n\int\left[1\leqslant y\leqslant\lfloor n/i\rfloor\right]\mathrm dy,
$$
hence
$$
S_n=\int_1^n\int_1^{u_n(x)}\mathrm dy\mathrm dx,\qquad u_n(x)=\left\lfloor n/\lceil x\rceil\right\rfloor.
$$
The difference between the integral $I_n$ and the sum $S_n$ is
$$
I_n-S_n=\int_1^n\int_{u_n(x)}^{n/x}\mathrm dy\mathrm dx=\int_1^n((n/x)-u_n(x))\mathrm dx.
$$
Since $u_n(x)\leqslant n/x$ for every $x$ in $(1,n)$, a consequence of this formula is that $I_n-S_n\geqslant0$. Another consequence is that $I_n-S_n=nJ+o(n)$ when $n\to\infty$, with
$$
J=\int_0^1((1/x)-\lfloor 1/x\rfloor )\mathrm dx=\int_1^{+\infty}(x-\lfloor x\rfloor )\frac{\mathrm dx}{x^2}.
$$
As noted by @Andrew, writing $J$ as a sum of integrals from $n$ to $n+1$ and then as a series gives
$$
J=\lim\limits_{n\to\infty}\left(\log(n)-\sum\limits_{k=2}^n\frac1k\right)=1-\gamma,
$$
where $\gamma$ is Euler's constant hence $\gamma=0.577\ldots$ and $J=0.423\ldots$