This commit is contained in:
Dhruv 2020-09-27 18:35:09 +05:30 committed by GitHub
parent 8904af98a1
commit 187e8ccc95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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