Home > Net >  How do you convert a list of coefficients to a polynomial in NumPy?
How do you convert a list of coefficients to a polynomial in NumPy?

Time:06-05

Let's say I have a list of coefficients [1,2,3]. How do I convert this to x^3 2x^2 3 or something similar in NumPy? Is it even possible?

CodePudding user response:

As described in the docs, which I recommend reading:

>>> p1 = np.polynomial.Polynomial([3, 2, 1])
>>> p1
Polynomial([3., 2., 1.], domain=[-1,  1], window=[-1,  1])
>>> p1(0)
3.0

Note that the order of coefficients is reversed.

  • Related