mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 10:50:05 +01:00
Fix my silly mistake (no reevaluation of functions)
This commit is contained in:
@@ -24,10 +24,8 @@ falls $F(x^*) = 0$ und $F^(x^*) \neq 0$
|
|||||||
def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
|
def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
|
||||||
""" Use Newton's method to find zeros, requires derivative of f """
|
""" Use Newton's method to find zeros, requires derivative of f """
|
||||||
k = 0
|
k = 0
|
||||||
fx = f(x)
|
while (np.abs(f(x)) > tol and k < maxIter):
|
||||||
dfx = df(x)
|
x -= f(x) / df(x)
|
||||||
while (np.abs(fx) > tol and k < maxIter):
|
|
||||||
x -= fx / dfx
|
|
||||||
k += 1
|
k += 1
|
||||||
|
|
||||||
return x, k
|
return x, k
|
||||||
|
|||||||
Reference in New Issue
Block a user