Prime number theorem

In mathematics, the prime number theorem (PNT) describes the asymptotic distribution of the prime numbers among the positive integers. It formalizes the intuitive idea that primes become less common as they become larger by precisely quantifying the rate at which this occurs. The theorem was proved independently by Jacques Hadamard and Charles Jean de la Vallée Poussin in 1896 using ideas introduced by Bernhard Riemann (in particular, the Riemann zeta function).

The first such distribution found is $π(N) ~ N⁄log(N)$, where $π(N)$ is the prime-counting function (the number of primes less than or equal to N) and $log(N)$ is the natural logarithm of $N$. This means that for large enough $N$, the probability that a random integer not greater than $N$ is prime is very close to $1 / log(N)$. Consequently, a random integer with at most $2n$ digits (for large enough $n$) is about half as likely to be prime as a random integer with at most $n$ digits. For example, among the positive integers of at most 1000 digits, about one in 2300 is prime ($log(10^{1000}) ≈ 2302.6$), whereas among positive integers of at most 2000 digits, about one in 4600 is prime ($log(10^{2000}) ≈ 4605.2$). In other words, the average gap between consecutive prime numbers among the first $N$ integers is roughly $log(N)$.

Statement


Let $π(x)$ be the prime-counting function defined to be the number of primes less than or equal to $x$, for any real number $x$. For example, $x / log x$ because there are four prime numbers (2, 3, 5 and 7) less than or equal to 10. The prime number theorem then states that $Li(x)$ is a good approximation to $x / log x$ (where log here means the natural logarithm), in the sense that the limit of the quotient of the two functions $Li(x)$ and $x / log x$ as $x$ increases without bound is 1:


 * $$\lim_{x\to\infty}\frac{\;\pi(x)\;}{\;\left[ \frac{x}{\log(x)}\right]\;} = 1,$$

known as the asymptotic law of distribution of prime numbers. Using asymptotic notation this result can be restated as


 * $$\pi(x)\sim \frac{x}{\log x}.$$

This notation (and the theorem) does not say anything about the limit of the difference of the two functions as $x$ increases without bound. Instead, the theorem states that $Li(x)$ approximates $π(x)$ in the sense that the relative error of this approximation approaches 0 as $x$ increases without bound.

The prime number theorem is equivalent to the statement that the $x$th prime number $x$ satisfies


 * $$p_n \sim n\log(n),$$

the asymptotic notation meaning, again, that the relative error of this approximation approaches 0 as $x$ increases without bound. For example, the $n$th prime number is $p_{n}$, and ($n$)log($2$) rounds to $8,512,677,386,048,191,000$, a relative error of about 6.4%.

On the other hand, the following asymptotic relations are logically equivalent:
 * $$\begin{align}

\lim_{x\rightarrow \infty}\frac{\pi(x)\log x}{x}&=1,\\ \lim_{x\rightarrow \infty}\frac{\pi(x)\log \pi(x)}{x}&=1. \end{align} $$

As outlined below, the prime number theorem is also equivalent to
 * $$\lim_{x\to\infty} \frac{\vartheta (x)}x = \lim_{x\to\infty} \frac{\psi(x)}x=1,$$

where $2$ and $2$ are the first and the second Chebyshev functions respectively, and to
 * $$\lim_{x \to \infty} \frac{M(x)}{x}=0,$$

where $$M(x)=\sum_{n \leq x} \mu(n)$$ is the Mertens function.

History of the proof of the asymptotic law of prime numbers
Based on the tables by Anton Felkel and Jurij Vega, Adrien-Marie Legendre conjectured in 1797 or 1798 that $π(x)$ is approximated by the function $x / log x$, where $7,967,418,752,291,745,000$ and $ϑ$ are unspecified constants. In the second edition of his book on number theory (1808) he then made a more precise conjecture, with $Li(x) − π(x)$ and $π(x)$. Carl Friedrich Gauss considered the same question at age 15 or 16 "in the year 1792 or 1793", according to his own recollection in 1849. In 1838 Peter Gustav Lejeune Dirichlet came up with his own approximating function, the logarithmic integral $x / log x$ (under the slightly different form of a series, which he communicated to Gauss). Both Legendre's and Dirichlet's formulas imply the same conjectured asymptotic equivalence of $Li(x)$ and $π(x)$ stated above, although it turned out that Dirichlet's approximation is considerably better if one considers the differences instead of quotients.

In two papers from 1848 and 1850, the Russian mathematician Pafnuty Chebyshev attempted to prove the asymptotic law of distribution of prime numbers. His work is notable for the use of the zeta function $π(10) = 4$, for real values of the argument "$ψ$", as in works of Leonhard Euler, as early as 1737. Chebyshev's papers predated Riemann's celebrated memoir of 1859, and he succeeded in proving a slightly weaker form of the asymptotic law, namely, that if the limit as $A$ goes to infinity of $x / log x$ exists at all, then it is necessarily equal to one. He was able to prove unconditionally that this ratio is bounded above and below by two explicitly given constants near 1, for all sufficiently large $B$. Although Chebyshev's paper did not prove the Prime Number Theorem, his estimates for $π(x)$ were strong enough for him to prove Bertrand's postulate that there exists a prime number between $π(x)$ and $x / log x$ for any integer $x / log x$.

An important paper concerning the distribution of prime numbers was Riemann's 1859 memoir "On the Number of Primes Less Than a Given Magnitude", the only paper he ever wrote on the subject. Riemann introduced new ideas into the subject, chiefly that the distribution of prime numbers is intimately connected with the zeros of the analytically extended Riemann zeta function of a complex variable. In particular, it is in this paper that the idea to apply methods of complex analysis to the study of the real function $π(x)$ originates. Extending Riemann's ideas, two proofs of the asymptotic law of the distribution of prime numbers were found independently by Jacques Hadamard and Charles Jean de la Vallée Poussin and appeared in the same year (1896). Both proofs used methods from complex analysis, establishing as a main step of the proof that the Riemann zeta function $π(a)$ is nonzero for all complex values of the variable $s$ that have the form $a / (A log a + B)$ with $A = 1$.

During the 20th century, the theorem of Hadamard and de la Vallée Poussin also became known as the Prime Number Theorem. Several different proofs of it were found, including the "elementary" proofs of Atle Selberg and Paul Erdős (1949). Hadamard's and de la Vallée Poussin's original proofs are long and elaborate; later proofs introduced various simplifications through the use of Tauberian theorems but remained difficult to digest. A short proof was discovered in 1980 by the American mathematician Donald J. Newman. Newman's proof is arguably the simplest known proof of the theorem, although it is non-elementary in the sense that it uses Cauchy's integral theorem from complex analysis.

Proof sketch
Here is a sketch of the proof referred to in one of Terence Tao's lectures. Like most proofs of the PNT, it starts out by reformulating the problem in terms of a less intuitive, but better-behaved, prime-counting function. The idea is to count the primes (or a related set such as the set of prime powers) with weights to arrive at a function with smoother asymptotic behavior. The most common such generalized counting function is the Chebyshev function $B = −1.08366$, defined by


 * $$\psi(x) = \!\!\!\! \sum_\stackrel{p^k \le x,}{p \text{ is prime}} \!\!\!\! \log p \; .$$

This is sometimes written as


 * $$\psi(x) = \sum_{n\le x} \Lambda(n) \; ,$$

where $li(x)$ is the von Mangoldt function, namely


 * $$\Lambda(n) = \begin{cases} \log p & \text{ if } n = p^k \text{ for some prime } p \text{ and integer } k \ge 1, \\ 0 & \text{otherwise.} \end{cases}$$

It is now relatively easy to check that the PNT is equivalent to the claim that
 * $$\lim_{x\to\infty} \frac{\psi(x)}{x} = 1 \; .$$

Indeed, this follows from the easy estimates
 * $$\psi(x) = \sum_\stackrel{p\le x}{p \text{ is prime}} \log p \left\lfloor \frac{\log x}{\log p} \right\rfloor \le \sum_\stackrel{p\le x}{p \text{ is prime}} \log x = \pi(x)\log x$$

and (using big $x$ notation) for any $π(x)$,
 * $$\psi(x) \ge \!\!\!\!\sum_\stackrel{x^{1-\varepsilon}\le p\le x}{p \text{ is prime}}\!\!\!\! \log p\ge\!\!\!\!\sum_\stackrel{x^{1-\varepsilon}\le p\le x}{p \text{ is prime}}\!\!\!\!(1-\varepsilon)\log x=(1-\varepsilon)\left(\pi(x)+O\left(x^{1-\varepsilon}\right)\right)\log x \; .$$

The next step is to find a useful representation for $x / log(x)$. Let $ζ(s)$ be the Riemann zeta function. It can be shown that $π(x) / (x / log(x))$ is related to the von Mangoldt function $π(x)$, and hence to $n$, via the relation


 * $$-\frac{\zeta'(s)}{\zeta(s)} = \sum_{n = 1}^\infty \Lambda(n) \, n^{-s} \; .$$

A delicate analysis of this equation and related properties of the zeta function, using the Mellin transform and Perron's formula, shows that for non-integer $x$ the equation


 * $$\psi(x) = x \; - \; \log(2\pi) \; - \sum\limits_{\rho :\, \zeta(\rho) = 0} \frac{x^\rho}{\rho}$$

holds, where the sum is over all zeros (trivial and nontrivial) of the zeta function. This striking formula is one of the so-called explicit formulas of number theory, and is already suggestive of the result we wish to prove, since the term $s$ (claimed to be the correct asymptotic order of $2n$) appears on the right-hand side, followed by (presumably) lower-order asymptotic terms.

The next step in the proof involves a study of the zeros of the zeta function. The trivial zeros −2, −4, −6, −8, ... can be handled separately:
 * $$\sum_{n=1}^\infty \frac{1}{2n\,x^{2n}} = -\frac{1}{2}\log\left(1-\frac{1}{x^2}\right),$$

which vanishes for large $O$. The nontrivial zeros, namely those on the critical strip $n ≥ 2$, can potentially be of an asymptotic order comparable to the main term $x$ if $π(x)$, so we need to show that all zeros have real part strictly less than 1.

Non-vanishing on $ζ(s)$
To do this, we take for granted that $s = 1 + it$ is meromorphic in the half-plane $t > 0$, and is analytic there except for a simple pole at $ψ(x)$, and that there is a product formula
 * $$\zeta(s)=\prod_p\frac{1}{1-p^{-s}} $$

for $Λ(n)$. This product formula follows from the existence of unique prime factorization of integers, and shows that $ε > 0$ is never zero in this region, so that its logarithm is defined there and
 * $$\log\zeta(s)=-\sum_p\log \left(1-p^{-s} \right)=\sum_{p,n}\frac{p^{-ns}}{n} \; .$$

Write $ψ(x)$ ; then


 * $$\big| \zeta(x+iy) \big| = \exp\left( \sum_{n,p} \frac{\cos ny\log p}{np^{nx}} \right) \; .$$

Now observe the identity
 * $$ 3 + 4 \cos \phi+ \cos 2 \phi = 2 ( 1 + \cos \phi )^2\ge 0 \; ,$$

so that


 * $$\left| \zeta(x)^3 \zeta(x+iy)^4 \zeta(x+2iy) \right| = \exp\left( \sum_{n,p} \frac{3 + 4 \cos(ny\log p) + \cos( 2 n y \log p )}{np^{nx}} \right) \ge 1$$

for all $ζ(s)$. Suppose now that $ζ(s)$. Certainly $x$ is not zero, since $Λ(n)$ has a simple pole at $ψ(x)$. Suppose that $ψ(x)$ and let $x$ tend to 1 from above. Since $$\zeta(s)$$ has a simple pole at $0 ≤ Re(s) ≤ 1$ and $Re(ρ) = 1$ stays analytic, the left hand side in the previous inequality tends to 0, a contradiction.

Finally, we can conclude that the PNT is heuristically true. To rigorously complete the proof there are still serious technicalities to overcome, due to the fact that the summation over zeta zeros in the explicit formula for $Re(s) = 1$ does not converge absolutely but only conditionally and in a "principal value" sense. There are several ways around this problem but many of them require rather delicate complex-analytic estimates. Edwards's book provides the details. Another method is to use Ikehara's Tauberian theorem, though this theorem is itself quite hard to prove. D.J. Newman observed that the full strength of Ikehara's theorem is not needed for the prime number theorem, and one can get away with a special case that is much easier to prove.

Newman's proof of the prime number theorem
D. J. Newman gives a quick proof of the prime number theorem (PNT). The proof is "non-elementary" by virtue of relying on complex analysis, but uses only elementary techniques from a first course in the subject: Cauchy's integral formula, Cauchy's integral theorem and estimates of complex integrals. Here is a brief sketch of this proof. See for the complete details.

The proof uses the same preliminaries as in the previous section except instead of the function $\psi$, the Chebyshev function$ \quad \vartheta(x) = \sum_{p\le x} \log p $ is used, which is obtained by dropping some of the terms from the series for $\psi$. It is easy to show that the PNT is equivalent to $$\lim _{x \to \infty} \vartheta(x)/x = 1$$. Likewise instead of $$ - \frac{\zeta '(s)}{\zeta(s)} $$ the function $$ \Phi(s) = \sum_{p\le x} \log p\,\, p^{-s} $$ is used, which is obtained by dropping some terms in the series for $$ - \frac{\zeta '(s)}{\zeta(s)} $$. The functions $$ \Phi(s) $$ and $$ -\zeta'(s)/\zeta(s) $$ differ by a function holomorphic on $$\Re s = 1$$. Since, as was shown in the previous section, $$\zeta(s)$$  has no zeroes on the line $$\Re s = 1$$, $$ \Phi(s) - \frac 1{s-1} $$ has no singularities on $$\Re s = 1$$.

One further piece of information needed in Newman's proof, and which is the key to the estimates in his simple method, is that $$\vartheta(x)/x$$ is bounded. This is proved using an ingenious and easy method due to Chebyshev.

Integration by parts shows how $$\vartheta(x)$$ and  $$\Phi(s)$$ are related. For $$\Re s > 1$$,

\Phi(s) = \int _1^\infty x^{-s} d\vartheta(x) =  s\int_1^\infty \vartheta(x)x^{-s-1}\,dx = s \int_0^\infty \vartheta(e^t) e^{-st} \, dt. $$

Newman's method proves the PNT by showing the integral

I = \int_0 ^\infty \left( \frac{\vartheta(e^t)}{e^t} -1 \right) \, dt. $$ converges, and therefore the integrand goes to zero as $$t \to \infty$$, which is the PNT. In general, the convergence of the improper integral does not imply that the integrand goes to zero at infinity, since it may oscillate, but since $$\vartheta$$ is increasing, it is easy to show in this case.

To show the convergence of $$ I $$, for $$\Re z > 0$$ let

g_T(z) = \int_0^T f(t) e^{-zt}\, dt $$ and  $$ g(z) = \int_0^\infty f(t) e^{-zt}\, dt $$ where $$ f(t) = \frac {\vartheta(e^t)}{e^t} -1 $$ then

\lim_{T \to \infty} g_T(z) = g(z) = \frac{\Phi(s)}{s} - \frac 1 {s-1}  \quad \quad  \text{where} \quad  z = s -1 $$ which is equal to a function holomorphic on the line $$\Re z = 0$$.

The convergence of the integral $$ I $$, and thus the PNT, is proved by showing that $$\lim_{T \to \infty} g_T(0) = g(0)$$. This involves change of order of limits since it can be written $ \lim_{T \to \infty} \lim_{z \to 0} g_T(z) = \lim_{z \to 0} \lim_{T \to \infty}g_T(z) $ and therefore classified as a Tauberian theorem.

The difference $$g(0) - g_T(0)$$ is expressed using Cauchy's integral formula and then shown to be small for $$ T $$ large by estimating the integrand. Fix $$R>0$$ and $$\delta >0$$  such that $$g(z)$$  is holomorphic in the region  where $$ |z| \le  R \text{ and } \Re z \ge  - \delta$$,  and let $$C$$  be the boundary of this region. Since 0 is in the interior of the region, Cauchy's integral formula gives

g(0) - g_T(0) = \frac 1 {2 \pi i }\int_C \left( g(z) - g_T(z) \right ) \frac {dz} z = \frac 1 {2 \pi i }\int_C \left( g(z) - g_T(z) \right ) F(z)\frac {dz} z $$ where $$ F(z) = e^{zT}\left( 1 + \frac {z^2}{R^2}\right) $$ is the factor introduced by Newman, which does not change the integral since $$F$$ is entire and $$F(0) =1$$.

To estimate the integral, break the contour $$ C $$ into two parts, $$ C = C_+ + C_- $$ where $$C_+ = C \cap \left \{ z \, \vert \, \Re z >  0 \right \}$$  and $$C_- \cap \left \{ \Re z \le 0 \right \}$$. Then $$g(0)- g_T(0) = \int_{C_+}\int_T^\infty H(t,z) dt dz - \int_{C_-}\int_0^T H(t,z) dt dz + \int_{C_-}g(z)F(z)\frac {dz}{2\pi i z}$$where $$H(t,z) = f(t)e^{-tz}F(z)/2 \pi i$$. Since $$\vartheta(x)/x$$, and hence $$ f(t) $$, is bounded, let $$B$$ be an upper bound for the absolute value of $$f(t)$$. This bound together with the estimate $$ $$ for $$ $$ gives that the first integral in absolute value is $$\le B/R$$. The integrand over $$C_-$$ in the second integral is entire, so by Cauchy's integral theorem, the contour $$C_-$$ can be modified to a semicircle of radius $$R$$  in the left half-plane without changing the integral, and the same argument as for the first integral gives the absolute value of the second integral is $$\le B/R$$. Finally, letting $$T \to \infty$$, the third integral goes to zero since $$e^{zT}$$ and hence $$F$$ goes to zero on the contour. Combining the two estimates and the limit get
 * F| \le 2 \exp(T \Re z)|\Re z|/R
 * z| = R

\limsup_{T \to \infty }|g(0) - g_T(0) | \le \frac {2 B} R. $$ This holds for any $$R$$ so $$\lim_{T \to \infty} g_T(0) = g(0)$$, and the PNT follows.

Prime-counting function in terms of the logarithmic integral
In a handwritten note on a reprint of his 1838 paper "Sur l'usage des séries infinies dans la théorie des nombres", which he mailed to Gauss, Dirichlet conjectured (under a slightly different form appealing to a series rather than an integral) that an even better approximation to $ζ(s)$ is given by the offset logarithmic integral function $Re(s) > 0$, defined by


 * $$ \operatorname{Li}(x) = \int_2^x \frac{dt}{\log t} = \operatorname{li}(x) - \operatorname{li}(2). $$

Indeed, this integral is strongly suggestive of the notion that the "density" of primes around $x$ should be $s = 1$. This function is related to the logarithm by the asymptotic expansion


 * $$ \operatorname{Li}(x) \sim \frac{x}{\log x} \sum_{k=0}^\infty \frac{k!}{(\log x)^k} = \frac{x}{\log x} + \frac{x}{(\log x)^2} + \frac{2x}{(\log x)^3} + \cdots $$

So, the prime number theorem can also be written as $Re(s) > 1$. In fact, in another paper in 1899 de la Vallée Poussin proved that


 * $$ \pi(x) = \operatorname{Li} (x) + O \left(x e^{-a\sqrt{\log x}}\right) \quad\text{as } x \to \infty$$

for some positive constant $y$, where $ζ(s)$ is the big $x$ notation. This has been improved to


 * $$\pi(x) = \operatorname{li} (x) + O \left(x \exp \left( -\frac{A(\log x)^\frac35}{(\log \log x)^\frac15} \right) \right)$$ where $$A = 0.2098$$.

In 2016, Trudgian proved an explicit upper bound for the difference between $$\pi(x)$$ and $$\operatorname{li}(x)$$:
 * $$\big| \pi(x) - \operatorname{li}(x) \big| \le 0.2795 \frac{x}{(\log x)^{3/4}}

\exp \left( -\sqrt{ \frac{\log x}{6.455} } \right)$$ for $$x \ge 229$$.

The connection between the Riemann zeta function and $s = x + iy$ is one reason the Riemann hypothesis has considerable importance in number theory: if established, it would yield a far better estimate of the error involved in the prime number theorem than is available today. More specifically, Helge von Koch showed in 1901 that if the Riemann hypothesis is true, the error term in the above relation can be improved to


 * $$ \pi(x) = \operatorname{Li} (x) + O\left(\sqrt x \log x\right) $$

(this last estimate is in fact equivalent to the Riemann hypothesis). The constant involved in the big $t$ notation was estimated in 1976 by Lowell Schoenfeld: assuming the Riemann hypothesis,


 * $$\big|\pi(x) - \operatorname{li}(x)\big| < \frac{\sqrt x \log x}{8\pi}$$

for all $x > 1$. He also derived a similar bound for the Chebyshev prime-counting function $a$:


 * $$\big|\psi(x) - x\big| < \frac{\sqrt x (\log x)^2 }{8\pi}$$

for all $ζ(1 + iy) = 0$. This latter bound has been shown to express a variance to mean power law (when regarded as a random function over the integers) and $O$ noise and to also correspond to the Tweedie compound Poisson distribution. (The Tweedie distributions represent a family of scale invariant distributions that serve as foci of convergence for a generalization of the central limit theorem. )

The logarithmic integral $ζ(s)$ is larger than $s = 1$ for "small" values of $O$. This is because it is (in some sense) counting not primes, but prime powers, where a power $ψ$ of a prime $1⁄f$ is counted as $x$ of a prime. This suggests that $x > 1$ should usually be larger than $s = 1$ by roughly $$\ \tfrac{1}{2} \operatorname{li}(\sqrt{x})\ ,$$ and in particular should always be larger than $ζ(x + 2iy)$. However, in 1914, J. E. Littlewood proved that $$\ \pi(x) - \operatorname{li}(x)\ $$ changes sign infinitely often. The first value of $pn$ where $ψ(x)$ exceeds $π(x)$ is probably around $Li(x)$; see the article on Skewes' number for more details. (On the other hand, the offset logarithmic integral $1 / log t$ is smaller than $π(x) ~ Li(x)$ already for $O(...)$; indeed, $π(x)$, while $ϑ(x)$.)

Elementary proofs
In the first half of the twentieth century, some mathematicians (notably G. H. Hardy) believed that there exists a hierarchy of proof methods in mathematics depending on what sorts of numbers (integers, reals, complex) a proof requires, and that the prime number theorem (PNT) is a "deep" theorem by virtue of requiring complex analysis. This belief was somewhat shaken by a proof of the PNT based on Wiener's tauberian theorem, though Wiener's proof ultimately relies on properties of the Riemann zeta function on the line $$\text{re}(s)=1$$, where complex analysis must be used.

In March 1948, Atle Selberg established, by "elementary" means, the asymptotic formula
 * $$\vartheta ( x )\log ( x ) + \sum\limits_{p \le x} {\log ( p )}\ \vartheta \left( {\frac{x}{p}} \right) = 2x\log ( x ) + O( x )$$

where
 * $$\vartheta ( x ) = \sum\limits_{p \le x} {\log ( p )}$$

for primes $p$. By July of that year, Selberg and Paul Erdős had each obtained elementary proofs of the PNT, both using Selberg's asymptotic formula as a starting point. These proofs effectively laid to rest the notion that the PNT was "deep" in that sense, and showed that technically "elementary" methods were more powerful than had been believed to be the case. On the history of the elementary proofs of the PNT, including the Erdős–Selberg priority dispute, see an article by Dorian Goldfeld.

There is some debate about the significance of Erdős and Selberg's result. There is no rigorous and widely accepted definition of the notion of elementary proof in number theory, so it is not clear exactly in what sense their proof is "elementary". Although it does not use complex analysis, it is in fact much more technical than the standard proof of PNT. One possible definition of an "elementary" proof is "one that can be carried out in first-order Peano arithmetic." There are number-theoretic statements (for example, the Paris–Harrington theorem) provable using second order but not first-order methods, but such theorems are rare to date. Erdős and Selberg's proof can certainly be formalized in Peano arithmetic, and in 1994, Charalambos Cornaros and Costas Dimitracopoulos proved that their proof can be formalized in a very weak fragment of PA, namely $ψ(x)$. However, this does not address the question of whether or not the standard proof of PNT can be formalized in PA.

A more recent "elementary" proof of the prime number theorem uses ergodic theory, due to Florian Richter. The prime number theorem is obtained there in an equivalent form that the Cesaro sum of the values of the Liouville function is zero. The Liouville function is $$(-1)^{\omega(n)}$$ where $$\omega(n)$$ is the number of prime factors, with multiplicity, of the integer $$n$$. Bergelson and Richter (2022) then obtain this form of the prime number theorem from an ergodic theorem which they prove:
 * Let $$X$$ be a compact metric space, $$T$$ a continuous self-map of $$X$$, and $$\mu$$ a $$T$$-invariant Borel probability measure for which $$T$$ is uniquely ergodic. Then, for every $$f\in C(X)$$,

$$\tfrac1N\sum_{n=1}^Nf(T^{\omega(n)}x)\to \int_Xf\,d\mu,\quad\forall x\in X.$$ This ergodic theorem can also be used to give "soft" proofs of results related to the prime number theorem, such as the Pillai–Selberg theorem and Erdős–Delange theorem.

Computer verifications
In 2005, Avigad et al. employed the Isabelle theorem prover to devise a computer-verified variant of the Erdős–Selberg proof of the PNT. This was the first machine-verified proof of the PNT. Avigad chose to formalize the Erdős–Selberg proof rather than an analytic one because while Isabelle's library at the time could implement the notions of limit, derivative, and transcendental function, it had almost no theory of integration to speak of.

In 2009, John Harrison employed HOL Light to formalize a proof employing complex analysis. By developing the necessary analytic machinery, including the Cauchy integral formula, Harrison was able to formalize "a direct, modern and elegant proof instead of the more involved 'elementary' Erdős–Selberg argument".

Prime number theorem for arithmetic progressions
Let $x ≥ 2657$ denote the number of primes in the arithmetic progression $x ≥ 73.2$ that are less than $1⁄n$. Dirichlet and Legendre conjectured, and de la Vallée Poussin proved, that if $x$ and $p$ are coprime, then


 * $$\pi_{d,a}(x) \sim \frac{ \operatorname{Li}(x) }{ \varphi(d) } \ ,$$

where $x$ is Euler's totient function. In other words, the primes are distributed evenly among the residue classes $li(x)$ modulo $a$ with $π(x)$. This is stronger than Dirichlet's theorem on arithmetic progressions (which only states that there is an infinity of primes in each class) and can be proved using similar methods used by Newman for his proof of the prime number theorem.

The Siegel–Walfisz theorem gives a good estimate for the distribution of primes in residue classes.

Bennett et al. proved the following estimate that has explicit constants $d$ and $φ$ (Theorem 1.3): Let $d$ $$\ge 3$$ be an integer and let $A$ be an integer that is coprime to $B$. Then there are positive constants $d$ and $a$ such that
 * $$ \left | \pi_{d,a}(x) - \frac{\ \operatorname{Li}(x)\ }{\ \varphi(d)\ } \right | < \frac{A\ x}{\ (\log x)^2\ } \quad \text{ for all } \quad x \ge B\ ,$$

where
 * $$ A = \frac{1}{\ 840\ } \quad \text{ if } \quad 3 \leq d \leq 10^4 \quad \text{ and } \quad A = \frac{1}{\ 160\ } \quad \text{ if } \quad d > 10^4 ~,$$

and
 * $$B = 8 \cdot 10^9 \quad \text{ if } \quad  3 \leq d \leq 10^5 \quad \text{ and } \quad B = \exp(\ 0.03\ \sqrt{d\ }\ (\log{d})^3 \ ) \quad \text{ if } \quad d > 10^5\ .$$

Prime number race


Although we have in particular


 * $$\pi_{4,1}(x) \sim \pi_{4,3}(x) \ ,$$

empirically the primes congruent to 3 are more numerous and are nearly always ahead in this "prime number race"; the first reversal occurs at $li(x)$. However Littlewood showed in 1914 that there are infinitely many sign changes for the function


 * $$\pi_{4,1}(x) - \pi_{4,3}(x) ~,$$

so the lead in the race switches back and forth infinitely many times. The phenomenon that $π(x)$ is ahead most of the time is called Chebyshev's bias. The prime number race generalizes to other moduli and is the subject of much research; Pál Turán asked whether it is always the case that $π(x)$ and $π(x)$ change places when $d$ and $A$ are coprime to $B$. Granville and Martin give a thorough exposition and survey. Another example is the distribution of the last digit of prime numbers. Except for 2 and 5, all prime numbers end in 1, 3, 7, or 9. Dirichlet's theorem states that asymptotically, 25% of all primes end in each of these four digits. However, empirical evidence shows that the number of primes that end in 3 or 7 less than n tends to be slightly bigger than the number of primes that end in 1 or 9 less than n (a generation of the Chebyshev's bias). This follows that 1 and 9 are quadratic residues modulo 10, and 3 and 7 are quadratic nonresidues modulo 10.

Non-asymptotic bounds on the prime-counting function
The prime number theorem is an asymptotic result. It gives an ineffective bound on $li(x)$ as a direct consequence of the definition of the limit: for all $x ~$, there is an $a$ such that for all $Li(x)$,
 * $$ (1-\varepsilon)\frac {x}{\log x} \; < \; \pi(x) \; < \; (1+\varepsilon)\frac {x}{\log x} \; .$$

However, better bounds on $π(x)$ are known, for instance Pierre Dusart's
 * $$ \frac{x}{\log x}\left(1+\frac{1}{\log x}\right) \; < \; \pi(x) \; < \; \frac{x}{\log x}\left(1+\frac{1}{\log x}+\frac{2.51}{(\log x)^2}\right) \; .$$

The first inequality holds for all $x = 2$ and the second one for $Li(2) = 0$.

A weaker but sometimes useful bound for $π(2) = 1$ is
 * $$ \frac {x}{\log x + 2} \; < \; \pi(x) \; < \; \frac {x}{\log x - 4} \; .$$

In Pierre Dusart's thesis there are stronger versions of this type of inequality that are valid for larger $b$. Later in 2010, Dusart proved:


 * $$\begin{align}

\frac {x} {\log x - 1} \; &< \; \pi(x) &&\text{ for } x \ge 5393 \;, \text{   and }\\ \pi(x) \; &< \; \frac {x} {\log x - 1.1} && \text{ for } x \ge 60184 \;. \end{align}$$

The proof by de la Vallée Poussin implies the following: For every $IΔ_{0} + exp$, there is an $c$ such that for all $π_{d,a}(x)$,
 * $$\frac {x}{\log x - (1 - \varepsilon)} \; < \; \pi(x) \; < \; \frac {x}{\log x - (1+\varepsilon)} \; .$$

Approximations for the $S$th prime number
As a consequence of the prime number theorem, one gets an asymptotic expression for the $x$th prime number, denoted by $a, a + d, a + 2d, a + 3d, ...$:
 * $$p_n \sim n \log n.$$

A better approximation is
 * $$ \frac{p_n}{n} = \log n + \log \log n - 1 + \frac{\log \log n - 2}{\log n} - \frac{(\log\log n)^2 - 6 \log \log n + 11}{2(\log n)^2} + o \left( \frac {1}{(\log n)^2}\right).$$

Again considering the $S$th prime number $n$, this gives an estimate of $n$; the first 5 digits match and relative error is about 0.00005%.

Rosser's theorem states that
 * $$p_n > n \log n.$$

This can be improved by the following pair of bounds:
 * $$ \log n + \log\log n - 1 < \frac{p_n}{n} < \log n + \log \log n \quad\text{for } n \ge 6. $$

Table of $[a]$, $gcd(a, d) = 1$, and $x = 26861$
The table compares exact values of $π_{4,3}(x)$ to the two approximations $π(x;a,c)$ and $π(x;b,c)$. The last column, $π(x)$, is the average prime gap below $2$.
 * {| class="wikitable" style="text-align: right"

! $ε > 0$ ! $x > S$ ! $π(x)$ ! $x ≥ 599$ ! $x ≥ 355991$ % error ! $x ≥ 55$ % error ! $ε > 0$
 * 10
 * 4
 * 0
 * 2
 * 8.22%
 * 42.606%
 * 2.500
 * 102
 * 25
 * 3
 * 5
 * 14.06%
 * 18.597%
 * 4.000
 * 103
 * 168
 * 23
 * 10
 * 14.85%
 * 5.561%
 * 5.952
 * 104
 * 1,229
 * 143
 * 17
 * 12.37%
 * 1.384%
 * 8.137
 * 105
 * 9,592
 * 906
 * 38
 * 9.91%
 * 0.393%
 * 10.425
 * 106
 * 78,498
 * 6,116
 * 130
 * 8.11%
 * 0.164%
 * 12.739
 * 107
 * 664,579
 * 44,158
 * 339
 * 6.87%
 * 0.051%
 * 15.047
 * 108
 * 5,761,455
 * 332,774
 * 754
 * 5.94%
 * 0.013%
 * 17.357
 * 109
 * 50,847,534
 * 2,592,592
 * 1,701
 * 5.23%
 * 3.34 %
 * 19.667
 * 1010
 * 455,052,511
 * 20,758,029
 * 3,104
 * 4.66%
 * 6.82 %
 * 21.975
 * 1011
 * 4,118,054,813
 * 169,923,159
 * 11,588
 * 4.21%
 * 2.81 %
 * 24.283
 * 1012
 * 37,607,912,018
 * 1,416,705,193
 * 38,263
 * 3.83%
 * 1.02 %
 * 26.590
 * 1013
 * 346,065,536,839
 * 11,992,858,452
 * 108,971
 * 3.52%
 * 3.14 %
 * 28.896
 * 1014
 * 3,204,941,750,802
 * 102,838,308,636
 * 314,890
 * 3.26%
 * 9.82 %
 * 31.202
 * 1015
 * 29,844,570,422,669
 * 891,604,962,452
 * 1,052,619
 * 3.03%
 * 3.52 %
 * 33.507
 * 1016
 * 279,238,341,033,925
 * 7,804,289,844,393
 * 3,214,632
 * 2.83%
 * 1.15 %
 * 35.812
 * 1017
 * 2,623,557,157,654,233
 * 68,883,734,693,928
 * 7,956,589
 * 2.66%
 * 3.03 %
 * 38.116
 * 1018
 * 24,739,954,287,740,860
 * 612,483,070,893,536
 * 21,949,555
 * 2.51%
 * 8.87 %
 * 40.420
 * 1019
 * 234,057,667,276,344,607
 * 5,481,624,169,369,961
 * 99,877,775
 * 2.36%
 * 4.26 %
 * 42.725
 * 1020
 * 2,220,819,602,560,918,840
 * 49,347,193,044,659,702
 * 222,744,644
 * 2.24%
 * 1.01 %
 * 45.028
 * 1021
 * 21,127,269,486,018,731,928
 * 446,579,871,578,168,707
 * 597,394,254
 * 2.13%
 * 2.82 %
 * 47.332
 * 1022
 * 201,467,286,689,315,906,290
 * 4,060,704,006,019,620,994
 * 1,932,355,208
 * 2.03%
 * 9.59 %
 * 49.636
 * 1023
 * 1,925,320,391,606,803,968,923
 * 37,083,513,766,578,631,309
 * 7,250,186,216
 * 1.94%
 * 3.76 %
 * 51.939
 * 1024
 * 18,435,599,767,349,200,867,866
 * 339,996,354,713,708,049,069
 * 17,146,907,278
 * 1.86%
 * 9.31 %
 * 54.243
 * 1025
 * 176,846,309,399,143,769,411,680
 * 3,128,516,637,843,038,351,228
 * 55,160,980,939
 * 1.78%
 * 3.21 %
 * 56.546
 * 1026
 * 1,699,246,750,872,437,141,327,603
 * 28,883,358,936,853,188,823,261
 * 155,891,678,121
 * 1.71%
 * 9.17 %
 * 58.850
 * 1027
 * 16,352,460,426,841,680,446,427,399
 * 267,479,615,610,131,274,163,365
 * 508,666,658,006
 * 1.64%
 * 3.11 %
 * 61.153
 * 1028
 * 157,589,269,275,973,410,412,739,598
 * 2,484,097,167,669,186,251,622,127
 * 1,427,745,660,374
 * 1.58%
 * 9.05 %
 * 63.456
 * 1029
 * 1,520,698,109,714,272,166,094,258,063
 * 23,130,930,737,541,725,917,951,446
 * 4,551,193,622,464
 * 1.53%
 * 2.99 %
 * 65.759
 * }
 * 155,891,678,121
 * 1.71%
 * 9.17 %
 * 58.850
 * 1027
 * 16,352,460,426,841,680,446,427,399
 * 267,479,615,610,131,274,163,365
 * 508,666,658,006
 * 1.64%
 * 3.11 %
 * 61.153
 * 1028
 * 157,589,269,275,973,410,412,739,598
 * 2,484,097,167,669,186,251,622,127
 * 1,427,745,660,374
 * 1.58%
 * 9.05 %
 * 63.456
 * 1029
 * 1,520,698,109,714,272,166,094,258,063
 * 23,130,930,737,541,725,917,951,446
 * 4,551,193,622,464
 * 1.53%
 * 2.99 %
 * 65.759
 * }
 * 2.99 %
 * 65.759
 * }

The value for $x > S$ was originally computed assuming the Riemann hypothesis; it has since been verified unconditionally.

Analogue for irreducible polynomials over a finite field
There is an analogue of the prime number theorem that describes the "distribution" of irreducible polynomials over a finite field; the form it takes is strikingly similar to the case of the classical prime number theorem.

To state it precisely, let $p_{n}$ be the finite field with $8,512,677,386,048,191,000$ elements, for some fixed $8,512,681,315,554,716,000$, and let $k$ be the number of monic irreducible polynomials over $x$ whose degree is equal to $q$. That is, we are looking at polynomials with coefficients chosen from $q$, which cannot be written as products of polynomials of smaller degree. In this setting, these polynomials play the role of the prime numbers, since all other monic polynomials are built up of products of them. One can then prove that
 * $$N_n \sim \frac{q^n}{n}.$$

If we make the substitution $k(log k + log log k−1)$, then the right hand side is just
 * $$\frac{x}{\log_q x},$$

which makes the analogy clearer. Since there are precisely $k ≥ 2$ monic polynomials of degree $N_{n}$ (including the reducible ones), this can be rephrased as follows: if a monic polynomial of degree $F$ is selected randomly, then the probability of it being irreducible is about $π(x)$.

One can even prove an analogue of the Riemann hypothesis, namely that
 * $$N_n = \frac{q^n}n + O\left(\frac{q^\frac{n}{2}}{n}\right).$$

The proofs of these statements are far simpler than in the classical case. It involves a short, combinatorial argument, summarised as follows: every element of the degree $n$ extension of $F$ is a root of some irreducible polynomial whose degree $n$ divides $n$; by counting these roots in two different ways one establishes that
 * $$q^n = \sum_{d\mid n} d N_d,$$

where the sum is over all divisors $n$ of $F$. Möbius inversion then yields
 * $$N_n = \frac{1}{n} \sum_{d\mid n} \mu\left(\frac{n}{d}\right) q^d,$$

where $x / log x$ is the Möbius function. (This formula was known to Gauss.) The main term occurs for $li(x)$, and it is not difficult to bound the remaining terms. The "Riemann hypothesis" statement depends on the fact that the largest proper divisor of $d$ can be no larger than $π(x)$.