Ask Your Question

Revision history [back]

You can simply use list comprehension:

Setting;

sage: R = PolynomialRing(QQ,3,'x',order='degrevlex') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: R.inject_variables()
Defining x0, x1, x2
sage: I = R.ideal([x0*x1-x2^2,x1*x2]) ; I
Ideal (x0*x1 - x2^2, x1*x2) of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: G = I.groebner_basis() ; G
[x2^3, x0*x1 - x2^2, x1*x2]

Then:

sage: [P.total_degree() for P in G]
[3, 2, 2]

You can simply use list comprehension:

Setting;Setting example:

sage: R = PolynomialRing(QQ,3,'x',order='degrevlex') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: R.inject_variables()
Defining x0, x1, x2
sage: I = R.ideal([x0*x1-x2^2,x1*x2]) ; I
Ideal (x0*x1 - x2^2, x1*x2) of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: G = I.groebner_basis() ; G
[x2^3, x0*x1 - x2^2, x1*x2]

Then:

sage: [P.total_degree() for P in G]
[3, 2, 2]