Ask Your Question

Revision history [back]

There is a dedicated function for that

sage: C.product_on_basis(s[1], s[2]*s[1]).monomial_coefficients()
{[ 1  0  0]
 [ 2  0 -1]
 [ 2 -1  0]: 1,
 [ 1  0  0]
 [ 1 -1  1]
 [ 0  0  1]: 1}

There is a dedicated function for that

sage: C.product_on_basis(s[1], s[2]*s[1]).monomial_coefficients()
{[ 1  0  0]
 [ 2  0 -1]
 [ 2 -1  0]: 1,
 [ 1  0  0]
 [ 1 -1  1]
 [ 0  0  1]: 1}

You can also get separately the indices (in the same order as the coefficients) with

sage: C.product_on_basis(s[1], s[2]*s[1]).monomials()
[C[1,2,1], C[1]]