Lecture 7 - Linear Congruence Equations, Con't.

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 m is 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

(1)
\begin{equation} d = ra + ms; \end{equation}

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

(2)
\begin{equation} b = de = a(re) + mse. \end{equation}

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)
\begin{align} ax_0 \equiv b \equiv ax_1 \mod{m}. \end{align}

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

(4)
\begin{align} x_0 + n_1\frac{m}{d} \equiv x_0 + n_2 \frac{m}{d} \mod{m}. \end{align}

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)
\begin{equation} mde = m(n_1-n_2), \end{equation}

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:

  1. we need to express 2 as a linear combination of 4 and 4, and
  2. 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)
\begin{align} \begin{split} 14 &= 3 \cdot 4 + 2\\ 4 &= 2\cdot 2 + 0 \end{split} \end{align}

and from this we see that

(7)
\begin{align} 2 = 14 - 3\cdot 4. \end{align}

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)
\begin{align} 3\cdot 2 = 3\cdot 14 - 9 \cdot 4. \end{align}

Taking this equation modulo 14 leaves us with

(9)
\begin{align} 6 \equiv -9\cdot 4 \mod{14}, \end{align}

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)
\begin{align} ax \equiv 1 \mod{m}; \end{align}

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 a and m are relatively prime, there is exactly one solution modulo m.

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 a modulo m.

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)
\begin{align} \begin{split} 67 &= 13 \cdot 5 + 2\\ 5 &= 2\cdot 2 + 1\\ 2 &= 2\cdot 1 + 0 \end{split} \end{align}

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

(12)
\begin{align} 1 = 5 - 2\cdot 2 = 5 - 2 ( 67 - 13\cdot 5) = 27 \cdot 5 - 2\cdot 67. \end{align}

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)
\begin{align} 5x \equiv 11 \mod{67} \quad \Longleftrightarrow 27 \cdot 5x \equiv 27\cdot 11 \mod{67}. \end{align}

(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

(14)
\begin{align} \begin{split} x &\equiv 1 \mod{2}\\ x &\equiv 2 \mod{3}. \end{split} \end{align}

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$

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License