Lecture 25: Modular Arithmetic

Reminder of facts about integers mod m

Definition: [a] = [b] if a ≡ b(modm) which means m∣(a − b) which means there is some k with a − b = km.

Equivalently, [a] = [b] if and only if a = b + km for some k. We'll use this form several times.

Operations on modular integers

Claim: defining [a] + [b] as [a + b] is well-defined. That is, if [a] = [aʹ] and [b] = [bʹ] then [a + b] = [aʹ + bʹ].

Proof: to start, we'll just choose a different representative of a.

Suppose [a] = [aʹ]. Then a = aʹ + km for some k. Thus a + b = aʹ + km + b = (aʹ + b) + km. Thus [a + b] = [aʹ + b].

Now, suppose [a] = [aʹ] and [b] = [bʹ]. Then we can use the above twice to conclude [a + b] = [aʹ + bʹ]:
[a + b] = [aʹ + b] = [b + aʹ] = [bʹ + aʹ] = [aʹ + bʹ]

Claim: defining [a][b] as [ab] is well defined.

Proof: as above, we'll just choose a different representative for [a] and then use commutativity.

Suppose [a] = [aʹ]. Then a = aʹ + km for some k. So
ab = (aʹ + km)b = aʹb + (kb)m
Thus [ab] = [aʹb].

Claim: defining  − [a] as [ − a] is well defined.

Proof: suppose [a] = [aʹ]. Then a = aʹ + km. Thus  − a =  − aʹ + ( − k)m. Thus [ − a] = [ − aʹ].

Claim: if n is an integer, then defining [a]n as [an] is well defined.

Proof: use induction on n and the fact that multiplication is well defined.

Using these facts for computation

Inverses and units

Exponentiation

Defining n[a] as [na] doesn't work. Counterexample: let m = 5, n = 2, a = 2. Then [a] = [2] = [7], but [22] = [4] and [27] = [128] = [3] ≠ [4].

Totient

The totient of m, written ϕ(m) (pronounced "phi" of m, LaTeX \phi) is the number of units of Zm.

Examples: ϕ(7) = 6, ϕ(4) = 2.

We'll use totient in next lecture to define exponentiation.