我试图求解悬链线方程,并想使用 Newton-Raphson 方法。
from math import sinh, cosh
y = 0.4 #Has taken to initiate the iteration.
k = 3/2
for _ in range(5): #Iterations for Newton-Raphson Method
y = y - (sinh(y)-y*k)/(cosh(y)-k)
print(y)
print(y)
- 输出
-0.05174312094834577
9.262910138898434e-05
-5.298477449974456e-13
0.0
0.0
0.0
我期待的意外输出1/0.6164729394