Number Theory A bit more depth. . . modular arithmetic primes - - PowerPoint PPT Presentation

number theory
SMART_READER_LITE
LIVE PREVIEW

Number Theory A bit more depth. . . modular arithmetic primes - - PowerPoint PPT Presentation

1 Number Theory A bit more depth. . . modular arithmetic primes Euclids algorithm Chinese remainder theorem Eulers totient function Eulers theorem 2 Modular Arithmetic m; n integers, n > 0


slide-1
SLIDE 1

1

Number Theory

A bit more depth. . .

modular arithmetic primes Euclid’s algorithm Chinese remainder theorem Euler’s totient function Euler’s theorem
slide-2
SLIDE 2

2

Modular Arithmetic

  • m;
n integers, n > remainder of m=n: smallest non-negative integer that differs from m by a multiple
  • f
n: m = a
  • n
+ r C: -7 % 10 = -7 example: 3, 13, -7, 23 have remainder 3 (/10) equivalent if same remainder usually use smallest positive to represent addition: (a + k n) + (b + l n) = (a + b) + (k + l )n = a + b multiplication: (a + k n)(b + l n) = ab + (al + k b + k l n)n
slide-3
SLIDE 3

3

Primes

divisible only by itself and 1 infinite number if finite: multiply them together, add 1 not divisible by any of them! thin out 1= ln
slide-4
SLIDE 4

4

Euclid’s Algorithm

find gcd, multiplicative inverses mo d n gcd of two integers = largest integer that divides both relatively prime if g d(x; y ) is 1
  • g d(12;
8) = 4; g d (12; 25) = 1; g d(12; 24) = 12
  • g d(0;
x) = x Euclid: replace x; y with smaller numbers until x or y =
slide-5
SLIDE 5

5

Euclid’s Algorithm

  • g d(x;
y ) = g d(x
  • y
; y ) (also divisors) if d divides x; y ➠ y = k d; x = j d ➠ x
  • y
= j d
  • k
d = (j
  • k
)d if d divides x; x
  • y ➠
y = k d; x
  • y
= l d ➠ x = (k + l )d subtract ny < x ➠ replace with remainder divided by y switch x; y if x < y: hx; y i ! hy ; x%y i example: g d(408; 595) x=y

quotient remainder 595/408 1 187 408/187 2 34 187/34 5 17 34/17 2 ➠

g d(408; 595) = 17
slide-6
SLIDE 6

6

Euclid’s Algorithm

also: g d(x; y ) = ux + v y (e.g., g d(408; 595) = 17 = 16
  • 408
+ 11
  • 595
if u = u + n ➠ multiple of gcd (since x is) thus, x; y rp iff 9u; v : ux + v y = 1(pmodn)
slide-7
SLIDE 7

7

Euclid’s Algorithm

n q n r n u n v n 2 x 1 1 y 1 n br n2 =r n1 r n2 %r n1 u n2
  • q
n u n1 v n2
  • q
n v n1 r n = r n2
  • q
n r n1 ; r = x
  • q
y = u n2 x
  • v
n2 y
  • q
n (u n1 x + v n1 y ) = (u n2
  • q
n u n1 )x + (v n2
  • q
n v n1 )y = u n x + v n y
slide-8
SLIDE 8

8

Euclid’s Algorithm

n q n r n u n v n 2 408 1 1 595 1 408 1 1 1 187 1 1 2 2 34 3 2 3 5 17 16 11 4 2 35 24
slide-9
SLIDE 9

9

Finding Multiplicative Inverses

multiplicative inverse of m mo d n ➠ um = 1 (mo d n)
  • r
um + v n = 1 for some v use Euclid’s algorithm for g d(m; n) to find u; v unique u: assume another x ➠ xm = 1 (mo d n)
  • xmu
= u (mo d n) ➠ x = u mo d n
slide-10
SLIDE 10

10

Chinese Remainder Theorem

Theorem 1 If

z 1 ; z 2 ; : : : ; z k are rp, and if y = x k mo d z k 8k, then one can compute y mo d z 1
  • z
  • k. If
y = x mo d z 1
  • z
k, one can compute y mo d z 1, etc.

➠ two representations standard:

x mo d z 1
  • z
k

decomposed:

hx 1 mo d z 1 ; : : : i

decomposed

(x 1 mo d p; x 2 mo d q ) ! standard x mo d pq find u; v such that up + v q = 1 (Euclid)
  • x
= x 1 + k p, x = x 2 + l q
  • x
= upx + v q x ➠ x mo d pq = (x 2 + l q )up + (x 1 + k p)v q mo d pq
  • x
= x 2 up + x 1 v q mo d pq
slide-11
SLIDE 11

11

CRT Example

  • p
= 7; q = 9
  • 50
mo d pq = 50 mo d 63 = (1 mo d 7; 5 mo d 9) find u; v for up + v q = 1 here: 4
  • 7
+ (3)
  • 9
= 1
  • x
= x 2 up + x 1 bq = 5
  • 4
  • 7
+ 1(3)9 = 113 = 50 mo d 63
slide-12
SLIDE 12

12

Z
  • n
  • Z
n integers mod n
  • Z
  • n = relatively prime to
n
  • Z
  • 10
= f1; 3; 7; 9g

Theorem 2

Z
  • n is closed under multiplication
mo d n.

Proof:

if a; b 2 Z
  • n ➠
9u a ; v a ; u b ; v b such that u a a + v a n = 1 and u b b + v b n = 1
  • (u
a u b )ab + (u a v b a + v a u b b + v a v b n)n = 1 ➠ ab 2 Z
  • n
slide-13
SLIDE 13

13

Euler’s Totient Function

  • (n) = number of elements in
Z
  • n
  • (p
  • ), with
p prime,
  • >

– only multiples of

p are not rp to p
  • – ➠ every
pth number

– ➠

p 1 not qualified

– ➠

(p
  • )
= p
  • p
1 = (p
  • 1)p
1
  • (pq
) ➠ Chinese Remainder Theorem
slide-14
SLIDE 14

14

Euler’s Theorem

Theorem 3

8a 2 Z
  • n
; a (n) = 1 mo d n

Proof:

multiply all (n) elements of Z
  • n
! x 2 Z
  • n
  • x has inverse
x 1 product of all elements
  • a ➠
a (n) x multiplication by a = rearrangement of entries
  • (n) rearrangements ➠
a (n) x = x multiply by x 1 ➠ result
slide-15
SLIDE 15

15

Euler’s Theorem, Variant

Theorem 4

8a 2 Z
  • n,
a k (n)+1 = a mo d n

Proof:

a k (n)+1 = a k (n) a = a (n)k a = 1 k a = a

if

k
  • 0 true also for
a not rp n ➠ message a for n = p
  • q