0% found this document useful (0 votes)
59 views16 pages

4.3. Solving Congruences - Discrete Structures For Computing

This document discusses solving linear congruences and systems of linear congruences. It introduces modular inverses, which allow solving single linear congruences. The Chinese Remainder Theorem states that a system of linear congruences with co-prime moduli always has a unique solution modulo the product of the moduli, and provides an algorithm for finding this solution. Examples are given to demonstrate computing modular inverses and applying the Chinese Remainder Theorem to solve a system of congruences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views16 pages

4.3. Solving Congruences - Discrete Structures For Computing

This document discusses solving linear congruences and systems of linear congruences. It introduces modular inverses, which allow solving single linear congruences. The Chinese Remainder Theorem states that a system of linear congruences with co-prime moduli always has a unique solution modulo the product of the moduli, and provides an algorithm for finding this solution. Examples are given to demonstrate computing modular inverses and applying the Chinese Remainder Theorem to solve a system of congruences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Solving Congruences

Contents
4.3.1. Linear Congruences
4.3.2. Systems of Linear Congruences
4.3.3. Exercises

We know from Section 4.1.3 that working modulo a positive integer forms a special
kind of equivalence relation known as a congruence relation. For example,
4 ≡ 16 mod 6 since 6 ∣ 16 − 4.

Now, we look to include variables in equivalence relations and solve for those
variables.

Linear Congruences
Modular Inverses
Computing Modular Inverses
Systems of Linear Congruences
:
s
Chinese Remainder Theorem
Exercises

4.3.1. Linear Congruences


A linear congruence is an equivalence of the form ax ≡ b mod m where x is a
variable, a, b are positive integers, and m is the modulus.

The solution to such a congruence is all integers x which satisfy the congruence.

 Solution to a linear congruence

2x ≡ 1 mod 5

By inspection we find that 2 ⋅ 3 = 6 ≡ 1 mod 5. Therefore, a solution this


linear congruence is x = 3. However, notice that x = 8 is also a solution
since 2 ⋅ 8 = 16 ≡ 1 mod 5.

In a linear congruence, there are infinitely many possible solutions. In the previouse
example we saw that x = 3 and x = 8 were both solutions. In this case, since x = 3
was a solution, then so is every element in the congruence class of 3. Recall that the
congruence class of 3 modulo 5 is defined as:
:
s

3 = {x | x ≡ 3 mod 5}.

Modular Inverses
To solve an equation like ax = b over the reals, we would normally divide through by
a, assuming a ≠ 0, to get x = ab . This is equivalent to multiplying both sides by the
multiplicative inverse of a. A multiplicative inverse of a number is another number
such that their product equals 1.

Over the real numbers we have a ⋅ a1 = 1 for any a. Therefore, we can solve ax = b
by multiplying both sides by a1 .

Just as over the rational numbers or real numbers, there are (often, but not always)
multiplicative inverses when working modulo a number. Given a number x and a
modulus m, the modular multiplicative inverse of x is another number a such that
ax ≡ 1 mod m.
:
s
 Modular inverse

Compute the inverse of 3 modulo 7.

3a ≡ 1 mod 7

15 ≡ 1 mod 7

→a≡5 mod 7

Similar to linear congruences, there may be many modular inverses of a number. In


the previous example, 5 was the modular inverse of 3 mod 7. Any number in the
congruence class of 5 modulo 7 is a multiplicative inverse. Moreover, any number in
the congruence class of 5 modulo 7 is a multiplicative inverse of any number in the
congruecne class of 3 modulo 7.

We can use modular inverses to solve linear congruences. Let a′ be the inverse of a
modulo m. Then, we have the following:

ax ≡ b mod m

a′ax ≡ a′bx mod m

x ≡ a′ b mod m
:
s
 Modular inverses may not exist

It may happen that certain numbers do not have multiplciative inverses


modulo a particular modulus.

Consider 2 modulo 6. It does not have an inverse. We can verify this by


attempting to multiply 2 by each of 0, 1, 2, 3, 4, 5.

2⋅0≡0 mod 6

2⋅1≡2 mod 6

2⋅2≡4 mod 6

2⋅3≡0 mod 6

2⋅4≡2 mod 6

2⋅5≡4 mod 6

Theorem 4.3.1 will establish when modular inverses exist.

But when do they not exist? In this case it is because gcd(2, 6) ≠ 1.


Because of that fact, 2 is called a zero-divisor for arithmeitc modulo m.

Computing
Print to PDF Modular Inverses
:
s
Finding the modular inverse of a number can be very challenging. It is easy to find by
inspection the inverse of 3 mod 8 (it is 3 itself since 3 ⋅ 3 = 9 ≡ 1 mod 8).

However, can you find the inverse of 151 mod 951?.

An algorithmic process exists to compute modular inverses using the Euclidean


algorithm and Bézout relations. This is based on the following theorem.

 Theorem 4.3.1

If a and m are relatively prime integers with m > 1, then there exists a
unique modular inverse x of a modulo m satisfying 0 < x < m.

Proof:

We first prove the exitence of x. By hypothesis we have gcd(a, m) = 1. Therefore,


By Bézout’s theorem there exists integers s and t such that sa + tm = 1.

We have:

1 − sa = tm

m ∣ (1 − sa)

1 ≡ sa mod m

Therefore, s = x is the modular inverse of m.


:
s
Next, we show uniqueness. Assume there exists another modular inverse b of a. By
the definition of modular inverses we have xa ≡ 1 mod m and ba ≡ 1 mod m.
Therefore, xa ≡ ba mod m.

From Theorem 4.2.10, we have x ≡ b mod m since gcd(a, m) = 1. Therefore, x is


unique for 0 < x < m. ■

The previous theorem establishes criteria for a modular inverse to exist. The proof of
this theorem suggests how to compute the inverses: we compute a Bézout relation
betwen the modulus and the number to invert.

 Computing an easy modular inverse

Find the inverse of 3 modulo 7.

Since gcd(3, 7) = 1, an inverse must exist. From Euclidean division we have


7 = 2 ⋅ 3 + 1 and thus −2 ⋅ 3 + 1 ⋅ 7 = 1. Hence, −2 is the Bézout
coefficient of 3 and −2 ≡ 5 mod 7 is the modular inverse of 3.

 Computing a hard modular inverse

Find the inverse of 151 modulo 951.

Using the Euclidean algorithm we find:


:
s
951 = 6 ⋅ 151 + 45

151 = 3 ⋅ 45 + 16

45 = 2 ⋅ 16 + 13

16 = 1 ⋅ 13 + 3

13 = 4 ⋅ 3 + 1

3=3⋅1+0

Therefore, gcd(951, 151) = 1. Morevoer, we can find a Bézout relation


between 951 and 151 via back substitution:

1 = 13 − 4 ⋅ 3

1 = 13 − 4(16 − 1 ⋅ 13) = −4 ⋅ 16 + 5 ⋅ 13

1 = −4 ⋅ 16 + 5(45 − 2 ⋅ 16) = 5 ⋅ 45 − 14 ⋅ 16

1 = 5 ⋅ 45 − 14(151 − 3 ⋅ 45) = −14 ⋅ 15147 ⋅ 45

1 = −14 ⋅ 151 + 47(951 − 6 ⋅ 151) = −296 ⋅ 151 + 47 ⋅ 951

Therefore, the modular inverse of 151 modulo 951 is


−296 ≡ 655 mod 951.
:
s
Checkpoint Solution

 Using inverses to solve linear congruences

Solve the following linear congruence by first computing an inverse.

57x ≡ 13 mod 67

4.3.2. Systems of Linear Congruences


Consider a system of linear congruences.

⎧x ≡ 3 mod 7


x ≡ 6 mod 13

Could we find a value of x that simultaneously satisfies both of these equations?

By inspection, one could find that 45 is a possible solution. Indeed,


7 ∣ (45 − 3) = 42 and 13 ∣ (45 − 6) = 39.

Is there an algorithmic process to find such an x? Yes!

Chinese Remainder Theorem


:
s
:
Proof:


 Theorem 4.3.2 (Chinese Remainder Theorem)

Let m, n be two co-prime integers greater than 1. Then,

⎧x ≡ a mod m


x ≡ b mod n

has a unique solution modulo m ⋅ n.

Since m and n are co-prime, by the Bézout theorem there exists integers s, t such
that:

sm + tn = 1

Then, notice that x = bsm + atn satisfies the linear congruences:

x = bsm + atn

= bsm + a(1 − sm)

= bsm + a − asm

≡a mod m
s
x = bsm + atn

= b(1 − tn) + atn

= b − btn + atn

≡b mod n
:
Therefore y ≡ z mod m ⋅ n. ■

Let’s try an example.

0 ≤ x < 15.

Now consider uniqueness. Let x = y and x = z be two solutions of this system.
Then, y and z must give the same remainder when divided by m or divided by n.
Therefore, m ∣ y − z and n ∣ y − z.

Since m and n are co-prime, it follows that m ⋅ n ∣ y − z (see Exercise 4.18).

 A system of linear congruences.

Find all integers x, 0 ≤ x < 15 such that:

⎧x ≡ 1 mod 3


x ≡ 2 mod 5

Since 3 and 5 are co-prime, Chinese Remainder Theorem states there exists
a unique solution modulo 15. Therefore, there is exactly one solution x with

Apply the Euclidean algorithm to find s, t such that 3s + 5t = 1. Or, by


inspection, we see 3(2) + 5(−1) = 1 implies s = 2, t = −1.

Therefore, x = 2(3s) + 1(5t) = 2(3)(2) + 1(5)(−1) = 7 ≡ 7 mod 15.


s
:
Checkpoint

4.3.3. Exercises
 Exercise 4.17

1. 8 modulo 17.

2. 9 modulo 23.

3. 11 modulo 71.
Solution

s

 Solve a system of linear congruences

Solve the system of linear congurences presented at the beggining of this


section for 0 ≤ x < 91 using the Chinese Remainder Theorem.

⎧x ≡ 3 mod 7


x ≡ 6 mod 13

Find the multiplicative inverse of:


:
 Exercise 4.18

Prove the following lemma.

 Lemma 4.3.3


Let m and n be co-prime integers.

For any integer x such that m ∣ x and n ∣ x, then mn ∣ x.

 Solution to Exercise 4.18

By hypothesis m ∣ x and n ∣ x, therefore there exists integers qm, qn such


that x = mqm and x = nqn. Hence mqm = nqn.

Since m and n are co-prime there exists s and t such that sm + tn = 1.

Therefore, we have smqm + tnqm = qm and, combining with our


hypotheses, gives snqn + tnqm = qm and thus n(sqn + tqm) = qm.

From x = mqm we get x = mn(sqn + tqm). Hence, mn ∣ x. ■


s
 Exercise 4.19

Solve the following linear congruences. Give the unique positive solution
which is less than the modulus.

1. x ≡ 12 mod 7

2. 2x ≡ 12 mod 7

3. 13x ≡ 15 mod 23

 Solution to Exercise 4.19

1. 5

2. 6

3. 10

 Exercise 4.20

Solve the following system of linear congruences for 0 ≤ x < 77.

⎧3x ≡ 2 mod 11


4x ≡ 6 mod 7
:
s
:
 Solution to Exercise 4.20

 Exercise 4.21


Computing modular inverses gives:

⎧x ≡ 8 mod 11

x ≡ 12 ≡ 5 mod 7

By CRT we have x ≡ 19 mod 77.

Solve the following system of linear congruences for 0 ≤ x < 221.


s
⎧4x ≡ 11 mod 13


2x ≡ 7 mod 17
:
 Solution to Exercise 4.21

Computing modular inverses gives:

⎧x ≡ 6 mod 13

By CRT we have x ≡ 97 mod 77.

By Alexander Brandt
© Copyright 2022.
s
x ≡ 12 mod 17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy