I am trying to prove the following
If $\pi(x) = \operatorname{Li}(x) + O(x^{\frac{1}{2}}\log(x))$ then $\psi(x) = x + O(x^{\frac{1}{2}} \log^2(x))$
I have tried using $\psi(x) = \theta(x) + O(x^{\frac{1}{2}} \log^2(x))$ and then bounding $\theta(x)$ but could not reach anywhere.
I have tried this problem for many hours now.
The definitions are as follows:
$\operatorname{Li}(x) = \int_2^x \frac{1}{\ln t} dt$
$\pi(x) = \sum_{p \leq x} 1$ with $p$ prime
$\theta(x) = \sum_{p \leq x} \ln p$ with $p$ prime
$\psi(x) = \sum_{p^k \leq x, k \geq 1} \ln p$ with $p$ prime
You can obtain the result by writing $\theta(x)$ as a Riemann-Stieltjes integral and integration by parts.
\begin{align} \theta(x) &= \int_{[2,x]} \ln t \, d\pi(t)\\ &= \pi(x)\ln x - \pi(2^-)\ln 2 - \int_2^x \pi(t)\,d\ln t\\ &= \pi(x)\ln x - \int_2^x \frac{\pi(t)}{t}\,dt. \end{align}
Now replace $\pi(y)$ by $\operatorname{Li}(y) + O(\sqrt{y}\ln y)$ and estimate the errors. To evaluate
$$\int_2^x \frac{\operatorname{Li}(t)}{t}\,dt,$$
change the order of integration.