【发布时间】:2019-11-29 14:20:55
【问题描述】:
我想知道如何在使用牛顿法找到根时输出迭代次数。我正在使用 Scipy 自动计算根,所以我想知道是否有办法知道它需要多少次迭代:
from spicy.optimize import newton
from math import *
f = lambda x : x**2 - sin(x)
ans = newton(f, 1, tol = 1.0E-8, maxiter = 100)
print(round(ans, 8))
【问题讨论】:
标签: python scipy newtons-method numerical-analysis