Find an approximation to $\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor (j-1)$ I want to find an approximate (ideally asymptotic) function $f_1:\mathbb{R}\to\mathbb{R}$ in order to approximate a function $f_0:\mathbb{R}\to\mathbb{N}$ with $f_0$ defined by
$$\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor (j-1)$$
My attempts so far have not worked, and I'd really appreciate a workable solution.
I know the following is wrong, and contains several unjustified steps. What I am after is primarily a solution that works, but it would of course also be good to see where I went wrong.
My first attempt was to assume that for large $x$, $\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor (j-1)\approx\sum _{j=1}^x (\frac{x}{j} -1)(j-1)$, giving
$$\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor(j-1)\approx\sum _{j=1}^x (\frac{x}{j} -1) (j-1)$$$$=\frac{1}{2}(x^2+x-2 H_x)$$
where $H_n$ is the $n$th harmonic number. However, the following plot suggests (heuristically) that the ratio
$$\frac{\frac{1}{2}(x^2+x-2 H_x)}{\sum _{j=1}^x (\frac{x}{j} -1)(j-1)}$$
has an asymptote at a value slightly greater than $3$:

Presumably, I could therefore get a reasonable approximation by writing
$$\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor(j-1)\approx\frac{1}{6}(x^2+x-2 H_x)$$
but I would have no logical justification for the approximation.
For my second attempt, I reasoned that in any half-open interval $a=(b,b+1]$ with $b$ a positive integer, the 'average' value (if 'average' is the right term) of $\left\lfloor a\right\rfloor$ is $b$, whereas the average value of the real number $a$ is $\frac{2b+1}{2}$ - and therefore the average value of the ratio $\frac{a}{\left\lfloor a\right\rfloor}\approx\frac{2b+1}{2b}$. I then assumed that this could be extended from integer $b$ to real $a$, giving the rough equivalence $\frac{a}{\left\lfloor a\right\rfloor}\approx\frac{2a+1}{2a}$. (This is almost certainly wrong!)
I then substituted $a\to(\frac{x}{j}-1)$ and wrote $$\frac{\frac{x}{j}-1}{\left\lfloor \frac{x}{j}-1\right\rfloor}\approx\frac{2(\frac{x}{j}-1)+1}{2(\frac{x}{j}-1)}$$ $$\implies\left\lfloor \frac{x}{j} -1\right\rfloor\approx \frac{2}{2(\frac{x}{j}-1)+1}$$
But, heuristically, the ratio
$$\frac{\sum _{j=1}^x \frac{2}{2(\frac{x}{j}-1)+1}(j-1)}{\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor(j-1)}$$
appears to converge (more slowly than my first attempt) towards a value somewhat less than $5$:

So: two failed attempts...
How do I go about finding a valid approximation to $\sum _{j=1}^x \left\lfloor \frac{x}{j} -1\right\rfloor (j-1)$?
 A: I suppose that $f_0(x) = 0$ for $x < 1$. Otherwise it's not clear how the sum should be interpreted, but with reasonable interpretations the behaviour can be determined much like the behaviour for $x \geqslant 1$.
First we split the terms $\bigl\lfloor \frac{x}{j} - 1\bigr\rfloor (j-1) = \bigl\lfloor \frac{x}{j}\bigr\rfloor j - \bigl\lfloor\frac{x}{j}\bigr\rfloor - (j-1)$.
For the sum over the first parts of the split terms we obtain
\begin{align}
\sum_{j \leqslant x} \biggl\lfloor \frac{x}{j}\biggr\rfloor j
&= \sum_{j \leqslant x} j\sum_{k \leqslant x/j} 1 \\
&= \sum_{k\cdot j \leqslant x} j \\
&= \sum_{k \leqslant x} \sum_{j \leqslant x/k} j \\
&= \frac{1}{2} \sum_{k \leqslant x} \biggl\lfloor \frac{x}{k}\biggr\rfloor \Biggl(\biggl\lfloor \frac{x}{k}\biggr\rfloor + 1\Biggr) \\
&= \frac{1}{2} \sum_{k \leqslant x} \biggl(\frac{x^2}{k^2} + O\biggl(\frac{x}{k}\biggr)\biggr) \\
&= \frac{x^2}{2}\biggl(\frac{\pi^2}{6} + O\biggl(\frac{1}{x}\biggr)\biggr) + O(x\log x) \\
&= \frac{\pi^2}{12}x^2 + O(x\log x)\,.
\end{align}
The error term in this cannot be much improved, but a little. Walfisz proved an $O(x(\log x)^{2/3})$ bound, and since $\limsup \frac{\sigma(n)}{n\log \log n} = e^{\gamma}$, the error term cannot be smaller than $O(x\log \log x)$.
If we use the error term derived above, we can completely ignore the second parts, since their sum is $O(x\log x)$, hence swallowed by the error term. If we use the stronger bound by Walfisz, the easy
$$\sum_{j \leqslant x} \biggl\lfloor \frac{x}{j}\biggr\rfloor = \sum_{j \leqslant x} \frac{x}{j} + O(x) = x\log x + O(x)$$
is all that we can fruitfully use. The stronger results for the summatory divisor function by Dirichlet and later improvements help not at all, everything but the main term is necessarily absorbed by the error term from the first parts.
Finally we know
$$\sum_{j \leqslant x} (j-1) = \frac{\lfloor x\rfloor(\lfloor x\rfloor - 1)}{2} = \frac{x^2}{2} + O(x)\,.$$
Putting everything together we obtain
$$f_0(x) = \frac{\pi^2}{12} x^2 - x\log x - \frac{1}{2}x^2 + O\bigl(x(\log x)^{2/3}\bigr) = \frac{\pi^2 - 6}{12}x^2 - x\log x + O\bigl(x(\log x)^{2/3}\bigr)$$
using Walfisz's result, and
$$f_0(x) = \frac{\pi^2-6}{12} x^2 + O(x\log x)$$
without appealing to that.
