Prove the equivalent form of the Selberg's Formula $\psi(x)\log x+\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p=2x\log x+\mathcal O(x).$

This is the Selberg's Formula: $$\psi(x)\log x+\sum_{n\leq x}\Lambda(n)\psi\bigg(\dfrac xn\bigg)=2x\log x+\mathcal O(x).$$ In the book Apostol Analytic Number Theory, the exercise tells me to use this Formula to give an equivalent formula which is $$\psi(x)\log x+\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p=2x\log x+\mathcal O(x).$$ I spotted the only difference is the sum terms, so I decided to prove that $$\sum_{n\leq x}\Lambda(n)\psi\bigg(\dfrac xn\bigg)-\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p=\mathcal O(x).$$ Then since the von mangoldt function is nonzero when $$n$$ is a prime power, I found that the sum over $$n\leq x$$ can be written as \begin{align*} \sum_{n\leq x}\Lambda (n)\psi\bigg(\dfrac xn\bigg)&=\sum_{m=1}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x} \psi\bigg(\dfrac x{p^m}\bigg)\log p\\ &=\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p+\sum_{m=2}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x}\psi\bigg(\dfrac x{p^m}\bigg)\log p \end{align*} So the last thing I want to show is that $$\sum_{m=2}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x}\psi\bigg(\dfrac x{p^m}\bigg)\log p =\mathcal O(x)$$ But this is a bit ugly to see, I don't know what should I do next. Any suggestion?

• The difference is $\sum_{p^k \le x, k \ge 2} \psi(x/p^k) \log p = O(\sum_{n \le x^{1/2}} \log n \sum_{n^k \le x, k \ge 2}\psi(x/n^k) )=O(\sum_{n \le x^{1/2}} \log n \sum_{n^k \le x, k \ge 2}\frac{x}{n^k} )$ $=O(\sum_{n \le x^{1/2}} \frac{x}{n^2} \log n) = O(x)$ where I used that $\psi(x) = O(x)$ and $\sum_{k \ge 2} n^{-k} = O(n^{-2})$ and $\sum_n \frac{\log n}{n^2}$ converges – reuns Jan 29 at 3:06
• @reuns seems messy, but I understand. Thank you. – kelvin hong 方 Jan 29 at 3:12
• @reuns can you post answer in the below section? I want to mark this question as solved. – kelvin hong 方 Jan 29 at 3:13