Minimization of scalar function of one variable.
New in version 0.11.0.
Parameters : | fun : callable
bracket : sequence, optional
bounds : sequence, optional
args : tuple, optional
method : str, optional
tol : float, optional
options : dict, optional
|
---|---|
Returns : | res : Result
|
See also
Notes
This section describes the available solvers that can be selected by the ‘method’ parameter. The default method is Brent.
Method Brent uses Brent’s algorithm to find a local minimum. The algorithm uses inverse parabolic interpolation when possible to speed up convergence of the golden section method.
Method Golden uses the golden section search technique. It uses analog of the bisection method to decrease the bracketed interval. It is usually preferable to use the Brent method.
Method Bounded can perform bounded minimization. It uses the Brent method to find a local minimum in the interval x1 < xopt < x2.
Examples
Consider the problem of minimizing the following function.
>>> def f(x):
... return (x - 2) * x * (x + 2)**2
Using the Brent method, we find the local minimum as:
>>> from scipy.optimize import minimize_scalar
>>> res = minimize_scalar(f)
>>> res.x
1.28077640403
Using the Bounded method, we find a local minimum with specified bounds as:
>>> res = minimize_scalar(f, bounds=(-3, -1), method='bounded')
>>> res.x
-2.0000002026