## Sunday, July 30, 2006

### Twin Primes Probability

Here a trivial little result relating to twin primes as if x is prime and greater than 3 the probability that x+2 is prime is given by:

prob = ((pj-2)/(pj-1))*((pj-1-2)/(pj-1-1))*...*(1/2)

where j is the number of primes up to sqrt(x+2), and pj is the jth prime, pj-1 is the prime before it and so forth.

The result is easy as it is just multiplying the probability for each prime that it is NOT true that

x + 2 ≡ 0 mod p

which probability is just the result of dividing one minus the number of non-zero residues by the total number of residues together to get the total probability that a prime plus 2 is also prime.

I thought I'd check quickly to see if the series converges but stopped with the last prime before 100, for which I got:

prob = 0.1558 to 4 significant digits.

So that says that the probability that for a prime between 972 and 1002 that adding 2 to it gives a prime is about 15.58% and there are 66 primes in that interval so there should be about 10 twin primes, and a quick count shows that there are:

(9419, 9421), (9431, 9433), (9437, 9439), (9461, 9463), (9629, 9631), (9677, 9679), (9719, 9721), (9767, 9769), (9857, 9859), (9929, 9931)

Come to think of it, it probably can't converge to a non-zero value but approaches 0 asymptotically, like the prime distribution itself.

Interestingly to get the distribution of twin primes you just multiply that result times the probability that a given number is prime.

Oh yeah, remarkably, efficiently the result holds for any even difference between primes towards infinity--so for any even gap g.

So then if the Twin Primes Conjecture is true it's also true that any even composite can be written as the difference of two primes.

Fascinating.

Hmmm...there's no reason for g to have to be positive, it could be negative, as the residue argument still holds.

Then the argument is that probability holds when

x + g ≡ 0 mod p

is NOT true for each prime p up to sqrt(x+g) if g is positive or sqrt(x-g) if it's negative.

So you could have p1 - C = -p2, where C is a composite and the p's are primes, as the residue result will also apply whether you take positive or negative residues, so you can consider the probability for the gap C, and if the Twin Primes Conjecture holds it would be non-zero, approaching 0 asymptotically.

Cool.

James Harris