Section 10.5 A Practical Use of Primitive Roots
(mod ) (mod )
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 moduloprimitive_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
xxxxxxxxxx
[mod(i,17)^4 for i in range(2,17)]
Example 10.5.2.
Finally, let's try solving the closely related
which definitely does have solutions.
In fact, there are three solutions (
so there are three solutions (
xxxxxxxxxx
a = mod(2,19)
[(a^b)^3 for b in [2, 8, 14]]
Example 10.5.3.
If we try solving
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
which gives us
which itself reduces to
So
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
yields
Since each of the numbers in this latter congruence is even, we can reduce this to
Taking
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
Again,
Thus our congruence becomes
which yields
However, since