Ask Your Question

Revision history [back]

I guess symbolic expressions do not have this feature. However, for polynomial rings, the order of the monomials has some importance (e.g. in the computation of a Groebner basis). Hence, you could transform your symbolic expression into a polynomial belonging to some polynomial ring with an appropriate ordering. Note that since ordering of monomials usually matters for multivariate polynomial rings, we have to construct a multivariate polynomial rings with one variable instead of an univeriate polynomial ring. Here is how:

sage: z = SR.var('z')
sage: s =2*z^3 + z^2 + z
sage: s
2*z^3 + z^2 + z
sage: s.parent()
Symbolic Ring

sage: R.<z>=PolynomialRing(ZZ,1,order='neglex')
sage: R(s)
z + z^2 + 2*z^3
sage: R(s).parent()
Multivariate Polynomial Ring in z over Integer Ring

I guess symbolic expressions do not have this feature. However, for polynomial rings, the order of the monomials has some importance (e.g. in the computation of a Groebner basis). Hence, you could transform your symbolic expression into a polynomial belonging to some polynomial ring with an appropriate ordering. Note that since ordering of monomials usually matters for multivariate polynomial rings, we have to construct a multivariate polynomial rings with one variable instead of an univeriate polynomial ring. Here is how:

sage: z = SR.var('z')
sage: s =2*z^3 + z^2 + z
sage: s
2*z^3 + z^2 + z
sage: s.parent()
Symbolic Ring

sage: R.<z>=PolynomialRing(ZZ,1,order='neglex')
sage: R(s)
z + z^2 + 2*z^3
sage: R(s).parent()
Multivariate Polynomial Ring in z over Integer Ring

To see which orders are available, you can do:

sage: sage.rings.polynomial.term_order?