TITLE: How to use the Prime Number Theorem in order to prove Selberg's Formula?
QUESTION [7 upvotes]: 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!

REPLY [6 votes]: 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$.

REPLY [2 votes]: Edit: Answer to GH from MO by author.
Edit2: Changed a sign.
Let
$$l(n)=\left\{\begin{array}{11} \log p, & if\ n = p\ prime \\ 0, & else. \end{array}\right.$$
Then
$$\sum_{pq\leq x}(\log p)(\log q)=\sum_{n\leq x}(l\ast l)(n)$$
So far, so good. However, using Dirichlet's hyperbola identity, I only obtain
$$\sum_{n\leq x}(l\ast l)(n)=2\sum_{p\leq x^\frac{1}{2}}(\log p)\vartheta(\frac{x}{p})-\vartheta(x^\frac{1}{2})^2 $$, where obviously $\vartheta(x^\frac{1}{2})^2=O(x)$.
Thus I am back at my original problem, as I would have to show
$$\sum_{p\leq x^\frac{1}{2}}(\log p)\vartheta(\frac{x}{p})=\frac{1}{2}x\log x+O(x)$$
Where do I fail to see the shortpath? Thanks for answering anyways, appreciate it!