我正在使用 python 和 scipy 编写一些代码,将笛卡尔坐标收敛到开普勒元素,反之亦然。
为了将笛卡尔坐标转换为开普勒坐标,我使用以下表达式:
E = scopt.newton(self.f, self.M, self.df, args=(), tol=10^(-10), maxiter=10000)
与
self.f = lambda x: x-self.e*scipy.sin(x)-self.M
self.df= lambda x: 1-self.e*scipy.cos(x)
运行整个代码时出现错误:
RuntimeError: Failed to converge after 10000 iterations, value is 5.25182613825
如果我以较少的迭代次数 (50) 运行它,我会得到:
RuntimeError: Failed to converge after 50 iterations, value is 5.25182613825
比较这两个值显然收敛了。即使我将容差降低到 10^(-2),我仍然会遇到相同的运行时错误。
有人知道为什么会出现这个错误吗?
请您参考如下方法:
Python 中的求幂运算符是**。使用 tol=10**(-10) 或 1E-10。
^ 是按位异或。
