Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

October 24, 2026

Counting Primes

Posted by John Baez

Since the probability that a number nn is prime is roughly 1/logn1/\log n, the number of primes ≤x\le x is close to

li(x)=∫ 0 xdslogs \mathrm{li}(x) = \int_0^x \frac{d s}{\log s}

Indeed, if π(x)\pi(x) is the number of primes ≤x\le x, the recently proved quasi-Riemann hypothesis implies

|li(x)−π(x)|≤Cx p |\mathrm{li}(x) - \pi(x)| \le C x^p

for some constants C>0C \gt 0 and p<1p \lt 1. If the Riemann hypothesis is true, any p>1/2p \gt 1/2 will do.

But here’s what I want to talk about today. For all xx where π(x)\pi(x) can actually be counted, π(x)<li(x)\pi(x) &lt; \mathrm{li}(x). But in 1914, Littlewood shocked the world by sketching a proof that π(x)−li(x)\pi(x) - \mathrm{li}(x) changes sign infinitely often!

I want to explain how that eventually led to a graph that shows an explicit region where π(x)\pi(x) exceeds li(x)\mathrm{li}(x).

Littlewood’s proof didn’t say when π(x)\pi(x) first exceeds li(x)\mathrm{li}(x). He gave his student Stanley Skewes the task of figuring that out.

In 1933, Skewes gave an enormous upper bound for where this first happens, assuming the Riemann hypothesis:

e e e 79≈10 10 10 34 e^{e^{e^{79}}} \approx 10^{10^{10^{34}}}

This is called Skewes’ number. Hardy called it “the largest number which has ever served any definite purpose in mathematics”. In 1955, still working on his advisor’s assignment, Skewes gave an even larger upper bound not assuming the Riemann hypothesis:

e e e e 7.705≈10 10 10 964 e^{e^{e^{e^{7.705}}}} \approx 10^{10^{10^{964}}}

This disgustingly large quantity is called the second Skewes number.

I first read about Skewes’ number as a kid in The Guinness Book of World Records. It always intrigued me, but I never tried to understand the math involved, because I figured it would be too hard. This article is my attempt to finally make some progress.

In 1966, Lehman found a trick that lowered Skewes’ bound to about 1.65×10 11651.65 \times 10^{1165}. In 1987, te Riele brought it down to a mere 6.66×10 3706.66 \times 10^{370}.

In 2000, Bays and Hudson went further. They proved that there are at least 10 15310^{153} integers xx near 1.39822×10 3161.39822 \times 10^{316} with π(x)>li(x)\pi(x) &gt; \mathrm{li}(x). Their paper includes many fascinating graphs—but the printing is of very poor quality, unpleasant to look at. I think the world deserves better pictures of their amazing result, so yesterday I decided to redo their work with the help of AI.

To draw these graphs we need to use Riemann’s explicit formula for π(x)\pi(x) as a sum over zeros of the Riemann zeta function. My calculations use twice as many zeros as Bays and Hudson had access to, but the computation now takes only a couple of seconds on a laptop. Here is my version of their Figure 2b:

Narrow window: blue and red curves of (pi(x) − li(x)) log x / sqrt(2) for x from 1.3977 to 1.3989 times 10^316

Bays and Hudson’s proof does not depend on the Riemann hypothesis, nor do the later proofs mentioned below. Their graphs are another matter—and the same is true for the graphs here. It’s hard to get a really precise approximation to π(x)\pi(x) for huge numbers xx without using the Riemann hypothesis, since our best formula for it is a sum over zeros of the Riemann zeta function, and even a single zero off the critical line Re(z)=12\mathrm{Re}(z) = \frac{1}{2} could have a big effect. However, a smoothed version of π(x)\pi(x) is much less sensitive to this problem.

The red curves in my graphs are smoothed. Since they go above zero for 10 31110^{311} integers near 1.39822×10 3161.39822 \times 10^{316}, and they go sufficiently high, Bays and Hudson were able to prove that π(x)>li(x)\pi(x) &gt; \mathrm{li}(x) for some xx near this number. On the other hand, the blue curve is not deliberately smoothed. Its calculation assumes the Riemann hypothesis, and could change substantially if that was wrong! There could also be other problems, as I’ll explain. But it’s probably close to correct if the Riemann hypothesis holds.

Intriguingly, π(x)−li(x)\pi(x) - \mathrm{li}(x) also becomes positive for some slightly smaller numbers, in a region around 1.39717×10 3161.39717 \times 10^{316}. Patrick Demichel spotted this region, Saouter and Demichel proved it exists in 2010, and Saouter, Trudgian and Demichel pinned it down more sharply in 2015. Here is a wider view that also includes their region. See the sharp spike in the blue curve?

Wider view: the same curves for x from 1.3955 to 1.3995 times 10^316

What is plotted

Nobody can compute π(x)\pi(x) exactly for numbers so large as 10 31610^{316}. What we can compute is an approximation coming from Riemann’s explicit formula, which expresses π(x)−li(x)\pi(x) - \mathrm{li}(x) as a sum over the nontrivial zeros ρ=12+iγ\rho = \tfrac12 + i\gamma of the zeta function. Assume the Riemann hypothesis, so γ\gamma is real. Write u=logxu = \log x and measure π(x)−li(x)\pi(x) - \mathrm{li}(x) in units of x/logx\sqrt{x} / \log x:

D(u):=(π(x)−li(x))logxx≈−(1+2u+8u 2)−2∑ 0<γ≤TRe[e iγuρ(1+1ρu)] D(u) := \bigl(\pi(x) - \mathrm{li}(x)\bigr)\,\frac{\log x}{\sqrt{x}} \;\approx\; -\Bigl(1 + \frac{2}{u} + \frac{8}{u^2}\Bigr) \;-\; 2\sum_{0\lt \gamma\le T} \mathrm{Re}\!\left[\frac{e^{i\gamma u}}{\rho}\Bigl(1 + \frac{1}{\rho u}\Bigr)\right]

The symbol ≈\approx hides several approximations of quite different kinds; the section “What is rigorous and what is not” explains exactly what it means. The term

−(1+2/u+8/u 2) &#8722;(1 + 2/u + 8/u^2)

comes from the squares of primes: π(x)\pi(x) counts primes, but the explicit formula naturally counts prime powers, and correcting for squares gives this term. This term is why π(x)−li(x)\pi(x) - \mathrm{li}(x) is usually negative, by about x/logx\sqrt{x} / \log x. Higher powers of primes give extra corrections that are negligible when xx is huge.

More interesting is the sum over zeros: each zero contributes an oscillation in D(u)D(u) with frequency γ\gamma and amplitude roughly 1/γ1/\gamma. These oscillations are the key: π(x)−li(x)\pi(x) - \mathrm{li}(x) becomes positive only when enough of these oscillations get in phase and add up to a positive number bigger than 1! Or more precisely, bigger than

1+2/u+8/u 2 1 + 2/u + 8/u^2

On the graphs, D>0D &gt; 0 means π(x)>li(x)\pi(x) &gt; \mathrm{li}(x), and the vertical axis is in units of x/logx\sqrt{x} / \log x, which is about 10 15510^{155} near x=10 316x = 10^{316}. Each graph shows two curves:

  • Blue: the sum over the first 2,001,052 zeros, with no smoothing. This approximates D(u)D(u) point by point. Leaving out the higher zeros causes an error of roughly ±0.002\pm 0.002 in these units, assuming the omitted terms behave like random noise.
  • Red: the choice Bays and Hudson made. It uses the first 10 610^6 zeros, each damped by a factor exp(−γ 2/2α)\exp(-\gamma^2/2\alpha) with α=10 10\alpha = 10^{10}. This is a Gaussian average of D(u)D(u) over a width of about 10 −510^{-5} in logx\log x, which is the quantity Lehman’s trick from 1966 controls rigorously.

Data and computation

The graphs here were made with a short Python program, skewes_window.py, using the NumPy, mpmath, Matplotlib and FINUFFT libraries.

The Riemann zeta zeros come from a table computed by Andrew Odlyzko: the first 2,001,052 zeros, accurate to within 4×10 −94 \times 10^{-9}. Back in 2000, Bays and Hudson needed a personal favor from Odlyzko to get a million zeros. Today the same table is a free download, and it is even packaged on PyPI as passagemath-database-odlyzko-zeta.

Each point on any curve in the graphs here is a sum of one or two million sine waves. Summing directly at 8000 points would take about 10 1010^{10} operations. Instead the program uses a nonuniform fast Fourier transform from the FINUFFT library, which finishes in about a second on one core. Two precautions matter: the program never forms xx itself, only u=logxu = \log x, and it computes each phase γu\gamma u modulo 2π2\pi carefully, because γu\gamma u reaches about 10 910^9.

Three graphs

Narrow window, 1.39771.3977-1.3989×10 3161.3989 \times 10^{316}. This graph shows our estimate of (π(x)−li(x))⋅logx/x(\pi(x) - \mathrm{li}(x)) \cdot \log x / \sqrt{x} for xx between 1.3977×10 3161.3977 \times 10^{316} and 1.3989×10 3161.3989 \times 10^{316}.

Narrow window: blue and red curves of (pi(x) − li(x)) log x / sqrt(x) for x from 1.3977 to 1.3989 times 10^316

This is the same range as Figure 2b in Bays and Hudson’s paper. The region they proved positive is the green hump near 1.39822×10 3161.39822 \times 10^{316}. DD usually hovers around −1-1, but throughout this window the low zeros happen to be nearly in phase, lifting it close to zero. Even so it is a narrow escape: the blue curve rises only about 0.017 above zero. The red curve peaks at about +0.010+0.010, which is what lets Lehman’s theorem prove that π(x)>li(x)\pi(x) &gt; \mathrm{li}(x) somewhere in this region. Two smaller bumps of the blue curve, near 1.3981 and 1.3983, barely cross zero; they are about as big as the truncation error, so they could be artifacts.

Narrower window, 1.39801.3980-1.3984×10 3161.3984 \times 10^{316}.

This is just a piece of the previous graph, to make the green hump more visible.

Wider view, 1.39551.3955-1.3995×10 3161.3995 \times 10^{316}. This zooms out to show what lies just to the left.

Wider view: the same curves for x from 1.3955 to 1.3995 times 10^316

The thin spike at about 1.39717×10 3161.39717 \times 10^{316} is a second positive region, found after Bays and Hudson. Saouter and Demichel proved π(x)>li(x)\pi(x) &gt; \mathrm{li}(x) there in 2010, and Saouter, Trudgian and Demichel later narrowed it to an interval centered at logx=727.951335426\log x = 727.951335426. In this graph the blue curve rises only about 0.0018 above zero at that spike. That is no larger than the error from using only two million zeros, so this graph alone could not prove the spike is positive. Their proof used about 5×10 85 \times 10^8 zeros. The red curve, smoothed too heavily to see so narrow a spike, stays below zero there.

What is rigorous and what is not

The red curve could be given rigorous error bars; the blue curve cannot, and π(x)−li(x)\pi(x) - \mathrm{li}(x) itself, point by point, is out of reach near 10 31610^{316}.

Where the formula comes from. The starting point is Riemann’s explicit formula for his prime-power counting function J(x)=∑ p k≤x1/kJ(x) = \sum_{p^k \le x} 1/k. For x>1x &gt; 1 it says

J(x)=li(x)−∑ ρli(x ρ)−log2+∫ x ∞dtt(t 2−1)logt J(x) = \mathrm{li}(x) - \sum_\rho \mathrm{li}(x^\rho) - \log 2 + \int_x^\infty \frac{d t}{t(t^2-1)\log t}

where the sum over zeros converges only conditionally and must be taken in order of increasing |γ||\gamma|. Proofs are in the books of Edwards and Ingham. Möbius inversion gives π(x)=∑ nμ(n)J(x 1/n)/n\pi(x) = \sum_n \mu(n) J(x^{1/n})/n, so

π(x)−li(x)=−12li(x)−∑ ρli(x ρ)+(smaller terms). \pi(x) - \mathrm{li}(x) = -\tfrac12 \mathrm{li}(\sqrt{x}) - \sum_\rho \mathrm{li}(x^\rho) + (\text{smaller terms}).

Expanding li(x)=(2x/u)(1+2/u+8/u 2+⋯)\mathrm{li}(\sqrt{x}) = (2\sqrt{x}/u)(1 + 2/u + 8/u^2 + \cdots) and li(x ρ)=Ei(ρu)=(x ρ/(ρu))(1+1/(ρu)+⋯)\mathrm{li}(x^\rho) = \mathrm{Ei}(\rho u) = (x^\rho/(\rho u))(1 + 1/(\rho u) + \cdots), multiplying by u/xu/\sqrt{x}, and pairing each zero with its complex conjugate gives the formula for D(u)D(u). Apart from the 1/(ρu)1/(\rho u) correction and the Gaussian damping, this is the function g(x)g(x) in Table 1 of Bays and Hudson.

What the ≈\approx means. Three separate approximations are involved, and they are very different in character.

  1. Dropped smaller terms. These come from x 1/3x^{1/3} and higher roots, the constants, and the zero sum belonging to J(x)J(\sqrt{x}). Assuming the Riemann hypothesis, they are smaller than the terms kept by factors like x −1/4log 2xx^{-1/4} \log^2 x, which is about 10 −7610^{-76} near 10 31610^{316}. Rigorous bounds for them are routine.
  2. Truncated asymptotic expansions. The first omitted prime-square term is about 48/u 3≈10 −748/u^3 \approx 10^{-7}. The error in expanding each li(x ρ)\mathrm{li}(x^\rho) is of order 1/(γ 3u 2)1/(\gamma^3 u^2), negligible even when summed over all zeros. This step too can be made rigorous with explicit remainder bounds.
  3. Stopping the sum at the 2,001,052nd zero. This is the step that could cause trouble. The best known rigorous bounds for truncating Riemann’s explicit formula at zeros of height TT give an error of order xlog 2(xT)/Tx \log^2(xT)/T. Making that smaller than x/logx\sqrt{x}/\log x would need TT of roughly xlog 2x\sqrt{x} \log^2 x, around 10 15810^{158} here, while the 2,001,052nd zero only has height T≈1.1×10 6T \approx 1.1 \times 10^6.

What can we do about the problem in item 3? Assuming the Riemann hypothesis, D(u)D(u) is an almost periodic function of uu, which is the setting Rubinstein and Sarnak use. A Parseval identity for such functions should then give the long-run mean square of the omitted tail as about ∑ γ>T2/|ρ| 2≈(0.002) 2\sum_{\gamma &gt; T} 2/|\rho|^2 \approx (0.002)^2. That is a statement about averages over very long stretches of uu. It does not bound the error at any particular point, or even the average error across our window. But we can say ±0.002\pm 0.002 is the typical error at each point of the blue curve if the omitted terms in the sum over zeta zeros act like random noise. This is just a heuristic, though it’s been checked at x=10 20x = 10^{20}. So the blue curve is just a good guess, not something proved.

The smoothed curve. Every positive region found so far was proved using a theorem of Lehman (1966), stated as Theorem 1 in Bays and Hudson’s paper. Instead of trying to pin down π(x)−li(x)\pi(x) - \mathrm{li}(x) at a single point, Lehman’s theorem handles a weighted average of it: the average of D(u)D(u) against a Gaussian bump of width 1/α1/\sqrt{\alpha} centred at some point ω\omega. The theorem says this average equals −1-1 minus a sum over the zeros, with each zero damped by a factor e −γ 2/2αe^{-\gamma^2/2\alpha}, plus an error term with explicit bounds that hold for every ω\omega. The red curve is essentially this damped sum, plotted as a function of ω\omega. The key point is that an average can only be positive if the function being averaged is positive somewhere. So if the damped sum is above zero by more than the largest possible error at some ω\omega, then π(x)>li(x)\pi(x) &gt; \mathrm{li}(x) for some xx with logx\log x near ω\omega. Bays and Hudson proved their result this way, and later authors used refined versions of the same theorem.

The smoothing is what gives this approach its teeth. The damping makes the contribution of the omitted zeros decay like e −T 2/2αe^{-T^2/2\alpha}, so stopping at height TT costs almost nothing. With these parameters the total error is a few thousandths. So one could draw an upper and a lower curve that provably bracket the smoothed function. Wherever the lower curve is above zero, π(x)>li(x)\pi(x) &gt; \mathrm{li}(x) somewhere nearby.

This holds without assuming the Riemann hypothesis. Lehman’s theorem needs the Riemann hypothesis only up to a finite height, which has been verified: Platt and Trudgian have now checked it up to height 3×10 123 \times 10^{12}. Any hypothetical zeros off the critical line beyond that height are covered by an extra error term, which the Gaussian smoothing makes harmless. For Bays and Hudson’s parameters this term is smaller than 10 −200110^{-2001}. So the positive regions near 1.39822×10 3161.39822 \times 10^{316} and 1.39717×10 3161.39717 \times 10^{316} are established unconditionally.

The method is one-sided, though. It can prove that crossings exist, but a negative average says nothing about a narrow positive spike hiding inside it.

Earlier crossings. Bays and Hudson observe (p. 1287) that current knowledge cannot rule out sign changes of π(x)−li(x)\pi(x) - \mathrm{li}(x) over gaps as large as 10 30010^{300} near 10 31610^{316}. For the same reason, nobody can currently rule out a crossing somewhere below 1.397×10 3161.397 \times 10^{316}. Bays and Hudson thought none is likely. Their Figure 1 marks near-misses around 10 17610^{176}, 10 17910^{179}, 10 19010^{190}, 10 26010^{260} and 10 29810^{298}. Rigorously, it is known only that π(x)<li(x)\pi(x) &lt; \mathrm{li}(x) for all x≤10 19x \le 10^{19}. So between 10 1910^{19} and about 1.397×10 3161.397 \times 10^{316} the question remains open!

In 2025, Michel and Rivers listed some places in this enormous interval where π(x)\pi(x) might get bigger than li(x)\mathrm{li}(x). If you want to contribute to this fascinating story, and you enjoy heavy-duty computations, you could look at those places. You may need a big table of Riemann zeta zeros.

References

The main papers

The explicit formula and its approximations

  • Davenport, Harold. Multiplicative Number Theory. 3rd ed. Revised by Hugh L. Montgomery. New York: Springer, 2000. Ch. 17.
  • Edwards, H. M. Riemann’s Zeta Function. New York: Academic Press, 1974.
  • Ingham, A. E. The Distribution of Prime Numbers. Cambridge: Cambridge University Press, 1932. Reprint, 1990.
  • Rubinstein, Michael, and Peter Sarnak. Chebyshev’s bias. Experimental Mathematics 3, no. 3 (1994): 173–97.

Historical background

  • Littlewood, J. E. Sur la distribution des nombres premiers. Comptes Rendus de l’Académie des Sciences, Paris 158 (1914): 1869–72.
  • Skewes, S. On the difference π(x)−li(x)\pi(x) - \mathrm{li}(x). Journal of the London Mathematical Society 8, no. 4 (1933): 277–83. https://doi.org/10.1112/jlms/s1-8.4.277.
  • Skewes, S. On the difference π(x)−li(x)\pi(x) - \mathrm{li}(x), II. Proceedings of the London Mathematical Society, 3rd ser., 5, no. 1 (1955): 48–70. https://doi.org/10.1112/plms/s3-5.1.48.
  • Skewes’s number. Wikipedia.

Data and software

Posted at October 24, 2026 5:05 PM UTC

TrackBack URL for this Entry:   https://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/3643

0 Comments & 0 Trackbacks

Post a New Comment