# Recap & Summary

Last class period we spent some time asking the question

When does $ax \equiv b \mod{m}$ have a solution?

Today we're going to continue talking about linear congruence equations, in particular seeing how to solve these equations in the case that solutions do exist. We'll do even better than this, though, since we'll find all distinct solutions (modulo m) to the equation. We'll also talk about a special case of these equations: when the constant term *b* is 1. This will lead us to *multiplicative inverses modulo m*. We'll finish by discussing the problem of simultaneous linear congruences; i.e., the problem of trying to find a common solution to a handful of different linear congruences.

# Solving Solvable Congruences

Last class period we finished off with the observation that $ax \equiv b \mod{m}$ will not have solutions if $(a,m) \nmid b$. Today we'll take the next step, showing

Theorem: The congruence $ax \equiv b \mod{m}$ has integer solutions if $(a,m) \mid b$. If $x_0$ is such a solution, then all other integral solutions take the form $x_0 + n\left(\frac{m}{(a,m)}\right)$, where $n \in \mathbb{Z}$. A complete list of the distinct solutions modulo

mis given by $x_0 + n\left(\frac{m}{(a,m)}\right)$ when $n \in \{0,\cdots,d-1\}$.

Proof: For notational convenience, we'll write *d* for the gcd of *a* and *m*. Now we'll proceed with the proof in steps: ^{(1)} produce a solution; ^{(2)} show that other solutions can be expressed in terms of one fixed solution; ^{(3)} determine when two integer solutions are congruent modulo *m*.

Step 1: To show that a solution exists when $d \mid b$, we start by noting that there exists integers *r* and *s* such that

this follows because the gcd of two integers can be expressed as an integral combination of the two integers. Now using the fact that $d \mid b$, we find an integer *e* so that $de = b$. Multiplying the displayed equation by *e* then gives

Taking this equation modulo *m*, we therefore have $b = a(re) \mod{m}$, and hence $x = re$ is an integer solution to the equation $ax \equiv b \mod{m}$.

Step 2: Now suppose we are given two solutions to the equation, $x_0$ and $x_1$, and we wish to show that $x_1 = x_0 + n\left(\frac{m}{d}\right)$. In order to do this, note that we have

(3)This tells us that $ax_0 \equiv ax_1 \mod{m}$, and so it follows that $m \mid a(x_0-x_1)$ — or, if we turn this divisibility statement into an equation, there exists some integer *k* so that $mk = a(x_0-x_1)$. We'll divide this equation on both sides by *d* — a legal move since *d* is a common divisor of *a* and *m* — and we find that $(\frac{m}{d})k = \frac{a}{d}(x_0-x_1)$. This is equivalent to the divisibility condition $\frac{m}{d} \mid \frac{a}{d}(x_0-x_1)$. Notice, however, that $(\frac{m}{d},\frac{a}{d}) = 1$, and hence homework problem 44a tells us that $\frac{m}{d} \mid x_0 -x_1$. This is the same as saying that $x_0 \equiv x_1 \mod{m}{d}$, so that $x_1 = x_0 + n\frac{m}{d}$ as desired.

Step 3: To find the distinct solutions (modulo *m*), suppose we pick up two solutions $x_1$ and $x_2$ which are the same modulo *m*. Since $x_i = x_0 + n_i \frac{m}{d}$ by the previous step, this means that we have

Getting rid of the $x_0$ that is common to both sides, we turn this divisibility condition into an equation: $me = \frac{m}{d}(n_1-n_2)$. Hence we have

(5)and after canceling the *m*'s on both sides of the equation (a legal move since this is an equation in integers, not a congruence equation) we're left with $de = n_1-n_2$ — i.e., that $n_1 \equiv n_2 \mod{d}$.

This tells us that two solutions $x_0 + n_1\frac{m}{d}$ and $x_0 + n_2\frac{m}{d}$ are distinct if and only if $n_1 \not\equiv n_2 \mod{d}$. Hence the distinct solutions to $ax \equiv b \mod{m}$ are given as $x_0 + n\left(\frac{m}{(a,m)}\right)$ when $n \in \{0,\cdots,d-1\}$. $\square$

#### Example: Solving $4x \equiv 6 \mod{14}$

Let's put these ideas in practice to try to solve $4x \equiv 6 \mod{14}$. To start, we need to decide whether this congruence will have solutions or not. For this, we just notice that $2=(4,14)$, and that $2 \mid 6$. Hence we know there are solutions, and we're expecting that there should be 2 distinct solutions modulo 14.

To find one such solution, we need to do two things:

- we need to express 2 as a linear combination of 4 and 4, and
- we need to express 6 as a multiple of 2.

Toward the first goal, we know that we can to use the Euclidean Algorithm. The algorithm runs like so:

(6)and from this we see that

(7)Now for the second goal, it isn't too hard to see that $2 \cdot 3 = 6$. Finding a solution, then means we should multiply our expression of 2 as a linear combination by 3:

(8)Taking this equation modulo 14 leaves us with

(9)and hence $x = -9$ is one integer solution. (Notice that this also means that $-9 + n\cdot 14$ is a solution for any integer choice of *n* — but that all these integers are congruent to each other modulo 14. This is good, but what we're really after is distinct solutions modulo 14, whereas this class of solutions produces only one distinct solution modulo 14.)

Now that we have one solution $x_0$, we can find all solutions by taking $x_0 + n\left(\frac{14}{2}\right)$ for $n \in \{0,1\}$. Doing so shows that the distinct solutions modulo 14 are given by $x \equiv -9,-2 \mod{14}$. $\square$

# Multiplicative Inverses

Having developed a machine for solving an arbitrary linear congruence, we'll now focus on congruences which take the form

(10)that is to say, we'll be focusing on the case where the constant term *b* from our general equation is taken to be 1.

We have the following

Theorem: The linear congruence $ax \equiv 1 \mod{m}$ has a solution if and only if $(a,m) = 1$. When

aandmare relatively prime, there is exactly one solution modulom.

Proof: Recall that $ax \equiv 1 \mod{m}$ has a solution if and only if $(a,m) \mid 1$. Of course there aren't a lot of choices for what $(a,m)$ can be if this divisibility is going to hold; in fact, $(a,m) = 1$ is the only way this divisibility can hold. Hence *a* and *m* must be relatively prime for this result to hold true.

When a solution does exist, our theorem on solving linear congruences says that the number of distinct solutions modulo *m* is given by the gcd of *a* and *m*. We've already seen that a solution exists if and only if $(a,m) = 1$, and so in this case there is only one solution modulo *m*.$\square$

This special linear congruence leads us to the following

Definition: A solution to the linear congruence $ax \equiv 1 \mod{m}$ is called a multiplicative inverse for

amodulom.

#### Example: Computing a multiplicative inverse

Suppose we want to find the multiplicative inverse of 5 modulo 67, if such an inverse exists. For this, we need to first compute $(5,67)$:

(11)Hence $(5,67) = 1$ as desired, and in fact we can write 11 as a linear combo of these two integers

(12)Taking this equation modulo 67 shows that $1 \equiv 27\cdot 2 \mod{67}$, and so 27 is the multiplicative inverse of 5 modulo 67.$\square$

## Solving Congruences Using Inverses

Multiplicative inverses can be quite useful in solving other linear congruences, since they allow one to solve a congruence by a simple multiplication.

#### Example: Solving $5x \equiv 11 \mod{67}$

Suppose we wish to solve $5x \equiv 11 \mod{67}$. We could proceed as we have before — finding a gcd, writing that gcd as a linear combination, etc. Alternatively, we can use the fact that we've already computed the multiplicative inverse of 5 as 27. To take this latter route, notice that we have

(13)(Notice: we're allowed to multiply by 27 on both sides of the expression without disturbing the solution set because $(27,67) = 1$, and you'll recall our theorem which says that $ca \equiv cb \mod{m}$ if and only if $a \equiv b \mod{\frac{m}{(c,m)}}$).

Using the fact that $27 \cdot 5 \equiv 1 \mod{67}$ by our previous example, this means that our solution is $x \equiv 27 \cdot 11 \mod{67}$. $\square$

# Simultaneous Congruence Equations

Having fully examined the problem of solving a linear congruence equation, we'll now move on to ask a related question: suppose that you're given a handful of linear congruence equations and you want to find a simultaneous solution to all these congruences. How do you go about solving this problem?

We finished class by simply playing around with an example.

#### Example: Simultaneous Congruence equations

Suppose you want to find an integer *x* which satisfies both of the congruences

We don't have a really good way for doing this systematically right now, but you can try out some small numbers to see if you can find a solution. For instance, we know that we can't have $x = 1$ since this fails the second congruence; we also can't have $x = 2$ since this fails the first congruence. We can similarly rule out $x = 3$ and $x = 4$, but notice that $x = 5$ does satisfy both of these equations. A little more experimentation shows that $x = 11$ works too, and the particularly diligent student might also come across the solution $x = 17$. In class next time we'll examine how to solve this problem in general using a technique called the Chinese Remainder Theorem.$\square$