Fix my silly mistake (no reevaluation of functions)

This commit is contained in:
Basil Feitknecht
2026-01-18 14:36:24 +01:00
committed by GitHub
parent 2765f49320
commit 8d8fc8bf7b

View File

@@ -24,10 +24,8 @@ falls $F(x^*) = 0$ und $F^(x^*) \neq 0$
def newton_method(f, df, x: float, tol=1e-12, maxIter=100): def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
""" Use Newton's method to find zeros, requires derivative of f """ """ Use Newton's method to find zeros, requires derivative of f """
k = 0 k = 0
fx = f(x) while (np.abs(f(x)) > tol and k < maxIter):
dfx = df(x) x -= f(x) / df(x)
while (np.abs(fx) > tol and k < maxIter):
x -= fx / dfx
k += 1 k += 1
return x, k return x, k