mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Small fix (#2498)
This commit is contained in:
@ -36,7 +36,7 @@ def newton(
|
|||||||
try:
|
try:
|
||||||
next_guess = prev_guess - function(prev_guess) / derivative(prev_guess)
|
next_guess = prev_guess - function(prev_guess) / derivative(prev_guess)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
raise ZeroDivisionError("Could not find root")
|
raise ZeroDivisionError("Could not find root") from None
|
||||||
if abs(prev_guess - next_guess) < 10 ** -5:
|
if abs(prev_guess - next_guess) < 10 ** -5:
|
||||||
return next_guess
|
return next_guess
|
||||||
prev_guess = next_guess
|
prev_guess = next_guess
|
||||||
|
Reference in New Issue
Block a user