def main():
x=1.5
maxit=20
tol=1.0*10**(-4)
result=fun(x,tol,maxit)
print(result)
x=np.arange(1,3,0.01)
y=x
x1=result
plt.plot(x,y,‘b’)
plt.scatter(x1,f(x1),color=‘red’)
plt.xlabel(‘x’)
plt.ylabel(‘y’)
plt.show()
if name ==‘main’:
main()
结果:
iter:1,xk=1.3572088082974532
iter:2,xk=1.3308609588014277
iter:3,xk=1.325883774232348
iter:4,xk=1.324939363401885
iter:5,xk=1.3247600112927027
Tolerance condition is satisfied:0.0001
result= 1.3247259452268871
3 牛顿迭代
3.1 基本思想
牛顿-拉夫逊法提出来的思路就是利用切线是曲线的线性逼近这个思想。太佩服这两个大佬了,简直是顶礼膜拜,他们这脑袋瓜子怎