ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 10 Jun 2012 04:46:35 -0500How do I iterate through factors of a monomial?http://ask.sagemath.org/question/9055/how-do-i-iterate-through-factors-of-a-monomial/I am (very naively) trying to implement a certain non-linear map of polynomial rings. I can get the monomials in a polynomial by simply iterating through a polynomial:
>>> R.<x,y,z>=QQ[]
>>> list(x*y^3 + 2*x*y)
[(1, x*y^3), (2, x*y)]
How do I now iterate through the factors of each monomial, i.e. convert x*y^3 into something like [(x, 1), (y, 3)] or even just [x, y, y, y]?
Also, what is the correct way to do the opposite conversion, i.e. [x, y, y, y] to x*y^3?
I hope you won't be offended by such newbie questions. I couldn't find this in any of the tutorials easily (did I miss the right one?) Thank you! IlyaSun, 10 Jun 2012 04:46:35 -0500http://ask.sagemath.org/question/9055/