我試圖求解懸鏈線方程并想使用 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
uj5u.com熱心網友回復:
你的曲線有 3 個根:

您的解決方案 (y = 0) 是一種解決方案。在 1.622 有一個正解,在 -1.622 有一個對稱的負解。
如果你不知道你的公式,最好是實際查看它(如果可能;在這里很容易做到),以獲得一些洞察力。
此外,Newton-Raphson 的結果,即根,將取決于您的起點,以及它如何向根收斂(大跳躍或小跳躍,取決于函式和導數值)。請注意這一點。
相關:https : //math.stackexchange.com/questions/3472880/solving-sinh-x-kx
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/312881.html
