Section 10.2 A Better Way to Primitive Roots
Subsection 10.2.1 A useful lemma
In order to find primitive roots, we might want a better approach than simply trying every single power ofExample 10.2.1. A motivating example.
Let's take a number
but which elements don't reach the unit before the tenth power?
We know by Theorem 8.3.12 that the order of an element has to divide
-
Let's try this with
so
must be a primitive root. -
What about with
so that seems promising, but
so
cannot be a primitive root modulo eleven (and in fact has order five).
The moral is that we didn't have to check all ten possible powers of
Sage note 10.2.2. How Sage does primitive roots.
As far as I understand, the following strategy is how even Sage tests for finding primitive roots, at least for basic cases. You can check for yourself by looking at the code from the component program, PARI; look for is_gener_expo
and is_gener_Fp
.
Lemma 10.2.3. Testing for Primitive Roots.
An element
Proof.
If \(a\) is in fact a primitive root, then \(\phi(n)\) is the smallest number \(k\) such that \(a^{k}\equiv 1\text{,}\) so certainly for numbers smaller than \(\phi(n)\text{,}\) like \(\phi(n)/q\text{,}\) those powers shouldn't be \(\equiv 1\text{.}\)
On the other hand, if \(a\) isn't a primitive root, then its order \(k\) must be a proper divisor of \(\phi(n)\text{.}\)
Now look at the prime divisors \(q\) of \(\phi(n)/k\text{.}\) For such a divisor,
That means \(\phi(n)/q=k\ell\) and so the power \(\phi(n)/q\) in the statement is actually a multiple of the order \(k\text{.}\) Since \(a^k\equiv 1\text{,}\) then certainly
as well, which completes the proof.
Instead of trying powers which are divisors of
we try powers which are divided by divisors. So becomes and becomes That seems like it's not doing anything other than rewriting, but at least it organizes things differently.Then, instead of having to try all
we use a trick to just need prime divisors (See the proof.)
xxxxxxxxxx
def _(n=(19,[2..100]),a=3):
phi=euler_phi(n)
pds=prime_divisors(phi)
if gcd(a,n)!=1:
pretty_print(html("Make sure $a$ and $n$ are relatively prime!"))
else:
a = mod(a,n)
pretty_print(html("Is $%s$ a primitive root of $%s$?"%(a,n)))
pretty_print(html(r"The prime divisors of $\phi(%s)=%s$ are $%s$"%(n, euler_phi(n), ','.join([str(pd) for pd in pds]))))
pretty_print(html("The powers are "+' and '.join([r'$%s^{%s/%s}\equiv %s$'%(a,phi,pd,a^(phi/pd)) for pd in pds])))
pretty_print(html("And the order of a=$%s$ is <tt>a.multiplicative_order()</tt>=$%s$"%( a , a.multiplicative_order())))
Subsection 10.2.2 Using the test lemma
If you tried various1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |
PR? | No | No |
Proposition 10.2.4.
If
Proof.
Let's think in terms of powers. If \(a^{\phi(n)/q}\not\equiv 1\text{,}\) then
So, as long as \(\phi(n)/q\) is even for all prime divisors of \(\phi(n)\text{,}\) the two powers (the one of \(a\) and the one of \(n-a\)) come to the same thing.
Since \(\phi(n)\) is already assumed to be even, the only possible odd \(\phi(n)/q\) comes from \(q=2\text{,}\) but \(\phi(n)\) is assumed to be divisible by four, so \(\phi(n)/q\) will be even.
Example 10.2.5.
If you did the table at the beginning of this subsection properly, you will note that
On the other hand, from the proof we can see that if