SESAME Modular Arithmetic MurphyKate Montee March 08 What is a Number? Examples of Number Systems: We think numbers should satisfy certain rules which we call axioms: Commutivity Associativity 3 Existence of an Identity Existence of Inverses Usually we want our numbers to satisfy these rules for two operations: addition and multiplication If a set of numbers satisfies these rules for one operation we call them a: If a set of numbers satisfies these rules for two operations (except that the additive identity has no multiplicative inverse) we call them a: Commutative Group IN Z Examples Q R modular sword modular 6 World ring NonExamples Commutative / t ) % noinvwses! group Ring I Q tin +x ) modular 5 World modular 6 World
' Arithmetic Modulo 5 In the system arithmetic modulo 5 there are 5 numbers : 0 3 and they follow the rule of addition around a circle 05 3 / In algebraic terms we say that two integers are equivalent mod 5 if they di er by a multiple of 5 We write this with a triple equals sign: If it is not totally clear we can write (mod 5) at the end \z i 0 0 0 Examples: + 5 0 (mod 5) 3+7 (mod D 3 FF ' 5) +3 3 (mod 5) 3 Mj ; z z z ' We can fill in an addition table to help our calculations: + 0 3 0 0 I 3 0 3 0 3 3 0 I 3 0 I 3 Question: Does this satisfy our axioms? because Commutative Yes! O Inverse Identity symmetric over diagonal is a 0 in exist because there and column each row
3 Subtraction Modulo 5 We want our subtraction to work like it does in the integers: 5+! 5 and 5 In the modulo 5 world we can use the addition table to help us Example: What is 0 (mod 5)? Since + 0 (mod 5) then 0 (mod 5) You try: 3 0 Since + since : + E 0 Mutiplication Modulo 5 We use the same rule as before: two integers are equivalent modulo 5 if they di er by a multiple of 5 Notice that you can still use the circle to help you * o* Example: 3 6 and 6 (5) + so 6 (mod 5) Therefore: 3 (mod 5) Example: 3 and (5) + so (mod 5) Therefore: 3 (mod 5) Notice that just like in the integers! 3 ( 3) 3
So 0 0 3 0 O 0 0 0 0 0 0 30 0 3 3 3 3 I Name at least three patterns that you see in the multiplication table: each number shows row and column 0 are all 0 rows come in paired Symmetric over up exactly once in each now and column minor diagonal images Kandis land ) Definition: A number k is a square root of n if k n Question: What elements in modulo 5 arithmetic have square roots? Which have cubed roots? Fourth roots? The numbers on the main diagonal and 3 aren't on the diagonal so they are squares aren't squares 030 3 33 3 so every number is a cube! If n ekt a square then n(k so ho or! n is a square of
5 Division Modulo 5 Just like subtraction we can use the multiplication table to help us divide Remember that 3 3 so we can say that 3 is the number n such that 3n Example: Since 3 6 (mod 5) (mod 5) 3 Example: Since 3 (mod 5) 3 (mod 5) You try: Calculate the following in modulo 5 arithmetic 3 FX 3 then use the multiplication table! 3 3 Ex 3 : + El!! 5
But 6 What s So Special About 5? Why should 5 have all the fun? You know from your last homework that you can play these games with 6 too Why not any integer? Fill in the following tables for modulo 6 arithmetic: + 0 3 5 0 3 5 0 0 3 0 0 0 0 0 0 0 5 3 5 5 0 0 3 3 5 0 0 0 3 3 5 0 3 0 3 0 3 0 3 I 5 0 3 O Y 0 5 0 3 5 0 5 3 I g Questions: What patterns are the same as the modulo 5 world? What are di erent? The addition tables au similar! But every the how very the mod 6 MWH table not has have 3 numbers number! Some rows way and the row has Zhumbosl What is 5 (mod 6)? We Want EX so 5 Is no such X! Ez DOES modulo 6! in Not there EXIST 6
3 In general it is not always fastest to solve a modular arithmetic problem by writing out an entire table We want to use the fact that two integers are equivalent modulo n if they di er by a multiple of n We write that in algebra by the following formula: Ab lmodn ) If A btkn Example: To calculate + 3 (mod 7) I first know that + 3 5 Then 5 (7) + 8 so 5 8 (mod 7) Therefore + 3 8 (mod 7) for some K You try: 6 3 (mod 7) 5 7 (mod 3) + 9 (mod3) 6 37 5 735 35 +9 ( mod 7 7+70 ) C mod 3 ) 33 33 3 0 ( mod 3 ) 7 Calculations in Modular Arithmetic There is more than one way to solve these problems Sometimes one method is faster and sometimes the other Example: Calculate 376 (mod 7) Method Method (calculate then reduce) (reduce then calculate) 376 8 (7) + 3 376 33 (b) + 8795+6 I 6 ( mod 7 ) zzy } 6 3 6 ( mod 7 ) ( mod 7 ) ( mod 'D Example: Calculate 39 63 (mod 633) Since 63 (mod 633) 39 63 3 3 3 + 633 9 (mod 633) 7
) You try: Calculate the following: 639 37 (mod 7) 507 37 (mod 509) 639 37 3 6(mod7 ) 367 (mod 369) 7 6 (mod D 5) 507 ( mod 509 ) 3 903 + 63 97 (mod 00) 507 37 05 37 (mod 7) ) 76(773 367 ( mod 369 ) 33 367 ( 39033 ( mod 369 ( 6399 7) + ( mod > ) 37 63+3 3 ( mod 7) 37 77+507 L mod 509 ) 79 ( mod 5 ) Lmod 00 ) 76 f)3 I E 6397 7 ( mod 00 ) 3 ( mod 5 ) 3903+6397 3+777 ( modloo ) 8 0575 ) 0 50 05 37 ( mod 7) 0 370 ( mod 7) 8
Then a) 8 Modular Division To solve an equation like x 5 (mod 6) we need division Indeed in this case x 5 (mod 6) But we saw earlier that there is no such number! What s going on? For division to be possible we need: to have every number in every row Fta m Theorem: If p is prime then division is always possible in modulo p arithmentic Proof: Suppose division isn't possible in some how inmate tmminsaomenyauenanapaear So nb " na In ba) 0 That means n ( b So Since is P Prime p But kp for some K is a factor of n or (b a) < and 0 b at p O< n < p that's impossible! 9
Question: What if p is not prime? (Hint: Look at the times table for modulo 6 arithmetic and make a hypothesis) Theorem: In arithmetic modulo n for any n we can divide by a if: ( n a) 0
9 Modular Division Now that we know when we can divide we want to be able to actually do it If we have a multiplication table it s not too hard But in general this is tricky! Example: Suppose I want to find 7 (mod ) Method : List all the possibilities until you find a solution: 7 7 3 7 7 5 7 6 7 7 7 8 7 9 7 56# 0 7 : 3 0 8 I 6 since 87 ( mod " ) 35 8 ( mod 9 95 )
Method : Find the number congruent to modulo which is also a multiple of 7: () + ( not a multiple of 7) () + 3 sits : 3() + () + 5() + Since 8756 El ( mod ) 8 mod )
CB 97 7 8) (6037) 5 55 3( }_ 3E8x8x+By Method 3: Do both at once! We want a number which is a multiple of 7 and is congruent to modulo That means we need to solve How do you solve this? 7x y + You try: Calculate the following fractions: 7 6 3 8 5 7 (mod 69) (mod 3) EUCLIDEAN ALGORITHM Ex so (mod 60) # 69 3 ( 6 )! 76 X so 76 +69 y 6 5 ( 5 ) + 5 + 569 6 ( mod b) 66 38 ) +5 538 (5) +3 385 5 (3) + so X 8 ) 6 So 767 ) And 6 ) ) (6936) 6 569 569 3 6± EhzYmod q#8 () HD 3 Ex mod 60 ) 57 7 +60 y F_xE35lmodbtIS 60 37 ) + 9 7 L 9) +8 9 (8) HD 960 87 9 (3) 7 60 (760) 8 (6037) 60 707 So : 5060 3 and 357 Cmod 60 )
IM Her 0 Powers in Modular Arithmetic Remember that x a x b x a+b and (x a ) b x ab Calculating large powers is usually very di cult because the numbers quickly get very large But in modular arithmetic we don t have that problem! Example: Calculate 7 (mod ) We could calculate this and then reduce but 7 397388537303303897609 which is a really big number so that seems like a bad plan Instead let s try to use modular arithmetic to make this a little easier I can write as a sum of powers of : 3 + 8 + So 7 7 3 7 8 7 7 7 8 7 7 6 7 7 3 So: 7 7 3 +7 8 +7 You try: a D 55 (mod 9) 65 (mod 7) 7 39 95 lmodh) 9 8 553 6 5 * 5 9 555 ( mod ") 656+ + 553+6 8++ I % E 7 ( and 9 ) EZ ( mod 7) ' ( mod 9 ) " iii 7 l mod 9 It ± ) 9 EH E 9 (mod 9) " I 7 l mod " ) 36 E 553 E 7 (77) 656 7H I I D 77 EH 'll 7Cmodl9D ( mod 7) 8 H)E l mod > ) " 36 / ( mod > ' 3
3+7 68 3 ' Theorem (Fermat): If p is prime and p is not a factor of a then a p (modp) Example: Calculate 55 (mod 9) Since 9 is prime and 9 is not a factor of we can use Fermat s Theorem Since 55 3(8) + we get 55 3(8)+ ( 8 ) 3 3 (mod 9) You try: Calculate the following: 6 373 (mod ) 7 86 (mod 3) 83 (mod 3) 373 370 ) +3 6373 ( 6 " ) " 633 ' 7lmodD) 63366 3 ' +0 86 3 ) 786(7 ) 370 787 @9) 9 (3) 8 3 3 83 You can also use Fermat s Theorem to find reciprocals Example: Find 8 (mod 9) By Fermat s Theorem 88 (mod 9) so 8 8 7 and 8 87 (mod 9) 83(93736) ' ( 6 ) 56 z (6 3 3 ( 9) z 3 9µ@odT) 6(mod3)) 5