Prime gap around $p_n$

As ${\rm li}(x)\sim \pi(x)$ and Cramer's conjecture predicts that the maximal prime gap around $p_n$ is $O(\log^{2}p_n)$, does a strong heuristics suggest that this prime gap is approximately $\int_{1}^{p_n}\left(\frac{dx}{dy}\right)\frac{dy}{y}$ where $y=\pi(x)$? Indeed the derivative of $\log^{2}x$ is $2\frac{\log x}{x}$ which is approximately $\frac{2}{\pi(x)}$.

• The heuristic is that $Pr(n \text{ is prime}) \approx \frac{1}{\ln n}$ en.wikipedia.org/wiki/… – reuns Jan 26 '17 at 14:55
• Yes, of course, but I expect something more conceptual, which doesn't take this for granted. Something that just uses the definition of the prime counting function and the change of variables while performing an integration. In other words, I'd like to express the prime gap around $p_n$ in terms of $\pi(x)$ , and finally use the prime number theorem to deduce that this gap is as predicted by Cramer. – Sylvain Julien Jan 26 '17 at 15:28
• To say it differently, are there theoretical reasons to expect that the maximal prime gap around $x$ is $O(\int_{2}^{x}\frac{dt}{\pi(t)})$? – Sylvain Julien Jan 26 '17 at 15:32
• If the probabilistic model would be effective in estimating difference between primes then the twin primes conjecture or Goldbach's conjecture would have already been solved. It is not difficult to prove that occasionally $p_{n+1}-p_{n}$ is very large, or that Cramer's model does not predict the Chebyshev bias. We cannot ask that such approximation proves something stronger than its claim, essentially because Cramer's model is unrelated with the arithmetical properties of primes. – Jack D'Aurizio Jan 26 '17 at 21:18
• $\int_{2}^{17}\dfrac{dt}{\pi(t)}=(3-2)/1+(5-3)/2+(7-5)/3+(11-7)/4+(13-11)/5+(17-13)/6=4.7333...$ which is roughly the maximal prime gap below 17, namely 4. – Sylvain Julien Apr 18 '17 at 20:30

Indeed, Wolf expresses the most likely value of $G(x)$, the maximal prime gap up to $x$, in terms of the prime counting function $\pi(x)$, somewhat like you suggest in your question: $$G(x) \sim {x\over\pi(x)}(2\log\pi(x) - \log x + c),$$ which, for all practical purposes, is equivalent to $$G(x) \sim \log^2 x − 2 \log x \log \log x + O(\log x).$$ Wolf's argument is more complicated than that of your question. Nevertheless, your conjecture and Wolf's formula give asymptotically the same (quite realistic) prediction for the size of maximal prime gaps.