Getting ready
We focus on the search for the local minima of a function f(x) in an interval [a, b] (the search for local maxima can then be regarded as the search of the local minima of the function –f(x) in the same interval). For this task, we have the minimize_scalar routine in the scipy.optimize module. It accepts as obligatory input a univariate function f(x), together with a search method.
Most search methods are based on the idea of bracketing that we used for root finding, although the concept of a bracket is a bit different in this setting. In this case, a good bracket is a triple x < y < z, where f(y) is less than both f(x) and f(z). If the function is continuous, its graph presents a U-shape on a bracket. This guarantees the existence ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access