Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to extract exponents from a monomial in a FreeAlgebra

I want something like this, or a way to get the equivalent information:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: m.my_exponents_function()
[(X,1),(Y,1),(X,2)]

or

sage: m.my_factor_function()
[X,Y,X,X]

would be as good or maybe better.

How can I get that information? I've looked over the available methods and can't seem to find anything. This is easy to do with Polynomial Rings.

I guess I could parse the string representation, but shouldn't there be a better way?