Output a primitive element for each field size

16

A primitive element of a finite field is a generator of the multiplicative group of the field. In other words, alpha in F(q) is called a primitive element if it is a primitive q−1th root of unity in F(q). This means that all the non-zero elements of F(q) can be written as alpha^i for some (positive) integer i.

All elements of the field F_{2^k} can be written as polynomials of degree at most k-1 with coefficients that are either 1 or 0. In order to make this complete, your code also needs to output an irreducible polynomial of degree k which defines the field you are using.

The task is write code that outputs a primitive element of F_{2^k} of your choosing for each k = 1 .. 32 in order.

Your output must simply list the k coefficients of the primitive element in any format that you like and then on a separate line the k+1 elements of the irreducible polynomial. Please separate the outputs for each value of k if possible.

Your code may take as long as you like but you must have run it to completion before submitting your answer.

You may not use any builtin or library function which returns primitive elements of a finite field or tests whether an element is primitive.

An example

For k = 1 the only primitive element is 1.

For k = 2 we have F_4. The 4 elements are {0, 1, x, x + 1} so there are two primitive elements x and x + 1. So the code could output

1 1
1 1 1

as the coefficients for example where the second line is the irreducible polynomial which in this case is x^2+x+1 which has coefficients 1 1 1.

user9206

Posted 2017-07-01T16:46:52.063

Reputation:

4Got any examples? – Okx – 2017-07-01T16:49:20.643

1May we also output the polynomials and/or field elements encoded as the bits of an integer we output? – orlp – 2017-07-01T17:57:49.513

@orlp Yes absolutely. – None – 2017-07-01T17:58:15.567

1

I think Pari/GP is the only language that has a built-in for this.

– alephalpha – 2017-07-02T01:57:48.307

Can I use a built-in to test whether a polynomial is primitive?

– alephalpha – 2017-07-02T02:24:57.790

@alephalpha Good question. No please don't. Having said that, if you have a non competing answer. In gp/pari I could add it to the question and use it to produce more examples. – None – 2017-07-02T02:29:33.037

1

@Lembik OK. Try it online!

– alephalpha – 2017-07-02T02:44:43.793

@alephalpha: Macaulay2 has a couple of builtins for this too.

– Not a tree – 2017-07-02T03:13:33.577

…or you can avoid those builtins with something like n->(k=GF 2^n;lift(k_0,ambient k)). – Not a tree – 2017-07-02T03:17:38.590

Your examples are wrong. You say k=1, k=2, but the fields you describe are F_1, F_2, not F_2, F_4. – isaacg – 2017-07-02T04:43:41.047

@isaacg, F_1 would be quite the challenge. – Peter Taylor – 2017-07-02T05:39:06.750

@isaacg I think the examples are OK. F_1 doesn't exist. See https://en.wikipedia.org/wiki/Field_with_one_element

– None – 2017-07-02T09:36:30.720

@Lembik You're right, I misunderstood the challenge – isaacg – 2017-07-02T10:00:42.467

Answers

2

Pari/GP, 114 bytes

Inspired by isaacg's answer in another question.

for(n=1,32,for(i=1,2^n,if(sumdiv(2^n-1,d,Mod(x,f=Mod(Pol(binary(2*2^n-i)),2))^d==1)==1,print([x,lift(f)]);break)))

Try it online!


If built-ins are allowed:

Pari/GP, 61 bytes (non-competing)

for(i=1,32,print([ffprimroot(ffgen(f=ffinit(2,i))),lift(f)]))

Try it online!

alephalpha

Posted 2017-07-01T16:46:52.063

Reputation: 23 988

4

Mathematica, 127 bytes

Do[For[i=2*2^n,PolynomialMod[x^Divisors[2^n-1]+1,i~IntegerDigits~2~FromDigits~x,Modulus->2]~Count~0!=1,i--];Print@{2,i},{n,32}]

Explanation:

If we choose a primitive polynomial as the irreducible polynomial, then \$x\$ is a primitive element. A irreducible polynomial of degree \$n\$ is primitive if and only if it has order \$2^n - 1\$, i.e., it is divisible by \$x^{2^n - 1} - 1\$, but not divisible by any \$x^i - 1\$, where \$i\$ runs through all the proper divisors of \$2^n - 1\$.

Output:

Outputs integers whose bits are the coefficients of the polynomials. For example, \$8589934581\$ is \$111111111111111111111111111110101\$ when written in binary, so it represents the polynomial $$x^{32}+x^{31}+x^{30}+x^{29}+x^{28}+x^{27}+x^{26}+x^{25}+\\x^{24}+x^{23}+x^{22}+x^{21}+x^{20}+x^{19}+x^{18}+x^{17}+\\x^{16}+x^{15}+x^{14}+x^{13}+x^{12}+x^{11}+x^{10}+x^9+\\x^8+x^7+x^6+x^5+x^4+x^2+1$$

{2,3}

{2,7}

{2,13}

{2,25}

{2,61}

{2,115}

{2,253}

{2,501}

{2,1019}

{2,2041}

{2,4073}

{2,8137}

{2,16381}

{2,32743}

{2,65533}

{2,131053}

{2,262127}

{2,524263}

{2,1048531}

{2,2097145}

{2,4194227}

{2,8388589}

{2,16777213}

{2,33554351}

{2,67108849}

{2,134217697}

{2,268435427}

{2,536870805}

{2,1073741801}

{2,2147483533}

{2,4294967287}

{2,8589934581}

alephalpha

Posted 2017-07-01T16:46:52.063

Reputation: 23 988

This is nice. I look forward to the Jelly version :) – None – 2017-07-02T11:21:40.683