polykin.math.optimization¤
fmin_brent ¤
fmin_brent(
f: Callable[[float], float],
xa: float,
xb: float,
*,
tolx: float = 1e-06,
maxiter: int = 50,
callback: (
Callable[[int, float, float], tuple[bool, bool]]
| None
) = None
) -> OptimumResult
Find the minimum of a scalar function using Brent's method.
Brent's method is a derivative-free optimization algorithm that combines golden-section search with inverse parabolic interpolation. It maintains a bracketing interval that contains a local minimum and iteratively refines this interval. When the function behaves smoothly, the method attempts a fast parabolic step; otherwise, it falls back to the more robust golden- section step.
References
- Brent, R. P. Algorithms for Minimization without Derivatives; Prentice-Hall: Englewood Cliffs, NJ, 1973.
| PARAMETER | DESCRIPTION |
|---|---|
f
|
Objective function to be minimized.
TYPE:
|
xa
|
Lower bound of the bracketing interval.
TYPE:
|
xb
|
Upper bound of the bracketing interval.
TYPE:
|
tolx
|
Absolute tolerance for
TYPE:
|
maxiter
|
Maximum number of iterations.
TYPE:
|
callback
|
Optional callback with signature
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OptimumResult
|
Dataclass with the results of the optimization. |
See Also
fmin_secant: Derivative-based minimization method using the secant approach.
Examples:
Find the minimum of the function f(x) = x^4 - x + 1.
>>> from polykin.math import fmin_brent
>>> f = lambda x: x**4 - x + 1
>>> fmin_brent(f, -3.0, 3.0)
method: Brent
success: True
message: |Δx| ≤ tolx
nfeval: 14
niter: 14
x: 6.29960526e-01
f: 5.27529606e-01
Source code in src/polykin/math/optimization/brent.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |