From 2765f4932063bf61c061f5736c9ac06cf9d4b0b6 Mon Sep 17 00:00:00 2001 From: Basil Feitknecht <114588139+bfeitknecht@users.noreply.github.com> Date: Sun, 18 Jan 2026 14:30:02 +0100 Subject: [PATCH] Fix Newton's Method The old one incorrectly uses the absolute value of the derivative --- semester3/numcs/parts/03_zeros/04_newton-one-d.tex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/semester3/numcs/parts/03_zeros/04_newton-one-d.tex b/semester3/numcs/parts/03_zeros/04_newton-one-d.tex index 208c701..712e7cb 100644 --- a/semester3/numcs/parts/03_zeros/04_newton-one-d.tex +++ b/semester3/numcs/parts/03_zeros/04_newton-one-d.tex @@ -23,9 +23,12 @@ falls $F(x^*) = 0$ und $F^(x^*) \neq 0$ \begin{code}{python} def newton_method(f, df, x: float, tol=1e-12, maxIter=100): """ Use Newton's method to find zeros, requires derivative of f """ - iter = 0 - while (np.abs(df(x)) > tol and iter < maxIter): - x -= f(x)/df(x); iter += 1 + k = 0 + fx = f(x) + dfx = df(x) + while (np.abs(fx) > tol and k < maxIter): + x -= fx / dfx + k += 1 - return x, iter + return x, k \end{code}