December 2017
Intermediate to advanced
386 pages
10h 42m
English
Let's run this method with this example:
def g(x): return -np.exp(-x)*np.sin(x)f = np.vectorize(lambda x: max(1-x, 2+x))print (good_bracket(f, [-1, -0.5, 1]))print (minimize_scalar(f, bracket=[-1, -0.5, 1], method=parabolic_step))
print (good_bracket(g, [0, 1.2, 1.5]))True
print (minimize_scalar(g, bracket=[0,1.2,1.5], method=parabolic_step))
fun: -0.32239694192707452
nfev: 54
nit: 18
x: 0.78540558549352946
There are two methods already coded for univariate scalar minimization, golden, using a golden section search, and brent, following an algorithm by Brent and Dekker:
minimize_scalar(f, method='brent', bracket=[-1, -0.5, 1]) fun: array(1.5) ...
Read now
Unlock full access