# Revision history [back]

You can simply pass the PolynomialRing object a list of names:

sage: n = 5
sage: xs = [var("x_%d" % i) for i in range(n)]
sage: R = PolynomialRing(ZZ, names=xs)
sage: R
Multivariate Polynomial Ring in x_0, x_1, x_2, x_3, x_4 over Integer Ring
sage: x_4
x_4
sage: x_4 in R
True


In practice you're probably going to want to refer to the generators in some structure and not explicitly (if you decide you want n to be 10, you don't want to have to go around and add up to x_9 everywhere) so R.gens() and R.gens_dict() will come in handy:

sage: R.gens()
(x_0, x_1, x_2, x_3, x_4)
sage: R.gens_dict()
{'x_4': x_4, 'x_2': x_2, 'x_3': x_3, 'x_0': x_0, 'x_1': x_1}