Biography matlab code for newton method method

  • Biography matlab code for newton method method
  • Biography matlab code for newton method method of thinking...

    Search code, repositories, users, issues, pull requests...

    % Define the Objective Function
    f = @(x,y) x.^3 .* exp(-x.^2 - y.^4);
    % Define the Gradient Function
    grad_f = @(x,y) [-3*x.^2 .* exp(-x.^2 - y.^4) + 2*x.^5 .* exp(-x.^2 - y.^4), ...
    -4*y.^3 .* x.^3 .* exp(-x.^2 - y.^4)];
    % Define the Hessian Function
    second_grad_f = @(x, y) [ ...
    -6*x.*exp(-x.^2 - y.^4) + 6*x.^4.*exp(-x.^2 - y.^4) - 4*x.^7.*exp(-x.^2 - y.^4), ...
    -12*y.^3.*x.^2.*exp(-x.^2 - y.^4); ...
    -12*y.^3.*x.^2.*exp(-x.^2 - y.^4), ...
    -12*y.^2.*x.^3.*exp(-x.^2 - y.^4) + 16*y.^6.*x.^3.*exp(-x.^2 - y.^4) ...
    starting_points = [0, 0; -1, -1; 1, 1];
    fprintf('Minimization of f With Newton Method\n');
    for i = 1:size(starting_points, 1)
    [xk, steps, points] = newtonMethod(epsilon, starting_points(i,:), f, gamma, grad_f, second_grad_f);
    fprintf('The lowest point found (%f, %f) with %f value and %d steps \n', xk(1), xk(2), f(xk(1), xk(2)), steps);
    fval = double(f(points(:,1), points(: