Lecture 7 - Linear Congruence Equations

Summary

Today we started by reviewing how one can go about "canceling" common factors in congruence equations. Afterwards we introduced the notion of a linear congruence equation, giving a theorem which told us exactly when such an equation has solutions (and, indeed, how many solutions exist).

Cancellation in Modular Equations

Last class period we stated the following

Proposition: $ca \equiv cb \mod{m}$ is equivalent to $a \equiv b \mod{\frac{m}{(c,m)}}$.

This result will play a central role in today's lecture, so we'll start by giving a full proof.

Proof: We'll use the notation $d = (a,m)$ to make our exposition easier to read.

Suppose first that $a \equib \mod{\frac{m}{d}}$. This means that $\frac{m}{d} \mid a - b$, so that there exists an integer e with $e\frac{m}{d} = a-b$. Multiplying this equation by c then gives $ce\frac{m}{d} = a-b$. Now notice that since $d \mid c$ we can rewrite the left hand side as $\frac{c}{d}em$, where each of these terms are bona fide integers. Hence we have

(1)
\begin{align} \left(\frac{c}{d}e\right)m = ca - cb. \end{align}

Since the left hand side is a multiple of m, we conclude that $ca \equiv cb \mod{m}$.

Now we'll prove the $(\Rightarrow)$ direction. Since we're told that $ca \equiv cb \mod{m}$, this translates to the divisibility statement $m \mid ca-cb$. Hence there is some integer e so that $me = ca-cb$. We can divide each of m and c by d (since $d = (c,m)$) and get an equation of integers

(2)
\begin{align} d~\frac{m}{d}~e = d~\frac{c}{d}(~a-b). \end{align}

Now since this is an equation of integers, we can cancel out the d on both sides, and we're left with the div

(3)
\begin{align} \frac{m}{d}~e = \frac{c}{d}~(a-b) \end{align}

from which we have $\frac{m}{d} \mid \frac{c}{d}(a-b)$. We know that $(\frac{m}{d},\frac{c}{d}) = 1$ by an old result, and we also know that this relative primality result together with our divisibility condition implies that

(4)
\begin{align} \frac{m}{d} \mid a-b \end{align}

from which we find $a \equiv b \mod{\frac{m}{d}}$ as desired.$\square$

Linear Congruences

Now that we've played around a bit with modular arithmetic, it's time that we take one of our favorite problems in mathematics and give it a modular spin: solving equations. We'll start off at the beginning, dealing with linear equations.

Definition: For integers a,b and m, the equation $ax \equiv b \mod{m}$ is called a linear congruence.

The goal, of course, is to find all integers x which solve this equation. Given that the equation is really a statement about modular congruence, though, you won't be surprised to hear that we're actually most interested in knowing solutions to the system modulo m; that is to say, we want to know which congruence classes modulo m solve the given equation.

Example: Some linear congruence equations

From our multiplication table, we can read off solutions to some equations modulo 6.

(5)
\begin{align} \begin{split} 5x \equiv 1 \mod{6} \quad &\Longleftrightarrow \quad x \equiv 5 \mod{6}\\ 2x \equiv 2 \mod{6} \quad &\Longleftrightarrow \quad x \equiv 1 \mod{6} \mbox{ or } x \equiv 4 \mod{6}\\ 3x \equiv 5 \mod{6} \quad & \mbox{ is not a valid congruence for any }x \in \{0,1,2,3,4,5\}. \end{split} \end{align}

$\square$

So we see that our linear congruences can have either no solutions, 1 solution, or several solutions (where by "solutions" we mean more precisely "distinct solutions modulo m"). The question, then, is how to distinguish when an equation does have a solution from when it doesn't. And if it does have a solution, how can we produce all solutions? How many solutions will there be?

Big Theorem on Linear Congruences: The congruence $ax \equiv b \mod{m}$ has integer solutions if and only 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) show that solutions exist if and only if $d \mid b$; (2) show that other solutions can be expressed in terms of one fixed solution; (3) determine when two integer solutions are congruent modulo m. (Note: we didn't get to prove this last part in class today.)

Step 1: First, suppose that a solution $x_0$ exists to the equation $ax \equiv b \mod{m}$. This implies that $m \mid ax_0 - b$, so that there exists an integer e with $me = ax_0-b$. Rearranging, we therefore have

(6)
\begin{equation} b = ax_0 - me. \end{equation}

Now since d is the gcd of a and m we have $d \mid a$ and $d \mid m$, and therefore d divides any integral linear combination of a and m. In particular,

(7)
\begin{align} d \mid ax_0 - me = b. \end{align}

Hence if our congruence equation has a solution, then $d \mid b$.

Now we'll prove the converse, showing that a solution exists when $d \mid b$. We start by noting that there exists integers r and s such that

(8)
\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

(9)
\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

(10)
\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: (Note: we didn't get to discuss this proof in class, but I'm including it in the notes for people interested in seeing the full proof.) 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

(11)
\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

(12)
\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 $6x \equiv 5 \mod{15}$

Suppose you want to solve the equation $6x \equiv 5 \mod{15}$. Notice that the gcd of 6 and 15 is 3, and that $3 \not\mid 5$. Our big theorem tells us that this congruence equation has no solutions. $\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:

(13)
\begin{align} \begin{split} 14 &= 3 \cdot 4 + 2\\ 4 &= 2\cdot 2 + 0 \end{split} \end{align}

and from this we see that

(14)
\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:

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

Taking this equation modulo 14 leaves us with

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

and hence $x = -9$ is one integer solution.

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}$.

Notice that if we had been interested in least non-negative solutions, we would write 5 in place of -9 (since $5 \equiv -9 \mod{14}$) and 12 in place of -2 (since $12 \equiv -2 \mod{14}$). $\square$

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