function [gamma] = gamma_minimized(f, ~, dk, xk) % Calculates the step based on minimizing f(xk​− γk*dk) % % % f: Objective function % ~: Gradient function of f - Not used % dk: Current value of selected direction -∇f or -inv{H}*∇f or -inv{H + lI}*∇f % xk: Current point (x,y) % Define the line search function fmin(g) = f(xk - g * dk) fmin = @(g) f(xk) + g * dk; % find g that minimizes fmin e = 0.0001; l = 0.001; [a,b,k,~] = fmin_bisection(fmin, 0.0001, 1, e, l); % g in (0, 1] gamma = 0.5*(a(k) + b(k)); % Define the line search function fmin(g) = f(xk - g * dk) %fmin = @(g) f(xk(1) - gamma * dk(1), xk(2) - gamma * dk(2)); % find g that minimizes fmin %gamma = fminbnd(g, 0, 1); end