We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8636195 commit 06db343Copy full SHA for 06db343
1 file changed
maths/numerical_analysis/brents_method.py
@@ -12,6 +12,7 @@
12
13
from collections.abc import Callable
14
15
+
16
def brent_method(
17
function: Callable[[float], float],
18
lower: float,
@@ -76,7 +77,11 @@ def brent_method(
76
77
s = upper - fb * (upper - lower) / (fb - fa)
78
79
conditions = [
- not ((3 * lower + upper) / 4 < s < upper if upper > lower else upper < s < (3 * lower + upper) / 4),
80
+ not (
81
+ (3 * lower + upper) / 4 < s < upper
82
+ if upper > lower
83
+ else upper < s < (3 * lower + upper) / 4
84
+ ),
85
mflag and abs(s - upper) >= abs(upper - c) / 2,
86
not mflag and abs(s - upper) >= abs(c - d) / 2,
87
mflag and abs(upper - c) < tolerance,
@@ -111,4 +116,5 @@ def brent_method(
111
116
112
117
if __name__ == "__main__":
113
118
import doctest
114
- doctest.testmod()
119
120
+ doctest.testmod()
0 commit comments