December 2017
Intermediate to advanced
386 pages
10h 42m
English
This is how we represent the solution of the Lagrange equation following, this represents the solution of the system:
import numpy as npfrom scipy.interpolate import lagrangefrom scipy.optimize import OptimizeResult, minimize_scalardef good_bracket(func, bracket): a, c, b = bracket return (func(a) > func(c)) and (func(b) > func(c))def parabolic_step(f, args, bracket, **options): stop = False funcalls = 0 niter = 0 while not stop: niter += 1 interpolator = lagrange(np.array(bracket), f(np.array(bracket))) funcalls += 3 a, b, c = interpolator.coeffs d = -0.5*b/a if np.allclose(bracket[1], d): minima = d stop = True elif bracket[1] < d: newbracket = [bracket[1], d, bracket[2]] if good_bracket(f, newbracket): bracket = newbracket ...
Read now
Unlock full access