User:Marty/UCSC Math 110 Fall 2008/Week 6

This week, we are introducing modular arithmetic and residues. Much of this material can be found in the modular arithmetic cluster. In particular, we are covering the following:
 * residues, and reduction. Arithmetic of residues, also known as modular arithmetic.
 * We will spend a great deal of time on modular arithmetic, with a prime modulus. Especially, this includes the facts that Covers::State/Multiplicative inverses exist mod p and Covers::State/There are no zero divisors mod p.

=Working with residues=

There are many approaches to modular arithmetic, all of which are equivalent, more or less, in the end. The crucial step in getting started is having the ability to translate between sentences in the (probably new) language of modular arithmetic, and sentences in the (hopefully familiar) language of integers and arithmetic operations.

Fix a positive integer $m$: this will be called the "modulus". Suppose that $a$ and $b$ are integers. The following four sentences are equivalent -- the first two are in a familiar language, and the last two are in a (perhaps) unfamiliar language:
 * $a - b$ is a multiple of $m$.
 * Dividing $a$ by $m$, and dividing $b$ by $m$, leaves the same remainder.
 * $a \equiv b$ (mod $m$).
 * $\bar a = \bar b$ (modulo $m$).

We will mostly follow the notation in the last sentence; however, for writing proofs (especially at the beginning), it is crucial that you can translate a sentence like "$\bar a = \bar b$ (modulo $m$)", into a sentence like "$a - b$ is a multiple of $m$".

Here are some translation exercises. Try to translate each of the following sentences into the other three forms, using the above four forms as models. The first exercise is a worked-example: Now, you should try the rest:
 * $3 \equiv 7$ (mod $4$).
 * $3-7$ is a multiple of $4$.
 * Dividing $3$ by $4$, and dividing $7$ by $4$, leaves the same remainder.
 * $\bar 3 = \bar 7$ (modulo $4$).
 * $\bar 5 = \bar 12$ (modulo $7$).
 * Dividing $12$ by $3$, and dividing $24$ by $3$, leaves the same remainder.
 * $n \equiv 0$ (mod $11$).
 * $m \equiv 2m$ (mod $m$).
 * If $a - 3$ is a multiple of $7$, then $2a - 6$ is a multiple of $7$.

=An equivalence relation=

It would be very deceiving to use notation like "$\equiv$", and "$=$", to mean anything but an equivalence relation. So we verify that "equivalence, mod $m$" is an equivalence relation (when $m$ is a fixed positive integer!). This is a relatively simple exercise in translation:
 * Reflexivity: For all integers $a$, $a - a = 0$.  $0$ is a multiple of $m$.  Hence $\bar a = \bar a$ (modulo $m$).
 * Symmetry: Suppose that $a,b \in \ZZ$, and $\bar a = \bar b$ (modulo $m$).  Then $a-b$ is a multiple of $m$.   Hence $b-a$ is a multiple of $m$.  Thus $\bar b = \bar a$ (modulo $m$).
 * Transitivity: Suppose that $a,b,c \in \ZZ$, and $\bar a = \bar b$, and $\bar b = \bar c$ (modulo $m$).  Then, there exist integers $r,s$ such that $a-b = rm$ and $b-c = sm$.  Hence $a-c = a-b + b-c = rm + sm = (r+s)m$.  Hence $a-c$ is a multiple of $m$.  Thus $\bar a = \bar c$ (modulo $m$).

=Good representatives=

Suppose we are working "mod $7$". Then $\bar 1 = \bar 8 = \overline{15} = \overline{22} = \overline{-41}$. While the numbers $1,8,15,22,-41$ are all distinct, they have the same residue mod $7$. If we only care about the residue mod $7$ (and not which specific number we are working with), we should choose the smallest "representative" as possible.

For example, rather than using a long notation, such as $\overline{-41}$, we should instead use the equivalent residue $\bar 1$. There are two natural ways to minimize notation:
 * If one is working with residues, mod $m$, every residue has a representative between $\bar 0$ and $\overline{m-1}$.
 * If one is working with residues, mod $m$, every residue has a representative between $\overline{- \lfloor (m-1)/2 \rfloor }$ and $\overline{ \lfloor m/2 \rfloor}$.

As an exercise, reduce all of the following residues using both methods, to find good representatives:
 * $\overline{46}$ (modulo $8$).
 * In the first method, $\overline{46} = \bar 6$, modulo $8$.
 * In the second method, $\overline{46} = \overline{-2}$, modulo $8$.
 * $\overline{13}$ (modulo $3$).
 * $\overline{71}$ (modulo $11$).
 * $\overline{47}$ (modulo $6$).
 * $\overline{10007}$ (modulo $10$).
 * $\overline{2m + 1}$ (modulo $m$).
 * $\overline{3m - 1}$ (modulo $m$).

=Addition,subtraction, and multiplication=

Fix a modulus $m$, i.e., a positive integer. The residues mod $m$ are the equivalence classes $\bar 0, \bar 1, \ldots, \overline{m-1}$ of integers, modulo $m$. Modular arithmetic is the study of the arithmetic of these residues. We begin with addition: $$\overline{a + b} = \overline{a' + b'}.$$ To prove this statement, we need to translate every statement about residues into a statement about divisibility. The hypothesis of the statement translates as: These statements imply that: It follows that: Hence, we find that:
 * Suppose that $a,b,a',b' \in \ZZ$. Then if $\bar a = \bar a'$ and $\bar b = \bar b'$, then:
 * Suppose that $a-a'$ is a multiple of $m$.
 * Suppose that $b - b'$ is a multiple of $m$.
 * $a - a' = mr$, for some integer $r$.
 * $b - b' = ms$, for some integer $s$.
 * $(a + b) - (a' + b') = m( r + s)$.
 * $\overline{a+b} = \overline{a' + b'}$.

This is a quite applicable result. For example, one may compute $\overline{a + b}$, by replacing $a$ and $b$ by "good representatives". Here is an example.
 * Let the modulus be $13$. Then $\overline{132 + 269} = \overline{2 + 9} = \overline{11}$.
 * Let the modulus be $7$. Then $\overline{764 + 86} = \overline{1 + 2} = \overline{3}$.

The result also allows us to make the following definition: Such a definition would not even make sense, without the previous result! For practice, add the following residues:
 * Define $\bar a + \bar b$ to be $\overline{a + b}$.
 * $\bar 2 + \bar 6$, modulo $7$.
 * $\overline{12} + \overline{13}$, modulo $15$.
 * $\overline{103} + \overline{23}$, modulo $10$.

Subtraction and multiplication are similarly "well-defined". Namely, if $\bar a = \bar a'$ and $\bar b = \bar b'$, modulo $m$, then: Proofs can be found at: State/Arithmetic of residues is well-defined.
 * $\overline{a - b} = \overline{a' - b'}$, modulo $m$.
 * $\overline{a \cdot b} = \overline{a' \cdot b'}$, modulo $m$.

This has great impact on arithmetic, if we care about remainders. For example, consider the following problem: We can answer this question by "working mod $7$". Indeed, if we care only about remainders, then we want to find a good representative for: $$\overline{ 50 \cdot 50 \cdot 30 + 23 \cdot 23 \cdot 23 }, \mbox{ modulo } 7.$$ But, in addition and multiplication problems, we can use good representatives for each number occurring. Observe that $\overline{50} = \bar 1$, $\overline{30} = \bar 2$, and $\overline{23} = \bar 2$, modulo $7$. Hence, we find that: $$\overline{ 50 \cdot 50 \cdot 30 + 23 \cdot 23 \cdot 23 } = \overline{1 \cdot 1 \cdot 2 + 2 \cdot 2 \cdot 2} = \overline{2 + 8} = \overline{10} = \bar 3, \mbox{ modulo } 7.$$ Hence, $50^2 \cdot 30 + 23^3$ leaves a remainder $3$ when divided by $7$.
 * What is the remainder when $50 \cdot 50 \cdot 30 + 23 \cdot 23 \cdot 23$ is divided by $7$?

=Practice Problems=

Compute the following, modulo $15$:
 * $\bar 9 + \bar 8 = \overline{17} = \bar 2$.
 * $\bar 3 \cdot \bar 6$.
 * $\bar 6 \cdot \overline{11}$.
 * $\bar 3 - \overline{13}$.
 * $\overline{10} + \overline{10}$.
 * $\bar 2^{10}$.
 * $\bar 2^{1000}$.
 * $\overline{14}^{1956}$

Techniques:
 * Reduce along the way.
 * Use negative numbers when helpful.

Solve the following, modulo 21:
 * $\bar x + \overline{15} = \bar 3$.
 * $\bar x - \bar 2 = \overline{12}$.
 * $\bar 3 \bar x + \bar 2 = \overline{16}$.
 * $\bar 5 \bar x = \bar 1$.