20 lines
596 B
Matlab
20 lines
596 B
Matlab
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
|
||
|