chapter 7 introduction to number theory
Download
Skip this Video
Download Presentation
Chapter 7 – Introduction to Number Theory

Loading in 2 Seconds...

play fullscreen
1 / 35

Chapter 7 – Introduction to Number Theory - PowerPoint PPT Presentation


  • 117 Views
  • Uploaded on

Chapter 7 – Introduction to Number Theory. Instructor: 孫宏民 [email protected] Room: EECS 6402, Tel:03-5742968, Fax : 886-3-572-3694. Prime Numbers. prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Chapter 7 – Introduction to Number Theory' - appollo-kristin


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 7 introduction to number theory

Chapter 7– Introduction to Number Theory

Instructor: 孫宏民

[email protected]: EECS 6402, Tel:03-5742968, Fax : 886-3-572-3694

prime numbers
Prime Numbers
  • prime numbers only have divisors of 1 and self
    • they cannot be written as a product of other numbers
    • note: 1 is prime, but is generally not of interest
  • eg. 2,3,5,7 are prime, 4,6,8,9,10 are not
  • prime numbers are central to number theory
  • 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 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

prime factorisation
Prime Factorisation
  • to factor a number n is to write it as a product of other numbers: n=a × b × c
  • note that factoring a number is relatively hard compared to multiplying the factors together to generate the number
  • the prime factorisation of a number n is when its written as a product of primes
    • eg. 91=7×13 ; 3600=24×32×52
relatively prime numbers gcd
Relatively Prime Numbers & GCD
  • two numbers a, b are relatively prime if have no common divisors apart from 1
    • 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 common factor
  • conversely can determine the greatest common divisor by comparing their prime factorizations and using least powers
    • eg. 300=21×31×52 18=21×32hence GCD(18,300)=21×31×50=6
fermat s theorem
Fermat\'s Theorem
  • ap-1 mod p = 1
    • where p is prime and gcd(a,p)=1
  • also known as Fermat’s Little Theorem
  • useful in public key and primality testing
euler totient function n
Euler Totient Function ø(n)
  • when doing arithmetic modulo n
  • complete set of residues is: 0..n-1
  • reduced set of residues is those numbers (residues) which are relatively prime to n
    • eg for n=10,
    • complete set of residues is {0,1,2,3,4,5,6,7,8,9}
    • reduced set of residues is {1,3,7,9}
  • number of elements in reduced set of residues is called the Euler Totient Function ø(n)
euler totient function n1
Euler Totient Function ø(n)
  • to compute ø(n) need to count number of elements to be excluded
  • in general need prime factorization, but
    • for p (p prime) ø(p) = p-1
    • for p.q (p,q prime) ø(p.q) = (p-1)(q-1)
  • eg.
    • ø(37) = 36
    • ø(21) = (3–1)×(7–1) = 2×6 = 12
euler s theorem
Euler\'s Theorem
  • a generalisation of Fermat\'s Theorem
  • aø(n)mod N = 1
    • where gcd(a,N)=1
  • eg.
    • a=3;n=10; ø(10)=4;
    • hence 34 = 81 = 1 mod 10
    • a=2;n=11; ø(11)=10;
    • hence 210 = 1024 = 1 mod 11
primality testing
Primality Testing
  • often need to find large prime numbers
  • traditionally sieve using trial division
    • ie. divide by all numbers (primes) in turn less than the square root of the number
    • only works for small numbers
  • alternatively can use statistical primality tests based on properties of primes
    • for which all primes numbers satisfy property
    • but some composite numbers, called pseudo-primes, also satisfy the property
miller rabin algorithm
Miller Rabin Algorithm
  • a test based on Fermat’s Theorem
  • algorithm is:

TEST (n) is:

1. Find integers k, q, k > 0, q odd, so that (n–1)=2kq

2. Select a random integer a, 1<a<n–1

3. if aqmod n = 1then return (“maybe prime");

4. for j = 0 to k – 1 do

5. if (a2jqmod n = n-1)

then return(" maybe prime ")

6. return ("composite")

probabilistic considerations
Probabilistic Considerations
  • if Miller-Rabin returns “composite” the number is definitely not prime
  • otherwise is a prime or a pseudo-prime
  • chance it detects a pseudo-prime is < ¼
  • hence if repeat test with different random a then chance n is prime after t tests is:
    • Pr(n prime after t tests) = 1-4-t
    • eg. for t=10 this probability is > 0.99999
prime distribution
Prime Distribution
  • prime number theorem states that primes occur roughly every (ln n) integers
  • since can immediately ignore evens and multiples of 5, in practice only need test 0.4 ln(n) numbers of size n before locate a prime
    • note this is only the “average” sometimes primes are close together, at other times are quite far apart
algebraic system
Algebraic System
  • Binary Operation: Given a nonempty set S and a function op : S×SS, then op is a binary operation on S.
  • Examples: S= N and op = × :the multiple of integer S= N and op = +: the addition of integer.
  • Algebratic Systems: (S, op1, op2, …, opn), where S is a nonenmpty set and there are at least one binary operation on S.
  • Examples: (R, +, ×) and (Z, +, ×)
slide14
Properties of Algebratic Systems
    • Closure: a op b  S, where a and b S.
    • Associative: (a op b) op c= a op (b op c) for (S, op), where a, b, and c S.
    • Communicative: a op b = b op a for (S, op) for a and b S.
    • (Z, -) have no communicative property.
    • Identity: For (S, op), eS, aS, such that a op e= e op a= a.
    • Example: For (Z, +), e=0, for (Z, ×), e= 1.
    • Inverses: For (S, op), aS, bS, such that a op b = b op a = e.
    • Symbol : a-1 or -a.
slide15
Example: For (Z, +), the inverse of a is -a.
  • Example: For (R/{0}, ×), the inverse of a is a-1 while, for (Z, ×), there is no inverse for any integer.
  • Distribution: For (S, +, *), a*(b+c)= a*b+a*c, where a, b, and cS.
  • Semigroup (G,*): An algebratic system (G, *) with the following properties: Closure, association, and an identity.
  • Theorem: For a semigroup (G, *), the identity is unique.
slide16
Groups (G, *) : A semigroup (G, *) with inverses.
  • Examples:(Z, +), (R/{0}, *) are groups.
  • Abelian (Commutative) Groups: the group with communitative property
  • Theorem: For a group (G, *), the inverse of an element in G is unique.
  • Field (F, +, *):
  • (F, +) is a commutative group.
  • (F, *) is a semigroup and (F-{0}, *) is a commutative group, where 0 is the identity for the operation +.
finite fields
Finite Fields
  • Finite Group (G, *): A group (G, *) with finite elements in G.
  • Example: ({0, 1, …, N-1}, +N) is a finite group, where N is an integer.
  • Cyclic Group (G, *): For a group (G, *), there exists an element a such that G= {an|nZ}, where an =a*a* …*a (n-1 times).
  • a:primitive root (with the order n=|G|).
  • Example: ({1, …, 6}, *7) is a cyclic group with the primitive root 3. [{3, 2, 6, 4, 5, 1}, & order= 6]
slide18
Generator with order m: am=1.
  • Finite Fields: A field (F, +, *) with finite elements in F.
  • Example:GF(P)= ({0, 1, …, P-1}, +P, *P) for a prime number P. [The first finite fields].
some famous finite fields p is a prime number
Some Famous Finite Fields [P is a prime number]
  • GF(P) or ZP.
  • GF(Pn): Given an irreducible polynomial Q(x) of degree n over GF(P).
  • GF(2n) for P= 2.
  • Example: Q(x)= x3+x+1 over GF(2)
  • (x+1)+ (x)= 1.
  • (x+1)*x2= x2+x+1.
congruences
Congruences
  • Given integers a, b, and n 0, a, is congruent to b modulo n, written

ab mod n

if and only if

ab = kn

for some integer k.

Ex. 41  93 mod13. 18  10 mod8.

slide21
If ab mod n, then b is called a residue of a modulo n (conversely, a is a residue of b modulo n).
  • A set of n integers {r1, …, rn} is called a complete set of residues modulo n if, for every integer a, there is exactly one ri in the set such that ari mod n.
  • For any modulus n, the set of integers {0, 1,…, n1} forms a complete set of residues modulo n.
computing inverses
Computing Inverses
  • Unlike ordinary integer arithmetic, modular arithmetic sometimes permits the computation of multiplicative inverse
  • That is, given an integer a in the range [0, n1], it may be possible to find a unique integer x in the range [0, n1] such that ax mod n = 1.
  • Ex. 3 and 7 are multiplicative inverses mod 10 because 21 mod 10 = 1.
  • Thm. If gcd(a, n) = 1, then (ai mod n)  (aj mod n) for each i, j such that 0 i < j < n.
slide23
This property implies that each ai mod n (i = 0, ..., n1) is a distinct residue mod n, and that the set {ai mod n}i=0, ..., n1
  • is a permutation of the complete set of residues {0, ..., n 1}.
  • This property does not hold when a and n have a common factor.
  • If gcd(a, n) = 1, then there exists an integer x, 0 < x < n, such that ax mod n = 1.
slide24
Ex. n = 5 and a = 3:

30 mod 5 = 0

31 mod 5 = 3

32 mod 5 = 1

33 mod 5 = 4

34 mod 5 = 2.

  • Ex. n = 4 and a = 2:

20 mod 4 = 0

21 mod 4 = 2

22 mod 4 = 0

23 mod 4 = 2.

solving for inverse
Solving for Inverse
  • Euler\'s generalization of Fermat\'s theorem gives us an algorithm for solving the equation

ax mod n = 1,

where gcd(a, n) = 1.

Since a(n) mod n = 1, we may compute x as

axa(n) , or

x = a(n)1 mod n.

If n is prime, this is simply

x = a(n1)1 mod n = an2 mod n.

slide26
Ex. Let a = 3 and n = 7. Then x = 35 mod 7 = 5.
  • Ex. Let a = 2 and n = 15. Then x = 27 mod 15 = 8.
  • With this approach, to compute x, you have to know (n).
another approach
Another Approach
  • x can also be computed using an extension of Euclid\'s algorithm for computing the greatest common divisor.
  • This is more suitable for computers to do.

Euclid\'s algorithm for computing greatest common divisor :

gcd(a, n)

g0n

g1a

i 1

whilegi 0

gi+1gi1modgi

ii + 1

returngi1

extended euclid s algorithm
Extended Euclid\'s Algorithm
  • Extended Euclid\'s algorithm for computing inverse (loop invariant: gi = uin + via):
  • inv(a, n)

g0n; g1a;

u0 1; v0 0;

u1 0; v1 1;

i 1

whilegi 0

ygi1divgi

gi+1gi1ygi

ui+1ui1yui

vi+1vi1yvi

ii + 1

xvi1

ifx 0

returnx

else

returnx + n

example
Example
  • Ex. To solve 3x mod 7 = 1 using the algorithm, we have
  • Because v2 = 2 is negative, the solution is x = 2 + 7 = 5.
chinese remainder theorem
Chinese Remainder Theorem
  • used to speed up modulo computations
  • working modulo a product of numbers
    • eg. mod M = m1m2..mk
  • Chinese Remainder theorem lets us work in each moduli mi separately
  • since computational cost is proportional to size, this is faster than working in the full modulus M
chinese remainder theorem1
Chinese Remainder Theorem
  • can implement CRT in several ways
  • to compute (A mod M) can firstly compute all (ai mod mi) separately and then combine results to get answer using:
example1
Example
  • Ex. Solve the equation "3x mod 10 = 1".

Since 10 = 2  5, d1 = 2 and d2 = 5. We first find solutions x1 and x2, as follows:

3x mod 2 = 1 mod 2 = 1 x1 = 1

3x mod 5 = 1 mod 5 = 1  x2 = 2

Then we apply the Chinese Remainder Theorem to find a common solution x to the equations:

slide33
x mod 2 = x1 = 1

x mod 5 = x2 = 2 .

We find y1 and y2 satisfying

(10/2) y1 mod 2 = 1 y1 = 1

(10/5) y2 mod 5 = 1 y2 = 3

Thus, we have

x = ((10/2) y1 x1 + (10/5) y2 x2) mod 10

= (511 + 232) mod 10 = 7.

primitive roots
Primitive Roots
  • from Euler’s theorem have aø(n)mod n=1
  • consider ammod n=1, GCD(a,n)=1
    • must exist for m= ø(n) but may be smaller
    • once powers reach m, cycle will repeat
  • if smallest is m= ø(n) then a is called a primitive root
  • if p is prime, then successive powers of a "generate" the group mod p
  • these are useful but relatively hard to find
discrete logarithms or indices
Discrete Logarithms or Indices
  • the inverse problem to exponentiation is to find the discrete logarithm of a number modulo p
  • that is to find x where ax = b mod p
  • written as x=loga b mod p or x=inda,p(b)
  • if a is a primitive root then always exists, otherwise may not
    • x = log3 4 mod 13 (x st 3x = 4 mod 13) has no answer
    • x = log2 3 mod 13 = 4 by trying successive powers
  • whilst exponentiation is relatively easy, finding discrete logarithms is generally a hard problem
ad