In mathematics, the prime counting function is the function counting the number of prime numbers less than or equal to some real number x. It is denoted by (although it has no connection with the number π).
Of great interest in number theory is the growth rate of the prime counting function. It was conjectured in the end of the 18th century by Gauss and by Legendre to be approximately
in the sense that
This statement is the prime number theorem. An equivalent statement is
where li is the logarithmic integral function. This was first proved around 1896 by Hadamard and by de la Vallée Poussin (independently), using properties of the zeta function introduced by Riemann in 1859.
More precise estimates of are now known; for example
where the O is big O notation. Proofs of the prime number theorem not using the zeta function or complex analysis were found around 1948 by Atle Selberg and by Paul Erdős (for the most part independently).
Algorithms for evaluating π(x)
A simple way to find , if isn't too large, is to use the sieve of Eratosthenes to produce the primes smaller or equal to and then to count them.
A more elaborate way of finding is due to Legendre: given , if are distinct prime numbers, then the number of integers smaller or equal to which are divisible by no is
(where denotes the floor function). This number is therefore equal to
when the numbers are the prime numbers smaller or equal to .
In a series of articles published between 1870 and 1885, Ernst Meissel described (and used) a pratical combinatorial way of evaluating . Let be the first primes and denote by the number of natural numbers not greater than which are divisible by no . Then
Given a natural number , if and if , then
Using this approach, Meissel computed , for equal to 5×105, 106, 107, and 108.
In 1959, Derrick Henry Lehmer extended and simplified Meissel's method. Define, for real and for natural numbers n, and k, as the number of numbers not greater than m with exactly k prime factors, all greater than . Furthermore, set . Then
where the sum actually has only finitely many nonzero terms. Let denote an integer such that , and set . Then and when . Therefore
The computation of can be obtained this way:
On the other hand, the computation of can be done using the following rules:
Using his method and an IBM 701, Lehmer was able to compute .
Other prime counting functions
Other prime counting functions are also used because they are more convenient to work with. One is Riemann's prime counting function, denoted or . This has jumps of 1/n for prime powers pn, with it taking a value half-way between the two sides at discontinuities. That added detail is because then it may be defined by an inverse Mellin transform. Formally, we may define J by
where p is a prime.
We may also write
except where we have discontinuities at prime powers, and hence π can be recovered from J by Möbius inversion.
Another prime counting function weights prime powers pn by ln p:
Formulas for prime counting functions
These come in two kinds, arithmetic formulas and analytic formulas. The latter are what allow us to prove the prime number theorem. From the work of Riemann and von Mangoldt, we have the following expression for J:
Here Li is the offset logarithmic integral, and the ρ are the zeros of the Riemann zeta function in the critical strip, where the real part of ρ is between zero and one. The formula is valid for values of x greater than one, which is the region of interest, and the sum over the roots is conditionally convergent, and should be taken in order of increasing absolute value of the imaginary part.
For ψ we have a simpler formula, due to von Mangoldt:
Again, the formula is valid for x > 1.
Here are some useful inequalities for π(x).
- for x ≥ 17.
- for x > 1.
- for x ≥ 55.
Here are some inequalities for the nth prime, pn.
- for n ≥ 6.
The left inequality holds for n ≥ 1 and the right inequality holds for n ≥ 6.
An approximation for the nth prime number is
The Riemann hypothesis
The Riemann hypothesis is equivalent to a much sharper bound on the error in the estimate for , and hence to a more regular distribution of prime numbers,
- Eric Bach and Jeffrey Shallit, Algorithmic Number Theory, volume 1, 1996, MIT Press. ISBN 0-262-02405-5, see page 234 in section 8.8.
- Marc Deléglise and Jöel Rivat, Computing : The Meissel, Lehmer, Lagarias, Miller, Odlyzko method, Mathematics of Computation, vol. 65, number 33, January 1996, pages 235–245
- Leonard Eugene Dickson, History of the Theory of Numbers I: Divisibility and Primality, 2005, Dover Publications. ISBN 0-486-44232-2