feat: newton verfahren mit Schrittweitensteuerung. Now works

This commit is contained in:
Sandro Zimmermann 2026-04-22 22:45:37 +02:00
parent 6ba240a1d5
commit 64a06eab94

View File

@ -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