MATH 13150: Freshman Seminar Unit 11 1. Modular arithmetic In

advertisement
MATH 13150: Freshman Seminar
Unit 11
1. Modular arithmetic
In this chapter, we discuss a new number system, where the only numbers are 0, 1, 2, 3
and 4. The idea is to add and multiply them the way we would on a clock with only 5
hours, instead of 12. This will produce unexpected equalities. In the last few sections
of the chapter, we discuss variants where we use another number in place of 5.
1.1. 4+2 = 1, or how to convince your parents that your math prof is crazy.
We want to introduce a new number system where the only numbers are
0
1
2
3
4
We call these numbers the mod 5 numbers. This number system will be based on
ordinary addition and multiplication. However, it has to be different!! The reason
for this is because we cannot now write 1 + 4 = 5, because 5 is not a number in our
number system. You should not take this to mean that 1 + 4 is not equal to 5, but
rather that the statement 1 + 4 = 5 does not make sense because 5 is not a number
in our number system.
ADDITION RULE: To add two mod 5 numbers a and b, we add them together as
ordinary numbers. If the result is less than 5, we just use the ordinary addition. If
the result is more than 5, we divide 5 into the result, and take the remainder. That
remainder is a + b (mod 5), the sum of a and b in mod 5 arithmetic.
For example, to add together 1 and 3 mod 5, we add together 1 + 3 = 4. Since 4 is
less than 5, the sum of 1 and 3 in mod 5 arithmetic is 4. We express this by writing:
1 + 3 ≡ 4 (mod 5).
Note that instead of using “=” to denote equality as in usual arithmetic, we use “≡”
to denote equality in mod 5 arithmetic. The symbol ≡ helps us remember that we
are working in mod 5 arithmetic.
Things get more interesting when we add 3 and 4 mod 5. Certainly 3 + 4 = 7, but
since 7 is at least as big as 5, we should divide 5 into 7 and take the remainder, which
is 2. Then according to the rule:
3 + 4 ≡ 2 (mod 5),
so if we add 3 and 4 together, we get 2 in mod 5 arithmetic.
Similarly,
1 + 4 ≡ 0 (mod 5), 2 + 4 ≡ 1 (mod 5), 4 + 4 ≡ 3 (mod 5).
To restate, if usual a + b is 4 or less, than a + b (mod 5) is the usual addition, but if
the usual a + b is 5 or more, we subtract 5 so that we get an actual mod 5 number.
This is exactly like what you do when you determine what time it is when it is six
hours after 8 pm. You would add 6 to 8 to get 14, and then since there are only 14
1
2
hours on the clock, you would subtract 12 to get the correct time 2 o’clock. This is
why we can think of modular arithmetic as clock arithmetic.
We can make an addition table that records the result of adding any two numbers:
MOD 5 ADDITION TABLE
+ 0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
For example, in the 3-row and 4-column, we find 2, and this means that 3 + 4 ≡ 2
(mod 5), which we verified above.
Of course, we would like to make sure that usual properties of addition work. For
example, is
4 + 3 ≡ 3 + 4 (mod 5)?
A quick glance at the table verifies that this is true. In fact,
FACT: For any two mod 5 numbers a and b, a + b ≡ b + a (mod 5).
You can verify that this fact is true by trying out all cases using the table. The
truth of this fact is the same as the observation that the table is symmetric about
the diagonal line with entries 0, 2, 4, 1, 3. A better way of thinking about it is just to
observe that 4 + 3 = 7 = 3 + 4 in usual arithmetic, and so they are still equal when we
take the remainder after dividing by 5. This argument explains the fact in general.
A similar argument shows that
FACT: For any three mod 5 numbers a, b and c, (a + b) + c ≡ a + (b + c) (mod 5).
For example, we can verify that
(3 + 4) + 1 ≡ 3 + (4 + 1)
(mod 5).
Indeed, from the table 3 + 4 ≡ 2 (mod 5), so (3 + 4) + 1 ≡ 2 + 1 ≡ 3 (mod 5). On the
other hand, from the table, 4 + 1 ≡ 0 (mod 5), so 3 + (4 + 1) ≡ 3 + 0 ≡ 3 (mod 5).
These two facts are useful, because they mean that the common facts we use in
addition are true in modular arithmetic. In essence, everything we are familiar with
for usual addition works for modular arithmetic as long as it makes sense. In other
words, unless we add two numbers and get a number that is 5 or larger, everything
works like before. If we do get a number that is 5 or larger, we just subtract 5, and
proceed.
1.2. Subtraction and negative numbers. In this section, we want to learn to
evaluate expressions like:
4 − 1 (mod 5) and 2 − 3 (mod 5)
For subtraction it is useful to use negative numbers, just as in ordinary arithmetic,
where a − b = a + −b.
3
Let’s think about what negative numbers mean in ordinary arithmetic. When we call
a number −7 in ordinary arithmetic, we mean that if we add −7 to 7, we get 0. To
explain this using a formula, we can say −7 is the number with the property that
−7 + 7 = 0.
Unfortunately, we cannot simply write −2 (mod 5) without explanation, because the
only mod 5 numbers are 0, 1, 2, 3, 4, and we do not see −2 on this list. However, we
can use the idea from ordinary arithmetic which says that −2 is the number with the
property that:
−2 + 2 ≡ 0 (mod 5).
We can now easily compute −2 using the table. We look in the 2-column and find
the entry 0 in the 3-row. This means that
3 + 2 ≡ 0 (mod 5), or that −2 ≡ 3 (mod 5).
Similarly,
4 + 1 ≡ 0 (mod 5), so −1 ≡ 4 (mod 5)
3 + 2 ≡ 0 (mod 5), so −2 ≡ 3 (mod 5)
2 + 3 ≡ 0 (mod 5), so −3 ≡ 2 (mod 5)
1 + 4 ≡ 0 (mod 5), so −4 ≡ 1 (mod 5)
0 + 0 ≡ 0 (mod 5), so −0 ≡ 0 (mod 5).
There is a pattern here. If k is a mod 5 number, then
−k ≡ 5 − k (mod 5), except when k = 0. In case k = 0, then −0 ≡ 0 (mod 5).
For example, −3 ≡ 5 − 3 ≡ 2 (mod 5).
We can now define a − b (mod 5) by the rule that
a − b ≡ a + −b (mod 5).
For example,
2 − 3 ≡ 2 + −3 ≡ 2 + 2 ≡ 4
(mod 5).
Similarly,
3 − 1 ≡ 3 + −1 ≡ 3 + 4 ≡ 2 (mod 5).
A key property that subtraction has is that:
KEY PROPERTY FOR SUBTRACTION: (a − b) + b ≡ a (mod 5).
In other words, a − b is the mod 5 number we need to add to b in order to get a. To
check that this is the case, compute as follows:
(a − b) + b ≡ (a + −b) + b ≡ a + −b + b ≡ a + 0 ≡ a (mod 5)
.
This is the property used to define substraction in ordinary arithmetic.
There is something inefficient about the method of subtraction presented here. For
example, in an example above, we had to work a little to check that 3 − 1 ≡ 2
(mod 5), which is something that should be obvious and require no work. We’ll give
a more efficient way to subtract in the next chapter.
4
1.3. Multiplication and powers. The real fun in modular arithmetic will come
from multiplication. We will multiply using the same idea as from addition, that is,
MULTIPLICATION RULE FOR MODULAR ARITHMETHIC: To multiply two
mod 5 numbers a and b, compute the remainder of when we divide a · b by 5. The
result is written as a · b (mod 5).
For example, 4 · 4 = 16 in usual arithmetic, and 16 has remainder 1 when divided by
5. From this, we get
4 · 4 ≡ 1 (mod 5)
Similarly, 3 · 3 ≡ 4 (mod 5), since 3 · 3 = 9 in usual arithmetic, and 5 divides 9 once
with remainder 4.
We can build a multiplication table for mod 5 arithmetic:
MOD 5 MULTIPLICATION TABLE
× 0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
For example, since there is a 1 in the 2-row and 3-column, 2 · 3 ≡ 1 (mod 5).
Note that there are some common features with usual arithmetic:
1. a · b ≡ b · a (mod 5) so changing the order in multiplication doesn’t change the
answer
2. a · 0 ≡ 0 (mod 5), so any mod 5 number multiplied by 0 is 0
3. a · 1 ≡ a (mod 5), so any mod 5 number multiplied by 1 is itself.
These properties are easy to see from the table. The first property is the same as the
fact that the table does not change when we reflect through the diagonal line with
0, 1, 4, 4, 1. The second property is the same as the fact that the zero row contains
all zeroes. The third property is the same as the fact that the entries in the one row
are just the number of the corresponding column.
In addition, there are some additional properties, which are valid whenever a, b and
c are mod 5 numbers.
4. (a · b) · c ≡ a · (b · c) (mod 5)
5. a · (b + c) ≡ a · b + a · c (mod 5)
PROBLEM 1: Verify properties 4. and 5. when a = 2, b = 3, and c = 4 in mod 5
arithmetic.
SOLUTION: Start with property 4. We compute:
(2 · 3) · 4 ≡ 1 · 4 (mod 5) since 2 · 3 ≡ 1 (mod 5). But 1 · 4 ≡ 4 (mod 5), so (2 · 3) · 4 ≡ 4
(mod 5). On the other hand, 2 · (3 · 4) ≡ 2 · 2 (mod 5) since 3 · 4 ≡ 2 (mod 5). But
2·2 ≡ 4 (mod 5), so 2·(3·4) ≡ 4 (mod 5). We have verified property 4. by computing
each side and getting the same answer.
5
Now let’s verify property 5. We compute:
2 · (3 + 4) ≡ 2 · 2 ≡ 4 (mod 5), where at the first step, we used 3 + 4 ≡ 2 (mod 5), and
at the second step, we used 2·2 ≡ 4 (mod 5). On the other hand, 2·3+2·4 ≡ 1+3 ≡ 4
(mod 5). In the first step, we used 2 · 3 ≡ 1 (mod 5), and in the second step, we used
2 · 4 ≡ 3 (mod 5).
These properties 1, 2, 3, 4, and 5 are very useful, because they mean that manipulations you are used to using from ordinary multiplication still work in modular
arithmetic.
We can also compute powers in modular arithmetic. If n is a usual number and a is
mod 5 number, then
an ≡ a · a · a · · · a (mod 5), where the dots indicate that we take the product of n
factors of a.
For example, 23 ≡ 2 · 2 · 2 ≡ 8 ≡ 3 (mod 5). Meanwhile, 35 ≡ 243 ≡ 3 (mod 5). Just
in case you don’t know that 35 = 243 in usual arithmetic, let’s see a calculator-free
way to compute 35 (mod 5).
35 ≡ 32 · 32 · 3 ≡ (4 · 4) · 3 ≡ 1 · 3 ≡ 3 (mod 5). We used the facts that 32 ≡ 3 · 3 ≡ 4
(mod 5) and 42 ≡ 4 · 4 ≡ 1 (mod 5).
In other words, you can simplify computations in modular arithmetic by grouping
them in the right way. We’ll come back to this later (a lot!!!).
1.4. What about mod 2, or mod 3, or mod 30? In the earlier sections of this
chapter, we did mod 5 arithmetic. What is special about 5? Why can’t we do
arithmetic mod 2, mod 3, mod 6, or mod 323.
The answer is that we can. We’ve just been using mod 5 arithmetic as an example
to investigate. This hopefully gave you some familiarity with the idea.
RULES FOR ARITHMETIC mod n
1. The numbers in mod n arithmetic are 0, 1, 2, 3, . . . , n − 1
2. If a and b are two mod n numbers, we compute the remainder c when we divide
a + b by n, and say a + b ≡ c (mod n).
3. If b is a mod n number, then −b ≡ n − b (mod n) unless b ≡ 0 (mod n), and
−0 ≡ 0 (mod n).
4. If a and b are mod n numbers, then a − b ≡ a + −b (mod n). The mod n number
a − b has the property that a − b + b ≡ a (mod n).
5. If a and b are two mod n numbers, we compute the remainder d when we divide
a · b by n, and say a · b ≡ d (mod n).
For example, if we want to arithmetic mod 6, then the mod 6 numbers are 0, 1, 2, 3, 4, 5.
We can make mod 6 addition and multiplication tables:
6
+
0
1
MOD 6 ADDITION TABLE 2
3
4
5
0
0
1
2
3
4
5
1
1
2
3
4
5
0
2
2
3
4
5
0
1
×
0
1
MOD 6 MULTIPLICATION TABLE 2
3
4
5
3
3
4
5
0
1
2
0
0
0
0
0
0
0
4
4
5
0
1
2
3
1
0
1
2
3
4
5
5
5
0
1
2
3
4
2
0
2
4
0
2
4
3
0
3
0
3
0
3
4
0
4
2
0
4
2
5
0
5
4
3
2
1
For example, 3 + 5 ≡ 2 (mod 6), since 3 + 5 = 8 in usual arithmetic, and 6 divides 8
once with remainder 2. This result can be read off from the addition table since the
entry in the 3-row and 5-column is 2. Similarly, 3 · 5 ≡ 3 (mod 6), since 3 · 5 = 15 in
usual arithmetic, and 6 divides 15 twice with remainder 3. This result can be read
off from the multiplication table since the entry in the 3-row and 5-column is 3.
Note that 3 · 2 ≡ 0 (mod 6), so a product of two nonzero mod 6 numbers can be 0.
This didn’t happen mod 5.
The following rules are always true for addition and multiplication. These rules are
familiar and you have used them all the time in ordinary arithmetic. You can use
them for modular arithmetic also.
ADDITION RULES:
1. a + b ≡ b + a (mod n), for any mod n numbers a and b.
2. (a + b) + c ≡ a + (b + c) (mod n) for any mod n numbers a, b and c.
3. a + 0 ≡ a (mod n) for any mod n number a.
MULTIPLICATION RULES:
1. a · b ≡ b · a (mod n) for any mod n numbers a and b
2. a · 0 ≡ 0 (mod n) for any mod n number a.
3. a · 1 ≡ a (mod n) for any mod n number a
4. (a · b) · c ≡ a · (b · c) (mod n) for any mod n numbers a, b and c
5. a · (b + c) ≡ a · b + a · c (mod n) for any mod n numbers a, b, and c.
We’ll explain why they are true in the next section. The important thing is that you
remember that these facts work just the same in modular arithmetic as in ordinary
arithmetic.
Let’s look at a few additional examples.
ARITHMETIC mod 2
The mod 2 numbers are 0 and 1. The addition and multiplication tables are:
7
+ 0 1
MOD 2 ADDITION TABLE 0 0 1
1 1 0
× 0 1
MOD 2 MULTIPLICATION TABLE 0 0 0
1 0 1
For example, 1 + 1 ≡ 0 (mod 2), since 2 divides 2 with remainder 0.
ARITHMETIC mod 3
The mod 3 numbers are 0, 1, and 2. The addition and multiplication tables are:
+
0
MOD 3 ADDITION TABLE
1
2
0
0
1
2
1
1
2
0
2
2
0
1
×
0
MOD 3 MULTIPLICATION TABLE
1
2
0
0
0
0
1
0
1
2
2
0
2
1
If you are asked to do a computation mod n, you compute the same way we did in
the examples of mod 5 and mod 6 arithmetic.
PROBLEM: Do the following modular arithmetic calculations.
1. 14 + 20 (mod 27)
2. 12 · 7 (mod 33)
3. 21 − 25 (mod 31)
4. 25 − 22 (mod 31)
5. 7 · 10 (mod 35).
SOLUTION: For the first calculation, note that 14+20 = 34 in usual arithmetic. Since
27 divides 34 with remainder 7, 14 + 20 ≡ 7 (mod 27). For the second calculation,
note that 12 · 7 = 84 in usual arithmetic. Since 33 divides 84 twice with remainder
18, 12 · 7 ≡ 18 (mod 33). For the third calculation, since −25 ≡ 6 (mod 31), 21 −
25 ≡ 21 + 6 ≡ 27 (mod 31). For the fourth calculation, −22 ≡ 9 (mod 31), so
25 − 22 ≡ 25 + 9 ≡ 3 (mod 31). For the last calculation, 7 · 10 = 70 in usual
arithmetic, and since 35 divides 70 with remainder 0, 7 · 10 ≡ 0 (mod 35).
1.5. Mathematical explorations, or we just took a trip to the moon. Let’s
stop for a moment and think about what we’ve just done. We’ve created a new
number system called mod n arithmetic for each number n. We’ve explained how
to add and multiply in mod n arithmetic. Then we’ve done some computations in
mod n arithmetic, and seen for example, that 14 + 20 ≡ 7 (mod 27). While mod
n arithmetic may seem strange, these computations, and the computations you will
have the unbridled joy of doing in the homework, will make you familiar with mod n
arithmetic.
8
You can think of this as analogous to taking a trip to a new city. When you arrive
in a new city, life is a little difficult at first. You don’t know where anything is, and
you’re always getting lost. However, when you look around for awhile and investigate
things for awhile, you get a better idea of how to find things. In other words, you
have begun to be familiar with the city, or to understand the city.
This is analogous to what scientists do when they are studying a problem. Imagine
that you are a chemist and you want to know what happens when you mix two
chemicals, like cesium chloride and water. Cesium chloride is a powder you can find
in most high school chemistry labs. If you drop a little cesium chloride in a testtube
filled with water, you’ll see a mild explosion. If you drop a lot of cesium chloride in a
testtube filled with water, you may blow up the lab. A chemist interprets this result
by saying that cesium reacts strongly with water. This tells the chemist something
about the atomic structure of cesium, and enables chemists to group cesium with other
atoms with similar properties. When the chemist mixes two chemicals together, this
is analogous to what you do when you walk around in a new place. The chemist is
gathering information about the chemicals, and you are gathering information about
the new place.
This is even harder for astronomers, who may be interested in the moon, or a planet
like Jupiter. In principle, an astronomer can travel to the moon and look around
(while wearing a space suit) and gather rocks and analyze them. In practice, going to
the moon is a long ordeal, so an astronaut or a robot goes and collects materials and
brings them back for the astronomer to study. This is analogous to the astronomer
taking a walk around the moon to get some idea of how things work, which is like
when you walk around a city and find out where things are located. If the astronomer
wants to study Jupiter, things are even harder. If an astronaut went to Jupiter, it
would take years to get there, and the astronaut would not find anything to stand
on, because Jupiter is composed of highly pressurized gas, and in any event, the
astronomer would have been crushed by then because of the high pressure in Jupiter’s
atmosphere. So instead, astronomers study Jupiter by taking pictures and analyzing
orbits of its moons, and studying properties of light that comes from Jupiter. While
this is indirect, the astronomer is still learning things about Jupiter by taking a look
at it, which is again analogous to walking around a new city to get the lay of the
land.
Life is considerably easier for mathematicians, in the sense that we don’t have to put
up with funny laboratory smells or risk blowing ourselves up, nor do we have to build
expensive precision machinery to measure something happending on Jupiter. The
math version of a new world is a new number system. Our version of exploration is
to investigate the new number system and try to understand how it works.
If you approach modular arithmetic with some spirit of investigation, you’ll have a
better sense of what is happening.
EXERCISES:
(1) Do the following modular arithmetic calculations:
(a) 35 + 17 (mod 50)
9
(2)
(3)
(4)
(5)
(6)
(7)
(b) 11 · 13 (mod 36)
(c) 11 − 13 (mod 36)
(d) 13 − 10 (mod 36)
(e) 12 · 10 (mod 50)
(f) 39 + 11 (mod 50)
(g) 10 · 10 (mod 11)
(h) 12 · 10 (mod 30)
(i) 13 · 5 (mod 60)
(j) 54 (mod 11)
Make an addition and multiplication table for mod 7 arithmetic.
Make an addition and multiplication table for mod 8 arithmetic.
In this Unit and in the last few problems, you’ve seen the multiplication tables
for mod n arithmetic when n = 2, 3, 5, 6, 7, 8. Look at the mod 5 table. Of
course, in the zero row and zero column all entries are 0. In every other row
and column, every mod n number occurs exactly once. For which values of n
from 2, 3, 5, 6, 7, 8 does every row and column besides the zero row and column
contain every mod n number exactly once?
For which of these values of n is it the case that 0 only occurs in the zero row
or the zero column? For which of these values of n is the case that no number
occurs more than once in any particular row or column? Make a guess about
which numbers n have these two properties (i.e., only zeroes in multiplication
table are in row 0 or column 0, and no number occurs more than once in any
row or column).
(a) Is there a mod 7 number x so that 3 · x ≡ 5 (mod 7)? What is it?
(b) Is there a mod 7 number x so that 2 · x ≡ 6 (mod 7)? How is it related
6
to the fraction ?
2
(c) Is there a mod 8 number x so that 3 · x ≡ 1 (mod 8)?
(d) Is there a mod 8 number x so that 6 · x ≡ 3 (mod 8)?
(e) How many mod 8 numbers x are there so that 6 · x ≡ 2 (mod 8)?
(a) Compute 30 + 40 (mod 60).
(b) Suppose you look at your watch and it is 6:30. 40 minutes later, you look
at your watch again. How many minutes after 7:00 is it?
(c) Compare your answers from Parts (a) and (b).
(a) Compute 7 · 35 (mod 60).
(b) Suppose at 5 minutes after the start of each hour, a security guard drives
by a particular ATM (so the security guard comes by at 1:05, 2:05, 3:05,
4:05, etc). Suppose also an anally retentive thief robs a customer at the
ATM at 12:35, and robs another customer every 35 minutes after that, so
at 12:35, 1:10, 1:45, etc. When does the security guard drive by exactly
when the thief is robbing a customer? How many customers has the thief
robbed by then?
(c) How are Part (a) and Part (b) related?
10
(8) Find two mod 10 numbers x so that 2 · x ≡ 2 (mod 10) (hint: x = 1 is one of
the numbers).
(9) Compute 21 · 17 + 7 · 17 (mod 27) (hint: you can do this in a second without
a calculator by rewriting the expression using the distribute law).
(10) (a) Compute 26 (mod 7).
(b) Compute 260 (mod 7) (hint: 260 ≡ (26 )10 (mod 7) using the laws of exponents, and this should make the calculation easier).
(c) Compute 262 (mod 7) (hint: use laws of exponents so that you can use
your last calculation).
Download