Using
from numpy.polynomial import polynomial as f
f.polyfromroots([2,2])
returns
[ 4. -4. 1.]
(the coefficients).
However, I could like it to return the polynomial x^2-4x+4 as an object.
Is there any such module available?
Using
from numpy.polynomial import polynomial as f
f.polyfromroots([2,2])
returns
[ 4. -4. 1.]
(the coefficients).
However, I could like it to return the polynomial x^2-4x+4 as an object.
Is there any such module available?
There's Polynomial:
poly = f.Polynomial(f.polyfromroots([2,2]))
poly(np.array([3, 5]))
# array([1., 9.])