Modular Arithmetic - PowerPoint PPT Presentation

About This Presentation
Title:

Modular Arithmetic

Description:

Modular Arithmetic Lecture 8 – PowerPoint PPT presentation

Number of Views:217
Avg rating:3.0/5.0
Slides: 27
Provided by: cse12
Category:

less

Transcript and Presenter's Notes

Title: Modular Arithmetic


1
Modular Arithmetic
  • Lecture 8

2
Modular Arithmetic
Def a ? b (mod n) iff n(a - b) iff a mod n b
mod n.
3
Modular Addition
Lemma If a ? c (mod n), and b ? d (mod n) then
ab ? cd (mod n).
4
Modular Multiplication
Lemma If a ? c (mod n), and b ? d (mod n) then
ab ? cd (mod n).
5
Exercise
1444 mod 713
6
Exercise
1243 mod 713
7
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).
8
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).
9
Linear Combination vs Common Divisor
Greatest common divisor
d is a common divisor of a and b if da and db
gcd(a,b) greatest common divisor of a and b
Smallest positive integer linear combination
d is an integer linear combination of a and b if
dsatb spc(a,b) smallest positive integer
linear combination of a and b
Theorem gcd(a,b) spc(a,b)
10
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
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) lt spc(a,b)
gcd(a,b) spc(a,b)
spc(a,b) is a common divisor of a and b
spc(a,b) lt gcd(a,b)
11
GCD lt SPC
12
GCD lt SPC
3. If d a and d b, then d sa tb for all s
and t.
Proof of (3) d a gt a dk1 d b gt
b dk2 sa tb sdk1 tdk2 d(sk1
tk2) gt d(satb)
Let d gcd(a,b). By definition, d a and d
b.
GCD SPC
Let f spc(a,b) satb
By (3), d f. This implies d lt f. That is
gcd(a,b) lt spc(a,b).
13
SPC lt GCD
We will prove that spc(a,b) is actually a common
divisor of a and b.
14
SPC lt GCD
We will prove that spc(a,b) is actually a common
divisor of a and b.
First, show that spc(a,b) a.
  1. Suppose, by way of contradiction, that spc(a,b)
    does not divide a.
  2. Then, by the Division Theorem,
  3. a q x spc(a,b) r and spc(a,b) gt
    r gt 0
  4. Let spc(a,b) sa tb.
  5. So r a q x spc(a,b) a q x (sa tb)
    (1-qs)a qtb.
  6. Thus r is an integer linear combination of a and
    b, and spc(a,b) gt r.
  7. This contradicts the definition of spc(a,b), and
    so r must be zero.

Similarly, spa(a,b) b.
So, spc(a,b) is a common divisor of a and b, thus
by definition spc(a,b) lt gcd(a,b).
15
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
This is a very useful theorem. Now we can
translate gcd(a,b) into an expression and back.
Corollary Every linear combination of a and b
is a multiple of gcd(a, b) and vice versa.
3. If d a and d b, then d sa tb for all s
and t.
(gt) gcd(a,b) sa tb. so every linear
combination is a multiple of gcd(a,b).
(lt) gcd(a,b) sa tb for some s and t.
so multiple of gcd(a,b) is also a linear
combination of a and b.
16
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
Lemma p prime and pab implies pa or pb.
Cor If p is prime, and p a1a2am then
pai for some i.
17
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
Lemma p prime and pab implies pa or pb.
pf say p does not divide a. so gcd(p,a)1. So
by the Theorem, there exist s and t such that
sa tp 1 (sa)b
(tp)b b
p
p
p
Cor If p is prime, and p a1a2am then
pai for some i.
18
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
Lemma. If gcd(a,b)1 and gcd(a,c)1, then
gcd(a,bc)1.
19
Linear Combination vs Common Divisor
Theorem gcd(a,b) spc(a,b)
Lemma. If gcd(a,b)1 and gcd(a,c)1, then
gcd(a,bc)1.
By the Theorem, there exist s,t,u,v such that
sa tb 1 ua vc 1
  • Multiplying, we have (sa tb)(ua vc) 1
  • saua savc tbua tbvc 1
  • (sau svc tbu)a (tv)bc 1

By the Theorem, since spc(a,bc)1, we have
gcd(a,bc)1
20
Fundamental Theorem of Arithmetic
Every integer, ngt1, has a unique factorization
into primes p0 p1 pk p0 p1 pk n
Example 61394323221 3337111137373753
21
Unique Factorization
Claim There is a unique factorization.
22
Unique Factorization
Claim There is a unique factorization.
pf suppose not. choose smallest n gt1 n
p1p2pk q1q2qm p1?p2??pk q1?q2??qm
can assume q1 lt p1 so q1 ? pi all i
now p1n, so by Cor., p1qi . so p1 qi with
i gt1. so p2pk q1q2qi-1qi1qm
and q1 ? p2
contradiction!
23
Extended GCD Algorithm
Example a 259, b70
24
Extended GCD Algorithm
25
GCD Algorithm
Example a 899, b493
26
GCD Algorithm
Example a 899, b493 899 1493 406 493
1406 87
406 487 58
87 158 29

58 229 0 done, gcd 29
27
Extended GCD Algorithm
Example a 899, b493 899 1493 406 so
406 1899 -1493 493 1406 87 so
87 493 1406
-1899 2493 406 487 58
so 58 406 - 487
5899 -9493 87 158 29
so 29 87 158
-6899 11493 58 229
0 done, gcd 29
28
Extended GCD Algorithm
Example a 899, b493 899 1493 406 so
406 1899 -1493 493 1406 87 so 87
493 1406
-1899 2493 406 487 58 so
58 406 - 487
5899 -9493 87 158 29
so 29 87 58
-6899 11493 58 229 0
done, gcd 29
s -6, t 11
29
Multiplication Inverse
The multiplicative inverse of a number a is
another number a such that a a 1 (mod n)
Does every number has a multiplicative inverse in
modular arithmetic?
30
Multiplication Inverse
Does every number has a multiplicative inverse in
modular arithmetic?
Nope
31
Multiplication Inverse
What is the pattern?
32
Multiplication Inverse
Theorem. If gcd(k,n)1, then have k
kk ? 1 (mod n). k is an
inverse mod n of k
33
Multiplication Inverse
Theorem. If gcd(k,n)1, then have k
kk ? 1 (mod n). k is an
inverse mod n of k
pf sk tn 1. So tn 1 - sk This means n 1
- sk just let k s .
34
Cancellation
So ? (mod n) a lot like . main diff cant
cancel 42 ? 12 (mod 6) 4 ? 1 (mod 6)
No general cancellation
Cor If ik ? jk (mod n), and gcd(k,n) 1,
then i ? j (mod n)
35
Fermats Little Theorem
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).
This means that rem(k, p), rem(2k,
p),,rem((p-1)k, p) must be a permutation of 1,
2, , (p-1)
36
Fermats Little Theorem
Theorem If p is prime k not a multiple of p
1 ? kp-1 (mod p)
37
Fermats Little Theorem
Theorem If p is prime k not a multiple of p
1 ? kp-1 (mod p)
Proof. 12(p-1) rem(k,p)rem(2k,p)rem((p-1
)k,p) ? (k)(2k) ((p-1)k) (mod p) ?
(kp-1)12 (p-1) (mod p) so 1 ? kp-1
(mod p)
A permutation
38
Chinese Remainder Theorem
Theorem If n1,n2,,nk are relatively prime and
a1,a2,,ak are integers, then
x ? a1 (mod n1) x ? a2 (mod n2) x ? ak (mod nk)
have a simultaneous solution x that is
unique modulo n, where n n1n2nk.
39
Proof of Chinese Remainder Theorem
40
Proof of Chinese Remainder Theorem
N1 n2 n3
Let
N2 n1 n3
N3 n1 n2
Since Ni and ni are reletively prime, this
implies that there exist x1 x2 x3
N1x1 ? 1 (mod n1)
N2x2 ? 1 (mod n2)
N3x3 ? 1 (mod n3)
a1N1x1 ? a1 (mod n1),
a2N2x2 ? a2 (mod n2),
a3N3x3 ? a3 (mod n3)
So,
Let x a1N1x1 a2N2x2 a3N3x3
x ? a1 N1x1 (mod n1)
Since n1N2 and n1N3,
x ? a1 (mod n1)
Since N1x1 ? 1 (mod n1),
x ? a2 (mod n2)
Similarly,
x ? a3 (mod n3)
Write a Comment
User Comments (0)
About PowerShow.com