created Script for Vereinfachtes Newton Verfahren
This commit is contained in:
parent
ea8547fcfc
commit
3367c775b9
|
@ -15,9 +15,11 @@ def f_diff(x):
|
||||||
def newtonStep(x0, function, function_diff):
|
def newtonStep(x0, function, function_diff):
|
||||||
return x0 - (function(x0)) / (function_diff(x0))
|
return x0 - (function(x0)) / (function_diff(x0))
|
||||||
|
|
||||||
|
def simpleNewtonStep(x0, function, function_diff_x0):
|
||||||
|
return x0 - ((function(x0)) / (function_diff_x0))
|
||||||
|
|
||||||
def newton(x0, iterations, function, function_diff):
|
def newton(x0, iterations, function, function_diff):
|
||||||
|
print("Newton Verfahren:")
|
||||||
x = []
|
x = []
|
||||||
x.append(x0)
|
x.append(x0)
|
||||||
print("x" + str(0) + ":", str(x[0]))
|
print("x" + str(0) + ":", str(x[0]))
|
||||||
|
@ -32,3 +34,4 @@ def newton(x0, iterations, function, function_diff):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
newton(x0=2, iterations=4, function=f, function_diff=f_diff)
|
newton(x0=2, iterations=4, function=f, function_diff=f_diff)
|
||||||
|
simpleNewton(x0=0.5, iterations=4, function=f, function_diff=f_diff)
|
Loading…
Reference in New Issue