WHY? Congruences: arithmetic (mod n) :

advertisement
Congruence mod n
Mathematics for Computer Science
Def: a b (mod n)
iff n|(a - b)
MIT 6.042J/18.062J
Congruences:
arithmetic (mod n)
example: 30 12 (mod 9)
since
9 divides 30 - 12
Albert R Meyer,
March 31, 2010
Congruence mod n
example:
WHY?
66666663
- 788253
xxxxxxx0
March 31, 2010
8W.3
March 31, 2010
Remainder Lemma
66666663 788253 (mod 10)
Albert R Meyer,
Albert R Meyer,
8W.1
a b (mod n)
iff
rem(a,n) = rem(b,n)
example: 30 12 (mod 9)
since
rem(30,9) = 3 = rem(12,9)
8W.4
Remainder Lemma
Albert R Meyer,
March 31, 2010
8W.8
proof: (if)
a b (mod n)
iff
rem(a,n) = rem(b,n)
abbreviate: rb,n
a = qan + ra,n
b = qbn + rb,n
if rem’s are =, then
a-b=(qa-qb)n so n|(a-b)
(only if) proof similar
Albert R Meyer,
4/2/08 2:20PM
March 31, 2010
8W.9
Albert R Meyer,
March 31, 2010
8W.11
‹#›
Remainder Lemma
Remainder arithmetic
Corollary:
a b (mod n)
iff
rem(a,n) = rem(b,n)
a rem(a,n) (mod n)
pf: 0 ra,n < n, so
rem(ra,n,n) = ra,n
QED
Albert R Meyer,
March 31, 2010
8W.14
More Corollaries
8W.15
If a b (mod n), then
a+c b+c (mod n)
pf: n | (a - b) implies
n | ((a+c) – (b+c))
a b (mod n) implies
b a (mod n)
• transitive
a b & b c (mod n)
implies a c (mod n)
March 31, 2010
March 31, 2010
Congruence mod n
• symmetric
Albert R Meyer,
Albert R Meyer,
8W.17
Albert R Meyer,
March 31, 2010
8W.18
Congruence mod n
Congruence mod n
Corollary:
If a b (mod n) &
c d (mod n),
then a+c b+d (mod n)
If a b (mod n), then
ac bc (mod n)
pf: n | (a - b) implies
n | (a - b)c, and so
n | ((ac) – (bc))
Albert R Meyer,
4/2/08 2:20PM
March 31, 2010
8W.19
Albert R Meyer,
March 31, 2010
8W.21
‹#›
Congruence mod n
Remainder arithmetic
Cor: if a a’ (mod n),
then replacing a by a’
in any arithmetic
formula gives an
(mod n) formula
Albert R Meyer,
March 31, 2010
important: congruence &
a rem(a,n) (mod n)
keeps (mod n) arithmetic
in the remainder range
0 to n-1
8W.22
2879 39 since r287,4 = 3
= ((32)2)23
(12)23 since r9,4 =1
= 3 (mod 4)
March 31, 2010
8W.24
When can you cancel k?
--when k has no common
factors with n
4/2/08 2:20PM
March 31, 2010
8W.23
So arithmetic (mod n) a lot
like ordinary arithmetic
the main difference:
8·2 32 (mod 10)
8 3 (mod 10)
no arbitrary cancellation
Albert R Meyer,
March 31, 2010
8W.25
inverses (mod n)
cancellation (mod n)
Albert R Meyer,
March 31, 2010
Congruence mod n
Remainder arithmetic
example: 2879 ? (mod 4)
Albert R Meyer,
Albert R Meyer,
8W.26
If gcd(k,n)=1, then have k’
k·k’ 1 (mod n).
k’ is an inverse mod n of k
pf: sk + tn = 1, so
just let k’ ::= s
Albert R Meyer,
March 31, 2010
8W.28
‹#›
cancellation (mod n)
cancellation (mod n)
If a·k b·k (mod n)
and gcd(k,n) = 1, then
multiply by k’:
(a·k)·k’ (b·k)·k’ (mod n)
1
1
a·(k·k’)
b·(k·k’)
so a b (mod n)
Albert R Meyer,
March 31, 2010
summary:
k is cancellable (mod n) iff
k has an inverse (mod n) iff
kgcd(k,n)=1
is relatively prime to n
8W.29
If p is prime & k not a multiple
of p, can cancel k. So
1k, 2k, …, (p-1)k
are all different (mod p).
So their remainders on division
by p are all different.
March 31, 2010
March 31, 2010
8W.30
arithmetic mod a prime, p
arithmetic mod a prime
Albert R Meyer,
Albert R Meyer,
so if p does not divide k,
then multiplying
1, 2, …, (p-1)
by k and taking remainders
just permutes them.
8W.32
permuting (mod 7)
Albert R Meyer,
March 31, 2010
8W.33
Fermat’s Little Theorem
so 1·2···(p-1) = rk,p·r2k,p··· r(p-1)k,p
0 1 2 3 4 5 6
1k·2k ··· (p-1)k (mod p)
2 0 2 4 6 1 3 5
= (kp-1)·1·2 ··· (p-1) (mod p)
now cancel 1·2 ··· (p-1):
3 0 3 6 2 5 1 4
Albert R Meyer,
4/2/08 2:20PM
March 31, 2010
1 kp-1 (mod p)
8W.35
Albert R Meyer,
March 31, 2010
8W.39
‹#›
inverses (mod prime)
Remainder arithmetic
2899885 [r28,5 = 3]
so kp-2 is a (mod p)
inverse of k
--an alternative to
finding inverses with
the pulverizer
Albert R Meyer,
8W.40
March 31, 2010
Remainder arithmetic
399885 ?
Albert R Meyer,
?
(mod 5)
8W.42
March 31, 2010
Remainder arithmetic
(mod 5)
= 34·q+rem(99885,4)
= (34)q ·3rem(99885,4)
399885 ?
(mod 5)
= 34·q+rem(99885,4)
= (34)q ·3rem(99885,4)
(1)q ·3rem(99885,4)
[Fermat]
Albert R Meyer,
8W.45
March 31, 2010
Remainder arithmetic
399885
?
3
4/2/08 2:20PM
March 31, 2010
March 31, 2010
8W.46
Team Problems
(mod 5)
= 34·q+rem(99885,4)
= (34)q ·3rem(99885,4)
(1)q ·3rem(99885,4)
3rem(99885,4) = 31
Albert R Meyer,
Albert R Meyer,
8W.47
Problems
13
Albert R Meyer,
March 31, 2010
8W.49
‹#›
MIT OpenCourseWare
http://ocw.mit.edu
6.042J / 18.062J Mathematics for Computer Science
Spring 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Download