0% found this document useful (0 votes)
37 views

CSCI3310 Lecture 02

This document discusses solving linear congruences. It begins with definitions of linear congruences and multiplicative inverses modulo m. It then provides examples of finding multiplicative inverses and using them to solve linear congruences. Theorems are presented about the existence and uniqueness of inverses when gcd(a,m)=1. Further examples demonstrate solving linear congruences through multiplying both sides by the inverse or directly solving for x.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

CSCI3310 Lecture 02

This document discusses solving linear congruences. It begins with definitions of linear congruences and multiplicative inverses modulo m. It then provides examples of finding multiplicative inverses and using them to solve linear congruences. Theorems are presented about the existence and uniqueness of inverses when gcd(a,m)=1. Further examples demonstrate solving linear congruences through multiplying both sides by the inverse or directly solving for x.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

CSCI 3310: Mathematical Computation

Solving Congruences

Bishr Mamoun Iquelan

Associate Professor
Department of Mathematics,
Islamic University of Gaza

2022-2023, Semester
1
Linear Congruences

Definition:
A congruence of the form:

ax ≡ b(mod m),

where m is a positive integer, a and b are integers, and x is


a variable, is called a linear congruence.
The solutions to a linear congruence ax ≡ b(mod m) are all
integers x that satisfy the congruence. In general, the solutions
are expressed as
x ≡ c(mod m)
for some fixed integers c and m, which means all integers of the
form c + km(k ∈ Z ) satisfy ax ≡ b(mod m).

Note:
Notice that we can translate the congruence a ≡ b mod m into
the equations a − b = mk or a = b + mk for some k ∈ Z .

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 1 / 22


inverse of a modulo m
► Every real number x, except x = 0, has a multiplicative
inverse
y = x1 , so xy = 1.
► Similarly for x mod m, except x = 0, we wish to find y mod m such
that xy ≡ 1 mod m

Definition:
An integer a¯ such that
a¯a ≡ 1 mod m
is said to be an inverse of a modulo m.
Multiplicative inverses can be used to solve congruences.
If ax ≡ b mod m then a¯ax ≡ (a¯b) mod m and thus x ≡ (a¯b)
mod m.
Example 1:
► x = 3 and m = 7. Then x.5 = 15 ≡ 1 mod 7, so 5 is a
multiplicative inverse of 3 mod 7.
► x = 8 and m = 15. Then x.2 = 16 ≡ 1 mod 15, so 2 is
a multiplicative inverse of 8 mod 15.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 2 / 22


Finding inverses

Example 2:
Let m = 15. Find an inverse of 8 modulo 15.
Solution: In order to find an inverse of 8 modulo 15, we
check 8.k for k = 1, 2, 3, . . . , 14 (i.e., the positive
integers smaller than 15), and find that
1.8 = 8 /≡ 1(mod 15), ?? 15 ‡ (8 − 1)
2.8 = 16 ≡ 1(mod 15), ?? 15 | (16 − 1)
3.8 = 24 /≡ 1(mod 15), ?? 15 ‡ (24 − 1)
4.8 = 32 /≡ 1(mod 15), ?? 15 ‡ (32 − 1)
(k ≤ 14).8 = k.8 /≡ 1(mod
15), so 2 is an inverse of 8 modulo 15.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 3 / 22


Finding inverses

Example 3:
Let m = 15. Find an inverse of 7 modulo 15.
Solution: In order to find an inverse of 7 modulo 15, we
check 8.k for k = 1, 2, 3, . . . , 14 (i.e., the positive
integers
smaller than 15),
Now check for:
≤ 3
1
between 4 and 8
2
3 between 9 and 11
4between 12 and 14
What is your answer !!!!

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 4 / 22


Finding inverses
Example 4:
Let m = 15. Find an inverse of 5 modulo 15.
Solution: In order to find an inverse of 7 modulo 15, we check 5.k for k
= 1, 2, 3, . . . , 14 (i.e., the positive integers smaller than 15). Now check
for:
► 1.5 = 5 ≡ 5(mod 15)
► 2.5 = 10 ≡ 10(mod 15)
► 3.5 = 15 ≡ 0(mod 15)
► 4.5 = 20 ≡ 5(mod 15)
► 5.5 = 25 ≡ 10(mod 15)
► 6.5 = 30 ≡ 0(mod 15)
► ... ...
Where is the inverse???
➣ 5 does not have any inverse modulo 15.
➣ The sequence {5k mod m | k = 1, 2, 3, . . . } is periodic, and
takes on the values { 5, 10, 0.} So, 5 has no multiplicative inverse
mod15
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 5 / 22
Inverse of a modulo m

Theorem 1:
If a and m are relatively prime integers and m > 1, then an
inverse of a modulo m exists. Furthermore, this inverse is
unique modulo m.
In other words, there is a unique positive integer a¯ less
than m that is an inverse of a modulo m and every other
inverse of a modulo m is congruent to a¯ modulo m.

Proof: Since gcd(a, m) = 1, by B´ezout’s Theorem there are inte-


gers s and t such that sa + tm = 1. Therefore, sa ≡ 1(mod m),
and s is an inverse of a modulo m.
For the uniqueness of s, suppose that there is another integer s ′
satisfying s ′ a ≡ 1(mod m), then
sa − s ′ a ≡ 0(mod m),
and consequently m | a(s − s ′ ). Since gcd(a, m) = 1, it follows
that
m | (s − s′ ), i.e., s ≡ s′(mod
Dr. Bishr M. Iquelan (IUGaza)
m), as desired.
4.4-Solving st 6 / 22
1 Semester, 2022-2023
Finding inverses
The Euclidean algorithm and B´ezout coefficients gives us a system-
atic approaches to finding inverses of a modulo m when a and m are
relatively prime.

Example 5:
Find an inverse of 3 modulo 7.
Solution: Because gcd(3, 7) = 1, by Theorem 1, an
inverse of 3 modulo 7 exists.
► Using the Euclidian algorithm: 7 = 2.3 + 1.
► From this equation, we get − 2.3 + 1.7 = 1, and
see that −2 and 1 are B´ezout coefficients of 3 and
7. Therefore, −2.3 ≡ 1(mod 7).
► Hence, −2 is an inverse of 3 modulo 7.
► Also every integer congruent to −2 modulo 7 is an
inverse of 3 modulo 7, i.e., 5 , -9, 12, etc.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 7 / 22


Finding inverses

Example 6:
Find an inverse of 101 modulo 4620.
Solution: First use the Euclidian algorithm to show that gcd(101, 4620) =
1.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 8 / 22


Examples of solving linear congruences

Example 7:
Solve the linear congruence 3x ≡ 4 mod 7, and find the smallest positive
integer that is a solution of this congruence.
Solution: In Example 4, We found that 5 is an inverse of 3 modulo 7,
i.e,

5.3 ≡ 1 mod 7.

Now we multiply both sides of 3x ≡ 4 mod 7 by 5, and obtain

15x ≡ 20 mod 7.

It follows that the solutions are the integers satisfying

x = 15x ≡ 20 ≡ 6 mod 7.

The smallest integer that solves the congruence is 6. Which means that
the solutions are the integers x such that x ≡ 6 mod 7. That is, all
integers of the form 6 + 7k (k ∈ Z ) will satisfy the congruence 3x ≡ 4
mod 7.
Dr. Bishr M. IquelanThe solutions,
(IUGaza) namely, are {. . . , −15, −8,
4.4-Solving −1, 6, 13,
1st Semester, 2022-2023 9 / 22
Examples of solving linear congruences

Example 8:
Find x such that 3x ≡ 7 mod 10.
Solution: You can easily show that 7 is an inverse of 3 modulo 10, i.e,

7.3 ≡ 1 mod 10.

Now we multiply both sides of 3x ≡ 7 mod 10 by 7, and obtain

21x ≡ 49 ≡ 9 mod 10.

It follows that the solutions are the integers satisfying

x = 21x ≡ 49 ≡ 9 mod 10.

The smallest integer that solves the congruence is 9. Which means that
the solutions are the integers x such that x ≡ 9 mod 10. That is, all
integers of the form 9 + 10k (k ∈ Z ) will satisfy the congruence 3x
≡ 7 mod 10.
The solutions, namely, are {. . . , −11, −1, 9, 19,
29, . . . }.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 10 / 22
Examples of solving linear congruences

Example 9:
Find x such that 3x ≡ 6 mod 12.
Solution: Oops. This time we don’t have a multiplicative inverse to
work with. So what to do?
Well, let’s take a look at what this would mean. If 3x ≡ 6 mod 12,
that means 3x − 6 is divisible by 12, so there is some k ∈ Z such that
3x − 6 = 12k. Now that we’re working in the integers, we can
happily divide by 3, and we thus obtain that x − 2 = 4k. Hence, we
have that x ≡ 2 mod 4 solves the desired congruence.
The solutions, namely, are {. . . , −5, −2, 2, 6, 10,
14, . . . }.
In general, we have that ax − b = ny for some y ∈ Z, and hence ax − ny =
b. This implies that we can find a solution to this congruence if and only if
gcd(a, n) | b.
Proposition 1
Let n ∈ Z, and let a, b ∈ Z. The congruence ax ≡ b mod n has a
solution for x if and only if gcd(a, n) | b.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 11 /
Examples of solving linear congruences
Example 10:
Solve the linear congruence 19x ≡ 4 mod
141.
Solution:
First we find an inverse of 19 Consequently,
modulo 141
141 = 19.7 + 8 1=3−2
19 = 8.2 + 3 = 3 − (8 − 3.2) = 3.3 − 8
8 = 3.2 + 2 = 3.(19 − 8.2) − 8 = 3.19 − 7.8
3 = 2.1 + 1 = 3.19 − 7.(141 − 19.7) = −7.141 +
it follows that gcd(19, 141) 52.19
= gcd(19, 8) = gcd(8, 3) = Thus 52.19 ≡ 1 mod 141, and thus 52 is
gcd(3, 2) = gcd(2, 1) = an
inverse of 19 modulo 141.
1.► Now we multiply both sides of 19x ≡ 4 mod 141 by 52, and obtain
52.19x ≡ 52.4 = 208 mod 141
It follows that the solutions are the integers x satisfying
x = 52.19x ≡ 208 ≡ 67 mod 141.
That is, all integers of the form 67 + 141k (k ∈ Z ) will satisfy the
congruence 19x ≡ 4 mod 141.
The solutions, namely, are {. . . , −282, −215, −74, 67, 208,
349, . . . }.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 12 / 22
The Chinese Remainder Theorem

■ In the first century, the Chinese mathematician Sun-Tsu


asked:
There are certain things whose number is unknown.
When divided by 3, the remainder is 2; when divided by
5, the remainder is 3; and when divided by 7, the
remainder is 2. What will be the number of things?
■ This puzzle can be translated into the following question:
What are the solutions of the systems of congruences
x ≡ 2 mod 3,
x ≡ 3 mod 5,
x ≡ 2 mod 7 ?

■ We’ll see how the theorem that is known as the Chinese


Remainder Theorem can be used to solve Sun-Tsu’s
problem.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 13 / 22
The Chinese Remainder Theorem
Example 11:
Consider the 3 congruences from Sun-Tsu’s problem:
x ≡ 2 mod 3, x ≡ 3 mod 5, x ≡ 2 mod
Solution:
7.
► Set m = 3 × 5 × 7 = 105. Following the notation of (Theorem 2 page
294), we have M 1 = m/3 = 35, M 2 = m/5 = 21, and M 3 = m/7 = 15.
► We now seek a multiplicative inverse for each M k modulo mk .
➣ First: y1 = 2 is an inverse of M 1 = 35 modulo m1 = 3 since 35 ×
2 ≡ 2 × 2 ≡ 1 mod 3.
➣ Second: y2 = 1 is an inverse of M 2 = 21 modulo m2 = 5 since 21 × 1
≡ 1 mod 5.
➣ Third: y3 = 1 is an inverse of M 3 = 15 modulo m3 = 7 since 15 ×
1 ≡ 1 mod 7.
► Therefore, the theorem states that a solution takes the form:
x = a1 M 1y1 + a2 M 2 y2 + a3 M 3 y3
= 2 × 35 × 2 + 3 × 21 × 1 + 2 × 15 × 1 = 233 ≡ 23 mod
105.
► We have shown that 234.4-Solving
Dr. Bishr M. Iquelan (IUGaza)
is the smallest positive integer
st
that is a 14 / 22
1 Semester, 2022-2023
Examples of solving linear congruences
Example 12:
Use the Chinese Remainder Theorem to find an x such that:
x ≡ 2 mod 5, x ≡ 3 mod 7, x ≡ 10 mod
Solution:
11.
► Set m = 5 × 7 × 11 = 385. Following the notation of (Theorem 2 page
294), we have M 1 = m/5 = 77, M 2 = m/7 = 55, and M 3 = m/11 = 35.
► We now seek a multiplicative inverse for each M k modulo mk .
➣ First: y1 = 3 is an inverse of M 1 = 77 modulo m1 = 5 since 77 ×
3 ≡ 2 × 3 ≡ 1 mod 5.
➣ Second: y2 = 6 is an inverse of M 2 = 55 modulo m2 = 7 since 55 × 6
≡ 6 × 6 ≡ 1 mod 7.
➣ Third: y3 = 6 is an inverse of M 3 = 35 modulo m3 = 11 since 35 ×
6 ≡ 26 × 6 ≡ 1 mod 11.
► Therefore, the theorem states that a solution takes the form:
x = a1M 1y1 + a2 M 2 y2 + a3 M 3y3

► We=have
2 × shown
77 × 3that
+ 387× is
55the
× 6smallest
+ 10 ×positive
35 × 6integer
= 3552that
≡ 87 mod
is a
simultaneous solution. Check it! 385.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 15 / 22
Examples of solving linear congruences
Example 13:
Find all solutions x, if they exist, to the system of equivalences:
2x ≡ 6 mod 14, 3x ≡ 9 mod 15, 5x ≡ 20 mod
60.
Solution:As in Example 9, we first wish to reduce this, where possible, using
the strategy outlined following the statement of Proposition 1. Since gcd(2,
14) = 2, we can cancel a 2 from all terms in the first equivalence to write x
≡ 3 mod 7. Likewise, we simplify the other two equivalences to reduce the
entire system to x ≡ 3 mod 7, x ≡ 3 mod 5, x ≡ 4 mod 12.
We can now use the Chinese Remainder Theorem: Set m = 7 × 5 × 12 = 420.
We have M 1 = m/7 = 60, M 2 = m/5 = 84, and M 3 = m/12 = 35. We now seek a
multiplicative inverse for each Mk modulo mk .
60 × 2 ≡ 4 × 2 ≡ 1 mod 7, ⇒ y1 = 2,

84 × 4 ≡ 4 × 4 ≡ 1 mod 5, ⇒ y2 = 4,
35 × 11 ≡ 11 × 11 ≡ 1 mod 12, ⇒ y3 = 11.
Therefore, our solution takes the form:
x = a1 M 1 y1 + a2 M 2 y2 + a3 M 3 y3
= 3 × 60 × 2 + 3 × 84 × 4 + 4 × 35 × 11 = 2908
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 16 /
Examples of solving linear congruences
Example 14 (Example 11 Re-visit Back Substitution):
Solution:If x ≡ 2 mod 3, then x = 3t + 2, where t ∈ Z. Substituting this
expression for x into the second congruence, we get
3t + 2 ≡ 3 mod 5,
and consequently 3t ≡ 1 mod 5. Since 2 is an inverse of 3 modulo 5, we
multiply both sides by 2 and obtain
3.2t ≡ 1.2 mod 5,
and consequently t ≡ 2 mod 5, which means t = 5u + 2, where u ∈ Z,
and thus x = 3(5u + 2) + 2 = 15u + 8.
Substituting this expression for x into the third congruence, we get
15u + 8 ≡ 2 mod 7,
and consequently 15u ≡ −6 ≡ 1 mod 7. Since 1 is an inverse of 15 module
7, it follows immediately that
u ≡ 1 mod 7,
which means u = 7v + 1, where v ∈ Z , and thus
x = 15(7v + 1) + 8 = 105v + 23.
Therefore, those integers x satisfy x ≡ 23 mod 105 are the solutions.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 17 / 22


Fermat’s Little Theorem

Theorem (Fermat’s Little Theorem):

If p is prime and a is an integer not divisible by p (p ‡


a),
then
ap− 1 ≡ 1 mod p.
Furthermore, for every integer a we have

ap ≡ a mod p.

Example 15:
► 217 ≡ 21 mod 7
► But 216 /≡ 1 mod 7. Notice, 7 | 21.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 18 / 22


Fermat’s Little Theorem

Example 16:
Calculate 2345 mod 11.
Solution:
The number 2 is not divisible by the prime 11, so by
Fer- mat’s Little Theorem

210 ≡ 1 mod

11 Using the division algorithm,


3
45 = 34 × 10 +
5.
Since 2345 =
2 34×10+5 = (2 ) × 25, then
10 34

2345 ≡
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 19 / 22
Fermat’s Little Theorem

Example 17:
Calculate 7222 mod 11.
Solution:
The number 7 is not divisible by the prime 11, so by
Fer- mat’s Little Theorem

710 ≡ 1 mod

11 Using the division algorithm,


2
22 = 22 × 10 +
2.
Since 7222 =
7 22×10+5 = (7 ) × 72, then
10 22

7222
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 20 / 22
Fermat’s Little Theorem
Example 18:
The number 21000 is divided by 13. What is the remainder?
Solution:
By Fermat’s Little Theorem,

212 ≡ 1 mod

13 Using the division algorithm,


1000 = 12 × 50 +
400.

Since 21000 =

212×50+400 = (212)50 × 2400, then

2100
0
≡ 1 × 2
50 400
≡ 1× 2 400
mod
13.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 21 / 22
Fermat’s Little Theorem

Question
1 Find 2925 mod 11.

2 Find 220 + 330 + 440 + 550 + 660 mod


7.

Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 22 / 22


End of lecture 2.
Thank you.!!!

You might also like