Question about Selberg's formula

Solution 1:

For some $\eta\in(n,n+1)$, $$ \begin{align} &\sum_{n\le x}\pi(n)(\log(n+1)^2-\log(n)^2)\\ &=\sum_{n\le x}\pi(n)\frac{2\log(\eta)}{\eta}\\ &=\sum_{n\le x}\left(\frac{n}{\log(n)}+O\left(\frac{n}{\log(n)^2}\right)\right)\left(\frac{2\log(n)}{n}+O\left(\frac{\log(n)}{n^2}\right)\right)\\ &=2x+O\left(\frac{x}{\log(x)}\right) \end{align} $$ Therefore, summing by parts, $$ \begin{align} \sum_{p\le x}\log(p)^2 &=\sum_{n\le x}\log(n)^2(\pi(n)-\pi(n-1))\\[6pt] &=\log(x)^2\pi(x)-\sum_{n\le x}\pi(n)(\log(n+1)^2-\log(n)^2)\\ &=\log(x)^2\left(\frac{x}{\log(x)}+\frac{x}{\log(x)^2}+O\left(\frac{x}{\log(x)^3}\right)\right)-2x+O\left(\frac{x}{\log(x)}\right)\\ &=x\log(x)-x+O\left(\frac{x}{\log(x)}\right) \end{align} $$


Experimental Results $$ \begin{array}{r|c|c|c} x&\sum_{p\le x}\log(p)^2&x\log(x)-x&\frac{x}{\log(x)}\\ \hline\\ 100 & 309.0926254 & 360.5170186 & 21.71472410\\ 1000 & 5686.965759 & 5907.755279 & 144.7648273\\ 10000 & 81399.38488 & 82103.40372 & 1085.736205\\ 100000 & 1048435.866 & 1051292.546 & 8685.889638 \end{array} $$