Section 21.4 A Slice of the Prime Number Theorem
¶Subsection 21.4.1 Functions to know
¶First, we'll review the main function. Think of the prime counting function π as a so-called step function, where every time you hit a new prime you add 1. The picture reminds you of this attribute.

Definition 21.4.3.
We call the function given by this formula Chebyshev's theta function:
Θ(x)=∑p≤xlog(p).
Sage note 21.4.4. Python can do math too.
We include an interactive version so you can see the code.
xxxxxxxxxx
def theta(x): return sum(math.log(p) for p in prime_range(1,floor(x)+1))
def _(n=100):
show(plot(theta,1,n))
The syntax math.log
is referring to Python's builtin calculation of the natural logarithm, accessible in the math
module. This is sometimes faster and easier to use than Sage's more powerful capabilities, because if you put an integer in Sage's logarithm, it will normally not approximate it. All we want here is an easy approximation, so this should be faster.
limx→∞Θ(x)x=1
This is certainly numerically plausible. Here is a plot of both limits, along with the constant function 1.

xxxxxxxxxx
def theta(x): return sum(math.log(p) for p in prime_range(1,floor(x)+1))
def pnt(n): return prime_pi(n)*log(n)/n
def pntli(n): return prime_pi(n)/Li(n)
def thox(n): return theta(n)/n
def _(end=100000,PNT=['log','Li']):
P = plot(1,(1,end),color='black')
P += plot(thox,(1,end),legend_label='Chebyshev Theta')
if PNT == "log":
P += plot(pnt,(1,end),color='red',legend_label='Prime Number Theorem')
if PNT == "Li":
P += plot(pntli,(1,end),color='red',legend_label='Prime Number Theorem')
show(P)
Proposition 21.4.6.
If the Prime Number Theorem is true, then it is also true that Θ(x)/x approaches 1.
Proof.
The rest of this section is the proof.
Subsection 21.4.2 Getting a formula with sleights of hand
¶In order to prove this implication, we will first need a formula telling us more about Θ(x). Our strategy 6 This is an expansion of the terse approach taken in [C.4.6, Theorems 4.3 and 4.4]. will be to first turn Θ(x) into an even more hopelessly complicated sum, but then use calculus trickily to get something usable by summing up integrals. In order to do this, we need two subsidiary functions. First, recall the notation ⌊x⌋ for the greatest integer less than x. Secondly:Definition 21.4.7.
We let a(n) be the prime number indicator function defined by
a(n)={1 if n is prime0 otherwise .
Another way to say this is
a(n)=π(n)−π(n−1).

prime_pi(x)-prime_pi(x-1)
.
For convenience we write m=⌊x⌋. Then we can rewrite these step functions as weighted sums of a(n):
π(x)=m∑n=1a(n) and Θ(x)=m∑n=1a(n)log(n).
Our goal is to rearrange Θ to be a sum of terms involving π. First we turn Θ into a difference of sums by rearranging (and using log(1)=0):
Θ(x)=∑1≤n≤xa(n)log(n)=m∑n=1a(n)log(n)=
m∑n=2[π(n)−π(n−1)]log(n)=m∑n=2π(n)log(n)−m−1∑n=1π(n)log(n+1)
This difference of sums can be combined into a single sum, with just two left over terms 7 Students a little more familiar with calculus may want to compare this process to integration by parts, but in a discrete context, sometimes called Abel summation..
Θ(x)=m−1∑n=2π(n)[log(n)−log(n+1)]+π(m)log(m)−π(1)log(2).
To continue, we will rewrite almost all of this as single integral. We use a few key facts:
- The difference which appears in the the sum in the immediately preceding Θ formula can be considered as an integral, −(log(n+1)−log(n))=−∫n+1ndtt.
- We have that π(x) is constant on the interval [⌊x⌋,x], and in particular on any given interval [n,n+1), so it may be factored out of any integral from n to n+1.
- We can rearrange and add sums and integrals as usual.
- Note that π(1)=0, so the second extra term is zero.
Θ(x)=−m−1∑n=2[π(n)∫n+1ndtt]+π(m)log(m)
=−m−1∑n=2[π(n)∫n+1ndtt]+π(m)log(m)−π(x)log(x)+π(x)log(x)
=−∫m2π(t)dtt+π(x)log(x)−∫xmπ(t)dtt=π(x)log(x)−∫x2π(t)dtt.
Now we have a formula for Θ which will allow us to prove something.Subsection 21.4.3 Finish the proof
¶We can divide the formula Θ(x)=π(x)log(x)−∫x2π(t)dtt by x:
Θ(x)x=π(x)log(x)x−∫x2π(t)tdtx.
Given that the Prime Number Theorem says that limx→∞ of the fraction with π(x) in it is 1, proving that limx→∞Θ(x)x is also 1 is equivalent to proving
limx→∞1x∫x2π(t)tdt=0.
Now, the Prime Number Theorem also implies that π(t)t and 1log(t) are asymptotic (recall Definition 21.2.1), so that their averaging integrals
1x∫x2π(t)tdt and 1x∫x2dtlog(t)
clearly are also asymptotic.
This reduces our proof to showing that the average value of 1/log(t) tends to zero. Since integrals have a graphical interpretation, we now use the following graph of the integral limit to finish the proof!
Consider that one possible upper sum for the integral of 1/log(t) between 2 and 9 is the area of the two rectangles shown below, one with area 1log(2)(√9−2) and the other with area 1log(√9)(9−√9). (Of course √9=3 but this form is more useful here.)

1log(2)(√x−2)+1log(√x)(x−√x)
and we want the limit as x→∞ of 1x times that quantity.
Now is the time to recklessly use logarithmic identities:
1x(1log(2)(√x−2)+1log(√x)(x−√x))
=1log(2)x1/2−2xlog(2)+1log(√x)−1log(√x)x1/2
=1log(2)x1/2−2xlog(2)+2log(x)−2log(x)x1/2
This last expression has positive powers of x and their logs in the denominators, so it pretty clearly goes to zero as x→∞.
If the algebra doesn't convince you, perhaps an interactive graph will. Below, black is the overestimate to the integral and red is 1/x times the integral.
xxxxxxxxxx
def _(top=(16,[n^2 for n in [2..10]])):
f(x)=1/log(x)
P=plot(f,1,top+1)
P += line([(2,0),(2,f(2)),(math.sqrt(top),f(2)), (math.sqrt(top),0)], rgbcolor='black')
P += line([(math.sqrt(top),f(math.sqrt(top))), (top,f(math.sqrt(top))),(top,0)], rgbcolor='black')
P += line([(2,0),(2,f(2)),(2+(math.sqrt(top)-2)/top,f(2)), (2+(math.sqrt(top)-2)/top,0)], rgbcolor='red')
P += line([(math.sqrt(top),f(math.sqrt(top))), (math.sqrt(top)+(top-math.sqrt(top))/top, f(math.sqrt(top))), (math.sqrt(top) + (top-math.sqrt(top))/top,0)], rgbcolor='red')
P.show(ymax=2)