[Numpy-discussion] polynomial fromroots

josef.pktd@gmai... josef.pktd@gmai...
Sat Oct 9 20:47:06 CDT 2010


I'm trying to see whether I can do this without reading the full manual.

Is it intended that fromroots normalizes the highest order term
instead of the lowest?


>>> import numpy.polynomial as poly

>>> p = poly.Polynomial([1, -1.88494037,  0.0178126 ])
>>> p
Polynomial([ 1.        , -1.88494037,  0.0178126 ], [-1.,  1.])
>>> pr = p.roots()
>>> pr
array([   0.53320748,  105.28741219])
>>> poly.Polynomial.fromroots(pr)
Polynomial([  56.14003571, -105.82061967,    1.        ], [-1.,  1.])
>>>

renormalizing

>>> p2 = poly.Polynomial.fromroots(pr)
>>> p2/p2.coef[0]
Polynomial([ 1.        , -1.88494037,  0.0178126 ], [-1.,  1.])


this is, I think what I want to do, invert roots that are
inside/outside the unit circle (whatever that means

>>> pr[np.abs(pr)<1] = 1./pr[np.abs(pr)<1]
>>> p3 = poly.Polynomial.fromroots(pr)
>>> p3/p3.coef[0]
Polynomial([ 1.        , -0.54270529,  0.0050643 ], [-1.,  1.])

Josef


More information about the NumPy-Discussion mailing list