mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Small fix (#2498)
This commit is contained in:
parent
8904af98a1
commit
187e8ccc95
@ -36,7 +36,7 @@ def newton(
|
||||
try:
|
||||
next_guess = prev_guess - function(prev_guess) / derivative(prev_guess)
|
||||
except ZeroDivisionError:
|
||||
raise ZeroDivisionError("Could not find root")
|
||||
raise ZeroDivisionError("Could not find root") from None
|
||||
if abs(prev_guess - next_guess) < 10 ** -5:
|
||||
return next_guess
|
||||
prev_guess = next_guess
|
||||
|
Loading…
Reference in New Issue
Block a user