feat: newton verfahren mit Schrittweitensteuerung. Now works
This commit is contained in:
parent
6ba240a1d5
commit
64a06eab94
@ -5,6 +5,7 @@ import matplotlib.pyplot as plt
|
|||||||
|
|
||||||
# Parameter
|
# Parameter
|
||||||
N = 200
|
N = 200
|
||||||
|
C = 0.7 # Schrittweitensteuerungskonstante
|
||||||
x = sp.Symbol("x")
|
x = sp.Symbol("x")
|
||||||
|
|
||||||
# Funktion
|
# Funktion
|
||||||
@ -53,6 +54,7 @@ for x_0 in startwerte:
|
|||||||
limit = 1000
|
limit = 1000
|
||||||
|
|
||||||
while np.abs(f_x_prime) > 1e-10 and limit > 0:
|
while np.abs(f_x_prime) > 1e-10 and limit > 0:
|
||||||
|
x_nm1 = x_i
|
||||||
x_i = x_n(x_i, c)
|
x_i = x_n(x_i, c)
|
||||||
if c == 1:
|
if c == 1:
|
||||||
n += 1
|
n += 1
|
||||||
@ -62,7 +64,8 @@ for x_0 in startwerte:
|
|||||||
f_x_second = f_second(x_i)
|
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")
|
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:
|
if f_x > f_nm1:
|
||||||
c *= 0.7
|
c *= C
|
||||||
|
x_i = x_nm1
|
||||||
else:
|
else:
|
||||||
c = 1
|
c = 1
|
||||||
limit -= 1
|
limit -= 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user