The most accurate estimate for the nth prime $\pi(n)$ counts how many primes are less than or equal to $n$. The most accurate estimate I know for the range of $n$ where it is not possible to compute the answer exactly is
$$\pi(n) \approx \operatorname{li}(n) - \frac{1}{2} \operatorname{li}(\sqrt{n})$$
But what is the most accurate estimate for the value of the $n$th prime?
In case I am using the wrong terminology, I am looking for a practically computable formula that gives a value which is as close as possible to the true value.
I could write code to use the estimate for $\pi(n)$ to search for this. Is there another similarly accurate formula?
 A: COMMENT.-An spectacular formula giving exactly the $n^{th}$ prime was appeared in $1964$. In the link below figure C.P. Williams as the author. I remember I read this in a small peruvian magazine and I believed the author was a peruvian really. It is the reason I am not sure that Williams was the author.
$$n^{th}\space \text {prime }=1+\sum_{i=1}^{2^n}\left\lfloor\left(\frac nD\right)^{\frac 1n}\right\rfloor$$ where $$D=\sum_{j=1}^i\left\lfloor\cos\left(\frac{(j-1)!+1)\pi}{j}\right)^2\right\rfloor$$.
https://youtu.be/j5s0h42GfvM
In those times (the $60$'s) there were no computers for public use, so the formula could not be verified. But currently it has been possible to verify the accuracy up to certain limits, naturally, of the formula.
A: A quick and fairly accurate (under RH, at least) estimate for the n-th prime is the inverse logarithmic integral $\operatorname{li}^{-1}$. The error is on the order of square-root, which is better than any of the estimates of the form n log n(1 + 1/log n + ...).
A: For different ranges of $n$, finding the exact $n$th prime rigorously and quickly should be done using different techniques. For all small $n$ (say less than $10^{10}$), it's hard to do much better than an optimized version of the Sieve of Eratosthenes.
For larger $n$, the space requirements of sieves become problematic. It instead becomes better to explicitly compute $\pi(n)$ using variations of the Meissel-Lehmer-Lagarias-Miller-Odylzko-Deleglise-Rivat method. See Staple's thesis for recent state of the art and a comparison of analytic and combinatorial methods.
In practice, it is possible to compute $\pi(X)$ with approximate time complexity $X^{2/3}$ and space complexity $X^{1/3}$. (I'm ignoring logs, but at this size logs matter. Staple's thesis saves a log factor from earlier methods). This suggests that a particularly dedicated, expensive effort might be able to find the $n$th prime for $n < 10^{30}$, say — though such effort might take on the order of a hundred thousand CPU-core years.
In principle, for larger $n$ the analytic method of Lagarias and Odlyzko is faster. But in practice there are very large constants in the asymptotic analysis. In theory, one can compute $\pi(X)$ in roughly $X^{1/2}$ time and $X^{1/4}$ space, though in practice the omitted constants (and log factors) have meant that this method has not yet been faster than the combinatorial options above.
For still larger $n$, one needs a new idea.
