Local unconstrained search
A smooth one-dimensional objective has a usable bracket but no fixed domain limits.
SciPy · Function
Find a local minimum of a scalar function of one variable. Select a bracketing-based solver or bounded minimization and receive an OptimizeResult.
The function evaluates a one-variable scalar objective and selects a local-minimization algorithm. Use Brent or golden when bracketing is appropriate; use bounded when restricting the search to finite bounds, then inspect the returned OptimizeResult.
scipy.optimize.minimize_scalar(fun, bracket=None, bounds=None, args=(), method=None, tol=None, options=None)| Name | Type | Description |
|---|---|---|
fun | callable | Callable objective that accepts one scalar and returns a scalar. |
bracket | sequence, optional | Optional bracket for Brent or golden: either three bracketing points or two starting points for downhill bracketing. |
bounds | sequence, optional | Optional finite two-item interval required by bounded minimization. |
args | tuple, optional | Extra positional arguments passed to fun. |
method | str or callable, optional | Solver name or callable solver; supported methods include Brent, bounded, and golden. |
tol | float, optional | Termination tolerance. |
options | dict, optional | Dictionary of solver-specific options. |
res: OptimizeResult — the optimization result, including the solution and status information such as success and message.
from scipy.optimize import minimize_scalar
result = minimize_scalar(lambda x: (x - 3) ** 2, method="bounded", bounds=(0, 10))
print(result.x, result.fun, result.success)This finds the minimum of a quadratic within the finite interval from 0 to 10.
A smooth one-dimensional objective has a usable bracket but no fixed domain limits.
The variable must stay between known finite lower and upper limits.
The objective requires additional fixed values during evaluation.
It performs local minimization of a scalar function of one variable and returns an OptimizeResult. The default method is Brent when no method is specified.
Follow-up: How would you impose an interval restriction? Use method='bounded' together with two finite bounds.
Use bracket with Brent or golden. A three-item bracket must satisfy a < b < c and have the middle point lower than both endpoints; two items start a downhill bracket search.
Follow-up: What is the alternative for a known finite search interval? Use bounded minimization with bounds.
The result contains the optimization outcome as an OptimizeResult, including the minimizing value and status information such as success and message. Solver-specific settings can be passed through options.
Follow-up: Where can solver-specific option names be checked? Consult show_options for the selected solver.
scipy.optimize.bracketscipy.optimize.show_optionsscipy.optimize.minimize_scalar(method='brent')scipy.optimize.minimize_scalar(method='bounded')scipy.optimize.minimize_scalar(method='golden')