Modular Arithmetic Part 2

Continuing Where We Left Off

On this page we will discuss some theorems and topics that are slightly more advanced and would likely scare πŸ‘» anyone away.

Remember that equivalence modn is literally an equivalence relation, that means we can actually create equivalence classes of items that are all equivalent to each other. As a mini refresher, lets do the following example

Example: Write all equivalence classes of the integers modulo 5, which is the quotient set of the integers mod5

Let’s write out the quotient set starting with [0] which is all the items equivilent to 0modn. This is [0]={0,5,βˆ’5,10,βˆ’10,15,…} and we can do the same thing with all the other integers [1]={1,6,βˆ’4,11,βˆ’9,16,…}[2]={2,7,βˆ’3,12,βˆ’8,17,…}[3]={3,8,βˆ’2,13,βˆ’7,18,…}[4]={4,9,βˆ’1,14,βˆ’6,19,…}.

This is all possible equivalence classes, which gives us that our quotient set is {[0],[1],[2],[3],[4]}. Notice that, even though we could have picked any item of the set, for all the representatives of our equivalence classes, I selected the smallest non-negative item. In order to explain why this is meaningful lets define some terminology. Normally when we say that 26≑1mod5 we think of 1 as the remainder from division, which is true. However, there is nothing saying that the remainder needs to be smaller than 5 similarly we have 26≑11mod5⟹26=3β‹…5+11 whereas in this case 11 is still a remainder, just not the smallest possible remainder that we can have. In fact there is a term for this remainder1

Definition: Given some value k, if we have that k≑amodn then we say that a is a residue of k modn. If 0≀a<n then we say that a is the least residue of k.

So in our prior example when k=26 and n=5 we have that 11 is a residue and 1 is the least residue. In fact, 26 is actually a residue of itself! Notice that all residues are equivalent and are in the same equivalence class, and similarly we have that items in different equivalence classes are not equal; this all follows from equivalence class properties and partitions.

Definition: The quotient set of all equivalence classes modn is called a complete system of incongruent residues, and is notated as Z/nZ={[0],[1],…,[nβˆ’1]}. Often people will leave out the square brackets and only include the least residue, and in the notation often leave out the first Z writing nZ={0,1,…,nβˆ’1}.

So from our previous example we would have that 5Z={0,1,2,3,4} which is a brief way to write the subsets of integers.

This might seem like a pretty theoretical way of looking at things, but surprisingly modular arithmetic proofs can include the usage of sets of residue classes. Lets prove a small lemma that will provide us some help later.

Lemma: If [x],[y] are two distinct residue classes modn, and gcd(k,n)=1, then β‹…[kx]β‰ [ky]

Before we prove this what is this saying. We are saying that if you have a number that is coprime to n and then multiply the items of two different equivalence classes by said number k, then those two classes will still be different to each other (although they may or may not be the same class as before). We can see in our 5Z example that [0]β‰ [4]. Since gcd(5,7)=1 we know that [7β‹…0]β‰ [7β‹…4] which is [0]β‰ [3]2. Now let us prove this

Proof Let a∈[x] and b∈[y]. We know that aβ‰’bmodn⟹n∀aβˆ’b. As such since gcd(n,k)=1 we know that n∀k(aβˆ’b)⟹n∀kaβˆ’kb⟹kaβ‰’kbmodn

Since ka≒kb they cannot be in the same equivalence class which means the two classes must be distinct.
Q.E.D.

Corollary: If gcd(k,n)=1 and Z/nZ={[a1],[a2],…,[an]}, where aj may not necessarily be the least residue, then Z/nZ={[ka1],[ka2],…,[kan]}. This means that the function f:Z/nZβ†’Z/nZ with f([x])=[kx] is bijective

This theorem is actually insanely easy to prove based on the previous lemma we have. However the hardest part is saying what this theorem is actually doing. Pretty much just take all the equivalence classes of the quotient set, and if you multiply by a number prime to n then you will still have all items of your quotient set. For n=5 and k=7 then Z/5Z={[0],[1],[2],[3],[4]}Z/5Z={[7β‹…0],[7β‹…1],[7β‹…2],[7β‹…3],[7β‹…4]}Z/5Z={[0],[7],[14],[21],[28]}Z/5Z={[0],[2],[4],[1],[3]}.


Prime Residues

Getting all the integers mod some number is cool, but sometimes its useful to work with a specific subset of those integers. There are often certain residues that have special properties that make them desireable to study in bulk. To avoid beating around the bush any longer, we will observe the idea of all residues that are relatively prime to n. Let us consider Z/6Z={[0],[1],[2],[3],[4],[5]}. We will define the set R6 to be the classes of all values relatively prime to 6, so R6={[1],[5]}. All items inside of these classes are also coprime to n by definition since all items in the set are equivalent to each other, none of which share a common factor with n. Also notice that [0]βˆ‰R6, which might seem weird, but observing other members of the class it makes sense. 6∈[0] and gcd(6,6)β‰ 1. In reality gcd(0,6)=6 as 06 has no remainder.

Also, 1 by definition is relatively prime to every number as gcd(1,n)=1 which is the definition of relatively prime. So [1] will always be an element. Similarly, we know3 that gcd(nβˆ’1,n)=1 always, so [nβˆ’1] will also be included in Rn. Lets provide two more examples, however for the sake of brevity I will not write the brackets for equivalence classes, but remember that they are R5={1,2,3,4}R14={1,3,5,9,11,13}

Now I will define the term that we are using here

Definition: The complete system of residues prime to n, RnβŠ‚Z/nZ is the set of all equivalence classes who’s members are coprime to n. In set notation Rn={[x]|[x]∈Z/nZ and gcd(x,n)=1}.

Similar to with the normal system of residues, we have the following theorem about multiplying another relatively prime item

Lemma: Let [x],[y]∈Rn be two different prime residue classes, and let gcd(k,n)=1. Then [kx],[ky]∈Rn are also prime residue classes, and [kx]β‰ [ky]

This is actually the same exact theorem as before, with just a minor additional caveat that if you multiply [kx] then the classes will still be prime residue classes and won’t (somehow) start sharing common factors.

Proof By the previous theorem we already know that [kx]β‰ [ky]. Now we will show that multiplying [kx] will keep it as a prime residue class. Choose some a∈[x], we know that gcd(a,n)=1=gcd(k,n). This is enough to see that gcd(kx,n)=1 as the product will also share no common factors as n by the definition of gcd
Q.E.D.

So if we were to multiply all the classes in R14 by 3 we would have. R14={1,3,5,9,11,13}R14={3β‹…1,3β‹…3,3β‹…5,3β‹…9,3β‹…11,3β‹…13}R14={3,9,15,27,33,39}R14={3,9,1,13,5,11} which is correct!

We can even get the same corollary

Corollary: If gcd(k,n)=1 and Rn={[a1],[a2],…,[ai]}, where aj may not necessarily be the least residue, then Rn={[ka1],[ka2],…,[kai]}. This means that the function f:Rnβ†’Rn with f([x])=[kx] is bijective.

This is also very straightforward using the pigeonhole principle so I will leave it at that.


Practice Problems

Example: Write out 4 residues of 29mod13, including the least residue

Example: Write out the residues prime to 36


  1. Of course it can’t just be remainder that would be too easy obviously β†©οΈŽ

  2. Note that we are doing math on the representative for the sake of brevity, but this can be proven rigorously using mod math β†©οΈŽ

  3. Via a practice problem on the GCD Intro Page β†©οΈŽ

Previous
Next