What is the easiest (and not very slow) way to get a list of monomials of a polynomial. For instance if I have 3x*y+3x^2+y
I want the list [3x*y,3x^2,y]. I can write a code that takes the total degree and walks through all possible monomial not exceeding this degree, but this will not be efficient. I can also convert the polynomial into string and then use python string manipulators that delimit all "+" and "-" and get the monomials, but I think giac has something more efficient.
Edit: I think I found a way that i think would be relatively fast.
Code : Tout sélectionner
from giacpy import giac,part f=giac("3x*y+3*x**2+y") monomials= for i in xrange(len(f)): monomials.append(part(f,i+1))