# irreducible polynomial code This post is a wiki. Anyone with karma >750 is welcome to improve it.

K.<a>=GF(2^3)
A = [0,1,a,a^2,a^3,a^4,a^5,a^6]
for i=0 in [A]
for j=0 in [A]
f(x)=x^2+A[i]x+A[j]
print f(x)


I have written this code to generate irreducible polynomial f(x) by taking different values from A so it is represent A[i] and A[j] but its gives me error.

edit retag close merge delete

Sort by » oldest newest most voted

There are at least 4 problems with your code:

• if you want polynomials, you need to declare x as a variable of a polynomial ring over K
• the syntax "f(x) = something" is only intended for symbolic functions, in your case you should just use standard affectation "f = something"
• implicit multiplication does not work A[i]x is an error you should write A[i]*x
• the syntax of the for loop is wrong

Here is a corrected version

K.<a> = GF(2^3)
x = polygen(K)
for ai in K:
for aj in K:
f = x^2 + ai*x + aj
print f

more

sir thanks for your help the above code gives me all the second degree polynomial for field GF(2^3). now i want to find out from that irreducible polynomial please help

[ x^2 + cx + d for c in K for d in K if ( x^2 + cx + d ) . is_irreducible() ] # does the job