Content deleted Content added
→Generalization to Banach space: remove duplicate equation |
inserted tolerance parameter in Python code: Zero tolerance doesn't work in many cases |
||
Line 101:
<syntaxhighlight lang="python">
from typing import Callable, Iterator
Func = Callable[[float], float, float]
def g(f: Func, x: float, fx: float) -> Func:
Line 113:
return lambda x: f(x + fx) / fx - 1
def steff(f: Func, x: float, tol: float) -> Iterator[float]:
"""Steffenson algorithm for finding roots.
Line 126:
fx = f(x)
gx = g(f, x, fx)(x)
if abs(gx)
break
else:
|