Friday, August 18, 2006

 

Prime probability remainder error, fixed

I talked for a while about using the lack of a prime preference for a particular residue modulo another prime i.e. given primes p_1 and p_2

p_1 mod p_2

shows no preference for a particular non-zero residue of p_2 to get prime probability, and this approach was considered to be heuristic, but a couple of days ago I stepped through how it is equivalent to using Legendre's Formula without the use of the floor() function, so errors crop up, which are remainder errors.

But with that explanation in hand, it turns out there is an easy way to correct for the remainder errors which I'll describe in this post.

What's remarkable though is that the research I've been doing does not show that mathematicians figured out the reason for the failure of what they seem to have thought was an intuitive idea—not rigorous—that was to be dropped because it failed, versus seeing the puzzling failure as an opportunity.

Now then consider this approach for the count of primes up to 100:

100*(6/7)*(4/5)*(2/3)*(1/2) = 22.857 to five significant figures

which is using the straightforward but flawed approach of just multiplying and dividing without any use of the floor() function, which adds remainder error.

But here's a simple trick for removing that problem, which is to divide off factors in common between x and p_j*···*2, and then divide by what remains, discarding the remainder as long the result is greater than 1—if it's not then you drop probabilities for the largest prime until it is, and then divide dropping off the remainder—and then multiply that result times (p_k - 1)*···*2, where k is the kth prime remaining and k=j if no primes were dropped, to get the expected.

For example with x=100, first you divide off 10, so what's left is

10*(6/7)*(4)*(2/3)

and since 21 is greater than 10, next you'd drop (6/7), so you have

10*4*(2/3) where now you use floor(), so you have

4*2*floor(10/3)= 4*2*3 = 24

which is only off by 1.

And notice that the the probability given by now dividing by 100, is 24% closer to the exact 25%, as there are 25 primes up to 100.

So there is a simple way to solve that problem.

The reason this idea works is that the actual count of naturals up to and including a natural number x that have a prime p as a factor is given by

floor(x/p)

so absolutely the probability can be said to be floor(x/p)/x. The idea I've outlined is more along the lines of that usage, so it's a simple idea that removes the remainder error.

Intriguingly then, this way of calculating x*(p_j - 1)*···*(1/2) cannot be approximated by using Merten's theorem, as the approximately 12% error that arise from the lack of use of the floor() function is removed.

Here is a recap of the technique written more rigorously:

probPrime(x) = ((p_k - 1)*···*2)*floor(x/(p_k*···*2))/x

such that x>(p_k*···*2), where k is the largest prime less than or equal to j that will fit, where j is the count of primes up to and including sqrt(x).

So shifting things about in a simple way changes everything, and explains the prime distribution without much fuss, while using what people thought was a flawed intuitive approach, when the approach wasn't the problem—the problem was error introduced by not using the floor() function.

This solution is a nice one on a scale that my fellow physics people should be able to appreciate, showing the power of simplicity in thinking, and is I think, an expression of Occam's Razor at work.

Short of it is, simple is good.





<< Home

This page is powered by Blogger. Isn't yours?