From 64a06eab94f49f2662eb1fb9766dd3c634918ea4 Mon Sep 17 00:00:00 2001 From: zimmersandro Date: Wed, 22 Apr 2026 22:45:37 +0200 Subject: [PATCH] feat: newton verfahren mit Schrittweitensteuerung. Now works --- src/optimierung/schrittweitensteuerung.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/optimierung/schrittweitensteuerung.py b/src/optimierung/schrittweitensteuerung.py index e6bd735..b5576ab 100644 --- a/src/optimierung/schrittweitensteuerung.py +++ b/src/optimierung/schrittweitensteuerung.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt # Parameter N = 200 +C = 0.7 # Schrittweitensteuerungskonstante x = sp.Symbol("x") # Funktion @@ -53,6 +54,7 @@ for x_0 in startwerte: limit = 1000 while np.abs(f_x_prime) > 1e-10 and limit > 0: + x_nm1 = x_i x_i = x_n(x_i, c) if c == 1: n += 1 @@ -62,7 +64,8 @@ for x_0 in startwerte: f_x_second = f_second(x_i) print(f"x_{n}: {x_i}\nc: {c}\nf(x_{n}): {f_x}\nf'(x_{n}): {f_x_prime}\nf''(x_{n}): {f_x_second}\n") if f_x > f_nm1: - c *= 0.7 + c *= C + x_i = x_nm1 else: c = 1 limit -= 1