Ask Your Question
1

Help with matrices over multivariable polynomial ring

asked 2016-05-03 20:04:31 +0100

Mrotsliah gravatar image

I want to work with matrices over a multivariable polynomial ring. I want the matrix

[x0^2,x1^2,x2^2]
[x0^4,x1^4,x2^4]
[x0^8,x1^8,x2^8]

so I can take the determinate of it. I have

R = PolynomialRing(GF(2), 3, 'x')

which is a "Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 2". I try

M = MatrixSpace(R,3,3,sparse=True)

which is the "Full MatrixSpace of 3 by 3 sparse matrices over Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 2". I am not even sure what "sparse" is.

Then I try

A = M([x0^2,x1^2,x2^2, x0^4,x1^4,x2^4, x0^8,x1^8,x2^8])
or
A = M([[x0^2,x1^2,x2^2], [x0^4,x1^4,x2^4], [x0^8,x1^8,x2^8]])

And it says "name 'x0' is not defined"

I have looked for examples in the Sage documentation, but I just can get Sage to make the matrix above.

Eventually, I want to do arbitrate number of variables and arbitrary n-by-n matrices.

Thank you for your help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-05-04 00:11:02 +0100

castor gravatar image

You can define a function to do the same for arbitrary $n$ (I am just guessing the shape of your matrices)

def MultiMatrix(n):
      R = PolynomialRing(GF(2), n, 'x')
      M = MatrixSpace(R,n,n)
      return M([[R.gen(k)^(2^l) for k in [0..n-1]] for l in [1..n]])

Then we have

MultiMatrix(3)
[x0^2 x1^2 x2^2]
[x0^4 x1^4 x2^4]
[x0^8 x1^8 x2^8]

and

MultiMatrix(4)
[ x0^2  x1^2  x2^2  x3^2]
[ x0^4  x1^4  x2^4  x3^4]
[ x0^8  x1^8  x2^8  x3^8]
[x0^16 x1^16 x2^16 x3^16].
edit flag offensive delete link more
0

answered 2016-05-04 01:01:32 +0100

tmonteil gravatar image

When you write:

sage: R = PolynomialRing(GF(2), 3, 'x')

You define a polynomial ring with indeterminates x0, x1, x2:

sage: R
Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 2
sage: R.gens()
(x0, x1, x2)

When you write:

sage: x0

You ask for the value of the Python name x0, which is not defined.

You can define the Python names a,b,c to point to the 3 indeterminates x0, x1, x2:

sage: a,b,c = R.gens()
sage: a
x0
sage: a^2+b
x0^2 + x1

If you want each Python name xi to automatically point to the polynomial indeterminate xi, you can use the inject_variables method:

sage: R.inject_variables()
Defining x0, x1, x2

Then you can define your matrix:

sage: A = M([x0^2,x1^2,x2^2, x0^4,x1^4,x2^4, x0^8,x1^8,x2^8])
sage: A
[x0^2 x1^2 x2^2]
[x0^4 x1^4 x2^4]
[x0^8 x1^8 x2^8]
edit flag offensive delete link more

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-05-03 20:04:31 +0100

Seen: 805 times

Last updated: May 04 '16