我的newtons方法的代码显示了被零除的错误。为什么我会得到这个?你知道吗
from math import *
x = 2
for iteration in range(1,1001):
N0 = .00003
NI =1000
b =.12
xnew = x - ((N0*exp((log1p(NI/N0))*(1-exp(-b*x))))-1)/(b*N0*exp((log1p(NI/N0))*(1-exp(-b*x))-b*x)) # the Newton-Raphson's formula
if abs(xnew - x) < 0.000001:
break
x = xnew
print('The root : %0.5f' % xnew)
print('The number of iterations : %d' % iteration)
w型
目前没有回答
相关问题 更多 >
编程相关推荐