Is there a way to generate the primitive elements in $GF(p^n)$, in say Sagemath, and perform operations with these elements?

For example, using the irreducible polynomial $p(x)=1+x+x^3$ in $GF(2^3)$, how can i generate these primitive elements and how would I go about adding/multiplying them?

I have looked at the online manual, but can't seem to find what I am looking for. Thank you.

  • $\begingroup$ Sagemath has the .gen() and .multiplicative_generator() methods which return a single primitive element. I don't think it has a simple command to get all the primitive elements of a Galois field. $\endgroup$
    – PM 2Ring
    Sep 2, 2021 at 14:33
  • $\begingroup$ FWIW, a comment to my answer here (to a question on mutually orthogonal latin squares) links to a Sage script that produces MOLS using finite field arithmetic. That script is rather terse, but you might find it helpful. $\endgroup$
    – PM 2Ring
    Sep 2, 2021 at 14:36
  • $\begingroup$ Thank you. Perhaps I should try looking at Octave or GAP. Manually generating these tables, and doing arithmetic is an absolute pain. I will take a look at that script also. $\endgroup$
    – user917000
    Sep 2, 2021 at 14:47
  • $\begingroup$ I think you want to extend $GF(2)$ with your polynomial. Does this question/answer help you? $\endgroup$
    – rickhg12hs
    Sep 3, 2021 at 14:06
  • $\begingroup$ It looks like the Frobenius companion matrix solves the issue. Creating a companion matrix of the irreducible polynomial allows me to add and multiply the elements in GF(2^n) with ease. I suspect it will hold for GF(p^n) - need to confirm still. Thanks again. $\endgroup$
    – user917000
    Sep 14, 2021 at 5:52


You must log in to answer this question.