Euclidean Algorithm and Congruence

Euclidean Algorithm and Congruence

Euclidean Algorithm Congruence Euclidean Algorithm and Congruence G. Carl Evans University of Illinois Fall 2018 Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Recall Euclidean Algorithm Remainder(a; b) is the remainder when a is divided by b. RecursiveGCD (a; b) r Remainder(a; b) if r = 0 return b return RecursiveGCD (b; r) Euclidean Algorithm and Congruence Euclidean Algorithm Congruence But why does Euclidean algorithm work? RecursiveGCD (a; b) r Remainder(a; b) if r = 0 return b return RecursiveGCD (b; r) The Euclidean algorithm works iff gcd(a; b) = gcd(b; r), where r = the remainder of the remainder when a is divided by b. Euclidean Algorithm and Congruence Let a; b; q; r 2 Z with b > 0 and a = bq + r. Let n = gcd(a; b) and m = gcd(b; r) So n is the largest integer that divides both a and b and m is the largest integer that divides both b and r. Since n j a and n j b it holds that a = nk; b = np for some k; p 2 Z. From a = bq + r we get r = bq − a expanding to r = nk − npq = n(k − pq) and since k − pq 2 Z then n j r. Euclidean Algorithm Congruence Proof of Euclidean algorithm Claim: For any integers a; b; q; r; with b > 0, if a = bq + r then gcd(a; b) = gcd(b; r). Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Proof of Euclidean algorithm Claim: For any integers a; b; q; r; with b > 0, if a = bq + r then gcd(a; b) = gcd(b; r). Let a; b; q; r 2 Z with b > 0 and a = bq + r. Let n = gcd(a; b) and m = gcd(b; r) So n is the largest integer that divides both a and b and m is the largest integer that divides both b and r. Since n j a and n j b it holds that a = nk; b = np for some k; p 2 Z. From a = bq + r we get r = bq − a expanding to r = nk − npq = n(k − pq) and since k − pq 2 Z then n j r. Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Proof of Euclidean algorithm pt2 Claim: For any integers a; b; q; r; with b > 0, if a = bq + r then gcd(a; b) = gcd(b; r). Similarly: m j b ^ m j r ! b = km; r = pm; k; p 2 Z a = bq + r = km + mp = m(kq + p) kq + p 2 Z So m j a. Since n and m divide a; b and r there are three cases either n < m; m < n or; n = m. Since n is the largest value that divides a and b, n is not less then m. Similarly since m is the largest value that divides b and r, m is not less then n. Thus m = n. QED Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Applications of congruence bitwise operations error checking encryption telling time etc. Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Congruence mod k Two integers are congruent mod k if the differ by an integer multiple of k Definition: If k is any positive integer, two integers a and b are congruent mod k if k divides (a − b). a ≡ b( mod k) $ k j (a − b) Euclidean Algorithm and Congruence Let a; b; c; d; k 2 Z with k > 0 s.t. a ≡ b (mod k) and c = d (mod k). From the definition of mod we get k j a − b and k j c − d. From linearity of divides we get k j (a − b) + (c − d) and then k j (a + b) − (b + d) so (a + c) ≡ (b + d) (mod k). QED Euclidean Algorithm Congruence Modulus addition proof Claim: For any integers a; b; c; d; k with k > 0, if a ≡ b (mod k) and c ≡ d (mod k) then (a + c) ≡ (b + d) (mod k). Definition: a ≡ b (mod k) $ k j (a − b) Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Modulus addition proof Claim: For any integers a; b; c; d; k with k > 0, if a ≡ b (mod k) and c ≡ d (mod k) then (a + c) ≡ (b + d) (mod k). Definition: a ≡ b (mod k) $ k j (a − b) Let a; b; c; d; k 2 Z with k > 0 s.t. a ≡ b (mod k) and c = d (mod k). From the definition of mod we get k j a − b and k j c − d. From linearity of divides we get k j (a − b) + (c − d) and then k j (a + b) − (b + d) so (a + c) ≡ (b + d) (mod k). QED Euclidean Algorithm and Congruence Let a; b; c; d; k 2 Z with k > 0 s.t. a ≡ b (mod k) and c = d (mod k). From the definition of mod we get k j a − b and k j c − d. So (a − b) = nk and (c − d) = pk by def divides. This leads to a = nk + b and c = pk + d and ac = (nk+b)(pk+d) = pnk2+dnk+bpk+bd = bd+(pnk+dn+b)k Since pnk + dn + b is an integer ac = bd + qk where q is an integer. Thus ac − bd = qk and k j (ac − bd) and ac ≡ bd (mod k). QED Euclidean Algorithm Congruence Modulus multiplication proof Claim: For any integers a; b; c; d; k with k > 0, if a ≡ b (mod k) and c ≡ d (mod k) then ac ≡ bd( mod k). Definition: a ≡ b( mod k) $ k j (a − b) Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Modulus multiplication proof Claim: For any integers a; b; c; d; k with k > 0, if a ≡ b (mod k) and c ≡ d (mod k) then ac ≡ bd( mod k). Definition: a ≡ b( mod k) $ k j (a − b) Let a; b; c; d; k 2 Z with k > 0 s.t. a ≡ b (mod k) and c = d (mod k). From the definition of mod we get k j a − b and k j c − d. So (a − b) = nk and (c − d) = pk by def divides. This leads to a = nk + b and c = pk + d and ac = (nk+b)(pk+d) = pnk2+dnk+bpk+bd = bd+(pnk+dn+b)k Since pnk + dn + b is an integer ac = bd + qk where q is an integer. Thus ac − bd = qk and k j (ac − bd) and ac ≡ bd (mod k). QED Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Equivalence classes with modulus The equivalence class of integer x (written [x]) is the set of all integers congruent to x( mod k). In ( mod 7); [3] = f:::; −11; −4; 3; 10; 17;::: g In ( mod 5); [3] = f:::; −7; −2; 3; 8; 13;::: g In Z5; [3] = [8] = [−2] Euclidean Algorithm and Congruence Euclidean Algorithm Congruence Modulus arithmetic [x] + [y] = [x + y] [x] ∗ [y] = [x ∗ y] Euclidean Algorithm and Congruence.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us