我正在尝试使用mpmath.polyroots
整数系数来查找简单多项式的根,该多项式x*(x-4)**3
在展开时具有 的系数向量[1, -12, 48, 64, 0]
。以下代码失败:
import mpmath
p = [ 1, -12, 48, -64, 0]
print mpmath.polyroots(p,maxsteps=2000)
出现错误:
Traceback (most recent call last):
File "poly.py", line 3, in <module>
print mpmath.polyroots(p,maxsteps=2000)
File "/usr/local/lib/python2.7/dist-packages/mpmath/calculus/polynomials.py", line 188, in polyroots
% maxsteps)
mpmath.libmp.libhyper.NoConvergence: Didn't converge in maxsteps=2000 steps.
增加步数没有帮助。预期的答案显然是[0,4,4,4]
。
如果存在多重性,mpmath 是否无法找到多项式的根?我该如何解决这个问题?