I am implementing an algorithm, and in it I need to get a factor polynomial f (x) = p (x) q (x) with p and q relatively simple. I can use, of course, sympy.factor, but I would like to build a function that returns, possibly, a list of factors as a result of sympy.factor.
For instance,
x = sympy.Symbol('x')
y = sympy.Symbol('y')
g = sympy.Poly(y**4 + x*y**3 + y**2 + x*y, y)
sympy.factor(g)
throws out
y*(x + y)*(y**2 + 1)
so maybe I could build a parser that interprets the string and divides it between the brackets, displaying a list of [y, x + y, y * * 2 + 1], but I would like to know: is it easier?
source
share