How do I create a polynomial out of a list of coefficients in SymPy?
For example, given a list [1, -2, 1]
I would like to get Poly(x**2 - 2*x + 1)
. I tried looking at the docs but could not find anything close to it.
You could use Poly.from_list
to construct the polynomial:
>>> x = sympy.Symbol('x')
>>> sympy.Poly.from_list([1, -2, 1], gens=x)
Poly(x**2 - 2*x + 1, x, domain='ZZ')