1 / 22

Prime Numbers

Prime Numbers. -Timothy Goodman -Tyson Slater. Sieve of Eratosthenes. Background Ancient Algorithm attributed to Eratosthenes Predecessor to the Sieve of Atkin Used to find primes up to n Wheel Factorization Speed increase. Seive of Eratosthenes. Algorithm

stevewebb
Download Presentation

Prime Numbers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prime Numbers -Timothy Goodman -Tyson Slater

  2. Sieve of Eratosthenes • Background • Ancient Algorithm attributed to Eratosthenes • Predecessor to the Sieve of Atkin • Used to find primes up to n • Wheel Factorization • Speed increase

  3. Seive of Eratosthenes • Algorithm • Write list of numbers from 2 to n • Create a list for holding the primes • Strike off 2 and all multiples • First remaining number in the list is prime • Strike of this number and all its multiples • Repeat last two steps until only primes left

  4. Illustration

  5. Sieve of Atkin • Background • Fast, modern algorithm • Created by A.O.L. Atkin & Daniel J. Berstein • Used to find primes up to n • Does preliminary work to increase efficiency • Multiples of 2, 3 and 5 • N mod 60 = 3, 9, 15, 21, 27, 33, 39, 45, 51, or 57 • N mod 60 = 5, 25, 35, or 55

  6. Sieve of Atkin • N mod 60 = 1, 13, 17, 29, 37, 41, 49, or 53 have a modulo-four remainder of 1. These numbers are prime if and only if the number of solutions to 4x² + y2 = n is odd and the number is squarefree • N mod 60 = 7, 19, 31, or 43 have a modulo-six remainder of 1. These numbers are prime if and only if the number of solutions to 3x² + y2 = n is odd and the number is squarefree • N mod 60 = 11, 23, 47, or 59 have a modulo-twelve remainder of 11. These numbers are prime if and only if the number of solutions to 3x² − y2 = n is odd and the number is squarefree • N mod 60 = any other remainder, ignore it

  7. Sieve of Atkin • Algorithm after preliminary work • Start with the lowest number • Take next number marked prime add to results • Square that number and mark all multiples as nonprime • Repeat

  8. Computational Complexity For computing primes up to n: • Sieve of Eratosthenes • uses O(N) operations • O(N¹/²(log log N) /log N ) bits of memory • Sieve of Atkins • using O(N /log log N) operations • N ^ ( 1/2 +O(1) ) bits of memory

  9. AKS Primality Test • Created by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena • Published in 2002 in the Annals of Mathematics in their paper titled “PRIMES is in P”. • The first such algorithm that is polynomial, unconditional, and deterministic!

  10. Polynomial – AKS was originally proven to run in O(log12+e(n)) where e is a small number. • Unconditional – It does not rely on an unproven hypothesis (the Riemann hypothesis) for correctness. • Deterministic – This algorithm is guaranteed to report whether the number is composite or prime.

  11. Basis of AKS (x – a)n= (xn – a) (mod n) iff n is prime On the following slides, I will show that if n is prime, the above congruency holds. I’ll leave the other direction of the proof as an exercise for the student.

  12. Proof – Binomial Theorem n choose k = 0 (mod n) for 0 < k < n iff n is prime. n choose 0 = n choose n = 1. yp= y (mod p) iff p is prime by Fermat’s Little Theorem. Therefore (x+y)n= xn + y (mod n) iff n is prime. Image thanks to Wikipedia.

  13. Proof – Con’t • Let n be prime. Then (x – a)n = Σ(0<=k<=n) nCk * xn-kak = nC0 * xn + nCn * an + Σ(0<k<n) nCk * xn-kak; • nC0 = nCn = 1. On the next slide I will prove that nCk is congruent to 0 mod n if n is prime. • Therefore: (x – a)n= xn – an (mod n) if n is prime.

  14. Proof – Con’t • nCk, where 0<k<n is congruent to 0 (mod n) if n is prime. nCk = n! / (k!*(n-k)!) • If 0<k<n, then k! and (n-k)! are smaller than n! Therefore the top of the equation is of the form n*(n-1)*(n-2)… -> a multiple of n. • Because n is prime, k! and (n-k)! are not factors of n, and the numerator will be larger than the denominator. Thus nCk is a multiple of prime n, which is always 0 (mod n).

  15. Proof – Con’t (x – a)n= xn - an (mod n) if n is prime. If n is prime, then an= a (mod n), by Fermat’s little theorem. Since n is prime, it is odd, and a negative value of a to a power maintains its sign. Therefore: (x – a)n= xn - a (mod n) if n is prime.

  16. AKS modification (x – a)n= (xn – a) (mod n) is therefore a primality test, where the two polynomials are congruent iff n is prime. But this takes exponential time to calculate. AKS evaluates this instead: (x – a)n= (xn – a) (mod n, xr - 1)

  17. (x – a)n= (xn – a) (mod n, xr - 1) can be evaluated in polynomial time, but some rare composites satisfy the above. The AKS paper proves that there is a suitably small r, and a suitably small set A such that if the above holds true for every a in A, then n must be prime.

  18. Choosing r • They choose an r = kq + 1 where • q is the largest prime factor of r – 1 and • q >= 4 * sqrt(r) * log2(n) and • nk != 1 (mod n) and • n is not divisible by any prime <= r They were able to prove that such an r exists and is less than some upper bound.

  19. (x – a)n= (xn – a) (mod n, xr - 1) Next, the above equivalence is tested for all a <= 2 * sqrt(r) * log2(n) in finite field GF(nr) They show that n is prime if and only if the above holds true for all such a.

  20. AKS updated Soon after the AKS algorithm was published, improvements were developed. In response, “PRIMES is in P” was republished with a new way to devise r and a more coherent proof (still not coherent enough for me)

  21. Choosing r r is now chosen to be the smallest number such that or(n) > log2(n). Set A is composed of all integers a where: a <= sqrt(Ø(r)) * log2(n). This changes the algorithm to O(log10.5n).

  22. References • To find the original paper: http://web.archive.org/web/20050716082540/www.cse.iitk.ac.in/news/primality.html • A long, well written paper which shows how to choose a polynomial to make AKS run in average time (log6(n)). http://www.math.dartmouth.edu/~carlp/PDF/complexity12.pdf • Generally good resource about AKS http://web.archive.org/web/20060528185603/http://crypto.cs.mcgill.ca/~stiglic/PRIMES_P_FAQ.html • Of course – wikipedia!

More Related