Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just define the appropriate polynomial rings so that coefficients does what you want:

sage: A.<a,b,c>=QQ[]
sage: B.<x,y,z>=A[]
sage: ex = 6*x*y^2-4*x*y*z+2*x^2*z
sage: ex.coefficients()
[6, 2, -4]
sage: ex.monomials()
[x*y^2, x^2*z, x*y*z]

Just define the appropriate polynomial rings so that coefficients does what you want:

sage: A.<a,b,c>=QQ[]
sage: B.<x,y,z>=A[]
sage: ex = 6*x*y^2-4*x*y*z+2*x^2*z
(1-a^2)*x*y^2+(a-b^2+c)*x*y*z+(b^2-c^2-a)*x^2*z
sage: ex.coefficients()
[6, 2, -4]
[-a^2 + 1, b^2 - c^2 - a, -b^2 + a + c]
sage: ex.monomials()
[x*y^2, x^2*z, x*y*z]