构建一个n阶多项式并找到numpy的根通常是一件容易的事:
import numpy
f = numpy.poly1d([1,2,3])
print numpy.roots(f)
array([-1.+1.41421356j, -1.-1.41421356j])
Run Code Online (Sandbox Code Playgroud)
但是,假设您想要一个类型的多项式:
f(x) = a*(x-x0)**0 + b(x-x0)**1 + ... + n(x-x0)**n
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法来构造一个numpy.poly1d类型函数并找到根?我已经尝试过scipy.fsolve,但它非常不稳定,因为它在很大程度上取决于我在特定情况下选择起始值.
在此先感谢最好的问候rrrak
编辑:将"多边形"(错误)更改为"多项式"(正确)