Section 10.5 A Practical Use of Primitive Roots
ΒΆx3β‘5 (mod 17)
5xβ‘17 (mod 19)
Subsection 10.5.1 Finding a higher root
ΒΆWith that as introduction, let's examine one way to solve the first congruence using this idea. First, find a primitive root modulo 17. Obviously we could just ask Sage and its builtin commandprimitive_root
, or use Lemma 10.2.3 with trial and error. In the not too distant past, the back of every number theory text had a table of primitive roots!
xxxxxxxxxx
primitive_root(17)
xxxxxxxxxx
a=mod(3,17)
L=[(i,a^i) for i in range(2,17)]
for item in L:
if item[1]!=5:
pretty_print(html(r"$%s^{%s}\equiv %s\not\equiv 5$"%(a,item[0],item[1])))
else:
pretty_print(html(r"$%s^{%s}\equiv %s$ - hooray!"%(a,item[0],item[1])))
break
xxxxxxxxxx
[mod(i,17)^3 for i in range(2,17)]
range
from Sage note 2.1.3. Why do you think we used it here?
Example 10.5.1.
If we change the congruence to a fourth power x4β‘5 (mod 17), the only change is that now we have to solve 4iβ‘5 (mod 16). However, there are no such solutions since gcd(4,16)=4β€5, and we confirm this by seeing that 5 does not show up in this list:
xxxxxxxxxx
[mod(i,17)^4 for i in range(2,17)]
Example 10.5.2.
Finally, let's try solving the closely related x3β‘7 (mod 19). Here, a primitive root is 2, and it turns out that 26β‘7, so we may attempt a solution. We obtain
which definitely does have solutions.
In fact, there are three solutions (2,8,14) to the reduced congruence
so there are three solutions (22,28,214) to the original congruence. Let's check this:
xxxxxxxxxx
a = mod(2,19)
[(a^b)^3 for b in [2, 8, 14]]
Example 10.5.3.
If we try solving x6β‘8 (mod 49), we'll need a primitive root of 49; 3 works. I can find out what power 3i of 3 yields 8:
xxxxxxxxxx
x = mod(primitive_root(49),49)
L=[(i,x^i) for i in range(2,euler_phi(49))]
for item in L:
if item[1]!=8:
pretty_print(html(r"$%s^{%s}\equiv %s\not\equiv 8$"%(x,item[0],item[1])))
else:
pretty_print(html(r"$%s^{%s}\equiv %s$ - hooray!"%(x,item[0],item[1])))
break
Looks like it's 336. So we write x=3i for some as yet unknown i, and get
which gives us
which itself reduces to
So i=6,13,20,27,34,41 all work, which means that x=3iβ‘43,10,16,6,39,33 all should work.
xxxxxxxxxx
[mod(d,49)^6 for d in [43,10,16,6,39,33]]
Subsection 10.5.2 Discrete logarithms
ΒΆSimilarly, we can try to solve logarithmic examples likeExample 10.5.4.
Let's solve 5xβ‘17 (mod 19). As we noted in Example 10.5.2, a primitive root modulo 19 is 2, and we can check that 5β‘216 (mod 19) and 17β‘210 (mod 19). Then, replacing these, we see that
yields
Since each of the numbers in this latter congruence is even, we can reduce this to 8xβ‘5 (mod 9), which further reduces to the easy-to-solve βxβ‘5 (mod 9).
Taking xβ‘β5β‘4, and keeping in mind the original modulus of 18, that suggests that we could let xβ‘4,13 in solving the original congruence. And indeed
as desired:
xxxxxxxxxx
mod(5,19)^13, mod(5,19)^4
Sage note 10.5.5. Reminder on equality.
To check whether two things are equal, remember that you can just use ==
with the two expressions and see if you get True
or False
.
Example 10.5.6.
Let's try to solve 16xβ‘13 (mod 19).
Again, 2 is a primitive root of 19, and obviously 16=24. It might look harder to represent 13; of course we could do it with the computer, but note that 13+19=32=25. Sometimes we really can do them by hand!
Thus our congruence becomes
which yields
However, since gcd(4,18)=2β€5, by Proposition 5.1.1 this latter congruence has no solutions, so neither does the original congruence. (It turns out that 16 has only order 9 as an element of U19, and evidently 13 is not one of the elements in the subgroup generated by 16.)