This is a version of the function in Numerical Recipes. It is initialized with a function value and gradient, and it does a series of quadratic searches until a convergence criterion is reached. This version includes code for display the progress of iteration for debugging purposes.
lnsrch(xold, fold, g, p, func, dataList, stpmax, itermax=20, TOLX=1e-10, dbglev=0)
The current parameter vector value.
The current function value.
The current gradient vector.
The current search direction vector.
The name of the function being optimized.
A list object containing objects specifying the function to be minimized.
The maximum step size.
The maximum number of iterations. Default 20
Convergence criterion.
The level of output. 0: no output; 1: function and slope at each iteration. 2 and above: also results within iteration.
A named list containing:
The parameter vector at the final minimum.
A boolean value indicating that problems were encountered.
Press, W. H., Taukolsky, S. A., Vetterline, W. T. and Flannery, B. P. (2020) Numerical Recipes, Third Edition, Cambridge