# 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).

• Very nice! Not at all what I expected. – Thomas Andrews Aug 4 '13 at 20:58
• @ThomasAndrews I didn't expect it either, but plugging in a few not too small values made it look not impossible. – Daniel Fischer Aug 4 '13 at 20:59
• Fantastic! I was worried for a second :D Thanks. – Valtteri Aug 4 '13 at 21:03

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/Logarithmic_integral

and so on.

• Yeah. Actually this whole question arose when I wanted a sequence of rational numbers (a_n) which approach logarithm of n as n grows. Hence this sequence seemed fitting... – Valtteri Aug 4 '13 at 20:39
• He's also not talking about $\lim \pi(x)-x/\log x$, rather he's talking about $\lim x/\pi(x) - \log x$. (I made the same mistake.) The standard error functions require some tweaking to get the error there. – Thomas Andrews Aug 4 '13 at 20:45
• @ThomasAndrews, not sure then. I would guess that quantity might be bounded but without a limit. – Will Jagy Aug 4 '13 at 20:50
• @WillJagy Yeah, that was my guess, too. – Thomas Andrews Aug 4 '13 at 20:50
• @daniel, he proves it, pages 103-104 in my paperback edition. – Will Jagy Aug 4 '13 at 21:03