TITLE: Integral of the error estimate in the prime number theorem
QUESTION [8 upvotes]: This seems like something that should be in discussed in the literature, but I can't find anything. Here $\pi(x)$ is the prime counting function and $\psi(x)$ is the usual sum of the Von Mangoldt function.
Are there non-trivial estimates for the quantity $\int_{1}^{N} |\psi(x) - x| dx$? The prime number theorem asserts $|\pi(x)- x/ln(x)| = o(x/ln(x))$, or, equivalently, $|\psi(x) - x| = o(x)$. Using this we trivially have the estimate $o(N^2)$ for the expression above (which we can make a bit more quantitative using quantitative forms of the pnt) however it seems plausible that this could be improved since we are asking for average case instead of worst case information about $|\psi(x) - x|$. In fact since we know that $\psi(x) - x$ oscillates to the extremes $\pm \sqrt{x}/ln(x)$ infinitely often, it seems plausible that it might spend a fair amount of time away from these extremes.

REPLY [7 votes]: The mean square version 
$\int_X^{2X} |\psi(x) - x|^2dx$
is more natural than the one you want. This is discussed on page 423 of Montgomery and Vaughan's book, on the assumption of the Riemann Hypothesis. Briefly, you can use the truncated explicit formula for $\psi(x)$ and multiply out and integrate. It does not look like one gets a great bound only by the zero-free region of Korobov and Vinogradov. The cancellation that you want seems to be there, but depends on the behavior of the differences $\gamma_1 - \gamma_2$ where $\gamma_1$,$\gamma_2$ are imaginary parts of nontrivial zeros of the Riemann zeta function, so it is hard to get at. 
If you have a bound for the above integral, you can get one for your integral by Cauchy-Schwarz, of course. I think your integral is hopeless to attack directly; it will either have to come from a pointwise bound as you tried above, or a bound on some even power, or perhaps some combination.
The range from X to 2X is a convenience so that things do not change enormously over the range; you can bound the whole integral from 1 to X by adding integrals over dyadic ranges.