Asymptotic property of the sum of $\ln^2 p$ where $p$ is prime Here is the problem I meet in analytical number theory($p$ is prime number here):
Prove:
$$
\sum_{p \leq N} \ln^2 p= N\ln N + o(N\ln N)
$$
I really don't know where to start or what is the right theorem to use. Any help is appreciated! 
 A: Let $\mathbf{1}_p(n)$ the function which equals $1$ if $n$ is a prime and $0$ otherwise. By summation by parts
$$ \sum_{p\leq N}\log^2 p = \sum_{n\leq N}\mathbf{1}_p(n) \log^2 n = \pi(N)\log^2 N-\sum_{n\leq N-1} \pi(n)\left[\log^2(n+1)-\log^2(n)\right] $$
On the other hand $\pi(N)\sim\frac{N}{\log N}$ by the PNT and 
$$ \log^2(n+1)-\log^2(n)=(\log n+\log(n+1))\log\left(1+\frac{1}{n}\right) = O\left(\frac{\log n}{n}\right) $$
such that
$$\sum_{n\leq N}\pi(n)\left[\log^2(n+1)+\log^2(n)\right]\ll\sum_{n\leq N}1 =   O(N)$$
and the claim is proved. Actually a stronger version of it, where $o(N\log N)$ has been replaced by $O(N)$.
A: Note that we can find more terms of this asymptotic quite easily. From the PNT in the form $$\pi\left(x\right)=\frac{x}{\log\left(x\right)}\sum_{k=0}^{n}\frac{k!}{\log^{k}\left(x\right)}+O_{n}\left(\frac{x}{\log^{n+2}\left(x\right)}\right)$$ we have, taking for example $n=1$ and using the Abel summation formula, that $$\sum_{p\leq N}\log^{2}\left(p\right)=\pi\left(N\right)\log^{2}\left(N\right)-2\int_{2}^{N}\frac{\pi\left(t\right)\log\left(t\right)}{t}dt$$ $$=N\log\left(N\right)+N+O\left(\frac{N}{\log\left(N\right)}\right)-2\int_{2}^{N}\left(1+\frac{1}{\log\left(t\right)}\right)dt+O\left(\int_{2}^{N}\frac{1}{\log^{2}\left(t\right)}dt\right).$$ Now, integrating by parts, it is not difficult to see that $$\int_{2}^{N}\frac{1}{\log\left(t\right)}dt\sim\frac{N}{\log\left(N\right)}$$ and $$\int_{2}^{N}\frac{1}{\log^{2}\left(t\right)}dt\ll\int_{2}^{N}\frac{1}{\log\left(t\right)}dt\sim\frac{N}{\log\left(N\right)}$$ so $$\sum_{p\leq N}\log^{2}\left(p\right)=\color{red}{N\log\left(N\right)-N+O\left(\frac{N}{\log\left(N\right)}\right)}.$$
