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 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 x^3\equiv 7 (mod 19). Here, a primitive root is 2\text{,} and it turns out that 2^6\equiv 7\text{,} 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 (2^2,2^8,2^{14}) 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 x^6\equiv 8 (mod 49), we'll need a primitive root of 49; 3 works. I can find out what power 3^i of 3 yields 8\text{:}
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 3^{36}\text{.} So we write x=3^i for some as yet unknown i\text{,} and get
which gives us
which itself reduces to
So i=6,13,20,27,34,41 all work, which means that x=3^{i}\equiv 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 5^x\equiv 17\text{ (mod }19)\text{.} As we noted in Example 10.5.2, a primitive root modulo 19 is 2, and we can check that 5\equiv 2^{16}\text{ (mod }19) and 17\equiv 2^{10}\text{ (mod }19)\text{.} Then, replacing these, we see that
yields
Since each of the numbers in this latter congruence is even, we can reduce this to 8x\equiv 5 (mod 9), which further reduces to the easy-to-solve -x\equiv 5 (mod 9).
Taking x\equiv -5\equiv 4\text{,} and keeping in mind the original modulus of 18\text{,} that suggests that we could let x\equiv 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 16^x\equiv 13\text{ (mod }19)\text{.}
Again, 2 is a primitive root of 19\text{,} and obviously 16=2^4\text{.} It might look harder to represent 13\text{;} of course we could do it with the computer, but note that 13+19=32=2^5\text{.} Sometimes we really can do them by hand!
Thus our congruence becomes
which yields
However, since \gcd(4,18)=2\nmid 5\text{,} 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 U_{19}\text{,} and evidently 13 is not one of the elements in the subgroup generated by 16\text{.})