Ask Your Question
0

irreducible polynomial code

asked 2016-08-03 16:51:19 +0100

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-08-03 16:57:22 +0100

vdelecroix gravatar image

updated 2016-08-03 17:32:09 +0100

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
edit flag offensive delete link more

Comments

thank a lot sir

santoshi gravatar imagesantoshi ( 2016-08-06 19:21:41 +0100 )edit

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 ( 2016-08-06 19:29:40 +0100 )edit

[ 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 ( 2017-03-05 19:56:43 +0100 )edit

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: 2016-08-03 16:51:19 +0100

Seen: 679 times

Last updated: Aug 03 '16