Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@benjaminfjones: I think what the OP wanted was how to define this in case of PolynomialRing. Something similar to this (obtained from the documentation):

sage: PolynomialRing(GF(7), 'y', 5)
Multivariate Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7

The answer is a simple modification to what you did, since I don't think two variable indices can be automatically created. But we can just create the same list as you did and provide it as the second argument:

sage: R = PolynomialRing(ZZ, ['x_%d%d' % (i,j) for i in [1..2] for j in [1..2]); R
Multivariate Polynomial Ring in x_11, x_12, x_21, x_22 over Integer Ring
sage: R.inject_variables()
Defining x_11, x_12, x_21, x_22
sage: x_11*x_12 # Now we can use the variables
x_11*x_12
click to hide/show revision 2
closing square bracket was missing.

@benjaminfjones: I think what the OP wanted was how to define this in case of PolynomialRing. Something similar to this (obtained from the documentation):

sage: PolynomialRing(GF(7), 'y', 5)
Multivariate Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7

The answer is a simple modification to what you did, since I don't think two variable indices can be automatically created. But we can just create the same list as you did and provide it as the second argument:

sage: R = PolynomialRing(ZZ, ['x_%d%d' % (i,j) for i in [1..2] for j in [1..2]); [1..2]]); R
Multivariate Polynomial Ring in x_11, x_12, x_21, x_22 over Integer Ring
sage: R.inject_variables()
Defining x_11, x_12, x_21, x_22
sage: x_11*x_12 # Now we can use the variables
x_11*x_12