Lecture 32: Operations on modular numbers

Addition, multiplication, subtraction

Last lecture, we defined modular numbers as equivalence classes of integers. In this lecture, we define basic operations on modular numbers. We will define the operations using representatives; we need to check that the operations are well defined.

Claim: Let \(+ : \mathbb{Z}_m \times \mathbb{Z}_m → \mathbb{Z}_m\) be given by \([a] + [b] ::= [a+b]\). Then \(+\) is well-defined.

Proof: We need to check that if \([a] = [a']\) and \([b] = [b']\) then \([a + b] = [a'+b']\). Assume \([a] = [a']\) and \([b] = [b']\). Then there exist \(c\) and \(d\) such that \(cm = a - a'\) and \(dm = b - b'\). Then \(a + b - (a' + b') = (a - a') + (b - b') = cm + dm = (c+d)m\). Therefore \(m | (a+b)-(a'+b')\), so \([a+b] = [a'+b']\).

Claim: Let the multiplication operation \(\cdot : \mathbb{Z}_m \times \mathbb{Z}_m → \mathbb{Z}_m\) be given by \([a][b] ::= [ab]\). Then \(\cdot\) is well defined.

Proof: Assume \([a] = [a']\) and \([b] = [b']\). Then as in the previous proof, there exist \(c\) and \(d\) with \(cm = a - a'\) and \(dm = b - b'\). We want to show that \(m | ab - a'b'\). We can substitute \(b'\) and \(a'\) in this equation using the assumptions:

\[ \begin{aligned} ab - a'b' &= ab - (a-cm)(b-dm) && \text{since $cm = a-a'$ and $dm = b-b'$} \\ &= ab - ab +(ad+bc)m - dcm^2 = (\cdots)m && \text{algebra} \\ \end{aligned} \]

This shows that \(m | ab-a'b'\) so \(\cdot\) is well-defined.

Claim: The negation operation \(- : \mathbb{Z}_m → \mathbb{Z}_m\) given by \(-[a] ::= [-a]\) is well-defined.

Proof: left as exercise.

Units and division

Definition: If \(x\) and \(y\) are numbers, we say that \(y\) is an inverse of \(x\) if \(xy = 1\). If \(x\) has an inverse, it is called a unit.

Note: This is a very general definition: it applies in any set that has a reasonable definition of multiplication and 1. Sets having operations called \(+\) and \(\cdot\) that satisfy certain conditions are called rings; one can talk about the units of any ring.

Examples: - The only units of \(\mathbb{Z}\) are \(1\) and \(-1\) - All non-zero elements of \(\mathbb{Q}\) and \(\mathbb{R}\) are units - We will see in a later lecture that \([a]\) is a unit of \(\mathbb{Z}_m\) if and only if \(gcd(a,m) = 1\).

As another example, let's consider \(\mathbb{Z}_5\). The elements of \(\mathbb{Z}_5\) are \(\{[0],[1],[2],[3],[4]\}\). \([0]\) is never a unit: there is nothing you can multiply 0 by to get 1. \([1]\) and \([-1]\) are always units, and are always their own inverses. In this case, \([-1] = [4]\). \([2]\) and \([3]\) are also units, because \([2][3] = [6] = [1]\).

In this case, all non-zero elements of \(\mathbb{Z}_5\) were units, but this is not always the case. For example, in \(\mathbb{Z}_6\), the only units are \([1]\) and \([-1] = [5]\). For example, \([2]\) is not a unit, because

Definition: \(φ(m)\) is the number of units of \(\mathbb{Z}_m\). It is called the totient of \(m\) (\(φ\) is also sometimes called the "Euler phi-function").

The above examples show that \(φ(5) = 4\) and \(φ(6) = 2\).

Claim: If \(x \in \mathbb{Z}_m\) has an inverse, then it is unique.

Proof: Suppose \(xy = [1]\) and \(xy' = [1]\). We want to show \(y = y'\). We have \[ y = [1]y = (xy')y = (xy)y' = [1]y' = y' \]

Since the inverse is unique, we can give it a symbol: \(x^{-1}\) is the inverse of \(x\). We define \(x^{-n} ::= (x^{-1})^n\) and note that \(x^nx^{-n} = [1]\).

Exponentiation

We have seen that addition, multiplication, and subtraction of equivalence classes, when defined in the obvious way, are well-defined. This is not true of exponentiation; we show this and fix it in the next lecture.