bundles / scipy 1.17.1 / scipy / optimize / _optimize / golden
function
scipy.optimize._optimize:golden
Signature
def golden ( func , args = () , brack = None , tol = 1.4901161193847656e-08 , full_output = 0 , maxiter = 5000 ) Summary
Return the minimizer of a function of one variable using the golden section method.
Extended Summary
Given a function of one variable and a possible bracketing interval, return a minimizer of the function isolated to a fractional precision of tol.
Parameters
func: callable func(x,*args)Objective function to minimize.
args: tuple, optionalAdditional arguments (if present), passed to func.
brack: tuple, optionalEither a triple
(xa, xb, xc)wherexa < xb < xcandfunc(xb) < func(xa) and func(xb) < func(xc), or a pair (xa, xb) to be used as initial points for a downhill bracket search (see scipy.optimize.bracket). The minimizerxwill not necessarily satisfyxa <= x <= xb.tol: float, optionalx tolerance stop criterion
full_output: bool, optionalIf True, return optional outputs.
maxiter: intMaximum number of iterations to perform.
Returns
xmin: ndarrayOptimum point.
fval: float(Optional output) Optimum function value.
funcalls: int(Optional output) Number of objective function evaluations made.
Notes
Uses analog of bisection method to decrease the bracketed interval.
Examples
We illustrate the behaviour of the function when `brack` is of size 2 and 3, respectively. In the case where `brack` is of the form (xa,xb), we can see for the given values, the output need not necessarily lie in the range ``(xa, xb)``.def f(x): return (x-1)**2✓
from scipy import optimize
✓minimizer = optimize.golden(f, brack=(1, 2))
✓minimizer
✗res = optimize.golden(f, brack=(-1, 0.5, 2), full_output=True) xmin, fval, funcalls = res f(xmin), fval✓
See also
- minimize_scalar
Interface to minimization algorithms for scalar univariate functions. See the 'Golden'
methodin particular.
Aliases
-
scipy.optimize.golden