Section 7.1 Modular Arithmetic
Section 7.1 Modular Arithmetic
Mathematical
Systems
Copyright © Cengage Learning. All rights reserved.
7.1
Section Modular Arithmetic
3
Introduction to Modular Arithmetic
If we want to determine a time in the future or in the past, it
is necessary to consider whether we have passed
12 o’clock. To determine the time 8 hours after 3 o’clock,
we add 3 and 8. Because we did not pass 12 o’clock, the
time is 11 o’clock (Figure 7.1A).
Figure 7.1A
4
Clock Arithmetic
However, to determine the time 8 hours after 9 o’clock, we
must take into consideration that once we have passed
12 o’clock, we begin again with 1. Therefore, 8 hours after
9 o’clock is 5 o’clock, as shown in Figure 7.1B
Figure 7.1B
5
Clock Arithmetic
• Another technique that can be applied to 12-hour-clock
arithmetic:
Example:
6
Clock Arithmetic
We can also perform subtraction on a 12-
hour clock. If the time now is 10 o’clock, then
7 hours ago the time was 3 o’clock, which is
the difference between 10 and 7 which is (10
– 7 = 3). If we use the symbol to denote
subtraction on a 12-hour clock, we can write
Figure 7.2
7
Example 1 – Perform Clock Arithmetic
Evaluate each of the following, where and indicate
addition and subtraction, respectively, on a 12-hour clock.
a. b. b. c. c. d.
Solution:
Calculate using a 12-hour clock.
a.
b.
c.
d.
8
Answers
9
Day-of-the-Week Arithmetic.
A similar example involves day-of-the-week arithmetic. If
we associate each day of the week with a number, as
shown below, then 6 days after Friday is Thursday and 16
days after Monday is Wednesday.
Symbolically, we write
and
Another way to determine the day of the week is to note that when the sum
5+6=11 is divided by 7, the number of days in a week, the remainder is 4,
the number associated with Thursday.
This works because the days of the week repeat every 7 days.
11
Introduction to Modular Arithmetic
Situations such as these that repeat in cycles are
represented mathematically by using modular arithmetic,
or arithmetic modulo n.
12
Example 2 – Determine Whether a Congruence Is True
Solution:
a. Find Because 7 is an integer,
29 8 mod 3 is a true congruence.
13
Answers
14
True Congruence
Monday Tuesday Wednes Thursday Friday Saturday Sunday
day
Note:
15
Example 3 – A Day of the Week
July 4, 2017, was a Tuesday. What day of the week is
July 4, 2022?
Solution:
There are 5 years between the two dates. Each year has
365 days except 2020, which has one extra day because it
is a leap year.
16
Example 3 – Solution cont’d
The day of the week 3288 days after Tuesday, February 12, 2008, will be
the same as the day 5 days later, a Sunday.
18
Arithmetic Operations Modulo n
19
Arithmetic Operations Modulo n
Arithmetic modulo n (where n is a natural number) requires
us to evaluate a modular expression after using the
standard rules of arithmetic.
20
Example 4 – Addition Modulo n
Evaluate: (23 + 38) mod 12
Solution:
Add 23 + 38 to produce 61. To evaluate 61 mod 12, divide
61 by the modulus, 12. The answer is the remainder.
22
Example 5 – Subtraction Modulo n
Evaluate each of the following.
a. (33 – 16) mod 6
b. (14 – 27) mod 5
Solution:
a. Subtract The result is positive. Divide the
difference by the modulus, 6. The answer is the
remainder.
Note: 24
Answer
25
Arithmetic Operations Modulo n
The methods of adding and subtracting in
modular arithmetic can be used for clock
arithmetic and days-of-the-week arithmetic.
26
Example 6 – Calculating Times
Disregarding A.M. or P.M., if it is 5 o’clock now, what time
was it 57 hours ago?
Solution:
The time can be determined by calculating
(5 – 57) mod 12. Because 5 – 57 = –52 is a negative
number, find a whole number x less than the modulus 12,
so that –52 x mod 12.
27
Example 6 – Solution cont’d
Answer
Let Tuesday correspond to 2 (see table above). So the day of
the week 93 days from now is represented by (2 + 93) mod 7.
Because ,
Thus
=
which corresponds to Thursday.
29
Arithmetic Operations Modulo n
Problems involving multiplication can also be performed
modulo n.
30
Example 7 – Multiplication Modulo n
Evaluate: (15 23) mod 11
Solution:
Find the product 15 23 and then divide by the modulus,11.
The answer is the remainder.
32
Solving Congruence Equations
33
Solving Congruence Equations p.297
Solving a congruence equation means finding all whole
number values of the variable for which the congruence is
true.
For example, to solve 3x + 5 3 mod 4, we search for
whole number values of x for which the congruence is true.
Solution:
Beginning with 0, substitute each whole number less than the modulo (4)
Note: 34
In general, once a solution is determined, the additional
solutions can be found by repeatedly adding the modulus
(mod 4) to the original solution.
Note: 35
A congruence equation can have more than one solution among
the whole numbers less than the modulus. The next example
Example
illustrates 8 –must
that you Solve a all
check Congruence
whole numbers Equation
less than the
modulus.
Solve: 2x + 1 3 mod 10
Solution:
Beginning with 0, substitute each whole number less than
10 into the congruence equation.
36
Example 8 – Solution cont’d
The solutions from 0 to 11 are 1, 4, 7, and 10. The remaining solutions are
obtained by repeatedly adding the modulus 12 to these solutions. So the
solutions are 1, 4, 7, 10, 13, 16, 19, 22, ... . 38
Additive and Multiplicative Inverses
in Modular Arithmetic
39
Additive and Multiplicative Inverses in Modular Arithmetic
Solution:
In mod 16 arithmetic, 7 + ?__ = 16
7+9 = 16
42
Additive and Multiplicative Inverses in Modular Arithmetic
Note:
43
Example 10 – Find a Multiplicative Inverse
To find the multiplicative inverse, solve the modular equation
ax 1 mod m
44
Example 10 – Solution cont’d
45
Answer
• Solve the congruence equation
5x 1 mod 11 by substituting
whole number values of x less
than the modulus.