I`m reading Melvin B. Nathanson's "Elementary Methods in Number Theory"
and I can't think of a way of deducing Selberg's formula (9.3) from the prime number theorem.
This is one of the tasks left for the reader at the end of chapter 9.3 (The Elementary Proof).


$$(9.3) \qquad \qquad \vartheta(x) \log x + \sum\_{p \leq x}(\log p) \vartheta(x/p) = 2x\log x +O(x)$$


Simply replacing $\vartheta(x)$ by $x + o(x)$ results in error terms of order $o(x\log x)$ which are
strictly worse than error terms of order $O(x)$.


I feel like I'm missing something rather simple, but I've been wasting just a little too much time on
that exercise.
Thanks in advance!



How to use the Prime Number Theorem in order to prove Selberg's Formula?
The $O(x)$ term can be refined by completely elementary means that are not at all complicated. Filip Saidak (On the prime number lemma of Selberg, Math. Scand. 103 (2008), no. 1, 5–10) proved a much clearer connection between Selberg's result and the prime number theorem. He stated this for $\psi(x) = \sum\_{n\leq x}\Lambda(n)$, but this holds with trivial modifications for $\vartheta(x)=\sum\_{p\leq x}\log p$.


If $\vartheta(x):=\sum\_{n\leq x}\Lambda(n) = x + E(x)$, then


$\vartheta(x)\log x + \sum\_{p\leq x} (\log p)\vartheta(x/p)=2x\log x -(2\gamma+1)x+O(E(x)(\log x)^2)$,


where $\gamma$ is the Euler-Mascheroni constant. So if all that you know is that $E(x) = o(x)$, then you cannot recover Selberg's result. Selberg's breakthrough that $-(2\gamma+1)x+O(E(x)(\log x)^2) = O(x)$ appears to be equivalent to the stronger estimate $E(x) \ll x/(\log x)^2$.


