We know how to do arithmetic operations -- addition and multiplication -- modulo some fixed positive integer. If this integer is a prime number, modular multiplication shows some non-obvious properties, having very practical applications -- in fact, secure communications today heavily rely on these properties. Let's see what they are.
Modular arithmetic: a brief recap
Firstly, let's recall that when doing arithmetic operations modulo , we replace all integers with their residues (in other words, the remainders obtained when we divide these integers by ). The set of these residues is, in fact, a range . But, to avoid confusion between usual operations and modular ones, we write the residues with a line over them:
Now, if we fix some (let ), we can write simply
instead of Of course, the "overlined" notation works only if we explicitly indicate .
We have already seen that is a group with respect to modular addition. The addition operation is associative, is a neutral element, and is an additive inverse for . Note that the group properties hold for any positive -- even for , although in this case is a trivial group containing only one element .
The group of units modulo m
But do the group properties hold when we consider with the operation of modular multiplication? Let's check! From now on, we will talk about .
We start with a promising observation that modular multiplication is associative. The next property to check is the existence of a neutral element. And here it is: But with the third property -- the existence of inverse for any element -- we encounter a problem. For example, has no inverse, because for any . In general, the residues that are relatively prime to -- and only them -- have inverses (which can be found using Euclid's algorithm).
So let's consider not the whole set , but only its invertible elements, the residues relatively prime to . Such residues are also called units modulo . The set of units will be denoted as . Note that a product of two units and will also be a unit (check that the product of inverses for and will be an inverse for their product!)
For , there are 4 units modulo :
and there is the same number of units modulo :
In fact, is a group with respect to modular multiplication -- the operation is associative, is a neutral element, and every unit has an inverse. For instance, in every element is its own inverse: But this is not a property shared by all groups of units -- you can check that in ,
The group of units modulo a prime
How many elements are there in the group of units ? Of course, the answer depends on . There is a special name and notation for this dependency.
Definition. Euler's phi function (also sometimes known as Euler's totient function) is defined as
That is, is the number of units modulo (or, equivalently, the number of integers in the range relatively prime to ).
There exists a simple general formula for , but for now, we'll only say that
Indeed, every integer in the range , except zero, is relatively prime to :
But in fact, possesses another more interesting property. It is not only a group but a cyclic group.
Definition. A group is called cyclic if there exists an element such that every element is a power of :
The element is called a generator of the cyclic group.
It turns out that for any , the group possesses a generator. Let's look at , for example. The residue will be a generator, since
Computing the powers of , we obtain each of the 10 elements of .
Generators in also have a special name -- they are called primitive roots modulo . and are primitive roots modulo 11. If you know some programming language or just have enough patience, you can try to find all primitive roots modulo 11 (or modulo some larger prime).
Conclusion
In this topic, we went through the basics of Modular arithmetics, here are some of the main points:
- Modular arithmetic operations on the set are addition and multiplication but of residues modulo .
- We showed that the set of invertible residues (units modulo ), is a group with respect to modular multiplication that consists of only those elements of that are prime relative to .
- We noted that is a cyclic group containing elements. Such that where is called a generator of the cyclic group and we can obtain all elements of the group by only changing the power .