Is $\lim_{x\rightarrow\infty}\frac{x}{\pi(x)}-\ln(x) =-1$?

$\pi(x)$ is the number of primes not exceeding $x$. The prime number theorem states that $\lim_{x\rightarrow \infty} \frac{\pi(x)}{x/\ln(x)} = 1.$ So I, naïvely, inferred that $\lim_{x\rightarrow\infty}\frac{x}{\pi(x)}-\ln(x) =0.$ But I did some tests and it would very much seem that the true value of the limit is minus one.

But just because $\lim_{x\rightarrow \infty} \frac{\pi(x)}{x/\ln(x)} = 1,$ this doesn't tell anything about the absolute error....

So I ask if $\lim_{x\rightarrow\infty}\frac{x}{\pi(x)}-\ln(x) =-1$?


Indeed we have the limit

$$\lim_{x\to\infty} \frac{x}{\pi(x)} - \log x = -1.$$

We have the estimate

$$\pi(x) = \operatorname{li}(x) + O(xe^{-\sqrt{\log x}/15})$$

cited in wikipedia. Now, for the logarithmic integral, we have

$$\operatorname{li}(x) = \frac{x}{\log x} + \frac{x}{\log^2 x} + o\left(\frac{x}{\log^2 x}\right),$$

and $e^{-c\sqrt{\log x}}$ is $o\left(\frac{1}{\log^k x}\right)$ for all $k > 0$. So

$$\pi(x) = \frac{x}{\log x} + \frac{x}{\log^2 x} + r(x)$$

where $\frac{r(x)\log^2 x}{x} \to 0$. Thus

$$\begin{gather}\frac{\pi(x)}{x} = \frac{1}{\log x}\left(1 + \frac{1}{\log x} + o\left(\frac{1}{\log x}\right)\right)\\ \frac{x}{\pi(x)} = \log x\left(1 - \frac{1}{\log x} + o\left(\frac{1}{\log x}\right)\right) = \log x - 1 + o(1). \end{gather}$$

As I just discovered by following a link from an unrelated question,

$$\lim_{n\to\infty} \left(\log n - \frac{n}{\pi(n)}\right) = B$$

is known as Legendre's constant (Legendre conjectured its existence, but of course could not prove it), which was proved to be $1$ by de la Vallée-Poussin (of Prime Number Theorem fame).


EEDDIITT: it turned out the OP wanted something else. That's life.

.......................... The Logarithmic Integral function is a better estimate for $\pi(x)$ than any rational function of $x, \log x,$ and the error is still known to be unbounded (absolute).

A good early result is Theorem 35 in The Distribution of Prime Numbers by A. E.Ingham, $$ \pi(x) - \operatorname{li}x = \Omega_{\pm} \left( \frac{\sqrt x}{\log x} \; \log \log \log x \right) $$

http://en.wikipedia.org/wiki/Prime-counting_function

http://en.wikipedia.org/wiki/Logarithmic_integral

http://en.wikipedia.org/wiki/Skewes%27_number

and so on.