First time here? Check out the FAQ!

Ask Your Question
1

Polygen and polygens

asked 8 years ago

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)
<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'>
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

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')
Preview: (hide)
link

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

Stats

Asked: 8 years ago

Seen: 1,659 times

Last updated: Mar 08 '17