Ask Your Question

Polygen and polygens

asked 2017-03-08 12:24:32 +0200

mforets gravatar image

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

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

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-08 13:47:03 +0200

tmonteil gravatar image

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')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-03-08 12:24:32 +0200

Seen: 1,301 times

Last updated: Mar 08 '17