20 lines
596 B
Matlab
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function [gamma] = gamma_minimized(f, grad_f, x0)
% Calculates the step based on minimizing f(xk γ*∇f(xk))
%
%
% f: Objective function
% grad_f: Gradient of objective function
% x0: Initial (x,y) point
% Define the line search function g(gamma) = f(x0 - gamma * grad)
grad = grad_f(x0(1), x0(2));
g = @(gamma) f(x0(1) - gamma * grad(1), x0(2) - gamma * grad(2));
% Perform line search
gamma = fminbnd(g, 0, 1);
% ToDo: Check if we can use fmin_bisection_der
% from the previous assigment here!
end