
% Rosenbruck valley function with analytical gradient of

% If your objective function includes a gradient, use 'LargeScale' = 'on'.

% Otherwise, use 'LargeScale' = 'off'.
clc
clear all
x0 = [-1.2 1.0]'; 
% 1. Nelder-Mead simplex method, fminsearch
options = optimset('LargeScale', 'off', 'MaxFunEvals', 300);

[x1, FunValue1, ExitFlag1, Output1] = fminsearch ('obj2', x0, options)

% 2. BFGS method, fminunc, default option

options = optimset('LargeScale', 'off', 'MaxFunEvals', 300,'GradObj', 'on');

[x2, FunValue2, ExitFlag2, Output2] = fminunc ('obj2', x0, options)

% 3. DFP method, fminunc, HessUpdate5dfp
options = optimset('LargeScale', 'off', 'MaxFunEvals', 300, 'GradObj', 'on', 'HessUpdate', 'dfp');

[x3, FunValue3, ExitFlag3, Output3] = fminunc ('obj2', x0, options)