Presentation is loading. Please wait.

Presentation is loading. Please wait.

Detecting Primes William Dotson.

Similar presentations


Presentation on theme: "Detecting Primes William Dotson."— Presentation transcript:

1 Detecting Primes William Dotson

2 Overview Definitions How many primes? How do we locate?
How do we prove primality? Quick Tests Classical Tests General Purpose Tests Application Summary

3 Definitions Prime Number – an integer p is prime if and only if the only positive integers that divide it are 1 and p. Composite Number – a integer that is not prime. Relatively Prime – 2 Integers are relatively prime if they share no common factors other 1. Pseudoprime – a number that can easily be proved composite but might not as easily be proved prime. Mersenne Prime – a prime number 2n-1 where n is itself prime.

4 How Many Primes? Answer – Infinite (Euclid, 2300 years ago)
So, How many primes less than x? Pi(x) ≡ the number of primes less than x Pi(3) = 2 ,(2,3) Pi(10) = 4,(2,3,5,7) Prime number Theorem – The number of primes not exceeding x is asymptotic to x*log*x Pi(x) ≈ x*log*x

5 How Many Primes? (cont.) Actually x / (log*(x – a)
a is an arbitrary constant 1 is best choice X Pi(x) x/(log x) x/(log x -1) 1000 168 145 169 10000 1229 1086 1218 100000 9592 8686 9512 78942 72382 78030 664579 620420 661459

6 Nth Prime P(n) ≈ n*log*n (Hardy Wright)
P(n) ≈ n(log n + loglog n – 1)(Ribenboim) For 1 millionth prime, Hardy Wright gives 13.8 million, Ribenboim 15.4 million. Actually 15,485,863 P(n) ≈ n(log n + loglog(n) – 1 + (loglog(n) – 2)/log n – ((loglog(n))2 – 6loglog(n) + 11)/(2 log2 n) + O((log log n / log n)3)(Cipolla, Dusart)

7 Probability of Being Prime
Probability of x being prime is 1/(log x) E.g. Randomly choose a 1000 digit number. Can expect to test log(101000) numbers. Can reduce by eliminating certain numbers.

8 Locating Primes Sieve of Eratosthenes Trial Division a-PRP a-SPRP
N-1 tests N+1 tests APR and ECPP AKS

9 Quick Tests For numbers < 10,000,000,000 most efficient is Sieve of Eratosthenes(240 B.C.) Start with list of odd numbers. Need small primer of known prime numbers 1 24 22 20 18 16 14 12 10 8 6 4 2 3 5 21 15 9 7 11 13 17 19 23 25

10 Quick Tests Trial Division – Dividing by all prime numbers less than the square root of n. For 97 Square root ≈ 9.8 97/2 = 48.5 97/3 ≈ 32.3 97/5 = 19.4 97/7 ≈ 13.8 Next Prime is 11, so stop here. 97 is prime.

11 Fermat’s Theorem – a-PRP
Fermat’s Little Theorem p is a prime, a is any positive integer ap = a (mod p) If p does not divide a, a^(p-1) = 1(mod p) So if a(p-1) mod p ≠ 1 mod p, p is composite If it is equal, then it MIGHT be prime. P is called a weak pseudoprime base a, or just a-PRP The larger the p, the more likely this test works.

12 Carmichael Numbers Obstacle to a-PRP test
If a^p-1 = 1(mod p) for all a relatively prime to p, p is composite. Hard to detect Rare – 2000 less than 109 Infinitely Many 561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, 52633, 62745, 63973, and

13 a-SPRP Improvement n-1 = 2sd where d is odd, s is a non-negative integer. N is SPRP if ad = 1(mod n) or (ad)2r = -1 (mod n) for some negative r less than s ¾ that pass are prime Can combine SPRP results to prove primality

14 a-SPRP N<1,373,653 is both 2 and 3 SPRP, then prime
N<25,326,001 is 2,3, and 5 SPRP, then prime N<118,670,087,467 is 2,3,5,7 SPRP then either prime or is the number 3,215,031,751 N<341,550,071,728,321 is 2,3,5,7,11,13,17 SPRP , then prime * - If the generalized Riemann hypothesis is true then if n is a-SPRP for all integers a with 1<a<2(logn)2 then n is prime

15 Classical Tests N-1 test
N > 1, If for every prime factor q of n – 1 there is an integer a such that. a(n-1) = 1 (mod n) and A^(n-1)/q is not 1(mod n) Then n is prime

16 Lucas-Lehmer Test Let p be a prime an odd prime.
The Mersenne number M(p)= 2n – 1 is prime if and only if S(n-2) = 0 (mod(M(n)), where S(0) = 4 and S(k+1) = S(k)2 – 2 Exceptionally fast on computers. 2 high school students programmed this theorem in 1978 discovering the then largest known Mersenne Prime number – 1 GIMPS (Greatest Internet Mersenne Prime Search) Latest Found, 224,036,583 – 1, 7 million digits.

17 More Classical Tests Pocklington’s Theorem Pepin’s Test
Proth’s Theorem

18 General-Purpose Tests
Most of the previous tests and theorems are old. Date back before most computing. 1970’s people began using other factors other than n±1 and began to use n^2 + 1, n^2 -1, n^2 + n + 1, etc etc. APR, APR-CL algorithms Almost polynomial  (log n)(c2 log log log n)

19 Elliptical Curves, ECPP Test
E(a,b) : y2 = x3 + ax + b (with 4a3 + 27b2 not zero) |E(a,b)/p| lies in the interval (p+1- 2sqrt(p),p+1+2sqrt(p)) and the orders are fairly uniformly distributed (as we vary a and b). Polynomial for some input

20 Agrawal, Kayal and Saxena
First true polynomial algorithm No unproved assumptions Deterministic O(n6) Implementations so far have run around O(n12) but this is probably due to large constants for lower order members.

21 Applications Public-Key Cryptography Graphics Nucleotide Sequencing
Hash Tables Pseudorandom Number Generators Natural World

22 Mersenne Twister 1997 – Makoto, Matsumoto Period of 219937-1
Equidistributed Faster than most statistically unsound PRNG Statistically random in all bits

23 Graphics Examples

24 Summary Prime number theory is old Many Methods
Search will for larger primes will continue Computer Scienists and mathematicians will continue to look for more efficient methods of determining primes.

25 References M. Agrawal, N. Kayal, N.Saxena. “Primes in P.” Aug, 2002.
A.O.L. Atkin and F. Morain. "Elliptic curves and primality proving," July Wikipedia, the Free Encyclopediahttp://en.wikipedia.org/wiki/Main_Page GFDL. September 2004. Aesthetics of Prime Sequencing. Turpel Armand 2001. Primality Proving. Chris Caldwell. Mersenne Prime Search. George Woltman. September 15th, 2004. Mathworld Wolfram Research.


Download ppt "Detecting Primes William Dotson."

Similar presentations


Ads by Google