Top Banner
Chapter 8 – Chapter 8 – Introduction Introduction to Number Theory to Number Theory Prime Numbers Prime Numbers prime numbers only have divisors of 1 and prime numbers only have divisors of 1 and self self they cannot be written as a product of other they cannot be written as a product of other numbers numbers note: 1 is prime, but is generally not of note: 1 is prime, but is generally not of interest interest eg. 2,3,5,7 are prime, 4,6,8,9,10 are not eg. 2,3,5,7 are prime, 4,6,8,9,10 are not prime numbers are central to number theory prime numbers are central to number theory list of prime number less than 200 is: list of prime number less than 200 is: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 151 157 163 167 173 179 181 191 193 197 199
35

Chapter 8 – Introduction to Number Theory Prime Numbers prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Chapter 8 – Chapter 8 – Introduction to Introduction to Number TheoryNumber Theory

Prime Numbers Prime Numbers prime numbers only have divisors of 1 and self prime numbers only have divisors of 1 and self

they cannot be written as a product of other numbers they cannot be written as a product of other numbers note: 1 is prime, but is generally not of interest note: 1 is prime, but is generally not of interest

eg. 2,3,5,7 are prime, 4,6,8,9,10 are noteg. 2,3,5,7 are prime, 4,6,8,9,10 are not prime numbers are central to number theoryprime numbers are central to number theory list of prime number less than 200 is: list of prime number less than 200 is:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 131 137 139 149 151 157 163 167 173 179 181 191

193 197 199193 197 199

Page 2: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Prime FactorisationPrime Factorisation

to to factorfactor a number a number nn is to write it as a is to write it as a product of other numbers: product of other numbers: n=a x b x cn=a x b x c

note that factoring a number is relatively note that factoring a number is relatively hard compared to multiplying the factors hard compared to multiplying the factors together to generate the number together to generate the number

thethe prime factorisation prime factorisation of a number of a number nn is is when its written as a product of primes when its written as a product of primes eg. eg. 91=7x13 ; 3600=291=7x13 ; 3600=244x3x322x5x522

Page 3: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Relatively Prime Numbers & GCDRelatively Prime Numbers & GCD

two numbers two numbers a, ba, b are are relatively primerelatively prime if have if have no common divisorsno common divisors apart from 1 apart from 1 eg. 8 & 15 are relatively prime since factors of 8 are eg. 8 & 15 are relatively prime since factors of 8 are

1,2,4,8 and of 15 are 1,3,5,15 and 1 is the only 1,2,4,8 and of 15 are 1,3,5,15 and 1 is the only common factor common factor

conversely can determine the greatest common conversely can determine the greatest common divisor by comparing their prime factorizations divisor by comparing their prime factorizations and using least powersand using least powers eg. eg. 300300=2=211x3x311x5x522 18=2 18=211x3x322 hencehence GCD(18,300)=2GCD(18,300)=211x3x311x5x500=6=6

Page 4: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Fermat's TheoremFermat's Theorem

aap-1p-1 = 1 (mod p) = 1 (mod p) where where pp is prime and is prime and gcd(a,p)=1gcd(a,p)=1

also known as Fermat’s Little Theoremalso known as Fermat’s Little Theorem also also aapp = p (mod p) = p (mod p) useful in public key and primality testinguseful in public key and primality testing

Page 5: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Euler Totient Function Euler Totient Function ø(n)ø(n)

when doing arithmetic modulo n when doing arithmetic modulo n complete set of residuescomplete set of residues is: is: 0..n-10..n-1 reduced set of residuesreduced set of residues is those numbers is those numbers

(residues) which are relatively prime to n (residues) which are relatively prime to n eg for n=10, eg for n=10, complete set of residues is {0,1,2,3,4,5,6,7,8,9} complete set of residues is {0,1,2,3,4,5,6,7,8,9} reduced set of residues is {1,3,7,9} reduced set of residues is {1,3,7,9}

number of elements in reduced set of residues is number of elements in reduced set of residues is called the called the Euler Totient Function ø(n)Euler Totient Function ø(n)

Page 6: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Euler Totient Function Euler Totient Function ø(n)ø(n)

to compute ø(n) need to count number of to compute ø(n) need to count number of residues to be excludedresidues to be excluded

in general need prime factorization, butin general need prime factorization, but for p (p prime) for p (p prime) ø(p) = p-1ø(p) = p-1 for p.q (p,q prime)for p.q (p,q prime) ø(pq) =(p-ø(pq) =(p-1)x(q-1)1)x(q-1)

eg.eg.ø(37) = 36ø(37) = 36ø(21) = (3–1)x(7–1) = 2x6 = 12ø(21) = (3–1)x(7–1) = 2x6 = 12

Page 7: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Euler's TheoremEuler's Theorem

a generalisation of Fermat's Theorem a generalisation of Fermat's Theorem aaø(n)ø(n) = 1 (mod n) = 1 (mod n)

for any for any a,na,n where where gcd(a,n)=1gcd(a,n)=1 eg.eg.

aa=3;=3;nn=10; ø(10)=4; =10; ø(10)=4; hence 3hence 34 4 = 81 = 1 mod 10= 81 = 1 mod 10

aa=2;=2;nn=11; ø(11)=10;=11; ø(11)=10;hence 2hence 210 10 = 1024 = 1 mod 11= 1024 = 1 mod 11

Page 8: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Primality TestingPrimality Testing

often need to find large prime numbers often need to find large prime numbers traditionally traditionally sievesieve using using trial divisiontrial division

ie. divide by all numbers (primes) in turn less than the ie. divide by all numbers (primes) in turn less than the square root of the number square root of the number

only works for small numbersonly works for small numbers alternatively can use statistical primality tests alternatively can use statistical primality tests

based on properties of primes based on properties of primes for which all primes numbers satisfy property for which all primes numbers satisfy property but some composite numbers, called pseudo-primes, but some composite numbers, called pseudo-primes,

also satisfy the propertyalso satisfy the property can use a slower deterministic primality testcan use a slower deterministic primality test

Page 9: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Miller Rabin AlgorithmMiller Rabin Algorithm

a test based on Fermat’s Theorema test based on Fermat’s Theorem algorithm is:algorithm is:

TEST (TEST (nn) is:) is:1. Find integers 1. Find integers kk, , qq, , k k > 0, > 0, q q odd, so that odd, so that ((nn–1)=2–1)=2kkqq2. Select a random integer 2. Select a random integer aa, 1<, 1<aa<<nn–1–13. 3. if if aaqq mod mod n n = 1= 1 then then return (“maybe prime");return (“maybe prime");4. 4. for for j j = 0 = 0 to to k k – 1 – 1 dodo

5. 5. ifif ( (aa22jjqq mod mod n n = = nn-1-1))

then then return(" maybe prime ")return(" maybe prime ")6. return ("composite")6. return ("composite")

Page 10: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Probabilistic ConsiderationsProbabilistic Considerations

if Miller-Rabin returns “composite” the if Miller-Rabin returns “composite” the number is definitely not primenumber is definitely not prime

otherwise is a prime or a pseudo-primeotherwise is a prime or a pseudo-prime chance it detects a pseudo-prime is < chance it detects a pseudo-prime is < 11//44

hence if repeat test with different random a hence if repeat test with different random a then chance n is prime after t tests is:then chance n is prime after t tests is: Pr(n prime after t tests) = 1-4Pr(n prime after t tests) = 1-4-t-t

eg. for t=10 this probability is > 0.99999eg. for t=10 this probability is > 0.99999

Page 11: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Prime DistributionPrime Distribution

prime number theorem states that primes prime number theorem states that primes occur roughly every (occur roughly every (ln nln n) integers) integers

but can immediately ignore evensbut can immediately ignore evens so in practice need only test so in practice need only test 0.5 ln(n)0.5 ln(n)

numbers of size numbers of size nn to locate a prime to locate a prime note this is only the “average”note this is only the “average” sometimes primes are close togethersometimes primes are close together other times are quite far apartother times are quite far apart

Page 12: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Chinese Remainder TheoremChinese Remainder Theorem

used to speed up modulo computations used to speed up modulo computations if working modulo a product of numbers if working modulo a product of numbers

eg. eg. mod M = mmod M = m11mm22..m..mkk

Chinese Remainder theorem lets us work Chinese Remainder theorem lets us work in each moduli min each moduli mi i separately separately

since computational cost is proportional to since computational cost is proportional to size, this is faster than working in the full size, this is faster than working in the full modulus Mmodulus M

Page 13: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Chinese Remainder TheoremChinese Remainder Theorem

can implement CRT in several wayscan implement CRT in several ways to compute to compute A(mod M)A(mod M)

first compute all first compute all aaii = A mod m = A mod mii separately separately determine constants determine constants ccii below, where below, where MMii = M/m = M/mii

then combine results to get answer using:then combine results to get answer using:

Page 14: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Primitive RootsPrimitive Roots

from Euler’s theorem have from Euler’s theorem have aaø(n)ø(n)mod n=1 mod n=1 consider consider aamm=1 (mod n), GCD(a,n)=1=1 (mod n), GCD(a,n)=1

must exist for must exist for m = m = ø(n)ø(n) but may be smaller but may be smaller once powers reach m, cycle will repeatonce powers reach m, cycle will repeat

if smallest is if smallest is m = m = ø(n)ø(n) then then aa is called a is called a primitive rootprimitive root

if if pp is prime, then successive powers of is prime, then successive powers of aa "generate" the group "generate" the group mod pmod p

these are useful but relatively hard to find these are useful but relatively hard to find

Page 15: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

Discrete LogarithmsDiscrete Logarithms

the inverse problem to exponentiation is to find the inverse problem to exponentiation is to find the the discrete logarithmdiscrete logarithm of a number modulo p of a number modulo p

that is to find that is to find xx such that such that y = gy = gxx (mod p) (mod p) this is written as this is written as x = logx = loggg y (mod p) y (mod p) if g is a primitive root then it always exists, if g is a primitive root then it always exists,

otherwise it may not, eg.otherwise it may not, eg.x = logx = log33 4 mod 13 has no answer 4 mod 13 has no answer

x = logx = log22 3 mod 13 = 4 by trying successive powers 3 mod 13 = 4 by trying successive powers whilst exponentiation is relatively easy, finding whilst exponentiation is relatively easy, finding

discrete logarithms is generally a discrete logarithms is generally a hardhard problem problem

Page 16: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

SummarySummary

have considered:have considered: prime numbersprime numbers Fermat’s and Euler’s Theorems & Fermat’s and Euler’s Theorems & ø(n)ø(n) Primality TestingPrimality Testing Chinese Remainder TheoremChinese Remainder Theorem Discrete LogarithmsDiscrete Logarithms

Page 17: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

73 74 75 76 77 78 79 80 81

72 43 44 45 46 47 48 49 50

71 42 21 22 23 24 25 26 51

70 41 20 7 8 9 10 27 52

69 40 19 6 1 2 11 28 53

68 39 18 5 4 3 12 29 54

67 38 17 16 15 14 13 30 55

66 37 36 35 34 33 32 31 56

65 64 63 62 61 60 59 58 57

Ulam’s Spiral

Page 18: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

                                                                                                                                                       

Credits: The Ulam Rose of 1 => 262,144 used here is an embellishment of an image originally created by Jean-François Colonna ©1996, CNET and the École Polytechnique, Paris France. The picture used here comes from Cracking the Bible Code by Jeffrey Satinover, M.D.

               

Page 19: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

http://www.imathination.org/3d_ulam_spiral_ani_large.html#mark2

More Ulam’s Spiral

Page 20: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 21: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 22: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 23: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 24: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.

let position (0,0).let counter = 0;Repeat {if (counter is a prime){let x = mod(counter,5);

if(x=1) move position up; else if(x=2) move position down;else if(x=3) move position right; else if(x=4) move position left;

increment colour of pixel at position; increment counter 1;}

Page 25: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 26: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 27: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 28: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 29: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 30: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 31: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 32: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 33: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 34: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Page 35: Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.