Ask Your Question

Revision history [back]

You can get the list of strings representing your variables as follows:

sage: [str(i) for i in Vlist]
['x', 'y']

So you can define your polynomial ring directly, without the <> construction:

sage: P = PolynomialRing(QQ, [str(i) for i in Vlist], order='degrevlex')
sage: P
Multivariate Polynomial Ring in x, y over Rational Field

But now, the Python variables x and y still point to the symbols x and y (that belong to the Symbolic Ring), not the indeterminates x and y that belong to P. For this you can do:

sage: P.inject_variables()
Defining x, y

Then:

sage: f=x^2+y^3
sage: f.lm()
y^3

You can get the list of strings representing your variables as follows:

sage: [str(i) for i in Vlist]
['x', 'y']

So you can define your polynomial ring directly, without the <> construction:

sage: P = PolynomialRing(QQ, [str(i) for i in Vlist], order='degrevlex')
sage: P
Multivariate Polynomial Ring in x, y over Rational Field

But now, the Python variables x and y still point to the symbols x and y (that belong to the Symbolic Ring), not the indeterminates x and y that belong to P. For this you can do:

sage: P.inject_variables()
Defining x, y

Then:

sage: f=x^2+y^3
sage: f.lm()
y^3

By the way, note that if your variables are going to be x0, x1,...,x9 (say), you can use the following construction:

sage: P = PolynomialRing(QQ, 10, 'x', order='degrevlex')
sage: P
Multivariate Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 over Rational Field
sage: P.inject_variables()
Defining x0, x1, x2, x3, x4, x5, x6, x7, x8, x9