在 python 中使用 Newton-Raphson 求解双曲函数

Solving hyperbolic function using Newton-Raphson in python

我正在尝试求解悬链线方程,并想使用 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

你的曲线有 3 个根:

您的解决方案 (y = 0) 是一种解决方案。在1.622处有一个正解,在-1.622处有一个对称的负解。

如果您不知道自己的公式,最好是实际查看它(如果可能;在这里很容易做到),以获得一些见解。

此外,Newton-Raphson 的结果,即根,将取决于您的起点,以及它如何收敛到根(大跳跃或小跳跃,取决于函数和导数值)。请注意这一点。


相关:https://math.stackexchange.com/questions/3472880/solving-sinh-x-kx