Section 21.3 The Prime Number Theorem
ΒΆSubsection 21.3.1 Stating the theorem
ΒΆTheorem 21.3.1. Prime Number Theorem.
If Ο(x) is the number of primes pβ€x, then
In fact, the first bound also has this property (see Exercise 21.5.6):
xxxxxxxxxx
def _(n=100):
P = plot(prime_pi,3,n, color='black',legend_label=r'$\pi(x)$')
P += plot(Li,3,n, color='green',legend_label='$Li(x)$')
P += plot(lambda x: Li(x) - sqrt(prime_pi(x)),3,n, color='orange', legend_label=r'$Li(x)-\sqrt{\pi(x)}$')
P += plot(lambda x: Li(x) - .5*Li(sqrt(x)),3,n, color='red', legend_label=r'$Li(x)-\frac{1}{2}Li(\sqrt{x})$')
P += plot(lambda x: Li(x) - sqrt(x)/log(x),3,n, color='purple', legend_label=r'$Li(x)-\sqrt{x}/\log(x)$')
show(P, xmin=max(n-1000,0), ymin=prime_pi(max(n-1000,0)))
Subsection 21.3.2 Chebyshev's contributions
ΒΆAlthough we cannot explore the theorem itself in depth, we can try to understand some of the intermediate steps. This is a good place to highlight the contributions of the great Russian mathematician Chebyshev (Π§Π΅Π±ΡΡΡΠ²), who made fundamental advances in this type of number theory as well as in statistics. He was the first person to prove a conjecture known (even today!) as Bertrand's Postulate, after the French mathematician who first proposed it.Theorem 21.3.2. Bertrand's Postulate.
For any integer nβ₯2, there is a prime between n and 2n.
Proof.
It is actually quite possible to prove this at the level we have reached, but any proof is long enough to take us a little far afield.
xxxxxxxxxx
def _(n=25):
pretty_print(html("$%s$ is a prime between $%s$ and $%s$"%(next_prime(n),n,2*n)))
Fact 21.3.3.
Multiply all the primes p from 2 to n+1 to get N=β2β€pβ€n+1p. Then we have n consecutive composite integers from Nβ(n+1) to Nβ2.
Proof.
We know that \(N\) is a multiple of a prime factorβ5βIn fact, all such factors. of each number \(x\) from \(2\) to \(n+1\text{.}\) For each such \(x\) and prime factor \(p_x\text{,}\) Proposition 1.2.8 guarantees that \(N-x\) is also a multiple of \(p_x\text{.}\)
xxxxxxxxxx
def _(n=5):
N = prod(prime_range(n+2))
pretty_print(html("The numbers between $%s$ and $%s$ are all composite"%(N-(n+1),N-2)))
L = [N-(n+1)..N-2]
print([N-(n+1)..N-2])
pretty_print(html("have factors"))
print([l.divisors()[1] for l in L])
pretty_print(html("and there are $%s$ of them"%(len(L))))
Theorem 21.3.4. Big Oh of Prime Pi.
It is true both that:
Ο(x) is O(xlog(x)) and
xlog(x) is O(Ο(x)).
Proposition 21.3.5.
For big enough x, Ο(x)<2xlog(x).
Proof.
We follow Stopple's presentation in Section 5.2 of [C.4.5] closely in sketching out most of a proof of this below; see also [C.2.11] for a very similar proof. It is a little longer than some of our other proofs. It uses some very basic combinatorial ideas and calculus facts, however, so it is a great example of several parts of mathematics coming together.
First, it's not hard to verify this for \(x<1000\text{,}\) as the following figure demonstrates.

Now we'll proceed by induction, in an unusual way. We'll assume it is true for \(n\text{,}\) and prove it is true for \(2n\text{.}\) This needs a little massaging for odd numbers, but is a legitimate induction method.
With this in mind, we first assume that \(\pi(n)<2\frac{n}{\log(n)}\text{.}\) Now what?
Below, in Lemma 21.3.7 we look at the product of all the primes (if any) between \(n\) and \(2n\text{,}\) which we write as
In that result some combinatorial thinking leads to the following estimate:
These bounds show that \(P\) is between a certain power of \(n\) and a certain power of \(2\text{.}\)
Now we will manipulate this to get the final result. Begin by taking \(\log\) of both ends to get
Now divide out and isolate to get
In Exercise 21.5.10 you will show that, as long as \(n> 1000\text{,}\) we have the inequality
Now we can put it all together to see that
which is exactly what the proposition would predict.
To rescue this for \(2n+1\text{,}\) we need another calculus comparison. First, from above we have
Since \(\frac{2n+1}{\log(2n+1)}>\frac{2n}{\log(2n+1)}\text{,}\) it will suffice then to show
Since \(n>1000\text{,}\)
so it suffices to show
Showing this is Exercise 21.5.11.
Lemma 21.3.7.
Let the product of all the primes between n and 2n be written
Then we can bound it as
Proof.
Think of all the primes in question. On the one hand, each of these primes \(p\) is greater than \(n\text{,}\) and there are \(\pi(2n)-\pi(n)\) of them. So
On the other hand, each of these primes is greater than \(n\) but they are all in the list of numbers from \(n\) to \(2n\text{,}\) so their product divides
That is to say \(P\) is a factor of a binomial coefficient
and in particular,
Now here is the conceptual key of the proof. We reinterpret this factorial fraction as the number of ways to choose \(n\) things from a collection of \(2n\) things! And the number of ways to choose \(n\) things is certainly less than the number of ways to pick any old collection out of \(2n\) things, which is \(2^{2n}\) (because you either pick it or you don't).
Since we showed both bounds, this concludes the proof.