The Euclidean Algorithm and Multiplicative Inverses

Similar documents
Ch 4.2 Divisibility Properties

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

Chapter 3: The Euclidean Algorithm and Diophantine. Math 138 Burger California State University, Fresno

2 Elementary number theory

Clock Arithmetic and Euclid s Algorithm

Number Theory Proof Portfolio

Intermediate Math Circles February 26, 2014 Diophantine Equations I

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

8 Primes and Modular Arithmetic

Elementary Properties of the Integers

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

CMPUT 403: Number Theory

Number theory (Chapter 4)

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

CISC-102 Winter 2016 Lecture 11 Greatest Common Divisor

Mathematical Foundations of Cryptography

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

Chapter 4 Finite Fields

ACCESS: Cryptography

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

Number Theory Notes Spring 2011

4 Powers of an Element; Cyclic Groups

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

Applied Cryptography and Computer Security CSE 664 Spring 2017

Chapter 3 Basic Number Theory

Algorithms CMSC Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse

Lecture 7: Number Theory Steven Skiena. skiena

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

Chapter 2. Divisibility. 2.1 Common Divisors

Homework #2 solutions Due: June 15, 2012

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

Math Circles - Lesson 2 Linear Diophantine Equations cont.

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

a the relation arb is defined if and only if = 2 k, k

Lecture 4: Number theory

Modular Arithmetic Instructor: Marizza Bailey Name:

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

Lecture Notes. Advanced Discrete Structures COT S

MATH 361: NUMBER THEORY FOURTH LECTURE

The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers:

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

CS250: Discrete Math for Computer Science

CSC 474 Information Systems Security

Lecture 7 Number Theory Euiseong Seo

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

EUCLID S ALGORITHM AND THE FUNDAMENTAL THEOREM OF ARITHMETIC after N. Vasiliev and V. Gutenmacher (Kvant, 1972)

NOTES ON SIMPLE NUMBER THEORY

Finite Fields. Mike Reiter

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

3 The fundamentals: Algorithms, the integers, and matrices

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

1 Overview and revision

Chapter 14: Divisibility and factorization

Solution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,

Q 2.0.2: If it s 5:30pm now, what time will it be in 4753 hours? Q 2.0.3: Today is Wednesday. What day of the week will it be in one year from today?

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

With Question/Answer Animations. Chapter 4

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6

Discrete Mathematics GCD, LCM, RSA Algorithm

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

Basic elements of number theory

Basic elements of number theory

Lecture 7.5: Euclidean domains and algebraic integers

CHAPTER 3. Congruences. Congruence: definitions and properties

Number Theory. Zachary Friggstad. Programming Club Meeting

Deepening Mathematics Instruction for Secondary Teachers: Algebraic Structures

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

Numbers. Çetin Kaya Koç Winter / 18

Rings and modular arithmetic

Euclidean Domains. Kevin James

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers

Some Facts from Number Theory

#26: Number Theory, Part I: Divisibility

Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

4 Number Theory and Cryptography

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

22. The Quadratic Sieve and Elliptic Curves. 22.a The Quadratic Sieve

Remainders. We learned how to multiply and divide in elementary

CISC-102 Fall 2017 Week 6

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

The Euclidean Algorithm

MATH 3240Q Introduction to Number Theory Homework 4

Number Theory and Group Theoryfor Public-Key Cryptography

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Number Theory and Divisibility

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Divisors. Common divisors. Let m, n P Z with m 0. Wesaythatm divides n if n is a multiple of m, i.e.

Number Theory Math 420 Silverman Exam #1 February 27, 2018

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Fall 2017 Test II review problems

Transcription:

1 The Euclidean Algorithm and Multiplicative Inverses Lecture notes for Access 2009 The Euclidean Algorithm is a set of instructions for finding the greatest common divisor of any two positive integers. Its original importance was probably as a tool in construction and measurement; the algebraic problem of finding gcd(a, b) is equivalent to the following geometric measuring problem: Given two different rulers, say of lengths a and b, find a third ruler which is as long as possible, but so that you can still use it as a scale on both of the longer rulers. There s a neat movie demonstration of how the algorithm works geometrically, on the Wikipedia page for Euclidean Algorithm. Euclid probably wasn t thinking about finding multiplicative inverses in modular arithmetic, but it turns out that if you look at his algorithm in reverse, that s exactly what it does! The Euclidean Algorithm makes repeated used of integer division ideas: We know that if a and b are positive integers, then we may write a b = q + r b where q is the quotient, and the remainder r satisfies 0 r < b. If we clear fractions, this is the equation a = bq + r. We really do know that this last equation is possible: starting with (b)(0), then (b)(1) etc. we may subtract increasing multiples of b from a until what remains is a non-negative number less than b. And that s actually the mathematical reason that the integer division fact we started with is true. (This procedure is called the division algorithm.) Here is the algebraic formulation of Euclid s Algorithm; it uses the division algorithm successively until gcd(a,b) pops out: Theorem 1 (The Euclidean Algorithm). Given two integers 0 < b < a, we make a repeated application of the division algorithm to obtain a series of division equations, which eventually terminate with a zero remainder: a = bq 1 + r 1,0 < r 1 < b, b = r 1 q 2 + r 2,0 < r 2 < r 1, r 1 = r 2 q 3 + r 3,0 < r 3 < r 2, r j 2 = r j 1 q j + r j,0 < r j < r j 1 r j 1 = r j q j+1. The greatest common divisor (a,b) of a and b is r j, the last nonzero remainder in the division process.

2 Let s look at an example of the Euclidean algorithm in action - it s really quick at finding gcd s when your two integers are large. We should be able to verify these steps with our scientific calculators: Example 1. Find the gcd of 42823 and 6409. 42823 = 6409(6) + 4369 6409 = 4369(1) + 2040 Solution. 4369 = 2040(2) + 289 2040 = 289(7) + 17 289 = 17(17) Therefore (42823,6409) = 17. Why does the Euclidean Algorithm actually give the gcd? It seems kind of strange that we can get the gcd of two numbers a and b by looking at the gcd s of the subsequent remainder values. Let s look at successive equations in this process: From the first equation a = bq 1 + r 1, we deduce that since the gcd divides a and b it must divide r 1. Similarly in the next equation b = r 1 q 2 + r 2, the gcd divides b and r 1, so it must also divide r 2. Thus the gcd (a,b) divides all the remainders, including the final non-zero one, r j. On the other hand, by working up from the last equation r j 1 = r j q j+1 we deduce that r j divides r j 1. From the second to last equation r j also divides r j 2, and working all the way back to the top we see that r j divides both a and b, so is a divisor. Putting our reasoning together, r j must be the greatest common divisor! But enough of these explanations, let s try some exercises! Exercise 1. Find the gcd s of the following pairs of numbers. Save your work because you ll need it later. 1. 7469 and 2464 2. 2689 and 4001 3. 2947 and 3997 4. 1109 and 4999

3 The fact that we can use the Euclidean algorithm work in order to find multiplicative inverses follows from the following algorithm: Theorem 2 (Multiplicative Inverse Algorithm). Given two integers 0 < b < a, consider the Euclidean Algorithm equations which yield gcd(a,b) = r j. Rewrite all of these equations except the last one, by solving for the remainders: r 1 = a bq 1, r 2 = b r 1 q 2, r 3 = r 1 r 2 q 3, r j 1 = r j 3 r j 2 q j 1 r j = r j 2 r j 1 q j. Then, in the last of these equations, r j = r j 2 r j 1 q j, replace r j 1 with its expression in terms of r j 3 and r j 2 from the equation immediately above it. Continue this process successively, replacing r j 2,r j 3,..., until you obtain the final equation r j = ax + by, with x and y integers. In the special case that gcd(a,b) = 1, the integer equation reads Therefore we deduce 1 = ax + by. 1 by mod a so that (the residue of) y is the multiplicative inverse of b, mod a. Examples! Example 2. Find integers x and y to satisfy 42823x + 6409y = 17. Solution. We begin by solving our previous equations for the remainders. We have: 4369 = 42823 6409(6) 2040 = 6409 4369 289 = 4369 2040(2) 17 = 2040 289(7) Now we do the substitutions starting with that last equation and working backwards and combining like terms along the way: 17 = 2040 289(7) = 2040 (4369 2040(2))(7) = 2040(15) 4369(7) 17 = (6409 4369)(15) 4369(7) = 6409(15) 4369(22) 17 = 6409(15) (42823 6409(6))(22) = 6409(147) 42823(22) Therefore x = 22,y = 147.

4 Example 3. Find the multiplicative inverse of 8 mod 11, using the Euclidean Algorithm. Solution. We ll organize our work carefully. We ll do the Euclidean Algorithm in the left column. It will verify that gcd(8,11) = 1. Then we ll solve for the remainders in the right column, before backsolving: 11 = 8(1) + 3 3 = 11 8(1) 8 = 3(2) + 2 2 = 8 3(2) 3 = 2(1) + 1 1 = 3 2(1) 2 = 1(2) Now reverse the process using the equations on the right. 1 = 3 2(1) 1 = 3 (8 3(2))(1) = 3 (8 (3(2)) = 3(3) 8 1 = (11 8(1))(3) 8 = 11(3) 8(4) = 11(3) + 8( 4) Therefore 1 8( 4) mod 11, or if we prefer a residue value for the multiplicative inverse, 1 8(7) mod 11. Be careful about the order of the numbers. We do not want to accidentally switch the bolded numbers with the non-bolded numbers! Exercise 2. Find the greatest common divisor g of the numbers 1819 and 3587, and then find integers x and y to satisfy 1819x + 3587y = g Exercise 3. Find the multiplicative inverses of the following: 1. 50 mod 71

5 2. 43 mod 64 Exercise 4. Using the information from the previous exercise, solve the following equation for x and check your answer. 50x 63 mod 71. Exercise 5. Solve 12345x 6 mod 54321. Hint: First find the gcd.