09 October 2007

Probabilities of relative primality

From The Universe of Discourse -- the probability that two randomly-selected polynomials over Z2 are relatively prime is 1/2. (More formally, the probability that two randomly-selected polynomials over Z2 of degree less than n are relatively prime is 1/2 + 1/4n; the original result holds as n goes to infinity.) There's actually an almost one-to-one correspondence between pairs which aren't relatively prime and pairs which are. You can find this, and some more general results, in "The Probability of Relatively Prime Polynomials", from the June 2007 issue of Mathematics Magazine, (Arthur T. Benjamin and Curtis D Bennett, page 196).

The most general result is as follows: if a1(x), ..., am(x) are randomly chosen polynomials of degree less than n in F[x], where F is the finite field with q elements, then the probability that they are relatively prime is 1 - 1/qm-1 + (q-1)/qmn; this is all shown with a counting argument that invokes the Euclidean algorithm. The case from The Universe of Discourse is the case m = 2, where n goes to infinity.

This reminds me of one of my favorite statements in mathematics: "the probability that two randomly chosen integers are relatively prime is 6/π2." This seems almost meaningless -- how can we choose integers "at random"? More formally, let A(n) be the number of relatively prime pairs of integers in {1, 2, ..., n}; then
\lim_{n \to \infty} {A(n) \over n^2} = {6 \over \pi^2}

The convergence is pretty quick; A(100)/1002 = 0.6087, and A(1000)/10002 = 0.608383, while 6/π2 = 0.6079...

Why is this true? Well, the probability that two integers are relatively prime is the probability that they're not both divisible by 2, times the probability that they're not both divisible by 3, times the probabiltiy that they're not both divisible by 5, and so on. The probability that two integers aren't both divisible by a given prime p is 1 - 1/p2. So the probability that two "randomly chosen integers" aren't both divisible by the same prime p for all primes p is
\prod_p \left( 1 - {1 \over p^2} \right)

and Euler showed that this was equal to 1/ζ(2), or 6/π2.

Similarly, the probability that n randomly chosen integers are relatively prime (not pairwise relatively prime; I count a triple like (6, 10, 15), since there isn't a prime number dividing all three of those) is 1/ζ(n). We recall that
ζ(n) = 1 + (1/2)n + (1/3)n + ...
and if n is large we can throw away all but the first two terms; thus the probability that n randomly chosen integers are relatively prime is about 1 - (1/2)n. This makes sense; if there are n integers that aren't relatively prime, the reason they're not relatively prime is almost always because they're all even.

The logical next question is: what is the average of the greatest common divisor of randomly chosen integers? From some quick numerical work, it looks like
{1 \over n^2} \sum_{i=1}^n \sum_{j=1}^n \gcd(i,j)

grows like log n, that is, the average of the GCDs of pairs of integers randomly chosen from {1, 2, ..., n} is about some constant times log n. (The constant, to one decimal place, looks like 0.6.) But I don't know the answer. If I get bored at some point in the next couple days I'll see if I can figure it out.

3 comments:

Anonymous said...

Isabell -- I decided to work out what that 0.6 was, and found it was something very nice. Do you mind if I write it up on the Secret Blogging Seminar?

Michael Lugo said...

David,

I'm pretty sure I know what it is, so I'd actually rather write it up myself.

Anonymous said...

OK. At some other point, I'll do a post on how to do basic number theory estimates, but I'll find another example.