Skip to content

Commit d55491a

Browse files
authored
Update newton_method.py
1 parent 8e20e61 commit d55491a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: arithmetic_analysis/newton_method.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ def newton(function: RealFunc, derivative: RealFunc, starting_int: int,) -> floa
2727
...
2828
ZeroDivisionError: Could not find root
2929
"""
30-
prev_guess: float = starting_int
30+
prev_guess float(starting_int)
3131
while True:
3232
try:
33-
next_guess: float = prev_guess - function(prev_guess) / derivative(
34-
prev_guess
35-
)
33+
next_guess = prev_guess - function(prev_guess) / derivative(prev_guess)
3634
except ZeroDivisionError:
3735
raise ZeroDivisionError("Could not find root")
38-
3936
if abs(prev_guess - next_guess) < 10 ** -5:
4037
return next_guess
4138
prev_guess = next_guess

0 commit comments

Comments
 (0)