numb3rs
play

Numb3rs 11 2 10 3 Modular Arithmetic 9 4 8 5 7 6 - PowerPoint PPT Presentation

0 12 1 Numb3rs 11 2 10 3 Modular Arithmetic 9 4 8 5 7 6 Congruence For a modulus m and two integers a and b, we say a b (mod m) if m|(a-b) Typically, we shall consider modulus > 0 a b (mod 0) a=b a b (mod 1)


  1. 0 12 1 Numb3rs 11 2 10 3 Modular Arithmetic 9 4 8 5 7 6

  2. Congruence For a “modulus” m and two integers a and b, we say a ≡ b (mod m) if m|(a-b) Typically, we shall consider modulus > 0 a ≡ b (mod 0) ↔ a=b a ≡ b (mod 1) a ≡ b (mod m) ↔ a ≡ b (mod |m|)

  3. Quotient-Remainder Theorem For any two integers m and n, m ≠ 0, there is a unique quotient q and remainder r (integers), such that n = q ⋅ m + r, 0 ≤ r < |m| rem(n,m) -14 -13 -12 -11 -10 -9 -8 -2 m=7 -7 -6 -5 -4 -3 -2 -1 -1 r 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 0 q q 7 8 9 10 11 12 13 1 1 14 15 16 17 18 19 20 2 2

  4. Congruence For a “modulus” m and two integers a and b, we say a ≡ b (mod m) if m|(a-b) Claim: a ≡ b (mod m) iff rem(a,m) = rem(b,m) Proof: Let rem(a,m) =r 1 , rem(b,m)=r 2 . Let a=q 1 m + r 1 and b =q 2 m + r 2 . Then a-b = (q 1 -q 2 )m + (r 1 -r 2 ). a-b=qm ⇒ (r 1 -r 2 ) = q’m. r 1 ,r 2 ∈ [0,m) ⇒ |r 1 -r 2 | < m ⇒ r 1 =r 2 r 1 =r 2 ⇒ a-b=qm where q=q 1 -q 2 .

  5. Congruence For a “modulus” m and two integers a and b, we say a ≡ b (mod m) if m|(a-b) distance between a&b -14 -13 -12 -11 -10 -9 -8 -2 is a multiple of m m=7 ⟷ -7 -6 -5 -4 -3 -2 -1 -1 r a&b on same column 0 1 2 3 4 5 6 ⟷ 0 1 2 3 4 5 6 0 q a&b have same 11 ≡ 18 (mod 7) 7 8 9 10 11 12 13 remainder w.r.t. m 1 11 ≡ -10 (mod 7) 18 ≡ -10 (mod 7) 14 15 16 17 18 19 20 2

  6. Modular Arithmetic Fix a modulus m. Elements of the universe: columns in the “table” for m Let [a] m stand for the column containing a i.e., stands for all elements x, s.t. a ≡ x (mod m) e.g.: [-17] 5 = [-2] 5 = [3] 5 Z m = { [0] m , …, [m-1] m } (or simply, {0,…,m-1}) We shall define operations in Z m , i.e., among the columns

  7. Modular Addition [a] m : the set of all elements x, s.t. a ≡ x (mod m) Modular addition: [a] m + m [b] m ≜ [a+b] m Well-defined? Or, are we defining the same element to have two different values? [a] m = [a’] m ∧ [b] m = [b’] m → [a+b] m = [a’+b’] m ? i.e., m|(a-a’) ⋀ m|(b-b’) → m| ((a+b) - (a’+b’)) ? (a+b)-(a’+b’) = (a-a’) + (b-b’) ✔

  8. Modular Addition [a] m : the set of all elements x, s.t. a ≡ x (mod m) Modular addition: [a] m + m [b] m ≜ [a+b] m Inherits various properties of standard addition: existence of identity and inverse, commutativity, associativity

  9. Modular Addition e.g. m = 6 + 0 1 2 3 4 5 0 1 2 3 4 5 0 Every element a has an 1 2 3 4 5 0 1 additive inverse -a, so 2 3 4 5 0 1 2 that a + (-a) ≡ 0 (mod m) 3 4 5 0 1 2 3 + 0 1 2 3 4 4 5 0 1 2 3 4 0 1 2 3 4 0 5 0 1 2 3 4 5 1 2 3 4 0 1 More generally, 2 3 4 0 1 2 a + x ≡ b (mod m) always e.g. m = 5 3 4 0 1 2 3 has a solution, x = b-a 4 0 1 2 3 4

  10. Modular Multiplication [a] m : the set of all elements x, s.t. a ≡ x (mod m) Modular multiplication: [a] m × m [b] m ≜ [a ⋅ b] m [a] m = [a’] m ∧ [b] m = [b’] m → [a ⋅ b] m = [a’ ⋅ b’] m ? Suppose a-a’ = pm, b-b’ = qm. Then a ⋅ b = (pm+a’)(qm+b’) = (mpq+pa’+qb’)m + a’b’ ✔

  11. Modular Multiplication [a] m : the set of all elements x, s.t. a ≡ x (mod m) Modular multiplication: [a] m × m [b] m ≜ [a ⋅ b] m -14 -13 -12 -11 -10 -9 -8 -6 × -3 Also ≡ 18 -7 -6 -5 -4 -3 -2 -1 commutative, ≡ 1 × 4 associative 0 1 2 3 4 5 6 ≡ 4 (mod 7) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 identity of 14 15 16 17 18 19 20 multiplication

  12. Modular Multiplication e.g. m = 6 0 0 1 1 2 2 3 3 4 4 5 5 × × 0 0 0 0 0 0 0 0 Sometimes, the product 0 1 2 3 4 5 1 1 of two non-zero numbers 0 2 4 0 2 4 can be zero! 2 2 0 3 0 3 0 3 3 3 0 1 2 3 4 × 0 4 2 0 4 2 4 4 0 0 0 0 0 0 0 5 4 3 2 1 5 5 0 1 2 3 4 1 0 2 4 1 3 2 Sometimes, a number other than 1 can have a e.g. m = 5 0 3 1 4 2 3 multiplicative inverse! 0 4 3 2 1 4

  13. Modular Arithmetic [a] m : the set of all elements x, s.t. a ≡ x (mod m) Modular addition: [a] m + m [b] m ≜ [a+b] m Modular multiplication: [a] m × m [b] m ≜ [a ⋅ b] m Multiplicative Inverse! a has a multiplicative inverse modulo m iff a is co-prime with m. gcd(a,m)=1 ↔ ∃ u,v au+mv=1 ↔ ∃ u [a] m × m [u] m = [1] m -1 = [5] 9 and [5] 9 -1 = [2] 9 e.g. [2] 9 × 9 [5] 9 = [1] 9 so [2] 9 For a prime modulus m, all except [0] m have inverses!

Recommend


More recommend