Honors 1: Undergraduate Math Lab^{∗}

Peter Sarnak^{†}, Steven Miller^{‡}, Alex Barnett^{§}

September 11th, 2002

Courant Institute of Mathematical Sciences New York University New York, NY

Abstract

We review many basic number theory results. We give efficient algorithms for polynomial evaluation, calculating x^{n}, and finding the greatest common divisor. We briefly review probability theory. After an introduction to Algebraic and Transcendental Numbers, we review Dirichlet’s Box Principle (aka the Pidgeonhole Principle), and give an application. We prove a weak version of Chebyshev’s Theorem on the approximate number of primes. Lecture by Steven Miller. Notes by Steven Miller (and Florin Spinu, who helped write up the notes on Dirichlet’s Box Principle and Chebyshev).

1 Notation

1. 𝕎 : the set of whole numbers: {1, 2, 3, 4, …}.

2. ℕ : the set of natural numbers: {0, 1, 2, 3, …}.

3. ℤ : the set of integers: {…, −2, −1, 0, 1, 2, …}.

4. ℚ: the set of rational numbers: \{x : x = \frac{p}{q}, p, q ∈ ℤ, q ≠ 0\}.

∗Homepage: http://www.math.nyu.edu/∼millerj/ †E-mail: sarnak@math.princeton.edu ‡E-mail: millerj@cims.nyu.edu or sjmiller@math.princeton.edu §E-mail: barnett@nmr.mgh.harvard.edu

5. ℝ: the set of real numbers.

6. ℂ: the set of complex numbers: {z : z = x + iy, x, y ∈ ℝ}.

7. ℤ/nℤ : the additive group of integers mod n.

8. (ℤ/nℤ)^{∗} : the multiplicative group of invertible elements mod n.

9. a|b : a divides b, i.e. the remainder after integer division \frac{b}{a} is 0.

10. (a, b) : greatest common divisor (gcd) of a and b, often written gcd(a, b).

11. x ≡ y(mod n) : there exists an integer a such that x = y + an.

12. wlog : without loss of generality.

13. s.t. : such that.

14. ∀ : for all.

15. ∃ : there exists.

16. big O notation : A(x) = O(B(x)), read “A(x) is of order B(x)”, means ∃C > 0 such that ∀x, |A(x)| ≤ C B(x).

17. |S| or #S : number of elements in the set S.

18. p : usually a prime number.

19. n : usually an integer.

2 Efficient Algorithms

For computational purposes, often having an algorithm to compute a quantity is not enough; we need an algorithm which will compute quickly. Below we study three standard problems, and show how to either rearrange the operations more efficiently, or give a more efficient algorithm than the obvious candidate.

2.1 Polynomial Evaluation

Let f(x) = a_{n}x^{n} + a_{n−1}x^{n−1} + ⋯ + a_{1}x + a_{0}. The obvious way to evaluate is to calculate x^{n} and multiply by a_{n} (n multiplications), calculate x^{n−1} and multiply by a_{n−1} (n − 1 multiplications) and add, et cetera. There are n additions and ∑_{k=0}^{n} k multiplications, for a total of n + \frac{n(n+1)}{2} operations. Thus, the standard method leads to O(n^{2}) computations.

Instead, consider the following:

(((a_{n}x + a_{n−1})x + a_{n−2})x + ⋯ + a_{1})x + a_{0}.  (1)

For example,

7x^{4} + 4x^{3} − 3x^{2} − 11x + 2 = (((7x + 4)x − 3)x − 11)x + 2.  (2)

Evaluating the long way takes 14 steps; cleverly rearranging takes 8 steps.

Exercise 1 Prove that the second method takes at most 2n steps to evaluate a_{n}x^{n} + ⋯ a_{0}.

2.2 Exponentiation

Consider x^{n}. The obvious way to evaluate involves n − 1 multiplications. By writing n in base two, we can evaluate x^{n} in at most 2 log_{2} n steps.

Let k be the largest integer such that 2^{k} ≤ n. Then ∃a_{i} ∈ {0, 1} such that

n = a_{k}2^{k} + a_{k−1}2^{k−1} + ⋯ + a_{1}2 + a_{0}.  (3)

It costs k multiplications to evaluate x^{2^{i}}, i ≤ k. How? Consider y_{0} = x^{2^{0}}, y_{1} = y_{0} · y_{0} = x^{2^{0}} · x^{2^{0}} = x^{2^{1}}, y_{2} = y_{1} · y_{1} = x^{2^{2}}, …, y_{k} = y^{k−1} · y^{k−1} = x^{2^{k}}.

Then

x^{n} = x^{a_{k}2^{k}+a_{k−1}2^{k−1}+···+a_{1}2+a_{0}}
= x^{a_{k}2^{k}} · x^{a_{k−1}2^{k−1}} ⋯ x^{a_{1}2} · x^{a_{0}}
= (x^{2^{k}})^{a_{k}} · (x^{2^{k−1}})^{a_{k−1}} ⋯ (x^{2})^{a_{1}} · (x^{1})^{a_{0}}
= y_{k}^{a_{k}} · y_{k−1}^{a_{k−1}} ⋯ y_{1}^{a_{1}} · y_{0}^{a_{0}}.  (4)

As each a_{i} ∈ {0, 1}, we have at most k +1 multiplications above (if a_{i} = 1 we have the term y_{i} in the product, if a_{i} = 0 we don’t).

Thus, it costs k multiplications to evaluate the x^{2^{i}} (i ≤ k), and at most another k multiplications to finish calculating x^{n}. As k ≤ log_{2} n, we see that x^{n} can be determined in at most 2 log_{2} n steps.

Note, however, that we do need more storage space for this method, as we need to store the values y_{i} = x^{2^{i}}, i ≤ log_{2} n.

Exercise 2 Instead of expanding n in base two, expand n in base three. How many calculations are needed to evaluate x^{n} this way? Why is it preferable to expand in base two rather than any other base?

2.3 Euclidean Algorithm

The Euclidean Algorithm is an efficient way to determine the greatest common divisor of x and y, denoted gcd(x, y) or (x, y). Without loss of generality, assume 1 < x < y.

The obvious way to determine gcd(x, y) is to divide x and y by all positive integers up to x. This takes at most 2x steps.

Let [z] denote the greatest integer less than or equal to z. We write

y = [\frac{y}{x}] · x + r_{1}, 0 ≤ r_{1} < x.  (5)

Exercise 3 Prove that r_{1} ∈ {0, 1, …, x − 1}.

Exercise 4 Prove gcd(x, y) = gcd(r_{1}, x). Hint: r_{1} = y − [\frac{y}{x}] · x.

We proceed in this manner until r_{k} equals zero or one. As each execution results in r_{i} < r_{i−1}, we proceed at most x times (although later we prove we need to apply these steps at most 2 log_{2} x times).

x = [\frac{x}{r_{1}} ] · r_{1} + r_{2}, 0 ≤ r_{2} < r_{1}
r_{1} = [\frac{r_{1}}{r_{2}} ] · r_{2} + r_{3}, 0 ≤ r_{3} < r_{2}
r_{2} = [\frac{r_{2}}{r_{3}} ] · r_{3} + r_{4}, 0 ≤ r_{4} < r_{3}

⋮
r_{k−2} = [\frac{r_{k−2}}{r_{k−1}} ] · r_{k−1} + r_{k}, 0 ≤ r_{k} < r_{k−1}.  (6)

Exercise 5 Prove that if r_{k} = 0, then gcd(x, y) = r_{k−1}, while if r_{k} = 1, then gcd(x, y) = 1.

We now analyze how large k can be. The key observation is the following:

Lemma 2.1 Consider three adjacent remainders in the expansion: r_{i−1}, r_{i} and r_{i+1} (where y = r_{−1} and x = r_{0}). Then gcd(r_{i}, r_{i−1}) = gcd(r_{i+1}, r_{i}), and r_{i+1} < \frac{r_{i−1}}{2} .

Proof: We have the following relation:

r_{i−1} = [\frac{r_{i−1}}{r_{i}} ] · r_{i} + r_{i+1}, 0 ≤ r_{i+1} < r_{i}.  (7)

If r_{i} ≤ \frac{r_{i−1}}{2} , then as r_{i+1} < r_{i}, we immediately conclude that r_{i+1} < r_{i}. If r_{i} > \frac{r_{i−1}}{2} , then we note that

r_{i+1} = r_{i−1} − [\frac{r_{i−1}}{r_{i}} ] · r_{i}.  (8)

But [\frac{r_{i−1}}{r_{i}} ] = 1 (easy exercise). Thus r_{i−1} < \frac{r_{i−1}}{2} . □

We count how often we apply Euclid’s Algorithm. Going from (x, y) = (r_{0}, r_{−1}) to (r_{1}, r_{0}) costs one application. Every two applications leads to the first entry in the last pair being at most half of the second entry of the first pair.

Thus, if k is the largest integer such that 2^{k} ≤ x, we see we apply Euclid’s Algorithm at most 1 + 2k ≤ 1 + 2 log_{2} x times. Each application requires one integer division, where the remainder is the input for the next step.

We have proven

Lemma 2.2 Euclid’s Algorithm requires at most 1+2 log_{2} x divisions to find the greatest common denominator of x and y.

Let us assume that r_{i} = gcd(x, y). Thus, the last equation before Euclid’s Algorithm terminated was

r_{i−2} = [\frac{r_{i−2}}{r_{i−1}} ] · r_{i−1} + r_{i}, 0 ≤ r_{i} < r_{i−1}.  (9)

Therefore, we can find integers a_{i−1} and b_{i−2} such that

r_{i} = a_{i−1}r_{i−1} + b_{i−2}r_{i−2}.  (10)

Looking at the second to last application of Euclid’s algorithm, we find that there are integers a′_{i−2} and b′_{i−3} such that

r_{i−1} = a′_{i−2}r_{i−2} + b′_{i−3}r_{i−3}.  (11)

Substituting for r_{i−1} = r_{i−1}(r_{i−2}, r_{i−3}) in the expansion of r_{i} yields that there are integers a_{i−2} and b_{i−3} such that

r_{i} = a_{i−2}r_{i−2} + b_{i−3}r_{i−3}.  (12)

Continuing by induction, and recalling r_{i} = gcd(x, y) yields

Lemma 2.3 There exist integers a and b such that gcd(x, y) = ax + by. Moreover, Euclid’s Algorithm gives a constructive procedure to find a and b.

Exercise 6 Find a and b such that a · 244 + b · 313 = gcd(244, 313).

Exercise 7 Add details to complete an alternate proof of the existence of a and b with ax + by = gcd(x, y):

1. Let d be the smallest positive value attained by ax + by as we vary a, b ∈ ℤ. Such a d exists: consider (a, b) = (1, 0) or (0, 1). Thus, d = ax + by. We now show d = gcd(x, y).

2. gcd(x, y)|d.

3. Let e = Ax+By > 0. Then d|e. Therefore, for any choice of A, B ∈ ℤ, d|(Ax + By).

4. d|x and d|y (consider clever choices of A and B; one choice gives d|x, one gives d|y). Therefore d| gcd(x, y). As we’ve shown gcd(x, y)|d, this completes the proof.

Note this is a non-constructive proof. By minimizing ax + by, we obtain gcd(x, y), but we have no idea how many steps is required. Prove that a solution will be found either among pairs (a, b) with a ∈ {1, …, y − 1} and −b ∈ {1, …, x − 1}, or −a ∈ {1, …, y − 1} and b ∈ {1, …, x − 1}.

3 Probabilities of Discrete Events

3.1 Introduction

Let Ω = {ω_{1}, ω_{2}, ω_{3}, …} be an at most countable set of events. We call Ω the sample (or outcome) space. We call the elements ω ∈ Ω the events. Let x : Ω → ℝ. That is, for each event ω ∈ Ω, we attach a real number x(ω). We call x a random variable.

Example 3.1 Flip a fair coin 3 times. The possible outcomes are Ω = {HHH, HHT, HT H, T HH, HT T, T HT, T T H, T T T }. One possible random variable is x(ω) equals the number of heads in ω. Thus, x(HHT) = 2 and x(T T T) = 0.

Example 3.2 Let Ω be the space of all flips of a fair coin where all but the last flip are tails, and the last is a head. Thus, Ω = {H, T H, T T H, T T T H, …}. One possible random variable is x(ω) is the number of tails; another is x(ω) equals the number of the flip which is a head.

We say p(ω) is a probability function on Ω if

1. 0 ≤ p(ω_{i}) ≤ 1 for all ω_{i} ∈ Ω.

2. p(ω) = 0 if ω ∉ Ω.

3. ∑_{i} p(ω_{i}) = 1.

We call p(ω) the probability of event ω.

Often, we have a random variables where x(ω) = ω. In a convenient abuse of notation, we write X for Ω and x for x(ω) and ω. For example, consider two rolls of a fair die. Let X be the result of the first roll, and Y of the second. Then the sample space is X = Y = {1, 2, 3, 4, 5, 6}.

In general, consider X and Y with x_{i} occurring with probability p(x_{i}) and y_{j} occurring with probability q(y_{j}). We analyze the joint probability r(x, y) of observing x and y.

X and Y are independent if ∀x, y, r(x, y) = p(x)q(y). In the example of rolling a fair die twice, r(x, y) = p(x)q(y) = \frac{1}{6} · \frac{1}{6} if x, y ∈ X = Y, and 0 otherwise.

Exercise 8 Consider again two rolls of a fair die. Now, let X represent the first roll, and Y the sum of the first two rolls. Prove X and Y are not independent.

Events X_{1} through X_{N} are independent if p(x_{1}, …, x_{N}) = p_{1}(x_{1}) ⋯ p(x_{N}).

Exercise 9 Construct three events such that any two are independent, but all three are not independent. Hint: roll a fair die twice.

3.2 Means

If x(ω) = ω, the mean (or expected value) of an event x is defined by

x̄ = ∑_{i} x_{i}p(x_{i}).  (13)

More generally, for a sample space Ω with events ω and a random variable x(ω), we have

x̄(ω) = ∑_{i} x(ω_{i})p(ω_{i}).  (14)

For example, the mean of one roll of a fair die is 3.5.

Exercise 10 Let X be the number of tosses of a fair coin needed before getting the first head. Thus, X = {1, 2, …}. Calculate p(x_{i}) and x̄. We could let Ω be the space of all tosses of a fair coin where all but the last toss are tails, and the last toss is a head. Then x(ω) is the number of tosses of ω.

Instead of writing x̄, we often write E[x] or E[X], read as the expected value of x or X. More generally, we would have x̄(ω) and E[x(ω)].

The k^{th} moment of X is the expected value of x^{k}:

E[x^{k}] = ∑_{i} x_{i}^{k}p(x_{i})  (15)

or

E[x^{k}(ω)] = ∑_{i} x^{k}(ω_{i})p(ω_{i}).  (16)

Lemma 3.3 (Additivity of the Means) Let X and Y be two independent events with joint probability r(x, y) = p(x)q(y). Let z = x + y. Then E[z] = E[x + y] = E[x] + E[y].

Proof:

E[x + y] = ∑_{(i,j)}(x_{i} + y_{j})r(x_{i}, y_{j})
= ∑_{i} ∑_{j}(x_{i} + y_{j})p(x_{i})q(y_{j})
= ∑_{i} ∑_{j} x_{i}p(x_{i})q(y_{j}) + ∑_{i} ∑_{j} y_{j}p(x_{i})q(y_{j})
= ∑_{i} x_{i}p(x_{i}) ∑_{j} q(y_{j}) + ∑_{i} p(x_{i}) ∑_{j} y_{j}q(y_{j})
= E[x] · 1 + 1 · E[y] = E[x] + E[y].  (17)

The astute reader may notice that some care is needed to interchange the order of summations. If ∑_{i} ∑_{j} |x_{i}y_{j}|r(x_{i}, y_{j}) < ∞, then Fubini’s Theorem is applicable, and we may interchange the summations at will.

We used the two events were independent to go from ∑_{(i,j)} x_{i}r(x_{i}, y_{j}) to ∑_{i} x_{i}p(x_{i}) ∑_{j} q(y_{j}) = E[x]. Lemma 3.3 is true even if the two events are not independent.

If the events are not independent, we encounter sums like ∑_{i} ∑_{j} x_{i}r(x_{i}, y_{j}); however, ∑_{j} r(x_{i}, y_{j}) = p(x_{i}). Why? By summing over all possible y, we are asking what is the probability that x = x_{i}; we do not care what y is. Thus, ∑_{i} ∑_{j} x_{i}r(x_{i}, y_{j}) = ∑_{i} x_{i}p(x_{i}) = E[x], and similarly for the other piece.

Exercise 11 Write out the proof of the generalization of Lemma 3.3, where X and Y are not assumed independent.

Given an outcome space X = {x_{1}, x_{2}, …} with probabilities p(x_{i}), let aX be shorthand for the event a times X with outcome space {ax_{1}, ax_{2}, …} and probabilities p_{a}(ax_{i}) = p(x_{i}).

Lemma 3.4 Let X_{1} through X_{N} be a finite collection of independent events. Let a_{1} through a_{N} be real constants. Then

E[a_{1}x_{1} + ⋯ + a_{N}x_{N}] = a_{1}E[x_{1}] + ⋯ + a_{N}E[x_{N}].  (18)

Lemma 3.5 Let X and Y be independent events. Then E[xy] = E[x]E[y].

Exercise 12 Prove Lemmas 3.4 and 3.5.

3.3 Variances

The variance σ_{x}^{2} (and its square-root, the standard deviation σ_{x}) measure how spread out a probability distribution is. Assume x(ω) = ω. Given an event X with mean x̄, we define the standard deviation σ_{x}^{2} by

σ_{x}^{2} = ∑_{i}(x_{i} − x̄)p(x_{i}).  (19)

More generally, given a sample space Ω, events ω, and a random variable x : Ω → ℝ,

σ_{x(ω)}^{2} = ∑_{i} (x(ω_{i}) − x̄(ω))p(ω_{i}).  (20)

Exercise 13 Let X = {0, 25, 50, 75, 100} with probabilities {.2, .2, .2, .2, .2}. Let Y be the same outcome space, but with probabilities {.1, .25, .3, .25, .1}. Calculate the means and the variances of X and Y.

For computing variances, instead of equation 19 one often uses

Lemma 3.6 σ_{x}^{2} = E[x^{2}] − E[x]^{2}.

Proof: Recall x̄ = E[x]. Then

σ_{x}^{2} = ∑_{i} (x_{i} − E[x])^{2}p(x_{i})
= ∑_{i}(x_{i}^{2} − 2x_{i}E[x] + E[x]^{2})p(x_{i})
= ∑_{i} x_{i}^{2}p(x_{i}) − 2E[x] ∑_{i} x_{i}p(x_{i}) + E[x]^{2} ∑_{i} p(x_{i})
= E[x^{2}] − 2E[x]^{2} + E[x]^{2} = E[x^{2}] − E[x]^{2}.  (21)

The main result on variances is

Lemma 3.7 (Variance of a Sum) Let X and Y be two independent events. Then σ_{x+y}^{2} = σ_{x}^{2} + σ_{y}^{2}.

Proof: We constantly use the expected value of a sum of independent events is the sum of expected values (Lemma 3.3 and Lemma 3.4).

σ_{x+y}^{2} = E[(x + y)^{2}] − E[(x + y)]^{2}
= E[x^{2} + 2xy + y^{2}] − (E[x] + E[y])^{2}
= (E[x^{2}] + 2E[xy] + E[y^{2}]) − (E[x]^{2} + 2E[x]E[y] + E[y]^{2})
= (E[x^{2}] − E[x]^{2}) + (E[y^{2}] − E[y]^{2}) + 2(E[xy] − E[x]E[y])
= σ_{x}^{2} + σ_{y}^{2} + 2(E[xy] − E[x]E[y]).  (22)

By Lemma 3.5, E[xy] = E[x]E[y], completing the proof.

Lemma 3.8 Consider n independent copies of the same event (for example, n flips of a coin or n rolls of a die). Then σ_{nx} = \sqrt{n}σ_{x}.

Exercise 14 Prove Lemma 3.8.

Note that, if the event X has units of meters, then the variance σ_{x}^{2} has units meters-squared, and the standard deviation σ_{x} and the mean x̄ have units meters. Thus, it is the standard deviation that gives a good measure of the deviations of an event around the mean.

There are, of course, alternate measures one can use. For example, one could consider

∑_{i}(x_{i} − x̄)p(x_{i}).  (23)

Unfortunately, this is a signed quantity, and large positive deviations can cancel with large negatives. This leads us to consider

∑_{i} |x_{i} − x̄|p(x_{i}).  (24)

While this has the advantage of avoiding cancellation of errors (as well as having the same units as the events), the absolute value function is not a good function analytically. For example, it is not differentiable. This is primarily why we consider the standard deviation (the square-root of the variance).

Exercise 15 Consider the following set of data: for i ∈ {1, …, n}, given x_{i} one observes y_{i}. Believing that X and Y are linearly related, find the best fit straight line. Namely, determine constants a and b that minimize the error (calculated via the variance)

∑_{i=1}^{n} (y_{i} − (ax_{i} + b))^{2} = ∑_{i=1}^{n} (Observed_{i} − Predicted_{i})^{2}.  (25)

Hint: use Multi-variable Calculus to find linear equations for a and b, and then solve with Linear Algebra.

If instead of measuring total error by the squares of the individual error (for example, using the absolute value), closed form expressions for a and b become significantly harder.

If one requires that a = 0, show that the b leading to least error is b = ȳ = \frac{1}{n} ∑_{i} y_{i}.

3.4 Random Walks

Consider the classical problem of a drunk staggering home from a lamp post late at night. We flip a fair coin N times. With probability \frac{1}{2} we get heads (tails). For each head (tail) the drunk staggers one unit to the right (left). How far do we expect the drunk to be?

It is very unlikely the drunk will be very far to the left or right.

Exercise 16 Let x be +1 if we flip a head, −1 for a tail. For a fair coin, prove E[x] = 0, σ_{x}^{2} = 1, σ_{x} = 1.

Exercise 17 Let p_{N}(y) be the probability that after N flips of a fair coin, the drunk is y units to the right of the origin (lamp post).

1. Prove p_{N}(y) = p_{N}(−y).

2. Consider N = 2M. Prove p_{2M}(2k) = \binom{2M}{M+k} \frac{1}{2^{2M}}, where \binom{n}{r} = \frac{n!}{r!(n−r)!}

3. Use Stirling’s formula (n! ≈ n^{n}e^{−n}\sqrt{2πn} = \sqrt{2π}n^{n+ \frac{1}{2}} e^{−n}) to approximate p_{N}(y).

Label the coin tosses X_{1} through X_{N}. Let X denote a generic toss of the coin, and Y_{N} be the distance of the drunkard after N tosses. By Lemma 3.4, E[y_{N}] = E[x_{1} + ⋯ + x_{N}] = E[x_{1}] + ⋯ + E[x_{N}]. As each E[x_{i}] = E[x] = 0, E[y_{N}] = 0.

Thus, we expect the drunkard to be at the lamp post. How spread out is his expected position? By Lemma 3.8,

σ_{y_{N}} = σ_{Nx} = \sqrt{N}σ_{x} = \sqrt{N}.  (26)

This means that a typical distance from the origin is \sqrt{N}. This is called a diffusion process and is very common in the real world.

3.5 Bernoulli Process

Recall \binom{N}{r} = \frac{N!}{r!(N−r)!} is the number of ways to choose r objects from N objects when order does not matter. Consider n independent repetitions of an event with only two possible outcomes. We typically call one outcome success and the other failure, the event a Bernoulli Trial, and a collection of independent Bernoulli Trials a Bernoulli Process.

In each Bernoulli Trial, let there be probability p of success and q = 1 − p of failure. Often, we represent a success with 1 and a failure with 0.

Exercise 18 For a Bernoulli Trial, show x̄ = p, σ_{x}^{2} = pq, and σ_{x} = \sqrt{pq}.

Let Y_{N} be the number of successes in N trials. Clearly, the possible values are Y_{N} = {0, 1, ⋯, N}. We analyze p_{N}(k). Rigorously, the sample space Ω is all possible sequences of N trials, and the random variable y_{N} : Ω → ℝ is given by y_{N}(ω) equals the number of successes in ω.

If k ∈ Y_{N}, we need k successes and N − k failures. We don’t care what order we have them (ie, if k = 4 and N = 6 then SSF SSF and F SSSSF both contribute). Each such string of k successes and N − k failures has probability of p^{k} · (1 − p)^{N−k}. There are \binom{N}{k} such strings.

Thus, p_{N}(k) = \binom{N}{k}p^{k} · (1 − p)^{N−k} if k ∈ \{0, 1, ⋯, N\} and 0 otherwise. By clever algebraic manipulations, one can directly evaluate the mean \overline{y_{N}}

and the variance σ_{y_{N}}^{2} ; however, Lemmas 3.4 and 3.8 allow one to calculate both quantities immediately, once one knows the mean and variance for one occurrence.

Lemma 3.9 For a Bernouilli Process with N trials, each having probability p of success, the expected number of successes is \overline{y_{N}} = Np, and the variance is σ_{y_{N}}^{2} = Npq.

Exercise 19 Prove Lemma 3.9.

Consider the following problem: Let Z = {0, 1, 2, …} be the number of trials before the first success. What is z̄ and σ_{z}^{2}?

First, we determine p(k), the probability that the first success occurs after k trials. Clearly this probability is non-zero only for k a positive integer, in which case the string of results must be k − 1 failures followed by 1 success. Therefore,

p(k) = p · (1 − p)^{k−1} if k ∈ {1, 2, …}, and 0 otherwise.  (27)

To determine the mean z̄ we must evaluate

z̄ = ∑_{k=1}^{∞} k · p · (1 − p)^{k−1}
= p ∑_{k=1}^{∞} kq^{k−1}, 0 < q = 1 − p < 1.  (28)

Consider the geometric series

f(q) = ∑_{k=0}^{∞} q^{k} = \frac{1}{1 − q} .  (29)

A careful analysis shows we can differentiate term by term if 0 ≤ q < 1. Then

f′(q) = ∑_{k=0}^{∞} kq^{k−1} = \frac{1}{(1 − q)^{2}} .  (30)

Recalling q = 1 − p and substituting yields

z̄ = p ∑_{k=1}^{∞} kq^{k−1}
= \frac{p}{(1 − (1 − p))^{2}} = \frac{1}{p}.  (31)

Differentiating under the summation sign is a powerful tool in Probability Theory.

Exercise 20 Calculate σ_{z}^{2}. Hint: differentiate f(q) twice.

3.6 Poisson Distribution

Divide the unit interval into N equal pieces. Consider N independent Bernoulli Trials, one for each sub-interval. If the probability of a success is \frac{λ}{N}, then by Lemma 3.9 the expected number of successes is N · \frac{λ}{N} = λ.

We consider the limit as N → ∞. Obviously, we still expect λ successes in each interval, but what is the probability of 3λ successes? How long do we expect to wait between successes?

We call this a Poisson process with parameter λ. For example, look at the midpoints of the N intervals. At each midpoint we have a Bernoulli Trial with probability of success \frac{λ}{N} and failure 1 − \frac{λ}{N}.

We determine the N → ∞ limits. For fixed N, the probability of k successes in a unit interval is

p_{N}(k) = \binom{N}{k}(\frac{λ}{N} )^{k}(1 − \frac{λ}{N} )^{N−k}
= \frac{N!}{k!(N − k)!} \frac{λ^{k}}{N^{k}} (1 − \frac{λ}{N} )^{N−k}
= \frac{N · (N − 1) ⋯ (N − k + 1)}{N · N ⋯ N} \frac{λ^{k}}{k!} (1 − \frac{λ}{N} )^{N} (1 − \frac{λ}{N} )^{−k}
= 1 · (1 − \frac{1}{N} ) ⋯ (1 − \frac{k − 1}{N})\frac{λ^{k}}{k!} (1 − \frac{λ}{N} )^{N} (1 − \frac{λ}{N} )^{−k}. (32)

For fixed, finite k, as N → ∞, the first k factors in p_{N}(k) tend to 1, (1 − \frac{λ}{N} )^{N} → e^{−λ}, and (1 − \frac{λ}{N} )^{−k} → 1.

Thus, we are led to the Poisson Distribution: Given a parameter λ (interpreted as the expected number of occurrences per unit interval), the probability of k occurrences in a unit interval is p(k) = \frac{λ^{k}}{k!} e^{−λ} for k ∈ \{0, 1, 2, …\}.

Exercise 21 Check that p(k) given above is a probability distribution. Namely, show ∑_{k≥0} p(k) = 1.

Exercise 22 Show, for the Poisson Distribution, that the mean x̄ = λ and the variance σ_{x}^{2} = λ. Hint: let

f(λ) = ∑_{k=0}^{∞} \frac{λ^{k}}{k!} = e^{λ}.  (33)

Differentiate once to determine the mean, twice to determine the variance.

3.7 Continuous Poisson Distribution

We calculate a very important quantity related to the Poisson Distribution (with parameter λ), namely, how long does one expect to wait between successes?

We’ve discussed that we expect λ successes per unit interval, and we’ve calculated the probability of k successes per unit interval.

Start counting at 0, and assume the first success is at x. What is p_{S}(x)? As before, we divide each unit interval into N equal pieces, and consider a Bernoulli Trial at the midpoint of each sub-interval, with probability \frac{λ}{N} of success.

We have approximately \frac{x−0}{1/N} = Nx midpoints from 0 to x (with N midpoints per unit interval). Let ⌈y⌉ be the smallest integer greater than or equal to y. Then we have ⌈Nx⌉ midpoints, where the results of the Bernoulli Trials of the first ⌈Nx⌉−1 midpoints are all failures and the last is a success.

Thus, the probability of the first success occuring in an interval of length \frac{1}{N} containing x (with N divisions per unit interval) is

p_{N,S}(x) = (1 − \frac{λ}{N} )^{⌈Nx⌉−1} · (\frac{λ}{N} )^{1}.  (34)

For N large, the above converges to e^{−λx} \frac{λ}{N}.

We say p(x) is a continuous probability distribution on ℝ if

1. p(x) ≥ 0 for all x ∈ ℝ.

2. ∫_{ℝ} p(x)dx = 1.

3. Probability(a ≤ x ≤ b) = ∫_{a}^{b} p(x)dx.

We call p(x) the probability density function.

Thus, as N → ∞, we see the probability density function p_{S}(x) = λe^{−λx}. In the special case of λ = 1, we get the standard exponential decay, e^{−x}.

For instance, let π(M) be the number of primes that are at most M. The Prime Number Theorem states π(M) = \frac{M}{log M} plus lower order terms.

Thus, the average spacing between primes around M is about log M. We can model the distribution of primes as a Poisson Process, with parameter λ = λ_{M} = \frac{1}{log M}. While possible locations of primes (obviously) is discrete (it must be an integer, and in fact the location of primes aren’t independent), a Poisson model often gives very good heuristics.

We can often renormalize so that λ = 1. This is denoted unit mean spacing. For example, one can show the M^{th} prime p_{M} is about M log M, and spacings between primes around p_{M} is about log M. Then the normalized primes, q_{M} ≈ \frac{p_{M}}{log M} will have unit mean spacing and λ = 1.

3.8 Central Limit Theorem

X_{1}, X_{2}, X_{3}, … are an infinite sequence of random variables such that the X_{j} are independent identically distributed random variables (abbreviated i.i.d.r.v.) with E[X_{j}] = X̄_{j} = 0 (can always renormalize by shifting) and variance E[X_{j}^{2}] = 1. Let S_{N} = ∑_{j=1}^{N} X_{j}.

Theorem 3.10 Fix −∞ < a ≤ b < ∞. Then as N → ∞,

Prob(\frac{S_{N}}{\sqrt{N}} ∈ [a, b]) → \frac{1}{\sqrt{2π}} ∫_{a}^{b} e^{− \frac{t^{2}}{2}} dt.  (35)

The probability function is called the Gaussian or the Normal distribution. This is the universal curve of probability. Note how robust the Central Limit Theorem is: it doesn’t depend on fine properties of the X_{j}.

4 Algebraic and Transcendental Numbers

4.1 Definitions

A function f : A → B is one-to-one if f(x) = f(y) implies x = y; f is onto if given any b ∈ B, ∃a ∈ A with f(a) = b. f is a bijection if f is a one-to-one and onto function.

We say two sets A and B have the same cardinality (ie, are the same size) if there is a bijection f : A → B. We denote this by |A| = |B|. If A has finitely many elements (say n elements), A is finite and |A| = n < ∞.

Exercise 23 Show two finite sets have the same cardinality if and only if they have the same number of elements.

Exercise 24 If f is a bijection from A to B, prove there is a bijection g = f^{−1} from B to A.

A is countable if there is a bijection between A and the integers ℤ. A is at most countable if A is either finite or countable.

Recall a binary relation R is an equivalence relation if

1. Reflexive: R(x, x) is true (x is equivalent to x).

2. Symmetric: R(x, y) true implies R(y, x) is true (if x is equivalent to y then y is equivalent to x).

3. Transitive: R(x, y) and R(y, z) true imply R(x, z) is true (if x is equivalent to y and y is equivalent to z, then x is equivalent to z).

We often denote equivalence by ≡ or =.

Exercise 25 Let x, y, z ∈ ℤ, and let n ∈ ℤ be given. Define R(x, y) to be true if n|(x − y) and false otherwise. Prove R is an equivalence relation. We denote it by x ≡ y.

Exercise 26 Let x, y, z be subsets of X (for example, X = ℚ, ℝ, ℂ, ℝ^{n}, et cetera). Define R(x, y) to be true if |x| = |y| (the two sets have the same cardinality), and false otherwise. Prove R is an equivalence relation.

4.2 Countable Sets

We show several sets are countable. Consider the set of non-negative integers ℕ. Define f : ℕ → ℤ by f(2n) = n, f(2n + 1) = −n − 1. By inspection, we see f gives the desired bijection.

Consider 𝕎 = {1, 2, 3, …} (the positive integers). Then f : 𝕎 → ℤ defined by f(2n) = n, f(2n + 1) = −n gives the desired bijection.

Thus, we have proved

Lemma 4.1 To show a set S is countable, it is sufficient to find a bijection from S to either ℤ, ℕ or 𝕎.

We need the intuitively plausible

Lemma 4.2 If A ⊂ B, then |A| ≤ |B|.

We can then prove

Lemma 4.3 If f : A → C is a one-to-one function (not necessarily onto), then |A| ≤ |C|. Further, if C ⊂ A, then |A| = |C|.

Exercise 27 Prove Lemmas 4.2 and 4.3.

If A and B are sets, the cartesian product A × B is {(a, b) : a ∈ A, b ∈ B}.

Theorem 4.4 If A and B are countable, so is A ∪ B and A × B.

Proof: we have bijections f : ℕ → A and g : ℕ → B. Thus, we can label the elements of A and B by

A = {a_{0}, a_{1}, a_{2}, a_{3}, …}
B = {b_{0}, b_{1}, b_{2}, b_{3}, …}.  (36)

Assume A ∩ B is empty. Define h : ℕ → A ∪ B by h(2n) = a_{n} and h(2n + 1) = b_{n−1}. We leave to the reader the case when A ∩ B is not empty.

To prove the second claim, consider the following function h : W → A×B:

h(1) = (a_{0}, b_{0})

h(2) = (a_{1}, b_{0}), h(3) = (a_{1}, b_{1}), h(4) = (a_{0}, b_{1})

h(5) = (a_{2}, b_{0}), h(6) = (a_{2}, b_{1}), h(7) = (a_{2}, b_{2}), h(8) = (a_{1}, b_{2}), h(9) = (a_{0}, b_{2})

⋮

h(n^{2} + 1) = (a_{n}, b_{0}), h(n^{2} + 2) = (a_{n}, b_{n−1}), …,

h(n^{2} + n + 1) = (a_{n}, b_{n}), h(n^{2} + n + 2) = (a_{n−1}, b_{n}), …,
h((n + 1)^{2}) = (a_{0}, b_{n})
⋮  (37)

Basically, look at all pairs of integers in the first quadrant (including those on the axes). Thus, we have pairs (a_{x}, b_{y}). The above function h starts at (0, 0), and then moves through the first quadrant, hitting each pair once and only once, by going up and over. Draw the picture! □

Corollary 4.5 Let A_{i} be countable ∀i ∈ ℕ. Then for any n, A_{1} ∪ ⋯ ∪ A_{n} and A_{1} ×⋯×A_{n} are countable, where the last set is all n-tuples (a_{1}, …, a_{n}), a_{i} ∈ A_{i}. Further, ∪_{i=0}^{∞}A_{i} is countable. If each A_{i} is at most countable, then ∪_{i=0}^{∞}A_{i} is at most countable.

Exercise 28 Prove Corollary 4.5. Hint: for ∪_{i=0}^{∞}A_{i}, mimic the proof used to show A × B is countable.

As the natural numbers, integers and rationals are countable, by taking each A_{i} = ℕ, ℤ or ℚ we immediately obtain

Corollary 4.6 ℕ^{n}, ℤ^{n} and ℚ^{n} are countable. Hint: proceed by induction. For example write ℚ^{n+1} as ℚ^{n} × ℚ.

Exercise 29 Prove there are countably many rationals in the interval [0, 1].

4.3 Algebraic Numbers

Consider a polynomial f(x) = 0 with rational coefficients. By multiplying by the least common multiple of the denominators, we can clear the fractions. Thus, without loss of generality it is sufficient to consider polynomials with integer coefficients.

The algebraic numbers, A, are the set of all x ∈ ℂ such that there is a polynomial of finite degree and integer coefficients (depending on x, of course!) such that f(x) = 0. The remaining complex numbers are the transcendentals.

The algebraic numbers of degree n, A_{n}, are the set of all x ∈ A such that

1. there exists a polynomial with integer coefficients of degree n such that f(x) = 0

2. there is no polynomial g with integer coefficients and degree less than n with g(x) = 0.

Thus, A_{n} is the subset of algebraic numbers x where for each x ∈ A_{n}, the degree of the smallest polynomial f with integer coefficients and f(x) = 0 is n.

Exercise 30 Show the following are algebraic: any rational, the square-root of any rational, the cube-root of any rational, r^{\frac{p}{q}} where r, p, q ∈ ℚ, i = \sqrt{−1}, \sqrt{3\sqrt{2} − 5}.

Theorem 4.7 The Algebraic Numbers are countable.

Proof: If we show each A_{n} is at most countable, then as A = ∪_{n=1}^{∞}A_{n}, by Corollary 4.5 A is at most countable.

Recall the Fundamental Theorem of Algebra (FTA): Let f(x) be a polynomial of degree n with complex coefficients. Then f(x) has n (not necessarily distinct) roots. Of course, we will only need a weaker version, namely that the Fundamental Theorem of Algebra holds for polynomials with integer coefficients.

Fix an n ∈ ℕ. We now show A_{n} is at most countable. We can represent every integral polynomial f(x) = a_{n}x^{n} + ⋯ + a_{0} by an (n + 1)-tuple (a_{0}, …, a_{n}). By Corollary 4.6, the set of all (n + 1)-tuples with integer coefficients (ℤ^{n+1}) is countable. Thus, there is a bijection from ℕ to ℤ^{n+1}, and we can index each (n + 1)-tuple a ∈ ℤ^{n+1}:

{a : a ∈ ℤ^{n+1}} = ⋃_{i=1}^{∞}{α_{i}},  (38)

where each α_{i} ∈ ℤ^{n+1}.

For each tuple α_{i} (or a ∈ ℤ^{n+1}), there are n roots. Let R_{α_{i}} be the roots of the integer polynomial associated to α_{i}. The roots in R_{α_{i}} need not be distinct, and the roots may solve an integer polynomial of smaller degree. For example, f(x) = (x^{2} − 1)^{4} is a degree 8 polynomial. It has two roots, x = 1 with multiplicity 4 and x = −1 with multiplicity 4, and each root is a root of a degree 1 polynomial.

Let R_{n} = {x ∈ ℂ : x is a root of a degree n polynomial}. One can show that

R_{n} = ⋃_{i=1}^{∞} R_{α_{i}} ⊃ A_{n}.  (39)

By Lemma 4.5, R_{n} is countable. Thus, by Lemma 4.2, as R_{n} is at most countable, A_{n} is at most countable.

Therefore, each A_{n} is at most countable, so by Corollary 4.5 A is at most countable. As A_{1} ⊃ ℚ (given \frac{p}{q} ∈ ℚ, consider qx − p = 0), A_{1} is at least countable. As we’ve shown A_{1} is at most countable, this implies A_{1} is countable. Thus, A is countable. □

4.4 Transcendental Numbers

A set is uncountable if there is no bijection between it and the rationals (or the integers, or any countable set).

Theorem 4.8 The set of irrationals in [0, 1] is uncountable.

Proof: Let I = [0, 1] − ℚ = {x : 0 ≤ x ≤ 1 and x ∉ ℚ}. Assume that I is countable (the case where I is finite is even easier).

We can write every number in I in a base two expansion, say y = .y_{1}y_{2}y_{3}y_{4} ⋯, y_{i} ∈ {0, 1}, y = ∑_{i} y_{i}2^{−1}. Certain numbers can be written two different ways. For example, 0.010011111111111 ⋯ = .0101. As we are assuming I is countable, including both representations of these numbers is equivalent to taking the union of two countable sets, which by Theorem 4.4 is countable.

Further, we can add back all the rationals in [0, 1], as there are countably many rationals in [0, 1]. Call this set S (the union of the irrationals, the alternate representation of some of the irrationals, and the rationals). As X is contained in the union of three at most countable sets (and two are countable), X is countable by Theorem 4.4.

There is therefore a bijection between ℕ and X. We can enumerate the elements by {x_{1}, x_{2}, x_{3}, …}.

For each x_{i}, let .x_{i1}x_{i2}x_{i3} ⋯ x_{ii} ⋯ be its binary expansion. We list the countable members of X:

x_{1} = x_{11}x_{12}x_{13}x_{14} ⋯
x_{2} = x_{21}x_{22}x_{23}x_{24} ⋯
x_{3} = x_{31}x_{32}x_{33}x_{34} ⋯
⋮
x_{n} = x_{n1}x_{n2}x_{n3}x_{n4} ⋯ x_{nn} ⋯
⋮  (40)

We construct a real number x ∈ [0, 1] not in X. As this was supposed to be (more than a) complete list of all reals in [0, 1], this will contradict the assumption that I is countable.

Consider the number z = .z_{1}z_{2}z_{3} ⋯ z_{n} ⋯ defined by z_{n} = 1 − x_{nn}. Can z be one of the numbers in our list? For example, could z = x_{m}?

No, as they differ in the m^{th} digit. Thus, z is not on our list, violating the assumption that we had a complete enumeration. Note we had to be careful and make sure we included all equivalent ways of writing the same number. Thus, while z disagrees with the base two expansion of x_{m}, it cannot be an equivalent way of representing x_{m}, as all equivalent ways of representing x_{m} are in our list. This is merely an annoying technical detail.

Thus, the set of irrationals in [0, 1] is not countable. □.

The above proof is due to Cantor (1873 − 1874), and is known as Cantor’s Diagonalization Argument. Note Cantor’s proof shows that most numbers are transcendental, though it doesn’t tell us which numbers are transcendental. We can easily show many numbers (such as \sqrt{3 + 2^{\frac{3}{5}} \sqrt{7}}) are algebraic. What of other numbers, such as π and e?

Lambert (1761), Legendre (1794), Hermite (1873) and others proved π irrational; Legendre (1794) also proved π irrational. In 1882 Lindemann proved π transcental.

What about e? Euler (1737) proved that e and e^{2} are irrational, Liouville (1844) proved e is not an algebraic number of degree 2, and Hermite (1873) proved e is transcendental.

Liouville (1851) showed transcendental numbers exist; we will discuss his construction later.

5 Introduction to Number Theory

5.1 Dirichlet’s Box Principle

Definition 5.1 (Dirichlet’s Box Principle / Pidgeon Hole Principle) Consider n boxes, and place n+1 objects in the n boxes. Then some box contains at least two objects.

We will use Dirichlet’s Box Principle to find good rational approximations to irrational numbers.

5.1.1 Approximation by Rationals

Let α ∈ ℝ− ℚ be an irrational number. We are looking for a rational number \frac{p}{q} such that |α − \frac{p}{q} | is small, so that \frac{p}{q} is a good rational approximation to α.

Lemma 5.2 Let α ∈ ℝ − ℚ. Then there exist p, q ∈ ℤ, q ≠ 0 such that:

|α − \frac{p}{q}| ≤ \frac{1}{q}  (1)

Proof. It is enough to prove this for α ∈ (0, 1). Let q ≥ 1 and divide the interval [0, 1) into q intervals [\frac{p}{q}, \frac{p+1}{q}) of length \frac{1}{q}. Then α belongs to one of these intervals. For some 0 < p < q we then have:

α ∈ [\frac{p}{q}, \frac{p + 1}{q}) ⇒ |α − \frac{p}{q}| ≤ \frac{1}{q}.  (2)

To obtain a better approximation, we start with an irrational number α ∈ (0, 1) and an integer parameter Q > 1. As before, divide the interval (0, 1) into Q equal pieces (\frac{a}{Q}, \frac{a+1}{Q}). Consider the Q + 1 numbers inside the interval (0, 1):

{α}, {2α}, ..., {(Q + 1)α},  (3)

where {x} denotes the fractional part of x. Letting [x] denote the greatest integer less than or equal to x, we have x = [x] + {x}.

By Dirichlet’s Box Principle, at least two of these numbers, say {q_{1}α} and \{q_{2}α\}, belong to a common interval of length \frac{1}{Q}. Without loss of generality, we may take 1 ≤ q_{1} < q_{2} ≤ Q + 1.

Hence

|\{q_{2}α\} − \{q_{1}α\}| ≤ \frac{1}{Q}  (4)

and

|(q_{2}α − n_{2}) − (q_{1}α − n_{1})| ≤ \frac{1}{Q}, n_{i} = [q_{i}α].  (5)

Now let q = q_{1} − q_{2}, 1 ≤ q ≤ Q and p = n_{1} − n_{2} ∈ ℤ. Then

|qα − p| ≤ \frac{1}{Q}  (6)

and hence

|α − \frac{p}{q}| ≤ \frac{1}{qQ} ≤ \frac{1}{q^{2}} .  (7)

We have proven

Theorem 5.3 Given α ∈ ℝ, there exist p, q ∈ ℤ, q ≠ 0, such that

|α − \frac{p}{q}| < \frac{1}{q^{2}} .  (8)

5.2 Counting the Number of Primes

5.2.1 Euclid

Lemma 5.4 (Euclid) There are infinitely many primes.

Proof by contradiction: Assume there are only finitely many primes, say p_{1}, p_{2}, …, p_{n}. Consider

x = p_{1}p_{2}..p_{n} + 1.  (9)

x cannot be prime, as we are assuming p_{1} through p_{n} is a complete list of primes. Thus, x is composite, and divisible by a prime. However, p_{i} cannot divide x, as it gives a remainder of 1. Thus, x would have to be divisible by some prime not in our list, again contradicting the assumption that p_{1} through p_{n} is a complete enumeration of the primes. □

Exercise 31 Try, using Euclid’s argument, to find an explicit lower bound (as weak as you like) to the function:

π(X) = #{p : p is prime and p ≤ X}.  (10)

5.2.2 Dirichlet’s Theorem

Theorem 5.5 (Primes in Arithmetic Progressions) Let a and b be relatively prime integers. Then there are infinitely many primes in the progression an + b. Further, for a fixed a, to first order all relatively prime b give progressions having the same number of primes.

Notice that the condition (a, b) = 1 is necessary. If gcd(a, b) > 1, an + b can never be prime. Dirichlet’s remarkable result is that this condition is also sufficient.

Exercise 32 Dirichlet’s theorem is not easy to prove, but try to prove it in the particular case a = 4, b = −1, i.e. for the arithmetic progression 4n − 1, using an argument similar to Euclid’s. Proving there are infinitely many primes of the form 4n + 1 is a lot harder.

5.2.3 Prime Number Theorem

Theorem 5.6 (Prime Number Theorem or PNT) As X → ∞,

π(X) ∼ \frac{X}{log X}  (11)

The Prime Number Theorem was proved in 1896 by Jacques Hadamard and Charles Jean Gustave Nicolas Baron de la Vallee Poussin. Of course, we need to quantify what π(X) ∼ \frac{X}{log X} means. Basically, there is an error function E(X) such that |π(X) − \frac{X}{log X} | ≤ E(X), and E(X) grows slower than \frac{X}{log X}.

A weaker version was proved by Pafnuty Chebyshev (around 1850).

Theorem 5.7 (Chebyshev) There exist explicit positive constants A and B such that, for n > 30:

\frac{AX}{log X} ≤ \frac{π(X)}{X} ≤ \frac{BX}{log X} .  (12)

Chebyshev showed one can take A = log (\frac{2^{\frac{1}{2}} 3^{\frac{1}{3}} 4^{\frac{1}{4}}}{30^{\frac{1}{30}}} ) ≈ .921 and B = \frac{6A}{5} ≈ 1.105, which are indeed very close to 1. To highlight the method, we will use cruder arguments and prove the theorem for a smaller A and a larger B.

Chebyshev’s argument uses an identity using von Mangoldt’s Lambda function Λ(n), where Λ(n) = log p if m = p^{k} for some prime p, and 0 otherwise.

Define the function

T (X) = ∑_{1≤n≤X} Λ(n)[\frac{X}{n} ] = ∑_{n≥1} Λ(n)[\frac{X}{n} ].  (13)

Exercise 33 Show that T (X) = ∑_{n≤X} log n.

Now, it is easy to see (compare upper and lower sums) that

∑_{n≤X} log n = ∫_{1}^{X} log t dt + O(log X) = X log X − X + O(log X), (14)

giving a good approximation to the function T (X). The trick is to look at

T (X) − 2T (\frac{X}{2} ) = ∑_{n} Λ(n)([\frac{X}{n} ] − 2[\frac{X}{2n}])  (15)

By the previous remarks, the LHS = X log 2 + O(log X). Also,

RHS ≤ ∑_{p≤X}(log p)\frac{log X}{log p} = π(X) log X.  (16)

Hence we immediately obtain the lower bound:

π(X) ≥ \frac{X log 2}{log X} + O(log X)  (17)

Exercise 34 Prove the bound in Equation 16.

To obtain an upper bound for π(X), we notice that, since [2α] ≥ 2[α], the sum in equation (15) has only positive terms. By dropping terms we get a lower bound.

T (X) − 2T (\frac{X}{2} ) ≥ ∑_{X/2<n≤X} Λ(n)([\frac{X}{n} ] − 2[\frac{X}{2n}])
≥ ∑_{X/2<p≤X} log p
≥ log (\frac{X}{2} ) ∑_{X/2<p≤X} 1

= log (\frac{X}{2} )(π(X) − π(\frac{X}{2} ))  (18)

Hence we obtain an upper bound for the number of primes between \frac{X}{2} and X:

π(X) − π(X/2) ≤ \frac{X log 2}{log(\frac{X}{2} )} + O(1)  (19)

Now, if we write inequality (19) for X, \frac{X}{2} , \frac{X}{2^{2}} , … we get

π(X) − π(X/2) ≤ 2\frac{X/2}{log(X/2)}
π(X/2) − π(X/2^{2}) ≤ 2\frac{X/2^{2}}{log(X/2^{2})}
⋮
π(X/2^{k−1}) − π(X/2^{k}) ≤ 2\frac{X/2^{k}}{log(X/2^{k})}  (20)

as long as \frac{X}{2^{k}} ≥ 1, i.e. k ≤ [log_{2} X] = k_{0}. Summing the above inequalities we get on the left hand side a telescoping sum. All the terms cancel, except for the leading term π(X) and π(X/2^{k_{0}}) = 0.

Thus

π(X) ≤ 2 ∑_{k=1}^{k_{0}} \frac{X/2^{k}}{log(X/2^{k})}  (21)

To evaluate the sum in the above inequality we split it into two parts, k ”small” and k ”large”. More precisely, let n_{0} = log_{2}(X^{1/10}) so that 2^{n_{0}} = X^{1/10} and note that:

2 ∑_{k>n_{0}} \frac{X/2^{k}}{log(X/2^{k})} ≤ 2 ∑_{k>n_{0}} \frac{X}{2^{k}} ≤ \frac{2X}{2^{n_{0}}} = \frac{2X}{X^{1/10}} = 2X^{9/10}.  (22)

Hence the contribution from k ”large” is very small compared to what we expect (i.e. order of magnitude \frac{X}{log X}), or we can say that the main term comes from the sum over k small.

We now evaluate the contribution from small k.

2 ∑_{k=1}^{n_{0}} \frac{X}{2^{k}} \frac{1}{log(X/2^{k})} ≤ \frac{2X}{log(X/2^{n_{0}})} ∑_{k=1}^{n_{0}} \frac{1}{2^{n_{0}}} ≤ \frac{2X}{log(X^{9/10})} = \frac{20}{9} \frac{X}{log X} (23)

Hence the right hand side of the equation (21) is made up of two parts, a main term of size \frac{BX}{log X} coming from equation (23), and a lower order term coming from equation (22).

For X sufficiently large,

π(X) ≤ \frac{BX}{log X}  (24)

where B can be any constant strictly bigger than \frac{20}{9}.

To obtain Chebyshev’s better constant we would have to work a little harder along these lines, but it is the same method.

Gathering equations (17) and (24) we see we have proven

\frac{AX}{log X} ≤ π(X) ≤ \frac{BX}{log X} .  (25)

While this is not an asymptotic for π(X), it does give the right order of magnitude for π(X), namely \frac{X}{log X}.

Exercise 35 Using Chebyshev’s Theorem, Prove Bertrand’s Postulate: for any integer n ≥ 1, there is always a prime number between n and 2n.