Ask Your Question

Revision history [back]

Order of coefficients of univariate polynomial: Bug or Feature?

I obsevered the following behaviour in SageMath 9.3 and 9.5.

sage: P.<x> = PolynomialRing(QQ)
sage: f = 1 + 2 * x + 3 * x**2
sage: f.coefficients()
[1, 2, 3]
sage: f.monomials()
[x^2, x, 1]

So the coefficients of $f$ are sorted in ascending order while the monomials are sorted in descending order. Is this a bug or a feature, because for multivariate polynomials coefficients and monomials are sorted in descending order with respect to the chosen monomial order?

sage: P.<x, y> = PolynomialRing(QQ)
sage: f = 1 + 2 * x + 3 * y + 4 * x * y
sage: f.coefficients()
[4, 2, 3, 1]
sage: f.monomials()
[x*y, x, y, 1]