Bounds for $n$-th prime

See the papers of:

  • Dusart 2010
  • Axler 2013
  • Axler 2014
  • Büthe 2014
  • Kotnick 2008
  • Schoenfeld 1976

For the nth prime upper bound, Axler 2013 viii Korollar G is best when $n \ge 8009824$. Dusart 2010 page 2 is best from $688383$ to $8009823$. Below that, either Dusart 2010 page 7, Dusart 1999 page 14, Robin 1983 or tweak the values since this is a limited range.

For the $n$-th prime lower bound, Axler 2013 vii Korollar I is best. For small values you can tweak things to get tighter.

By tweak, I mean something like starting with the Dusart 2010 formula $\pi(x) \le \frac{x}{\ln x}\big(1 + \frac{1}{\ln x} + \frac{C}{\ln^2 x}\big)$ where he proves $C=2.334$ works for $x \ge 2953652287$. But we can take a piecewise range and come up with a value of $C$ that works for all values in the range, which can give a tighter result within that range. If you're not interested in small inputs where we can do this sort of computational testing, or you don't care about this sort of small optimization, then by all means just use one or more of the simpler formulas given in the papers.

If you want even tighter bounds, it turns out that the published bounds for prime counts are tighter than the nth prime bounds. By using an inverse lookup (binary search) of the opposite prime count bound, we can achieve tighter bounds for a pretty large range. In particular, Büthe 2014 gives a large range (to $1.4\times 10^{25}$) where the Schoenfeld 1976 bounds apply irrespective of the truth of the Riemann Hypothesis, and Axler's bounds are also very good. At $10^{17}$ this gives a couple orders of magnitude tighter bound on both the upper and lower nth prime. If you want to assume the Riemann Hypothesis then of course you can continue using the Schoenfeld bounds.