Skip to content

Commit e3f1eae

Browse files
committed
brents3
1 parent 56d6f97 commit e3f1eae

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

maths/numerical_analysis/brents_method.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def brent_method(
3939
for _ in range(max_iter):
4040
if fb == 0:
4141
return b
42-
if fa != fc and fb != fc:
42+
if fc not in {fa, fb}:
4343
# Inverse quadratic interpolation
4444
s = (
4545
a * fb * fc / ((fa - fb) * (fa - fc)) +
@@ -85,4 +85,4 @@ def brent_method(
8585

8686
if __name__ == "__main__":
8787
from doctest import testmod
88-
testmod()
88+
testmod()

0 commit comments

Comments
 (0)