Lecture 6 - Modular Arithmetic and Linear Congruence Equations

Recap & Summary

In the last class period, we defined the important notion of congruence modulo an integer m: $a \equiv b \mod{m} \Leftrightarrow m \mid a-b$. We finished by talking about complete residue systems module m, and we showed that the set $\{0,1,\cdots,m-1\}$ is one example of a complete residue system. This complete residue system gets used the most in practice, and that for it gets the special name of least non-negative residue system. This isn't to say that other complete residue systems aren't useful: in fact, it's often quite useful to use other representatives than those in the least non-negative residue system when working in congruence world.

In today's class we will discuss how congruences behave with respect to addition and multiplication. We'll then move on to study linear congruences in 1 variable, determining a criterion when these kinds of equations have a solution.

Congruence and Arithmetic

The reason that congruences are so important in number theory is that the notion of congruence plays well with addition and multiplication. By this we mean

For integers $a,b,c,d,m$ with $a \equiv c \mod{m}$ and $b \equiv d \mod{m}$, we have

  • $a+b \equiv c+d \mod{m}$ and
  • $ab \equiv cd \mod{m}$

This result is important because it tells us that when we're doing arithmetic computations module m, we can do our computations by choosing any integers which sit in thegiven congruence classes module m. We'll see an example of this after we prove the theorem.

Proof: We're given that $a \equiv c \mod{m}$ and $b \equiv d \mod{m}$, and these statements translate into the divisibility statements $m \mid a-c$ and $m \mid b-d$. By our result on divisibility of integral linear combinations, we have that

\begin{align} m \mid (a-c) + (b-d) = (a+b)-(c+d). \end{align}

This divisibility statement, in turn, tells us that $a+b \equiv c+d \mod{m}$. To verify the second statement, we'll choose a different integral linear combination:

\begin{align} m \mid b(a-c) + c(b-d) = ab - bc+bc -cd = ab-cd, \end{align}

and by the definition of congruence we have $ab \equiv cd \mod{m}$.$\square$

Example: Arithmetic Modulo 6

The following tables tells us how addition and multiplication work modulo six

+ 0 1 2 3 4 5
0 0 1 2 3 4 5
1 1 2 3 4 5 0
2 2 3 4 5 0 1
3 3 4 5 0 1 2
4 4 5 0 1 2 3
5 5 0 1 2 3 4
x 0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 2 3 4 5
2 0 2 4 0 2 4
3 0 3 0 3 0 3
4 0 4 2 0 4 2
5 0 5 4 3 2 1

An important thing to notice about this table is that it gives us examples where $ca \equiv cb \mod {m}$ does not imply $a \equiv b \mod{m}$. This kind of cancellation is something you're probably really used to, so you need to be wary when doing modular arithmetic that you aren't carelessly "dividing" by constants. The following lemma tells us exactly what relationship such a,b have to each other.

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

Proof: We'll only prove the $(\Rightarrow)$ direction, leaving the other direction for the enthusiastic student. Now if we're told that $ca \equiv cb \mod{m}$, then this translates to the divisibility statement $m \mid ca-cb$. Hence there is some integer e so that $me = ca-cb$. If we write $d = (c,m)$, then we can divide each of m and c by d and get an equation of integers

\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

\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

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

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

Example: A divisibility criterion for 17

We'll use this idea to prove the result we stated on the second day of class: that $17 \mid 10a+b$ if and only if $17 \mid a-5b$. For this, we note that the first condition is the same as

\begin{align} 10a+b \equiv 0 \mod{17}. \end{align}

Now since $(-5,17) = 1$, the previous theorem (with $c = -5$) tells us that

\begin{align} 10a+b \equiv 0 \mod{17} \quad \Leftrightarrow \quad -5(10a) - 5b \equiv 0 \mod{17}. \end{align}

This is almost what we want: all we have to do now is show that $-50 \equiv 1 \mod{17}$, and we can substitute in the previous expression as desired. To show that $-50 \equiv 1 \mod{17}$, note that 17 divides $-50 - 1= -51$. $\square$

Example: Computing large powers (modularly)

One of the benefits of modular arithmetic is that it provides a context in which really large powers of a given integer can be computed. As an example, we'll compute $10^{80} \mod{13}$. (This is more than the number of atoms in the universe!). To do this, we start by computing successive square powers of 10. To do this, I'll often use the trick of substituting a given integer with another small integer which is equivalent modulo 13. Witness:

\begin{align} \begin{split} &10^2 \equiv (-3)^{2} \equiv 9 \mod{13}\\ &10^4 \equiv 9^2 \equiv (-4)^2 \equiv 16 \equiv 3 \mod{13}\\ &10^8 \equiv 3^2 \equiv 9 \mod{13}\\ &10^{16} \equiv 9^2 \equiv 3 \mod{13}\\ &10^{32} \equiv 3^2 \equiv 9 \mod{13}\\ &10^{64} \equiv 9^2 \equiv 3 \mod{13}. \end{split} \end{align}

Now when it comes to computing $10^{80}$, we just notice that

\begin{align} 10^{80} = 10^{64 + 16} = 10^{64}10^{16} \equiv 3 \cdot 3 \equiv 9 \mod{13}. \end{align}


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.

\begin{align} \begin{split} 5x \equiv 1 \mod{6} \quad &\Longleftrightarrow \quad x \equiv 5 \mod{6}\\ 2x \equiv 4 \mod{6} \quad &\Longleftrightarrow \quad x \equiv 2 \mod{6} \mbox{ or } x \equiv 5 \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}


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 we 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? We'll answer this first question today.

Lemma: The linear congruence $ax \equiv b \mod{m}$ has no solutions if and only if $(a,m) \nmid b$.

Proof: Suppose that $ax \equiv b \mod{m}$ has at least one solution, so that x is an integer which makes the congruence valid. This happens if and only if $m \mid ax - b$, which occurs if and only if there exists some integer g with $mg = ax - b$. But this equation is equivalent to $b = ax - mg$, which occurs if and only if $(a,m) \mid b$. (Certainly if this equation is true then since the right hand side is divisible by $(a,m)$, so too must the left hand side be divisible by $(a,m)$. The fact that an equation of this form forces $(a,m) \mid b$ follows from one of the bonus problems you'll do for the first midterm).

In class tomorrow, we'll determine exactly how to find all solutions (i.e., all distinct solutions modulo m) in the case that solutions actually exist.

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