diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py index 836f473636e0..c37b2c6d623d 100644 --- a/numpy/polynomial/chebyshev.py +++ b/numpy/polynomial/chebyshev.py @@ -1743,7 +1743,8 @@ def chebroots(c): if len(c) == 2: return np.array([-c[0]/c[1]]) - m = chebcompanion(c) + # rotated companion matrix reduces error + m = chebcompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index dcd0a2b4d29a..3870d1054a4a 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -1476,7 +1476,8 @@ def hermroots(c): if len(c) == 2: return np.array([-.5*c[0]/c[1]]) - m = hermcompanion(c) + # rotated companion matrix reduces error + m = hermcompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r diff --git a/numpy/polynomial/hermite_e.py b/numpy/polynomial/hermite_e.py index 48e5eab207f2..b12c0d792c98 100644 --- a/numpy/polynomial/hermite_e.py +++ b/numpy/polynomial/hermite_e.py @@ -1471,7 +1471,8 @@ def hermeroots(c): if len(c) == 2: return np.array([-c[0]/c[1]]) - m = hermecompanion(c) + # rotated companion matrix reduces error + m = hermecompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r diff --git a/numpy/polynomial/laguerre.py b/numpy/polynomial/laguerre.py index 41d15142ae1f..e103dde92f28 100644 --- a/numpy/polynomial/laguerre.py +++ b/numpy/polynomial/laguerre.py @@ -1475,7 +1475,8 @@ def lagroots(c): if len(c) == 2: return np.array([1 + c[0]/c[1]]) - m = lagcompanion(c) + # rotated companion matrix reduces error + m = lagcompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py index d56e2ae2c0e7..9eec9740d9c9 100644 --- a/numpy/polynomial/legendre.py +++ b/numpy/polynomial/legendre.py @@ -1505,7 +1505,8 @@ def legroots(c): if len(c) == 2: return np.array([-c[0]/c[1]]) - m = legcompanion(c) + # rotated companion matrix reduces error + m = legcompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index e3eb7ec5aaaa..afa330502602 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -1428,7 +1428,8 @@ def polyroots(c): if len(c) == 2: return np.array([-c[0]/c[1]]) - m = polycompanion(c) + # rotated companion matrix reduces error + m = polycompanion(c)[::-1,::-1] r = la.eigvals(m) r.sort() return r