Ask Your Question
0

irreducible polynomial code

asked 8 years ago

this post is marked as community wiki

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 8 years ago

vdelecroix gravatar image

updated 8 years ago

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
Preview: (hide)
link

Comments

thank a lot sir

santoshi gravatar imagesantoshi ( 8 years ago )

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

santoshi gravatar imagesantoshi ( 8 years ago )

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

dan_fulea gravatar imagedan_fulea ( 8 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 810 times

Last updated: Aug 03 '16