modular arithmetic

26
Modular Arithmetic Lecture 8

Upload: shen

Post on 05-Jan-2016

95 views

Category:

Documents


2 download

DESCRIPTION

Modular Arithmetic. Lecture 8. Modular Arithmetic. Def : a  b (mod n) iff n|( a - b) iff a mod n = b mod n. Modular Addition. Lemma : If a  c (mod n), and b  d (mod n) then a+b  c+d (mod n). Modular Multiplication. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Modular Arithmetic

Modular Arithmetic

Lecture 8

Page 2: Modular Arithmetic

Def: a b (mod n) iff n|(a - b) iff a mod n = b mod n.

Modular Arithmetic

Page 3: Modular Arithmetic

Lemma: If a c (mod n), and b d (mod n) then

a+b c+d (mod n).

Modular Addition

Page 4: Modular Arithmetic

Lemma: If a c (mod n), and b d (mod n) then

ab cd (mod n).

Modular Multiplication

Page 5: Modular Arithmetic

Exercise

1444 mod 713 =

Page 6: Modular Arithmetic

Exercise

1243 mod 713 =

Page 7: Modular Arithmetic

Application

Why is a number written in decimal evenly divisible by 9 if and

only if the sum of its digits is a multiple of 9?

Hint: 10 1 (mod 9).

Page 8: Modular Arithmetic

Linear Combination vs Common Divisor

Greatest common divisor

d is a common divisor of a and b if d|a and d|b

gcd(a,b) = greatest common divisor of a and b

d is an integer linear combination of a and b if d=sa+tb

spc(a,b) = smallest positive integer linear combination of a and b

Smallest positive integer linear combination

Theorem: gcd(a,b) = spc(a,b)

Page 9: Modular Arithmetic

Theorem: gcd(a,b) = spc(a,b)

Linear Combination vs Common Divisor

For example, the greatest common divisor of 52 and 44 is 4.

And 4 is a linear combination of 52 and 44:

6 · 52 + (−7) · 44 = 4

Furthermore, no linear combination of 52 and 44 is equal

to a smaller positive integer.

To prove the theorem, we will prove:

gcd(a,b) <= spc(a,b)

spc(a,b) <= gcd(a,b)

gcd(a,b) | spc(a,b)

spc(a,b) is a common divisor of a and b

Page 10: Modular Arithmetic

GCD <= SPC

Page 11: Modular Arithmetic

SPC <= GCD

We will prove that spc(a,b) is actually a common divisor of a and b.

Page 12: Modular Arithmetic

Theorem: gcd(a,b) = spc(a,b)

Linear Combination vs Common Divisor

Lemma: p prime and p|a·b implies p|a or p|b.

Cor : If p is prime, and p| a1·a2···am then p|ai for some i.

Page 13: Modular Arithmetic

Lemma. If gcd(a,b)=1 and gcd(a,c)=1, then gcd(a,bc)=1.

Theorem: gcd(a,b) = spc(a,b)

Linear Combination vs Common Divisor

Page 14: Modular Arithmetic

Every integer, n>1, has a unique factorization into primes:

p0 ≤ p1 ≤ ··· ≤ pk

p0 p1 ··· pk = n

Fundamental Theorem of Arithmetic

Example:

61394323221 = 3·3·3·7·11·11·37·37·37·53

Page 15: Modular Arithmetic

Unique Factorization

Claim: There is a unique factorization.

Page 16: Modular Arithmetic

Extended GCD Algorithm

Example: a = 259, b=70

Page 17: Modular Arithmetic

Example: a = 899, b=493

GCD Algorithm

Page 18: Modular Arithmetic

The multiplicative inverse of a number a is another number a’ such that:

a · a’ = 1 (mod n)

Multiplication Inverse

Does every number has a multiplicative inverse in modular arithmetic?

Page 19: Modular Arithmetic

Multiplication Inverse

Nope…

Does every number has a multiplicative inverse in modular arithmetic?

Page 20: Modular Arithmetic

Multiplication Inverse

What is the pattern?

Page 21: Modular Arithmetic

Theorem. If gcd(k,n)=1, then have k’

k·k’ 1 (mod n).

k’ is an inverse mod n of k

Multiplication Inverse

Page 22: Modular Arithmetic

Cancellation

So (mod n) a lot like =.

main diff: can’t cancel

4·2 1·2 (mod 6)

4 1 (mod 6)

No general cancellation

Cor: If i·k j·k (mod n), and gcd(k,n) = 1,

then i j (mod n)

Page 23: Modular Arithmetic

If p is prime & k not a multiple of p, can cancel k. So

k, 2k, …, (p-1)k

are all different (mod p).

So their remainders on division by p are all different (mod p).

Fermat’s Little Theorem

This means that

rem(k, p), rem(2k, p),…,rem((p-1)k, p)

must be a permutation of

1, 2, ···, (p-1)

Page 24: Modular Arithmetic

Fermat’s Little Theorem

1 kp-1 (mod p)

Theorem: If p is prime & k not a multiple of p

Page 25: Modular Arithmetic

Chinese Remainder Theorem

x a1 (mod n1)

x a2 (mod n2)

x ak (mod nk)

Theorem: If n1,n2,…,nk are relatively prime and

a1,a2,…,ak are integers, then

have a simultaneous solution x that is unique

modulo n, where n = n1n2…nk.

Page 26: Modular Arithmetic

Proof of Chinese Remainder Theorem