Section 8.1 The Integers Modulo n
ΒΆSubsection 8.1.1 Definition
ΒΆIt is time for us to finally define what we have been working with for quite a while now.Definition 8.1.1. Integers Modulo n.
For a positive integer n\text{,} the set of equivalence classes of integers modulo n is called the integers modulo n. We denote it \mathbb{Z}_n\text{.} That is,
In the case where n=p is a prime, we usually write \mathbb{Z}_p\text{.} (For those who have had an abstract algebra course, this may be different notation than you have used, but we will consistently use this one.)
xxxxxxxxxx
def addition_table_(n=(11,[2..50])):
P=[[mod(a,n)+mod(b,n) for a in [0..n-1]] for b in [0..n-1]]
pretty_print(html("The addition table for modulus $%s$"%(n,)))
pretty_print(html(table(P, header_row = True, frame = True)))
xxxxxxxxxx
def _(n=(11,[2..50])):
P=[[mod(a,n)*mod(b,n) for a in [0..n-1]] for b in [0..n-1]]
pretty_print(html("The multiplication table for modulus $%s$"%(n,)))
pretty_print(html(table(P, frame=True)))
Subsection 8.1.2 Visualization
ΒΆWhat's even better is to see this visually! I still can't get over how easy it is for me to do this in Sage (and other math programs), such as in the following graphic and interact. It is so cool that my (non-mathematician) wife says, βWhat's that β it's neat!β I wish more people could experience this joy of beauty in math.
xxxxxxxxxx
def multiplication_table_plot(n=(7,[2..50])):
P=matrix_plot(matrix(n,[mod(a,n)*mod(b,n) for a in srange(n) for b in srange(n)]),cmap='jet')
show(P,figsize=7)
Subsection 8.1.3 Inverses
ΒΆLet's focus on the tables/graphs for when n=p a prime. There's at least one interesting observation we can make about them. Every row and every column (other than the ones corresponding to 0) has the entry 1 in it. (That's the deepest nonzero blue in the default coloring.) You can't necessarily say this about other numbers. Let's translate this into notation.Fact 8.1.3.
When p is prime, every nonzero element of \mathbb{Z}_p has an inverse.
Proof.
If \(\gcd(a,n)=1\text{,}\) then \(ax\equiv b\) (mod \(n\)) has a unique solution in \(\mathbb{Z}_n\text{.}\) So if \(n=p\) is prime, then \(\gcd(a,p)=1\) always, except for \(a\equiv 0\text{.}\)
Now we let \(b=1\text{,}\) and finding \(x\) becomes the same as finding an inverse element of \(a\text{.}\) So for prime moduli, every non-zero element has a unique inverse in \(\mathbb{Z}_p\text{.}\)
xxxxxxxxxx
inverse_mod(26,31)
xxxxxxxxxx
c = mod(26,31)
c^-1
xxxxxxxxxx
c = mod(26,31)
c*c^-1