Order and Primitive Elements

The Order of a Unit

Recall that is the set of units of ; the elements with , i.e. exactly the elements that have a multiplicative inverse. Recall also Euler's Theorem: for any ,

So some power of every unit eventually equals ; it is natural to ask for the first time this happens.

Note

Definition
Given any for , the order of , written , is the smallest positive integer such that in .

Basically, the order of measures how long the powers take to first return to ; after that point the powers just repeat the same cycle forever. Other notation for the order of includes , and .

Be careful: "order" can mean something different depending on context; the order of a finite field sometimes refers to the number of elements in .

It is important to note that the order is only defined for units; if , then no power of ever reaches .

Example. Explain why does not exist.
Notice that , so . Watching the powers directly,

so every power of collapses back to itself and can never equal . More generally, for every , but for any ; so in is impossible. Therefore does not exist; always check that is a unit before talking about its order.

Example. Find the orders of each of the elements in .
We previously found the power table for :

Reading along each row until the first appears,

Notice how every order that shows up ( and ) is a divisor of ; this is not a coincidence, as we are about to see.

Order Divides the Totient

Before the main theorem, we need a small lemma that describes exactly which powers of a unit equal .

Note

Lemma
For any and , we have in if and only if .

Proof. Let .
() Suppose ; then for some , so

() Suppose . By the Division Theorem we can write with , so

But is the smallest positive exponent giving , and ; the only way out is . Hence ; that is, .

Basically, the powers of hit at and nowhere else; the sequence of powers is periodic with period exactly . Since is invertible, (for ) is the same as , which gives a fact worth boxing:

Note

Theorem
For any , we have that .
Proof. By Euler's Theorem, in ; so by the Lemma above, .

This theorem is what makes computing orders fast. Instead of grinding through one power at a time, you only ever need to test the exponents that divide ; the order must be one of those divisors, and it is the smallest one that works.

Example. Find .
First, , so . Testing the divisors in increasing order,

Therefore, .

Example. Find .
Here , so the order is one of . Testing,

Every proper divisor of has failed, so the order is forced to be itself; we do not even need to compute , since Euler's Theorem already guarantees . Therefore, .

Notice how landing on was a bonus; once you see , you immediately know , and that no smaller multiple of can give along that chain. Keep an eye out for ; it saves a lot of arithmetic.

Example. Find in .
From earlier, , so the powers of repeat with period ; we only care about modulo the order:

Therefore, in . You could also have reduced the exponent modulo (Euler), but the order gives the tightest possible reduction. Reduce the exponent modulo the order, never modulo ; tells you nothing about .

Primitive Elements

Since the order of a unit always divides , the largest an order can possibly be is itself. The units that actually achieve this maximum get a special name.

Note

Definition
For any , a primitive element of (or a primitive root modulo ) is any element such that .

Basically, a primitive element is a unit whose powers take the longest possible route before cycling back to ; as we will see shortly, its powers visit every unit along the way.

Example. The primitive elements of are and , since we saw in the order table that .

Example. What are the primitive elements of ?
Here and . Clearly , and

so . Therefore, the only primitive element of is .

Example. What are the primitive elements of ?
Here and . Squaring each unit,

so every unit other than has order , and ; no element has order . Therefore, has no primitive elements. Not every has a primitive element; never assume one exists without checking.

Primitive Elements as Generators

Note

Notation
For any element of a finite group, the (cyclic) group generated by is written and given by .

Note

Theorem
If is a primitive element of , then

Proof. Each power is a product of units and hence a unit, so . Now suppose two of the listed powers were equal; say with . Since is invertible, we can multiply both sides by to get

But is primitive, so ; there is no positive exponent smaller than giving , which is a contradiction. Hence the powers are distinct elements of ; and since only has elements in total, the two sets must be equal.

Basically, a primitive element generates the whole unit group; every single unit mod is some power of . This is exactly why primitive elements are so useful: one element single-handedly produces everything.

For example, the first six powers of either primitive element of sweep out all of ; all six units appear in the rows for and :

Contrast this with , which is not primitive; its powers only ever produce , i.e. .

Multiplication with Primitive Elements

In for any prime , we can use the fact that the powers of a primitive element generate to build a method for multiplication in that is very time-efficient for very large .

Suppose we know is a primitive element of and have recorded the powers of in a lookup table. Then we can multiply two numbers as follows:

  • Use the lookup table to find and such that and in .
  • Calculate .
  • Use the lookup table to find in .

The reason we reduce the exponent mod is that , so by our boxed fact the exponents only matter modulo . The efficiency of this method for large (and ) comes from the fact that the only calculation required is addition, which is computationally much cheaper than multiplication; this is basically how logarithm tables worked before calculators, with playing the role of .

Example. Given the powers of in , find and in .

For : from the table, and , so

For : from the table, and , so

As a sanity check, and ; both answers agree with direct computation.

The lookup table also lets you run this machine in reverse, which is exactly a discrete logarithm.

Example. Find all such that in .
From the table, ; and since the powers of repeat with period , we have if and only if . Therefore, the solutions are exactly .

Example. Solve in .
Every non-zero element of is a power of the primitive element , so write ; from the table . The equation becomes

where we divided the congruence (and the modulus) by , then multiplied by the inverse of mod . So modulo , giving

Checking: and in . Therefore, the solutions are and . Notice how the primitive element converted a nasty power equation into a linear congruence in the exponent; this is the standard trick for equations of the form in .

Which Unit Groups Have Primitive Elements

We saw that has no primitive element, so existence is a genuine question. Fortunately there is a complete answer.

Note

Theorem
The unit group has a primitive element if and only if is equal to , , , , or , where is any odd prime and .

The proof of this one is apparently quite complicated so it's omitted for this course; these questions are just pattern matching against the list. In particular, every prime modulus has a primitive root, which is why the multiplication trick above always works in .

Example. Do each of the following groups of units have primitive elements?

  • : here with , ; so yes. (Indeed works: its powers in are , so .)
  • : here is a product of two distinct odd primes, which is not on the list; so no.
  • : here ; so yes.

Example. Show directly that has no primitive element.
Since is not of any of the allowed forms, the theorem says no; but it is worth seeing this happen by hand. We have and , and

so every unit has order at most . This is the same behaviour as ; everything squares to , so no single element can generate all four units.

Finding a Primitive Element

In general, there is no known efficient method to find a primitive element of . The method we use (inefficient, but fine by hand) is:

  • Choose to be a small element of , taking candidates from the list of numbers that are not pure powers: in order.
  • For each prime divisor of , compute in .
  • If in for all prime divisors of , then (and only then) is a primitive element of .

The reason this works comes back to order dividing the totient. If , then is a proper divisor of ; its prime factorisation must be missing at least one copy of some prime divisor of , so , and hence by the Lemma. Conversely, if is primitive then no exponent smaller than can give . So testing just those few exponents detects primitivity exactly; you never have to check every divisor of .

We skip pure powers like in the candidate list because they can never succeed after their base has failed; if were primitive, then would already have to be (a power of can't cycle for longer than does), so would have been primitive first.

Example. Find a primitive element of .
Here , so the exponents to test are

Candidate :

so fails the test (in fact ) and is not primitive.
Candidate : first note in , then

since . All three tests pass; therefore is a primitive element of . Notice how writing as made every one of these computations painless; working with small negative representatives is almost always faster than working with large positive ones.

Finding All Primitive Elements

Once you have found one primitive element, you get all the others essentially for free.

Note

Theorem
Given is a primitive element of , we have that is a primitive element of if and only if .

Proof. Let and let . Since , the Lemma from earlier gives

Dividing both and by , this is equivalent to ; and since , this happens exactly when . The smallest positive such is , so

which equals precisely when .

The exact same argument works with replaced by the order of any unit, giving a formula that is genuinely worth memorising:

Basically, raising to the power shrinks its cycle by exactly the factor ; if shares no factors with the order, the cycle length is untouched.

Note

Corollary
If is a primitive element of , then the complete set of all primitive elements in is given by .

Note

Corollary
If has a primitive element, then altogether has exactly primitive elements.

This matches everything we have seen so far: has primitive element () and , while has primitive elements ( and ) and .

Example. Given is a primitive element of , find all the primitive elements of .
Here , and ; so by the corollary, the primitive elements are exactly and :

Therefore, the primitive elements of are and ; as a check, elements, as expected.

Example. Find all primitive elements of .
From the previous section, is a primitive element of and . The units mod are the numbers coprime to , and :

which has elements; so there are exactly primitive elements, namely for each . First tabulate the powers of up to :

The exponents up to can be read straight off the table, and since , every later power is just the negative of an earlier one; :

Therefore, the primitive elements of are

and there are of them, as expected.

Example. Construct the full order table for and hence find all primitive elements of .
The lazy way is to compute the whole power table; the smart way is to find one primitive element and then use the boxed formula for .

First, , so the prime divisors of are and and we test the exponents and . Trying :

so is a primitive element of . Its powers are:

Every unit is for exactly one , and

For instance , so ; checking, in . Running through every gives the complete order table:

The primitive elements are the units of order ; therefore the primitive elements of are

and indeed of them. Notice also how every order in the table is a divisor of , and for each divisor of the number of elements of order is exactly :

This pattern holds whenever a primitive element exists; it is a handy sanity check that your order computations are consistent, since the counts have to add up to .