MODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.



Similar documents
CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

8 Primes and Modular Arithmetic

Math 319 Problem Set #3 Solution 21 February 2002

Continued Fractions and the Euclidean Algorithm

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

V Quantitative Reasoning: Computers, Number Theory and Cryptography

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

8 Divisibility and prime numbers

26 Integers: Multiplication, Division, and Order

Stupid Divisibility Tricks

Applications of Fermat s Little Theorem and Congruences

So let us begin our quest to find the holy grail of real analysis.

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

4.5 Finite Mathematical Systems

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

CONTENTS 1. Peter Kahn. Spring 2007

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

Lectures on Number Theory. Lars-Åke Lindahl

Quotient Rings and Field Extensions

SUM OF TWO SQUARES JAHNAVI BHASKAR

Discrete Mathematics, Chapter 4: Number Theory and Cryptography

Handout NUMBER THEORY

3 Some Integer Functions

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

MATH10040 Chapter 2: Prime and relatively prime numbers

Homework until Test #2

26 Ideals and Quotient Rings

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

Properties of Real Numbers

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

k, then n = p2α 1 1 pα k

Math Workshop October 2010 Fractions and Repeating Decimals

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, Notes on Algebra

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Notes on Algebraic Structures. Peter J. Cameron

Factoring Whole Numbers

DIVISIBILITY AND GREATEST COMMON DIVISORS

Math 223 Abstract Algebra Lecture Notes

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Playing with Numbers

Lecture 13 - Basic Number Theory.

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Section 4.2: The Division Algorithm and Greatest Common Divisors

Every Positive Integer is the Sum of Four Squares! (and other exciting problems)

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Solve addition and subtraction word problems, and add and subtract within 10, e.g., by using objects or drawings to represent the problem.

3. Mathematical Induction

Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan

Pigeonhole Principle Solutions

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003

Elementary Number Theory

Lecture 16 : Relations and Functions DRAFT

Test1. Due Friday, March 13, 2015.

Today s Topics. Primes & Greatest Common Divisors

ABSTRACT ALGEBRA: A STUDY GUIDE FOR BEGINNERS

Permutation Groups. Tom Davis April 2, 2003

5544 = = = Now we have to find a divisor of 693. We can try 3, and 693 = 3 231,and we keep dividing by 3 to get: 1

GCDs and Relatively Prime Numbers! CSCI 2824, Fall 2014!

6.2 Permutations continued

Full and Complete Binary Trees

Chapter 3. if 2 a i then location: = i. Page 40

Student Outcomes. Lesson Notes. Classwork. Discussion (10 minutes)

Zeros of a Polynomial Function

Number Theory: A Mathemythical Approach. Student Resources. Printed Version

Notes on Factoring. MA 206 Kurt Bryan


A Little Set Theory (Never Hurt Anybody)

Chapter 11 Number Theory

5.1 Radical Notation and Rational Exponents

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

ALGEBRAIC APPROACH TO COMPOSITE INTEGER FACTORIZATION

RSA Encryption. Tom Davis October 10, 2003

Factoring Polynomials

Solutions of Linear Equations in One Variable

Session 6 Number Theory

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

NUMBER SYSTEMS. William Stallings

PYTHAGOREAN TRIPLES KEITH CONRAD

4. FIRST STEPS IN THE THEORY 4.1. A

Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

Math Content by Strand 1

Lemma 5.2. Let S be a set. (1) Let f and g be two permutations of S. Then the composition of f and g is a permutation of S.

Mathematical Induction

Just the Factors, Ma am

Handout #1: Mathematical Reasoning

Grade 6 Math Circles March 10/11, 2015 Prime Time Solutions

Lecture 3: Finding integer solutions to systems of linear equations

Congruent Number Problem

The BBP Algorithm for Pi

GREATEST COMMON DIVISOR

Chapter 7: Products and quotients

Answer Key for California State Standards: Algebra I

Computing exponents modulo a number: Repeated squaring

6.3 Conditional Probability and Independence

Solution to Homework 2

Transcription:

MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on the other hand, is another story, since dividing one integer by another doesn t always produce another integer For example, the number 3 divides evenly into 6, producing a quotient of 2, but 3 does not divide evenly into 14 Attempting to divide 3 into 14 produces a quotient of q = 4 and a remainder of r = 2 Here you can obtain the quotient q = 4 as the integer part of the fraction 14 3 = 4 2 3 The remainder is then r = 14 3q = 14 12 = 2 The above procedure is quite general Theorem 1 (Division Theorem) Let a and b be any integers with a > 0 There are unique integers q (the quotient) and r (the remainder) satisfying (1) b = aq + r (2) 0 r < a Proof There are two assertions, existence and uniqueness, which must be proved separately We begin with existence Let S = {b ak : k Z} We first show that S contains a non-negative integer Taking k = b, we obtain b + a b S Since a 1, we obtain b + a b b + b 0 Thus S has at least one non-negative member Let S + be the set of all non-negative members of S By the Well Ordering Principle, 1 S + contains a smallest element Call it r Since r S, there is an integer q such that r = b aq, and rearranging gives item 1 Since r S +, we have r 0, so to prove item 2, we only have to show that r < a Suppose r a Then r a 0, and clearly r a S, so r a S + Since r a < r, this contradicts the choice or r as the smallest member of S + This establishes item 2, which completes the existence proof We now turn to uniqueness Suppose the pairs q 1, r 1 and q 2, r 2 both satisfy the conditions of the theorem We may assume without loss that r 1 r 2 We have (1) q 1 a + r 1 = b = q 2 a + r 2, so r 2 r 1 = (q 1 q 2 )a Therefore r 2 r 1 is a multiple of a But since 0 r 2 r 1 r 2 < a, we must have r 2 r 1 = 0, so r 1 = r 2 Inserting this into (1) gives q 1 = q 2, and uniqueness is established 1 The Well Ordering Principle asserts that every non-empty set of non-negative integers contains a smallest member It is equivalent to the Principle of Mathematical Induction 1

MODULAR ARITHMETIC 2 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Table 1 The Integers Modulo 5 The problem of calculating the quotient q and remainder r from the numbers a and b is the integer division problem There s an algorithm for efficiently solving the integer division problem even for very large values of a and/or b In fact, it s just the long division algorithm you learned in school Most high level computer languages include instructions for integer division For example with Sage, q and r are given by b//a and b%a respectively In written work, we often use the notation b mod a for the remainder r when a is divided by b Exercise 2 For each of the following pairs a and b, calculate the quotient and remainder when b is divided by a (1) a = 9, b = 23 (2) a = 9, b = 27 (3) a = 9, b = 23 (4) a = 10, b = 27 (5) a = 10, b = 123456789 (6) a = 54, b = 9876543 3 Working With Remainders Modular arithmetic works like the numbers on a clock, which repeat in cycles of 12 In the case of a clock the number 12 is the modulus, and you identify any two numbers which differ by a multiple of 12 Thus, the numbers 9, 3, 15, and 27 all register the same way on the clock face We say that these numbers are all the same modulo 12 Of course there s nothing magical about the number 12 The same kind of identifications could be carried out using another positive integer for the modulus For example, using a modulus of 5, you d identify any two numbers that differ by a multiple of 5 You can visualize this by imagining all the integers arranged in a 5 column table, a portion of which is shown in Table 1 When working modulo 5, numbers in the same column of Table 1 are identified, so that, for example, you don t distinguish between the numbers 4 and 11 In general, when working modulo n, you ll identify any two numbers which differ by a multiple of n To be precise, we ll write a b (mod n) to mean that a b is divisible by n The above expression is read a is congruent to b modulo n Again, you can imagine arranging the integers into a table with n columns as in Table 2, and identifying any two numbers that are in the same column

MODULAR ARITHMETIC 3 n n + 1 1 0 1 n 1 n n + 1 2n 1 Table 2 The Integers Modulo n The following theorem summarizes the key properties of congruence modulo n Its proof is left as an exercise Theorem 2 Let n be a positive integer (1) (Reflexivity) For every integer a we have a a (mod n) (2) (Symmetry) a b (mod n) if and only if b a (mod n) (3) (Transitivity) If a b (mod n) and b c (mod n) then a c (mod n) (4) If a b (mod n) and c d (mod n) then a + c b + d (mod n) and ac bd (mod n) We now make precise the idea of partitioning the integers into columns, that we discussed informally above We fix an positive integer n, which we call a modulus For any integer a, we define the congruence class of a modulo n as [a] n = {b Z : a b (mod n)} We will sometimes write [a], omitting the subscript n, when the modulus is clear from context Theorem 3 a b (mod n) if and only if [a] n = [b] n Proof Suppose first that [a] n = [b] n By reflexivity, we have b [b] n Since [a] n = [b] n, we have b [a] n By definition of congruence classes, we have a b (mod n) Conversely, suppose a b (mod n) Let c [a] n By definition of congruence classes, a c (mod n) By symmetry, b a (mod n), and so, by transitivity, b c (mod n) By definition of equivalence classes, c [b] n Since c represents an arbitrary member of [a] n, we have shown that [a] n [b] n A similar argument, reversing the roles of a and b, gives the reverse inclusion, [a] n = [b] n Corollary 4 Every integer is in exactly one congruence class modulo n Proof For every integer a, we have a [a] n, so to complete the proof, we must show that any two congruence classes are either equal or disjoint Suppose [a] n and [b] n are not disjoint Let c [a] n [b] n Thus a c (mod n) and b c (mod n), so, by reflexivity and transitivity, a b (mod n) By the previous theorem, [a] n = [b] n We define Z n to be the set of all congruence classes modulo n Theorem 5 Z n = {[0] n, [1] n,, [n 1] n }, and the congruence classes [0] n,, [n 1] n are distinct

MODULAR ARITHMETIC 4 + 4 0 1 2 3 0 0 1 2 3 1 1 2 3 0 2 2 3 0 1 3 3 0 1 2 4 0 1 2 3 0 0 0 0 0 1 0 1 2 3 2 0 2 0 2 3 0 3 2 1 Table 3 Addition and Multiplication Modulo 4 Proof Let a Z Dividing a by n, we obtain integers q and r with 0 r < n 1 and a = qn + r It follows that a r (mod n), so a [r] n This establishes the first assertion For the second assertion, suppose 0 r 1 < r 2 n 1 Then 0 r 2 r 1 < n, so n is not a divisor of r 2 r 1, and therefore r 1 r 2 (mod n), and so [r 1 ] n [r 2 ] n 4 Arithmetic in Z n We want to define addition and multiplication as binary operations on Z n by setting [a] n + [b] n = [a + b] n and [a] n [b] n = [ab] n To make sense of this, we must check that congruence classes on the right do not depend on the choice of representatives a and b of the congruence classes on the left For this, suppose that [a] n = [a ] n and [b] n = [b ] n We must show that [a + b] n = [a + b ] n and [ab] n = [a b ] n By Theorem 3 we have a a (mod n) and b b (mod n) It now follows from Theorem 2 that a + b a + b (mod n) and ab a b (mod n) Another application of Theorem 3 gives [a + b] n = [a + b ] n and [ab] n = [a b ] n Therefore, the addition and multiplication are unambiguously defined binary operations on Z n Associativity and commutativity of integer addition and multiplication carry over immediately to addition and multiplication on Z n Further, we have [0] n + [a] n = [a] n and [a] n + [ a] n = [0] n for every integer a, so Z n is an abelian group under addition of congruence classes By Theorem 5, every congruence class modulo n contains exactly one of the numbers 0, 1,, n 1 It is common practice to use these numbers as representatives of their congruence classes When we do this, we write, somewhat imprecisely, Z n = {1, 2,, n 1}, with the understanding that the integer j stands for the congruence class [j] n When taking this point of view, we sometimes denote addition and multiplication in Z + n by + n and n, respectively, to distinguish them from the usual integer operations Mod n addition or multiplication is performed by first adding or multiplying as ordinary integers, and then replacing the sum or product by the remainder upon division by n In symbols, j + n k = (j + k) mod n, j n k = (j k) mod n For any given modulus, you can, at least in principle, write out the entire addition and multiplication tables Table 3 gives the addition and multiplication tables modulo 4

MODULAR ARITHMETIC 5 Exercise 5 Build a addition and multiplication tables modulo 6 Exercise 6 Use your answer to Exercise 5 to find all solutions x (if any) to each of the following (1) 5x 1 (mod 6) (2) 4x 1 (mod 6) (3) 4x 2 (mod 6) 61 Modular Arithmetic in Sage The algebraic structure Z n can be constructed in Sage with Integers(n) Here are a few lines of Sage code to perform some calculations in Z 42 sage: Z42=Integers(42) sage: a=z42(27) sage: b=z42(31) sage: a,b (27, 31) sage: a+b 16 sage: a*b 39 sage: a^100 15