Ask Your Question

Revision history [back]

Yep, see the coefficients() method:

...
sage: g = f^3
sage: g.coefficients() 
[b2^3, 3*b1*b2^2, a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2, 2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2, 2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2, 2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1, 2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2]

Yep, see the coefficients() method:

...
sage: g = f^3
sage: g.coefficients() 
[b2^3, 3*b1*b2^2, a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2, 2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2, 2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2, 2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1, 2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2]

--- edit

Sorry, I answered the wrong question. If you want to simplify the coefficients, you can map the simplify function over your list:

sage: g = f^3
sage: map(simplify, g.coefficients())
[b2^3,
 3*b1*b2^2,
 a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2,
 2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2,
 2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2,
 2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1,
 2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2]

But, if you look at the resulting list you'll see that it's identical to g.coefficients(), so the coefficients are "simplified". Maybe what you really want is to expand the coefficients (which is less simple that the factored form by some definition):

sage: map(expand, g.coefficients())
[b2^3,
 3*b1*b2^2,
 3*a0*b2^2 + 3*b1^2*b2,
 6*a0*b1*b2 + 3*a1*b2^2 + b1^3,
 3*a0^2*b2 + 3*a0*b1^2 + 6*a1*b1*b2 + 3*a2*b2^2,
 3*a0^2*b1 + 6*a0*a1*b2 + 3*a1*b1^2 + 6*a2*b1*b2 + 3*a3*b2^2,
 a0^3 + 6*a0*a1*b1 + 6*a0*a2*b2 + 3*a1^2*b2 + 3*a2*b1^2 + 6*a3*b1*b2 + 3*a4*b2^2]

If you're curious about other powerful list operations, check out map, reduce, and filter here.