This StackExchange question -- Is the $n$-th prime smaller than $n(\log n + \log\log n-1+\frac{\log\log n}{\log n})$? -- assumes the following statement: $$\log n + \log\log n -1 \leq \frac{p_n}{n} \leq \log n + \log\log n.$$ My question is: how can we prove that statement?
Using the version of the Prime Number Theorem that states $$\pi (n) \sim \frac{n}{\log n},$$ we can quite easily show that $$p_n \sim n\log n,$$ or in other words $$p_n = n\log n + o(n\log n),$$ but this doesn't seem to get us any closer to a big-O estimate of the kind assumed in the above question. Is there a standard, quick method of obtaining such an estimate?
(Answering my own question because I was given the solution elsewhere.)
By a known result and simple logarithm laws we have
$$\begin{align} p_n &\sim n\log n \\ \log p_n &= \log n + \log \log n + o(1). \end{align}$$
We also know that $\pi (n) = \frac{n}{\log n} + O\left(\frac{n}{(\log n)^2}\right),$ and therefore $$n = \pi (p_n) = \frac{p_n}{\log p_n} + O\left(\frac{p_n}{(\log p_n)^2} \right).$$
Meanwhile $O\left(\frac{p_n}{(\log p_n)^2} \right)$ simplifies, using the little-o estimates above, to $O\left(\frac{n}{\log n} \right)$. Plugging this in gives $$n= \frac{p_n}{\log n +\log\log n + o(n)} +O\left(\frac{n}{\log n} \right),$$
and therefore, just by rearranging terms and cancellation, $$p_n = n\log n + n\log\log n + O(n).$$