% Given environment clear; % Setup the function under test syms x y; fexpr = x^5 * exp(-x^2 - y^2); title_fun = "$f(x,y) = x^5 \cdot e^{-x^2 - y^2}$"; % Calculate the gradient and Hessian grad_fexpr = gradient(fexpr, [x, y]); % Gradient of f hessian_fexpr = hessian(fexpr, [x, y]); % Hessian of f % Convert symbolic expressions to MATLAB functions fun = matlabFunction(fexpr, 'Vars', [x, y]); % Function grad_fun = matlabFunction(grad_fexpr, 'Vars', [x, y]); % Gradient hessian_fun = matlabFunction(hessian_fexpr, 'Vars', [x, y]); % Hessian % Minimum reference Freference = @(x) x(1).^5 .* exp(-x(1).^2 - x(2).^2); [Xmin, Fmin] = fminsearch(Freference, [-1, -1]); % Amijo globals global amijo_beta; % Step reduction factor in [0.1, 0.5] (typical range: [0.1, 0.8]) global amijo_sigma; % Sufficient decrease constant in [1e-5, 0.1] (typical range: [0.01, 0.3]) %fixed step size globals global gamma_fixed_step global image_width, global image_height; image_width = 960; image_height = 640;