Lecture 8 - Multiplicative Inverses; the Chinese Remainder Theorem

# Summary

We started off today by talking about a special class of linear congruence equations, namely those of the form $ax \equiv 1 \mod{m}$. These led to multiplicative inverses, which we saw were useful in solving certain congruence equations. We drove this point home when we used multiplicative inverses to prove the Chinese Remainder Theorem, a tool that is used to solve simultaneous linear congruence equations.

# Multiplicative Inverses

Last time we talked about solving linear congruence equations. Let's do another example of this kind of problem.

#### Example: Solving the linear congruence $5x \equiv 1 \mod{67}$

Suppose we want to solve the equation $5x \equiv 1 \mod{67}$. We first check to see if solutions exist. In this case, we know that $(5,67) = 1$, and since $(5,67) = 1 \mid 1$, we know there are solutions. In fact, we know that there is exactly 1 solution mod 67. To compute it, we first need to write $(5,67)$ as a linear combination. We'll use the Euclidean Algorithm. This gives

(1)
\begin{align} \begin{split} 67 &= 13 \cdot 5 + 2\\ 5 &= 2\cdot 2 + 1\\ 2 &= 2\cdot 1 + 0 \end{split} \end{align}

Now we can use these equations to express 1 as a combination of 5 and 67:

(2)
\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 5 \mod{67}$, and so 27 is the multiplicative inverse of 5 modulo 67.$\square$

This example leads 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: The Inverse of 5 mod 67

The previous example can be translated to say "27 is the multiplicative inverse of 5 modulo 67."$\square$

Notice that we already have machinery that tells us when multiplicative inverses exist.

Theorem: An integer a has a multiplicative inverse modulo m if and only if $(a,m) = 1$. When a and m are relatively prime, the multiplicative inverse of a mod m is unique mod 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 if a is going to have a multiplicative inverse mod m.

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$

## 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

(3)
\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$

# The Chinese Remainder Theorem

We've now defined arithmetic on congruence classes mod m, and we've also managed to solve linear equations mod m. Now we're going to try to solve simultaneous linear congruences mod m.

#### Example: Simultaneous Congruence equations

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

(4)
\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$. $\square$

This example shows us that we "experimentally" solve these simultaneous congruences, but they don't provide a very systematic (or efficient) way of computing solutions. For this, we turn to

The Chinese Remainder Theorem: If $m_1,\cdots,m_k$ are pairwise relatively prime integers, then the congruence equations $x \equiv a_i \mod{m_i}$ for each $1 \leq i \leq k$ have a unique solution modulo $\prod_{i=1}^k m_i$.

Proof: We'll break the proof into two pieces: first we'll construct a simultaneous solution to the given congruences, and then we'll show this solution is unique in the given modulus.

To start, we'll define $M = \prod_{j=1}^k m_j$, and for each $1 \leq i \leq k$ we'll write $N_i$ for $\frac{M}{m_i}$. Now since the $m_i$ are pairwise relatively prime, you showed in your homework (in the course of #43(c) in chapter 1) that $(N_i,m_i) = 1$. Hence for every i, there exists an integer $x_i$ which satisfies $N_ix_i \equiv 1 \mod{m_i}$.

With the $N_i,x_i$ so constructed, we claim that

(5)
\begin{align} x = N_1x_1a_1 + \cdots + N_kx_ka_k \end{align}