# Polygen and polygens

The polygens function allows to inject variables for constructing multivariate polynomials, as in:

sage: x, y = polygens(QQ, 'x, y')
sage: type(x)
<type'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>


And then an object like f = x^2*y^2 - 1 will also be a multivariate polynomial. But if we do instead:

sage: x = polygens(QQ, 'x')
sage: type(x)
<type 'tuple'>


We get a tuple!? Are there good reasons? I'd rather expect just a MPolynomial_libsingular, or a univariate polynomial, as with:

sage: x = polygen(QQ, 'x')
sage: type(x)
<type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>

edit retag close merge delete

Sort by ยป oldest newest most voted

polygens(QQ, 'x') returns a tuple consistantly with polygens(QQ, 'x, y') which also returns a tuple. If you want x to get the unique element of that tuple, not the tuple itself, you can do:

sage: x, = polygens(QQ, 'x')


or (equivalently):

sage: (x,) = polygens(QQ, 'x')

more