Ask Your Question
2

Generate a Matrix over a Finite Field with symbolic variables

asked 2017-01-03 16:47:45 +0100

benliu gravatar image

Hi everyone,

I am currently trying to generate a matrix over a finite field of 2 using symbolic variables a,b,c,and d instead of integers. The current problem I am having is that sage tries to convert these variables into integers and do not allow me to generate the matrix.

Inputting: var('a, b, c, d') m = matrix(GF(2), [[a,b], [e,f]]) gives me the error: TypeError: unable to convert a to an integer

Please help, Thank you!!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-01-03 17:43:02 +0100

tmonteil gravatar image

updated 2017-01-03 17:45:59 +0100

A classical trick is not to work in the symbolic ring, but to see your variables as polynomial indeterminates:

sage: R.<a,b,c,d,e,f> = PolynomialRing(GF(2)) ; R
Multivariate Polynomial Ring in a, b, c, d, e, f over Finite Field of size 2
sage: m = matrix(R, [[a,b], [e,f]]) ; m
[a b]
[e f]
sage: m^3
[                  a^3 + b*e*f a^2*b + b^2*e + a*b*f + b*f^2]
[a^2*e + b*e^2 + a*e*f + e*f^2                   a*b*e + f^3]

Alternatively, if you want not only to have 2=0 as before, but also x^2=x for your indeterminates:

sage: R.<a,b,c,d,e,f> = BooleanPolynomialRing() ; R
Boolean PolynomialRing in a, b, c, d, e, f
sage: m = matrix(R, [[a,b], [e,f]]) ; m
[a b]
[e f]
sage: m^3
[              a + b*e*f a*b*f + a*b + b*e + b*f]
[a*e*f + a*e + b*e + e*f               a*b*e + f]
edit flag offensive delete link more

Comments

Thank you so much!!!

benliu gravatar imagebenliu ( 2017-01-06 23:57:15 +0100 )edit

^_^ .

tmonteil gravatar imagetmonteil ( 2017-01-07 16:10:41 +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: 2017-01-03 16:47:45 +0100

Seen: 2,573 times

Last updated: Jan 03 '17