# Prove that $\pi(x)=Li(x)+\mathcal O\left(\frac{E(x)}{\log(x)}\right)$

Let $\psi(x)=\sum_{n\leq x}\Lambda (n)$ where $$\Lambda (n)=\log(p)\boldsymbol 1_{\{n=p^k\mid p\ \text{prime}\}}(n)$$ and $E(x)$ s.t. $x^{1/2}\log(x)\ll E(x).$

Show that if $\psi(x)=x+\mathcal O(E(x))$ then $$\pi(x)=\text{Li}(x)+\mathcal O\left(\frac{E(x)}{\log(x)}\right).$$

Attempts

$$\psi(x)=\sum_{n\leq x}\Lambda (n)=\sum_{p^k\leq x}\log(p)=\sum_{p\leq x}\log(p)+\sum_{p^k\leq x, k\geq 2}\log(p)=\sum_{p\leq x}\log(p)+\sum_{p\leq x}\left(\left\lfloor\frac{\log(x)}{\log(p)}\right\rfloor-1\right) \log(p)=\sum_{p\leq x}\log(p)+\pi(x)\log(x)+\sum_{p\leq x}\mathcal O(1)\log(p)=\sum_{p\leq x}\log(p)+\pi(x)\log(x)+\mathcal O\left(\sum_{p\leq x}\mathcal\log(p)\right)=\sum_{p\leq x}\log(p)+\pi(x)\log(x)+\mathcal O\left(\theta (x)\right).$$

Therefore, if $\psi(x)=x+\mathcal O(E(x))$, we get $$\pi(x)=\frac{x}{\log(x)}+\mathcal O\left(\frac{E(x)}{\log(x)}\right)+\mathcal O\left(\frac{\theta (x)}{\log(x)}\right)-\frac{1}{\log(x)}\sum_{p\leq x}\log(p).$$

Q1) If it's true, how can I get that $\frac{\theta (x)}{\log(x)}=\mathcal O\left(\frac{E(x)}{\log(x)}\right)$ ?

Now, to estimate $-\frac{1}{\log(x)}\sum_{p\leq x}\log(p)$, I use Abel sommation with $a_n=\log(p)\boldsymbol 1_{n=p\text{ prime}}$ and $f(x)=\frac{-1}{\log(x)}$. Then I get $$-\sum_{p\leq x}1+\int_2^x\frac{1}{t\log^2(t)}\sum_{p\leq t}\log(p)\mathrm d t=-\pi(x)+\int_2^x \frac{\theta (t)}{t\log^2(t)}\mathrm dt.$$

Q2) How can I continue ?

My idea is the following one : since $\theta (x)\sim \psi(x)$ we have that $\theta (x)=x+\mathcal O(E(x))$

Q3) Is it true ?

And thus $$\int_2^x\frac{\theta (t)}{t\log^2(t)}\mathrm d t=\int_2^x \frac{1}{\log^2(t)}\mathrm dt +\int_2^x \mathcal O\left(\frac{E(t)}{t\log^2(t)}\right)\mathrm dt.$$ The first integral on the RHS is $$\left[-\frac{t}{\log(t)}\right]_2^\infty +\text{Li(x)}=-\pi(x)+o(\pi(x))+\text{Li}(x),$$ but I'm not sure how to conclude, and same for the second integral in the RHS, I don't see how to conclude.