Section 22.1 Prime Races
ยถQuestion 22.1.1.
How many primes of each type there are up to n=10, n=20, and n=50? Try making a table.
xxxxxxxxxx
import itertools
โ
def _(n=7):
L = itertools.zip_longest([p for p in prime_range(n+1) if p%4==1],[p for p in prime_range(n+1) if p%4==3])
L = [['',l[1]] if l[0] is None else l for l in L]
T = [[r'$p\equiv 1\text{ (mod }4)$',r'$p\equiv 3\text{ (mod }4)$']]
pretty_print(html(table(T+L,header_row=True, frame=True)))
xxxxxxxxxx
def _(k=100):
p1 = 0
p3 = 0
for i in prime_range(k):
if i%4==1:
p1 += 1
if i%4==3:
p3 += 1
pretty_print(html("Up to $k=%s$, there are"%k))
pretty_print(html(r"%s primes $p\equiv 1\text{ (mod }4)$ and "%p1))
pretty_print(html(r"%s primes $p\equiv 3\text{ (mod }4)$."%p3))
Question 22.1.2.
Do you detect the bias Chebyshev did? Do you think it will persist?
Subsection 22.1.1 Infinitude of types of primes
ยถOf course, for this question to make sense, we need to make sure this โprime raceโ won't suddenly run out of gas. We know there are infinitely many primes, but what about each type of prime?Fact 22.1.3.
There are infinitely many primes congruent to 3 modulo 4 and there are infinitely many primes congruent to 1 modulo 4.
Proof.
Proposition 22.1.4. Infinitude of primes 3 (mod 4).
There is no largest prime congruent to 3 modulo 4.
Proof.
We'll prove this by contradiction. Suppose \(p_1,p_2,\ldots,p_k\) is the (finite) set of all primes congruent to 3 modulo 4.
Form the product of all these primes, together with four; then subtract one to let
What are the prime divisors of this number?
Clearly none of the \(p_i\) can be a prime divisor, since \(m\) is congruent to \(-1\) modulo all the \(p_i\text{.}\)
Since \(m\) is not even, it is also not divisible by a power of 2.
If \(m\) were a product only of primes congruent to 1 modulo 4, then it would have to be 1 modulo 4 itself (since any product of \(1\)s is 1).
That is false, so there must be a prime congruent to 3 modulo 4 which divides it, which cannot be on the original list of \(p_i\text{.}\)
This contradicts our assumption of having the full set of such primes, so that assumption must have been wrong.
Proposition 22.1.5. Infinitude of primes 1 mod 4.
There is no largest prime congruent to 1 modulo 4.
Proof.
As usual, suppose there are finitely many primes \(p_i\) which are congruent to 1 modulo 4. Let's form the modified product
What are its prime divisors?
For the same reasons as in the proof of Proposition 22.1.4, it is clear that \(m\) is odd and that it is not divisible by any of the \(p_i\) or \(2\text{.}\) Initially, one might assume one could also modify that argument to show that at least one of the primes \(p\) which divides \(m\) is not 3 modulo 4.
Unfortunately, as \(3^2\) is congruent to 1 modulo 4, this argument fails. However, we can use an indirect argument.
For any prime divisor \(p\) of \(m\) and for \(x=2p_1 p_2\ldots p_k\) we have \(m=x^2+1\equiv 0\text{ (mod }p)\text{.}\) So by definition \(-1\) is a quadratic residue modulo \(p\text{!}\) Because of Fact 13.3.2, this can only happen if \(p\equiv 1\) (mod \(4\)).
Since this \(p\) wouldn't be one of the \(p_i\text{,}\) its existence contradicts the assumption that we already had all such primes.
Subsection 22.1.2 Back to bias
ยถNow that we know we will always have primes of both kinds, let's return to the prime race. From what we've seen previously, it looks like the 4k+3-type primes will always stay ahead. But that's not quite right. The next Sage cell computes one place where they fall behind.xxxxxxxxxx
def prime_race_up_to_n(n):
p1 = 0
p3 = 0
for i in prime_range(n):
if i%4==1:
p1 += 1
if i%4==3:
p3 += 1
pretty_print(html(r"Up to $n=%s$, there are:<ul><li>%s primes $p\equiv 1\text{ (mod }4)$</li><li>%s primes $p\equiv 3\text{ (mod }4)$.</li></ul>"%(n,p1,p3)))
โ
def _(n=[26860,26862,26864,26880]):
prime_race_up_to_n(n)
Fact 22.1.6.
No matter how far out you go, there exists an n where the 4k+1 team is ahead at n by

xxxxxxxxxx
def _(n=26862):
L = []
p1 = 0
p3 = 0
for i in prime_range(n):
if i%4==1:
p1 += 1
L.append([i,p1-p3])
if i%4==3:
p3 += 1
L.append([i,p1-p3])
P = plot(1/2*sqrt(x)/log(x)*log(log(log(x))), (x,10,n+10))
P += plot_step_function(L)
show(P)
Subsection 22.1.3 Other prime races
ยถThere are many races we can check out, and mathematicians have. (Indeed, this section is indebted to the excellent expository article [C.7.3], which has a host of recent references.) What is the pattern here, for modulus eight?
xxxxxxxxxx
def _(n=100):
p1,p3,p5,p7=0,0,0,0
L1 = []
L3 = []
L5 = []
L7 = []
for i in prime_range(n):
if i%8==1:
p1 += 1
L1.append([i,p1])
elif i%8==3:
p3 += 1
L3.append([i,p3])
elif i%8==5:
p5 += 1
L5.append([i,p5])
elif i%8==7:
p7 += 1
L7.append([i,p7])
L1.append([n,p1])
L3.append([n,p3])
L5.append([n,p5])
L7.append([n,p7])
P = Graphics()
P += plot_step_function(L1,color='red',legend_label='1 (mod 8)')
P += plot_step_function(L3,color='green',legend_label='3 (mod 8)')
P += plot_step_function(L5,color='blue',legend_label='5 (mod 8)')
P += plot_step_function(L7,color='orange',legend_label='7 (mod 8)')
show(P,xmin=max(0,n-1000),ymin=max(0,L1[-1][1]-100))