* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download SectionModularArithm..
Foundations of mathematics wikipedia , lookup
Abuse of notation wikipedia , lookup
Wiles's proof of Fermat's Last Theorem wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
List of first-order theories wikipedia , lookup
Infinitesimal wikipedia , lookup
Positional notation wikipedia , lookup
Location arithmetic wikipedia , lookup
List of prime numbers wikipedia , lookup
Real number wikipedia , lookup
Large numbers wikipedia , lookup
Collatz conjecture wikipedia , lookup
P-adic number wikipedia , lookup
Elementary mathematics wikipedia , lookup
1
Modular Arithmetic
HW # 1-2 p. 7 at the end of the notes
In this section, we discuss the basics of modular arithmetic. As we will see later, the most
basic number systems that we are accustomed to working with are examples of groups,
rings and fields. First, we review some basic set notation and then the basics of modular
arithmetic.
Notation for Special Sets
Recall that a set is a collection of objects enclosed in braces. The objects in the sets are
call elements. If a is an element of a set, we write a S . For example, 2 {1, 2, 3, 4} but
5 1, 2, 3, 4} . Sets can have both a finite and an infinite number of elements. The
following represents special notations that are used for widely known infinite sets.
Notation for Special Sets
1. Z = the set of integers { , 4, 3, 2, 1, 0, 1, 2, 3, 4,}
2. Q = the set of rational numbers (numbers that can be expressed as the quotient
two integers m and n, where n 0 .
3. R = the set of real numbers.
m
of
n
4. Z , Q , and R represent the set of positive integers, positive rational numbers, and
positive real numbers, respectively. For example, Z {1, 2, 3, 4, 5, 6, } .
5. C = the set of complex numbers, that is, numbers of the form a bi , were i is the
imaginary unit given by i 1 . Examples of the complex numbers include 2 3i
3
and 4 i .
2
*
*
6. Z * , Q* , R , and C represent the set of non-zero integers, non-zero rational
numbers, non-zero real numbers, and non-zero complex numbers, respectively. For
example, Z * {,5, 4, 3, 2, 1, 1, 2, 3, 4, 5,} .
7. M n (R) represent the set of n n matrices with real entries. The matrices
3 3 0
3 6 1 and 1 1 are examples.
2 3
1 1 0
2
Modular Arithmetic
To begin, we first review what it means to divide two numbers..
Definition 1.1: We say that a divides b, denoted as a | b , if b ka for some integer a.
For instance, we know that 7 | 21 since 21 3 7 . However, we know that 5 | 21 since
there is no integer multiple of 5 that gives 21. Dividing two numbers gives a special case
of the division algorithm, which we state next.
Division algorithm: Let m be a positive integer ( m 0 ) and let b be any integer. When
computing b m , there is exactly one pair of integers q (called the quotient) and r
(called the remainder) such that
b qm r where 0 r m .
This leads into the definition of modular arithmetic.
Definition 1.2: Given two integers a, b Z and a positive integer m Z , we say that a
is congruent to b modulo m, written
a b (mod m)
if m | (a b) . The number m is called the modulus of the congruence.
Example 1: Explain why 23 3 (mod 5), 48 12 (mod 6) but 20 3 (mod 4) .
Solution: 23 3 (mod 5) and 48 12 (mod 6) since 5 | (23 3) or 5 | 20 and 6 | (48 12)
or 6 | 36 . However, 20 3 (mod 4) since 4 | (20 3) or 4 | 17 .
█
3
Theorem 1.3: a b (mod m) if and only if a b km for some integer k
Proof:
█
Fact: Computationally, b (mod m) gives the integer remainder of b m . We say that
a b (mod m) if a and b produce the same integer remainder upon division by m.
For example, 23 8 (mod 5) since both 23 and 8 produce are remainder of 3 when
divided by 5, that is 23 (mod 5) 3 and 8 (mod 5) 3 . We can write 23 8 3 (mod 5) .
Note: When performing modular arithmetic computationally, the remainder r should
never be negative. Hence, when finding the remainder for b (mod m) , look for the nearest
integer that m divides that is less than b.
Example 2: Compare computing 23 (mod 9) with 23 (mod 9) .
Solution:
█
4
Doing Modular Arithmetic For Larger Numbers With A Calculator
To do modular arithmetic with a calculator, we use the fact from the division algorithm
that
b qm r ,
and solve for the remainder to obtain
r b qm .
We put this result in division tableau format as follows:
m
q
b
qm
b qm r
Take Floor of Quotient (largest integer
less than calculator value of b m ).
(1)
Remainder
Example 3: Compute 1024 (mod 37)
Solution:
█
5
Example 4: Compute 500234 (mod 10301)
500234
48.6 . The largest integer less than 48.6
10301
is 48. Hence, we assign q = floor(48.6) = 48. If we let b= 500234 and m = 10301 in (2),
then
48
10301 500234 .
Solution: Using a calculator, we obtain
494448
5786
The remainder of the division is r = 5786. Hence, 500234 (mod 10301) 5786 .
█
Example 5: Compute 3071 (mod 107)
3071
28.7 . The largest integer less than
107
28.7 is 29 . Hence, we assign q = floor(-28.7) = -29. If we let b= -3071 and m = 107
in (2), then
Solution: Using a calculator, we obtain
29
3071
107
3103
32
Thus, 3071 (mod 107) 32
█
Generalization of Modular Arithmetic
Fact: The common remainder of two numbers have when they are divided can be used to
define a congruence class. The remainder r will be the smallest positive integer in the
congruence class. Suppose r is the remainder of x divided by m, that is
x r (mod m).
Theorem 1 says that then
x r km , where k is an integer.
6
Example 6: Find all elements of the congruence class x 4 (mod 7) .
Solution:
█
Example 7 Find congruence class 2 modulo 7.
Solution:
█
Note: For x b (mod 7) , the set of distinct congruence classes are 0 , 1 , 2 , 3 , 4 , 5 ,
and 6 . This partitions the integers Z into disjoint subsets.
Fact: Given x b (mod m) , Z can be partitioned into distinct congruence classes of the
form
_____
0
,
1
,
2
,
3
,
m
1
Definition 3: We define the set of integers modulo m, denoted by Z m , as the set
Z m {0, 1, 2, 3, m 1}
For example, Z 6 {0, 1, 2, 3, 4, 5} and Z 50 {0, 1, 2, 3, 49} . Informally, Z m represents
all for the possible integer remainders in modulo m arithmetic. This set will be important
when we study later concepts.
7
Exercises
1. For the following, used the division algorithm to compute b m . State the quotient q
and remainder r for the division. Use the result to compute b (mod m) .
a. b = 30, m = 7.
b. b = -30, m = 7.
c. b = 100, m = 26.
d. b = -100, m = 26.
e. b = 2047, m = 137.
f. b = 123129, m = 10371.
g. b = -319212, m = 31233.
2. Find the set of elements that make up the following congruence classes.
a. The elements of the congruence class x 3 (mod 7) .
b. The elements of the congruence class x 7 (mod 11) .
c. The elements of the congruence class x 2 (mod 26) .