Newtown Verfahren. Sehr simpel gehalten
This commit is contained in:
parent
1d47fd2ac4
commit
3a997bd099
18
newton_verfahren.py
Normal file
18
newton_verfahren.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
try:
|
||||||
|
x_zero = float(input("X0 eingeben: "))
|
||||||
|
except ValueError as error:
|
||||||
|
print(f"Value {error} is not a number")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
n = 0
|
||||||
|
T = math.e ** x_zero + 2 * x_zero
|
||||||
|
|
||||||
|
while(T>10**-16):
|
||||||
|
f_a2 = math.e ** x_zero + 2
|
||||||
|
x_zero -= T/f_a2
|
||||||
|
T = math.e ** x_zero + 2 * x_zero
|
||||||
|
n += 1
|
||||||
|
print(T)
|
||||||
|
print(n)
|
||||||
Loading…
x
Reference in New Issue
Block a user