This article uses technical mathematical notation for logarithms. All instances oflog(x) without a subscript base should be interpreted as anatural logarithm, also commonly written asln(x) orloge(x).
A symmetric variant seen sometimes isπ0(x), which is equal toπ(x) −1⁄2 ifx is exactly a prime number, and equal toπ(x) otherwise. That is, the number of prime numbers less thanx, plus half ifx equals a prime.
More precise estimates ofπ(x) are now known. For example, in 2002,Kevin Ford proved that[7]
Mossinghoff andTrudgian proved[8] an explicit upper bound for the difference betweenπ(x) andli(x):
For values ofx that are not unreasonably large,li(x) is greater thanπ(x). However,π(x) − li(x) is known to change sign infinitely many times. For a discussion of this, seeSkewes' number.
Riemann's explicit formula using the first 200 non-trivial zeros of the zeta function
whereμ(n) is theMöbius function,li(x) is thelogarithmic integral function,ρ indexes every zero of the Riemann zeta function, andli(xρ/n) is not evaluated with abranch cut but instead considered asEi(ρ/n logx) whereEi(x) is theexponential integral. If the trivial zeros are collected and the sum is takenonly over the non-trivial zerosρ of the Riemann zeta function, thenπ0(x) may be approximated by[10]
TheRiemann hypothesis suggests that every such non-trivial zero lies alongRe(s) =1/2.
The table shows how the three functionsπ(x),x/logx, andli(x) compared at powers of 10. See also,[3][11] and[12]
x
π(x)
π(x) −x/logx
li(x) −π(x)
x/π(x)
x/logx % error
10
4
0
2
2.500
−8.57%
102
25
3
5
4.000
+13.14%
103
168
23
10
5.952
+13.83%
104
1,229
143
17
8.137
+11.66%
105
9,592
906
38
10.425
+9.45%
106
78,498
6,116
130
12.739
+7.79%
107
664,579
44,158
339
15.047
+6.64%
108
5,761,455
332,774
754
17.357
+5.78%
109
50,847,534
2,592,592
1,701
19.667
+5.10%
1010
455,052,511
20,758,029
3,104
21.975
+4.56%
1011
4,118,054,813
169,923,159
11,588
24.283
+4.13%
1012
37,607,912,018
1,416,705,193
38,263
26.590
+3.77%
1013
346,065,536,839
11,992,858,452
108,971
28.896
+3.47%
1014
3,204,941,750,802
102,838,308,636
314,890
31.202
+3.21%
1015
29,844,570,422,669
891,604,962,452
1,052,619
33.507
+2.99%
1016
279,238,341,033,925
7,804,289,844,393
3,214,632
35.812
+2.79%
1017
2,623,557,157,654,233
68,883,734,693,928
7,956,589
38.116
+2.63%
1018
24,739,954,287,740,860
612,483,070,893,536
21,949,555
40.420
+2.48%
1019
234,057,667,276,344,607
5,481,624,169,369,961
99,877,775
42.725
+2.34%
1020
2,220,819,602,560,918,840
49,347,193,044,659,702
222,744,644
45.028
+2.22%
1021
21,127,269,486,018,731,928
446,579,871,578,168,707
597,394,254
47.332
+2.11%
1022
201,467,286,689,315,906,290
4,060,704,006,019,620,994
1,932,355,208
49.636
+2.02%
1023
1,925,320,391,606,803,968,923
37,083,513,766,578,631,309
7,250,186,216
51.939
+1.93%
1024
18,435,599,767,349,200,867,866
339,996,354,713,708,049,069
17,146,907,278
54.243
+1.84%
1025
176,846,309,399,143,769,411,680
3,128,516,637,843,038,351,228
55,160,980,939
56.546
+1.77%
1026
1,699,246,750,872,437,141,327,603
28,883,358,936,853,188,823,261
155,891,678,121
58.850
+1.70%
1027
16,352,460,426,841,680,446,427,399
267,479,615,610,131,274,163,365
508,666,658,006
61.153
+1.64%
1028
157,589,269,275,973,410,412,739,598
2,484,097,167,669,186,251,622,127
1,427,745,660,374
63.456
+1.58%
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
65.759
+1.52%
Graph showing ratio of the prime-counting functionπ(x) to two of its approximations,x/logx andLi(x). Asx increases (notex-axis is logarithmic), both ratios tend towards 1. The ratio forx/logx converges from above very slowly, while the ratio forLi(x) converges more quickly from below.
The value forπ(1024) was originally computed by J. Buethe,J. Franke, A. Jost, and T. Kleinjung assuming theRiemann hypothesis.[13]It was later verified unconditionally in a computation by D. J. Platt.[14]The value forπ(1025) is by the same four authors.[15] The value forπ(1026) was computed by D. B. Staple.[16] All other prior entries in this table were also verified as part of that work.
The values for 1027, 1028, and 1029 were announced by David Baugh and Kim Walisch in 2015,[17] 2020,[18] and 2022,[19] respectively.
A simple way to findπ(x), ifx is not too large, is to use thesieve of Eratosthenes to produce the primes less than or equal tox and then to count them.
A more elaborate way of findingπ(x) is due toLegendre (using theinclusion–exclusion principle): givenx, ifp1,p2,…,pn are distinct prime numbers, then the number of integers less than or equal tox which are divisible by nopi is
(where⌊x⌋ denotes thefloor function). This number is therefore equal to
when the numbersp1,p2,…,pn are the prime numbers less than or equal to the square root ofx.
In a series of articles published between 1870 and 1885,Ernst Meissel described (and used) a practical combinatorial way of evaluatingπ(x): Letp1,p2,…,pn be the firstn primes and denote byΦ(m,n) the number of natural numbers not greater thanm which are divisible by none of thepi for anyi ≤n. Then
Given a natural numberm, ifn =π(3√m) and ifμ =π(√m) −n, then
Using this approach, Meissel computedπ(x), forx equal to5×105, 106, 107, and 108.
In 1959,Derrick Henry Lehmer extended and simplified Meissel's method. Define, for realm and for natural numbersn andk,Pk(m,n) as the number of numbers not greater thanm with exactlyk prime factors, all greater thanpn. Furthermore, setP0(m,n) = 1. Then
where the sum actually has only finitely many nonzero terms. Lety denote an integer such that3√m ≤y ≤√m, and setn =π(y). ThenP1(m,n) =π(m) −n andPk(m,n) = 0 whenk ≥ 3. Therefore,
The computation ofP2(m,n) can be obtained this way:
where the sum is over prime numbers.
On the other hand, the computation ofΦ(m,n) can be done using the following rules:
Using his method and anIBM 701, Lehmer was able to compute the correct value ofπ(109) and missed the correct value ofπ(1010) by 1.[20]
Further improvements to this method were made by Lagarias, Miller, Odlyzko, Deléglise, and Rivat.[21]
Riemann's prime-power counting function is usually denoted asΠ0(x) orJ0(x). It has jumps of1/n at prime powerspn and it takes a value halfway between the two sides at the discontinuities ofπ(x). That added detail is used because the function may then be defined by an inverseMellin transform.
Formally, we may defineΠ0(x) by
where the variablep in each sum ranges over all primes within the specified limits.
Formulas for prime-counting functions come in two kinds: arithmetic formulas and analytic formulas. Analytic formulas for prime-counting were the first used to prove theprime number theorem. They stem from the work of Riemann andvon Mangoldt, and are generally known asexplicit formulae.[23]
Hereρ 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 ofx greater than one, which is the region of interest. The sum over the roots is conditionally convergent, and should be taken in order of increasing absolute value of the imaginary part. Note that the same sum over the trivial roots gives the lastsubtrahend in the formula.
ForΠ0(x) we have a more complicated formula
Again, the formula is valid forx > 1, whileρ are the nontrivial zeros of the zeta function ordered according to their absolute value. The first termli(x) is the usuallogarithmic integral function; the expressionli(xρ) in the second term should be considered asEi(ρ logx), whereEi is theanalytic continuation of theexponential integral function from negative reals to the complex plane with branch cut along the positive reals. The final integral is equal to the series over the trivial zeros:
is Riemann's R-function[24] andμ(n) is theMöbius function. The latter series for it is known asGram series.[25][26] Becauselogx <x for allx > 0, this series converges for all positivex by comparison with the series forex. The logarithm in the Gram series of the sum over the non-trivial zero contribution should be evaluated asρ logx and notlogxρ.
Folkmar Bornemann proved,[27] when assuming theconjecture that all zeros of the Riemann zeta function are simple,[note 1] that
whereρ runs over the non-trivial zeros of the Riemann zeta function andt > 0.
The sum over non-trivial zeta zeros in the formula forπ0(x) describes the fluctuations ofπ0(x) while the remaining terms give the "smooth" part of prime-counting function,[28] so one can use
as a good estimator ofπ(x) forx > 1. In fact, since the second term approaches 0 asx → ∞, while the amplitude of the "noisy" part is heuristically about√x/logx, estimatingπ(x) byR(x) alone is just as good, and fluctuations of thedistribution of primes may be clearly represented with the function
The left inequality holds forx ≥ 17 and the right inequality holds forx > 1. The constant 1.25506 is30log 113/113 to 5 decimal places, asπ(x)logx/x has its maximum value atx =p30 = 113.[30]
More recently, Dusart has proved[32](Theorem 5.1) that
forx ≥ 88789 andx > 1, respectively.
Going in the other direction, an approximation for thenth prime,pn, is
Here are some inequalities for thenth prime. The lower bound is due to Dusart (1999)[33] and the upper bound to Rosser (1941).[34]
The left inequality holds forn ≥ 2 and the right inequality holds forn ≥ 6. A variant form sometimes seen substitutes An even simpler lower bound is[35]
which holds for alln ≥ 1, but the lower bound above is tighter forn >ee ≈15.154.
In 2010 Dusart proved[31] (Propositions 6.7 and 6.6) that
forn ≥ 3 andn ≥ 688383, respectively.
In 2024, Axler[36] further tightened this (equations 1.12 and 1.13) using bounds of the form
proving that
forn ≥ 2 andn ≥ 3468, respectively.The lower bound may also be simplified tof(n,w2) without altering its validity. The upper bound may be tightened tof(n,w2 − 6w + 10.667) ifn ≥ 46254381.
There are additional bounds of varying complexity.[37][38][39]
^Riesel, Hans (1994).Prime Numbers and Computer Methods for Factorization. Progress in Mathematics. Vol. 126 (2nd ed.). Birkhäuser. pp. 50–51.ISBN0-8176-3743-5.