Some Consequences. Example of Extended Euclidean Algorithm. The Fundamental Theorem of Arithmetic, II. Characterizing the GCD and LCM

Similar documents
Math 261 Exercise sheet 2

THE CHINESE REMAINDER THEOREM. We should thank the Chinese for their wonderful remainder theorem. Glenn Stevens

Foundations of Arithmetic

Introduction to Algorithms

a b a In case b 0, a being divisible by b is the same as to say that

Example: (13320, 22140) =? Solution #1: The divisors of are 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 41,

Introduction to Algorithms

Problem Solving in Math (Math 43900) Fall 2013

Algorithms for factoring

Hashing. Alexandra Stefan

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

18.781: Solution to Practice Questions for Final Exam

(2mn, m 2 n 2, m 2 + n 2 )

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

COMPLEX NUMBERS AND QUADRATIC EQUATIONS

Lecture 4: Universal Hash Functions/Streaming Cont d

International Mathematical Olympiad. Preliminary Selection Contest 2012 Hong Kong. Outline of Solutions

Advanced Algebraic Algorithms on Integers and Polynomials

Attacks on RSA The Rabin Cryptosystem Semantic Security of RSA Cryptology, Tuesday, February 27th, 2007 Nils Andersen. Complexity Theoretic Reduction

Discussion 11 Summary 11/20/2018

Société de Calcul Mathématique SA

Math Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

APPENDIX A Some Linear Algebra

Outline and Reading. Dynamic Programming. Dynamic Programming revealed. Computing Fibonacci. The General Dynamic Programming Technique

Linear, affine, and convex sets and hulls In the sequel, unless otherwise specified, X will denote a real vector space.

Lecture 10: May 6, 2013

Section 8.3 Polar Form of Complex Numbers

THERE ARE INFINITELY MANY FIBONACCI COMPOSITES WITH PRIME SUBSCRIPTS

Complex Numbers. x = B B 2 4AC 2A. or x = x = 2 ± 4 4 (1) (5) 2 (1)

LECTURE V. 1. More on the Chinese Remainder Theorem We begin by recalling this theorem, proven in the preceeding lecture.

MEM 255 Introduction to Control Systems Review: Basics of Linear Algebra

Polynomials. 1 What is a polynomial? John Stalker

DISCRIMINANTS AND RAMIFIED PRIMES. 1. Introduction A prime number p is said to be ramified in a number field K if the prime ideal factorization

Inner Product. Euclidean Space. Orthonormal Basis. Orthogonal

Feature Selection: Part 1

The Order Relation and Trace Inequalities for. Hermitian Operators

Lecture 5 Decoding Binary BCH Codes

MTH 819 Algebra I S13. Homework 1/ Solutions. 1 if p n b and p n+1 b 0 otherwise ) = 0 if p q or n m. W i = rw i

2 More examples with details

Affine transformations and convexity

No-three-in-line problem on a torus: periodicity

princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 7: LP Duality Lecturer: Matt Weinberg

8.6 The Complex Number System

The internal structure of natural numbers and one method for the definition of large prime numbers

MULTIPLICATIVE FUNCTIONS: A REWRITE OF ANDREWS CHAPTER 6

Errors for Linear Systems

Kernel Methods and SVMs Extension

PRIMES 2015 reading project: Problem set #3

1 GSW Iterative Techniques for y = Ax

2.3 Nilpotent endomorphisms

Exhaustive Search for the Binary Sequences of Length 2047 and 4095 with Ideal Autocorrelation

Module 2. Random Processes. Version 2 ECE IIT, Kharagpur

Difference Equations

Lecture 10 Support Vector Machines II

Singular Value Decomposition: Theory and Applications

Quantum Mechanics for Scientists and Engineers. David Miller

REDUCTION MODULO p. We will prove the reduction modulo p theorem in the general form as given by exercise 4.12, p. 143, of [1].

k(k 1)(k 2)(p 2) 6(p d.

p 1 c 2 + p 2 c 2 + p 3 c p m c 2

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

Generalized Linear Methods

LECTURE 9 CANONICAL CORRELATION ANALYSIS

5 The Rational Canonical Form

Lecture 4: November 17, Part 1 Single Buffer Management

ALGEBRA HW 7 CLAY SHONKWILER

PRIME NUMBER GENERATION BASED ON POCKLINGTON S THEOREM

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

Speeding up Computation of Scalar Multiplication in Elliptic Curve Cryptosystem

First day August 1, Problems and Solutions

Assortment Optimization under MNL

Smarandache-Zero Divisors in Group Rings

Modelli Clamfim Equazioni differenziali 7 ottobre 2013

On the Multicriteria Integer Network Flow Problem

Polynomials. 1 More properties of polynomials

3.1 Expectation of Functions of Several Random Variables. )' be a k-dimensional discrete or continuous random vector, with joint PMF p (, E X E X1 E X

Parametric fractional imputation for missing data analysis. Jae Kwang Kim Survey Working Group Seminar March 29, 2010

1 Matrix representations of canonical matrices

Integers and Division

763622S ADVANCED QUANTUM MECHANICS Solution Set 1 Spring c n a n. c n 2 = 1.

Linear Feature Engineering 11

Some basic inequalities. Definition. Let V be a vector space over the complex numbers. An inner product is given by a function, V V C

A New Refinement of Jacobi Method for Solution of Linear System Equations AX=b

Complex Numbers Alpha, Round 1 Test #123

PHYS 705: Classical Mechanics. Newtonian Mechanics

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Christian Aebi Collège Calvin, Geneva, Switzerland

Self-complementing permutations of k-uniform hypergraphs

MA 323 Geometric Modelling Course Notes: Day 13 Bezier Curves & Bernstein Polynomials

On the correction of the h-index for career length

FINITELY-GENERATED MODULES OVER A PRINCIPAL IDEAL DOMAIN

Computing Correlated Equilibria in Multi-Player Games

EEE 241: Linear Systems

Exercises. 18 Algorithms

Lecture 2: Gram-Schmidt Vectors and the LLL Algorithm

Split alignment. Martin C. Frith April 13, 2012

Math 594. Solutions 1

AN EXTENDED CLASS OF TIME-CONTINUOUS BRANCHING PROCESSES. Rong-Rong Chen. ( University of Illinois at Urbana-Champaign)

THERE ARE NO POINTS OF ORDER 11 ON ELLIPTIC CURVES OVER Q.

SL n (F ) Equals its Own Derived Group

Lecture 3 January 31, 2017

Transcription:

Example of Extended Eucldean Algorthm Recall that gcd(84, 33) = gcd(33, 18) = gcd(18, 15) = gcd(15, 3) = gcd(3, 0) = 3 We work backwards to wrte 3 as a lnear combnaton of 84 and 33: 3 = 18 15 [Now 3 s a lnear combnaton of 18 and 15] = 18 (33 18) = 2(18) 33 [Now 3 s a lnear combnaton of 18 and 33] = 2(84 2 33)) 33 = 2 84 5 33 [Now 3 s a lnear combnaton of 84 and 33] Some Consequences Corollary 2: If a and b are relatvely prme, then there exst s and t such that as + bt = 1. Corollary 3: If gcd(a, b) = 1 and a bc, then a c. Proof: Exst s, t Z such that sa + tb = 1 Multply both sdes by c: sac + tbc = c Snce a bc, a sac + tbc, so a c Corollary 4: If p s prme and p Π n =1 a, then p a for some 1 n. Proof: By nducton on n: If n = 1: trval. Suppose the result holds for n and p Π n+1 =1 a. note that p Π n+1 =1 a = (Π n =1 a )a n+1. If p a n+1 we are done. If not, gcd(p, a n+1 ) = 1. By Corollary 3, p Π n =1 a By the IH, p a for some 1 n. 1 2 The Fundamental Theorem of Arthmetc, II Theorem 3: Every n > 1 can be represented unquely as a product of prmes, wrtten n nondecreasng sze. Proof: Stll need to prove unqueness. We do t by strong nducton. Base case: Obvous f n = 2. Inductve step. Suppose OK for n < n. Suppose that n = Π s =1 p = Π r j=1 q j. p 1 Π r j=1 q j, so by Corollary 4, p 1 q j for some j. But then p 1 = q j, snce both p 1 and q j are prme. But then n/p 1 = p 2 p s = q 1 q j 1 q j+1 q r Result now follows from I.H. Characterzng the GCD and LCM Theorem 6: Suppose a = Π n =1 p α where p are prmes and α, β N. Some α s, β s could be 0. Then gcd(a, b) = Π n =1 p mn(α,β ) lcm(a, b) = Π n =1 p max(α,β ) Proof: For gcd, let c = Π n =1 p mn(α,β ). Clearly c a and c b. and b = Π n =1 p β, Thus, c s a common dvsor, so c gcd(a, b). If q γ gcd(a, b), must have q {p 1,..., p n } Otherwse q a so q gcd(a, b) (lkewse b) If q = p, q γ gcd(a, b), must have γ mn(α, β ) E.g., f γ > α, then p γ a Thus, c gcd(a, b). Concluson: c = gcd(a, b). 3 4

For lcm, let d = Π n =1 p max(α,β ). Clearly a d, b d, so d s a common multple. Thus, d lcm(a, b). Suppose lcm(a, b) = Π n =1 p γ. Must have α γ, snce p α Smlarly, must have β γ. Thus, max(α, β ) γ. Concluson: d = lcm(a, b). a and a lcm(a, b). Example: 432 = 2 4 3 3, and 95256 = 2 3 3 5 7 2, so gcd(95256, 432) = 2 3 3 3 = 216 lcm(95256, 432) = 2 4 3 5 7 2 = 190512. Corollary 5: ab = gcd(a, b) lcm(a, b) Proof: mn(α, β) + max(α, β) = α + β. Example: 4 10 = 2 20 = gcd(4, 10) lcm(4, 10). Modular Arthmetc Remember: a b (mod m) means a and b have the same remander when dvded by m. Equvalently: a b (mod m) ff m (a b) a s congruent to b mod m Theorem 7: If a 1 a 2 (mod m) and b 1 b 2 (mod m), then (a) (a 1 + b 1 ) (a 2 + b 2 ) (mod m) (b) a 1 b 1 a 2 b 2 (mod m) Proof: Suppose So a 1 = c 1 m + r, a 2 = c 2 m + r b 1 = d 1 m + r, b 2 = d 2 m + r a 1 + b 1 = (c 1 + d 1 )m + (r + r ) a 2 + b 2 = (c 2 + d 2 )m + (r + r ) m ((a 1 + b 1 ) (a 2 + b 2 ) = ((c 1 + d 1 ) (c 2 + d 2 ))m Concluson: a 1 + b 1 a 2 + b 2 (mod m). 5 6 For multplcaton: a 1 b 1 = (c 1 d 1 m + r c 1 + rd 1 )m + rr a 2 b 2 = (c 2 d 2 m + r c 2 + rd 2 )m + rr m (a 1 b 1 a 2 b 2 ) Concluson: a 1 b 1 a 2 b 2 (mod m). Bottom lne: addton and multplcaton carry over to the modular world. Modular arthmetc has lots of applcatons. Here are four... Hashng Problem: How can we effcently store, retreve, and delete records from a large database? For example, students records. Assume, each record has a unque key E.g. student ID, Socal Securty # Do we keep an array sorted by the key? Easy retreval but dffcult nserton and deleton. How about a table wth an entry for every possble key? Often nfeasble, almost always wasteful. There are 10 10 possble socal securty numbers. Soluton: store the records n an array of sze N, where N s somewhat bgger than the expected number of records. Store record wth d k n locaton h(k) h s the hash functon Basc hash functon: h(k) := k (mod N). A collson occurs when h(k 1 ) = h(k 2 ) and k 1 k 2. Choose N suffcently large to mnmze collsons Lots of technques for dealng wth collsons 7 8

Pseudorandom Sequences ISBN Numbers For randomzed algorthms we need a random number generator. Most languages provde you wth a functon rand. There s nothng random about rand! It creates an apparently random sequence determnstcally These are called pseudorandom sequences A standard technque for creatng psuedorandom sequences: the lnear congruental method. Choose a modulus m N +, a multpler a {2, 3,..., m 1}, and an ncrement c Z m = {0, 1,..., m 1}. Choose a seed x 0 Z m Typcally the tme on some nternal clock s used Compute x n+1 = ax n + c (mod m). Warnng: a poorly mplemented rand, such as n C, can wreak havoc on Monte Carlo smulatons. 9 Snce 1968, most publshed books have been assgned a 10-dgt ISBN numbers: dentfes country of publcaton, publsher, and book tself The ISBN number for DAM3 s 1-56881-166-7 All the nformaton s encoded n the frst 9 dgts The 10th dgt s used as a party check If the dgts are a 1,..., a 10, then we must have a 1 + 2a 2 + + 9a 9 + 10a 10 0 (mod 11). For DAM3, get 1 + 2 5 + 3 6 + 4 8 + 5 8 + 6 1 +7 1 + 8 6 + 9 6 + 10 7 = 286 0 (mod 11) Ths test always detects errors n sngle dgts and transposton errors Two arbtrary errors may cancel out Smlar party checks are used n unversal product codes (UPC codes/bar codes) that appear on almost all tems The numbers are encoded by thcknesses of bars, to make them machne readable 10 Castng out 9s Lnear Congruences Notce that a number s equvalent to the sum of ts dgts mod 9. Ths can be used as a way of checkng your addton and of dong mndreadng [come to class to hear more... ] The equaton ax = b for a, b R s unquely solvable f a 0: x = ba 1. Can we also (unquely) solve ax b (mod m)? If x 0 s a soluton, then so s x 0 + km k Z... snce km 0 (mod m). So, unqueness can only be mod m. But even mod m, there can be more than one soluton: Consder 2x 2 (mod 4) Clearly x 1 (mod 4) s one soluton But so s x 3 (mod 4)! Theorem 8: If gcd(a, m) = 1 then there s a unque soluton (mod m) to ax b (mod m). Proof: Suppose r, s Z both solve the equaton: then ar as (mod m), so m a(r s) Snce gcd(a, m) = 1, by Corollary 3, m (r s) But that means r s (mod m) So f there s a soluton at all, then t s unque mod m. 11 12

Solvng Lnear Congruences The Chnese Remander Theorem But why s there a soluton to ax b (mod m)? Key dea: fnd a 1 mod m; then x ba 1 (mod m) By Corollary 2, snce gcd(a, m) = 1, there exst s, t such that as + mt = 1 So as 1 (mod m) That means s a 1 (mod m) x bs (mod m) Suppose we want to solve a system of lnear congruences: Example: Fnd x such that x 2 (mod 3) x 3 (mod 5) x 2 (mod 7) Can we solve for x? Is the answer unque? Defnton: m 1,..., m n are parwse relatvely prme f each par m, m j s relatvely prme. Theorem 9 (Chnese Remander Theorem): Let m 1,..., m n N + be parwse relatvely prme. The system x a (mod m ) = 1, 2... n (1) has a unque soluton modulo M = Π n 1m. The best we can hope for s unqueness modulo M: If x s a soluton then so s x + km for any k Z. Proof: Frst I show that there s a soluton; then I ll show t s unque. 13 14 CRT: Exstence CRT: Example Key dea for exstence: Suppose we can fnd y 1,..., y n such that Now consder y := Σ n j=1 y j. y a (mod m ) y 0 (mod m j ) f j. Σ n j=1 y j a (mod m ) Snce y = a mod m and y j = 0 mod m j f j. So y s a soluton! Now we need to fnd y 1,..., y n. Let M = M/m = m 1 m 1 m +1 m n. gcd(m, m ) = 1, snce m j s parwse relatvely prme No common prme factors among any of the m j s Choose y such that (M )y a (mod m ) Can do that by Theorem 8, snce gcd(m, m ) = 1. Let y = y M. y s a multple of m j f j, so y 0 (mod m j ) y = y M a (mod m ) by constructon. So y 1 + + y n s a soluton to the system, mod M. 15 Fnd x such that x 2 (mod 3) x 3 (mod 5) x 2 (mod 7) Fnd y 1 such that y 1 2 (mod 3), y 1 0 (mod 5/7): y 1 has the form y 1 5 7 35y 1 2 (mod 3) y 1 = 1, so y 1 = 35. Fnd y 2 such that y 2 3 (mod 5), y 2 0 (mod 3/7): y 2 has the form y 2 3 7 21y 2 3 (mod 5) y 2 = 3, so y 2 = 63. Fnd y 3 such that y 3 2 (mod 7), y 3 0 (mod 3/5): y 3 has the form y 3 3 5 15y 3 2 (mod 7) y 3 = 2, so y 3 = 30. Soluton s x = y 1 + y 2 + y 3 = 35 + 63 + 30 = 128 16

CRT: Unqueness What f x, y are both solutons to the equatons? x y (mod m ) m (x y), for = 1,..., n Clam: M = m 1 m n (x y) so x y (mod M) Theorem 10: If m 1,..., m n are parwse relatvely prme and m b for = 1,..., n, then m 1 m n b. Proof: By nducton on n. For n = 1 the statement s trval. Suppose statement holds for n = N. Suppose m 1,..., m N+1 relatvely prme, m b for = 1,..., N + 1. by IH, m 1 m N b b = m 1 m N c for some c By assumpton, m N+1 b, so m (m 1 m N )c gcd(m 1 m N, m N+1 ) = 1 (snce m s parwse relatvely prme no common factors) by Corollary 3, m N+1 c so c = dm N+1, b = m 1 m N m N+1 d so m 1 m N+1 b. An Applcaton of CRT: Computer Arthmetc wth Large Integers Suppose we want to perform arthmetc operatons (addton, multplcaton) wth extremely large ntegers too large to be represented easly n a computer Idea: Step 1: Fnd sutable modul m 1,..., m n so that m s are relatvely prme and m 1 m n s bgger than the answer. Step 2: Perform all the operatons mod m j, j = 1,..., n. Ths means we re workng wth much smaller numbers (no bgger than m j ) The operatons are much faster Can do ths n parallel Suppose the answer mod m j s a j : Use CRT to fnd x such that x a j (mod m j ) The unque x such that 0 < x < m 1 m n s the answer to the orgnal problem. 17 18 Example: The followng are parwse relatvely prme: 2 35 1, 2 34 1, 2 33 1, 2 29 1, 2 23 1 We can add and multply postve ntegers up to (2 35 1)(2 34 1)(2 33 1)(2 29 1)(2 23 1) > 2 163. 19 Fermat s Lttle Theorem Theorem 11 (Fermat s Lttle Theorem): (a) If p prme and gcd(p, a) = 1, then a p 1 1 (mod p). (b) For all a Z, a p a (mod p). Proof. Let A = {1, 2,..., p 1} B = {1a mod p, 2a mod p,..., (p 1)a mod p} Clam: A = B. 0 / B, snce p ja, so B A. If j, then a mod p ja mod p snce p (j )a Thus A = p 1, so A = B. Therefore, Π A Π B (mod p) (p 1)! a(2a) (p 1)a = (p 1)! a p 1 (mod p) p (a p 1 1)(p 1)! p (a p 1 1) [snce gcd(p, (p 1)!) = 1] a p 1 1 (mod p) It follows that a p a (mod p) Ths s true even f gcd(p, a) 1;.e., f p a Why s ths beng taught n a CS course? 20