Extension field arithmetic

asked 2017-05-16 20:08:44 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Code

p=(2^3)
F.<a>=GF(2^3);F.modulus();#F
R.<x>=F[];#R
K.<b>=F.extension(x^2+(a^2+a+1)*x+a^2);#K
R.<z>=PolynomialRing(K) ;#R                 
R1.<a1,b1,a2,b2>=PolynomialRing(K,4) ;#R1 
var('R b z a')
f3=z + (a^2 + a)*b + a + 1
M= f3.operands();M                     
f=M[0];f
new4=f.coefficients(b);new4
M1=new4[0]
R=(M[1],M1[0]+M[1]);R
M2= M1[0]+M[1]

I have written the above code over extension field to separate out terms (a+1) and (a^2+a) , but the code is not working properly . following error is obtained

**AttributeError: 'PolynomialRing_field_with_category.element_class' object has no attribute 'operands',**
edit retag flag offensive close merge delete

Comments

It is very hard to say, both mathematically and/or pythonically, what is the meaning of the message. Please write the code, so that a copy+paste reconstructs the problem. The post can be (hardly) understood: After some edit, the first lines of code are of the shape:

F.<a> = GF( 8 )
print "modulus of F is %s" % F.modulus()
S.<x> = F[];
K.<b> = F.extension( x^2 + (a^2+a+1)*x + a^2 )
R1.<a1,b1,a2,b2> = PolynomialRing( K, 4 )

(Edit as follows: Copy, paste, mark, hit that button with 101 and 010.) And all this is never used again!

Then it can be compiled:

var('R,b,z,a')
f3   = z + (a^2 + a)*b + a + 1
M    = f3.operands()
f    = M[0]

e.g.

sage: f3
(a^2 + a)*b + a + z + 1
sage: M
[(a^2 + a)*b, a, z, 1]

And soon ...(more)

dan_fulea gravatar imagedan_fulea ( 2017-05-16 21:30:08 +0200 )edit

Running this code in the Sage cell does not give an error.

kcrisman gravatar imagekcrisman ( 2017-05-16 22:01:31 +0200 )edit