I was trying to solve an equation for the catenary and wanted to use the Newton-Raphson method.
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)
- Output
-0.05174312094834577
9.262910138898434e-05
-5.298477449974456e-13
0.0
0.0
0.0
The unexpected output I was expecting 1/0.6164729394