# Lecture 13: modular division and exponentiation

• Exponentiation
• [a]n is well defined, n[a] is not.
• Some elements of Zm have inverses
• key terms: inverse, unit, relatively prime/coprime, totient
• key fact: [a]m has an inverse if gcd(a, m) = 1.
• Teaser for next lecture: [a]m[b]ϕ(m) is well defined.

## Multiplication

We quickly did the proof that multiplication in Zm is well defined. It is very similar to the proof that addition of equivalence classes is well defined.

Proof sketch: Assume [a] = [aʹ] and [b] = [bʹ]. Unfolding these definitions gives a = aʹ − mc and b = bʹ − mc. Muliplying these gives ab = aʹbʹ + m(⋯). Rearranging gives us ab − aʹbʹ = m(⋯), so mab − aʹbʹ, and thus [ab] = [aʹbʹ] as required.

## Exponentiation

Raising an equivalence class to an integer power is well defined.

In more detail: exp: Zm × Z → Zm given by exp: [a], n↦[an] is well defined. We could prove this directly, but it follows from the fact that raising a to the n is just multiplying a by itself n times. One can do induction on n; the inductive step just uses the fact that multiplication is well defined.

Raising an integer (or an equivalence class) to the power of an equivalence class is not well defined.

In more detail: exp: Z × ZmZm given by exp: n, [a]↦[na] is not well defined. For example, working mod 5, we would hope that 2[3] = 2[8]. But 23 = 8 and 28 = 256, and [8] = [3] ≠ [1] = [256].

Summary: [a]n is okay, n[a] is not.

We will recover exponentiation next lecture.

## Division

Unlike the integers, you can divide by some of the elements of Zm.

### Definitions

• If S is a set with some (reasonable) notion of multiplication, and if x ∈ S, then an inverse of x is an element y ∈ S such that xy = 1.

• If x has an inverse, then x is called a unit

### Examples

• The units of Z are 1 (its inverse is 1) and  − 1 (its inverse is  − 1).

• The units of R (the real numbers) are all reals except 0.

• The units of Q (the rational numbers) are all rationals except 0

• (if you're familiar with linear algebra) the units in the set of n × n matrices are those with non-zero determinants.

### Units in Zm

Important Fact: [a] ∈ Zm is a unit if and only if gcd(a, m) = 1. This is only true if a and m share no common factors (other than 1). In this case, a and m are said to be coprime or relatively prime.

You are proving this fact on the current homework.

Definition: (Zm) *  is the set of units of Zm.

Examples:

• (Z5) *  = {[1], [2], [3], [4]}. Note that [0] is not a unit. By inspection, the inverse of [1] is [1], the inverse of [4] is [4], and [2] and [3] are inverses of each other.

• More generally, if p is prime, then all non-zero elements of Zp are units, because they can't share a factor with p (since p is prime).

• (Z6) *  = {[1], [5]}. 2, 3, and 4 all share factors with 6, and are thus not units.

• [0] is never a unit. [1] is always a unit. [m − 1] = [ − 1] is also always a unit (and is its own inverse).

Definition: The totient of m, written ϕ(m) is the number of units of Zm.

• By examples above, ϕ(5) = 4, ϕ(6) = 2, and ϕ(p) = p − 1 if p is prime.