Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes. It offers the convenience of not having to define your variables. The number denotes the number of variables in the multivariate polynomial ring.

sage: PolynomialRing(QQ,"x",2)
Multivariate Polynomial Ring in x0, x1 over Rational Field
sage: R = PolynomialRing(QQ,"x",5); R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Rational Field
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4
sage: x0 in R
True

So, now you can programmatically access the variables and play around with them.

sage: xvars = R.gens(); xvars
(x0, x1, x2, x3, x4)
sage: xvars[0] in R
True