clear all x0 = [1.5; 2]; tolf = 1.e-10; tolx = 1.e-10; maxit = 100; % Newton's metjod [x, ithist, iflag] = newtnd( 'ex1', x0, tolf, tolx, maxit ); fprintf('\n Newton''s Method \n ') fprintf(' iter || x ||_2 || F(x) ||_2 || t*s ||_2 t\n ') for i = 1:size(ithist,1) fprintf('%4d &$ %13.8e $&$ %13.8e $&$ %13.8e $&$ %13.8e $\\\\ \n ', ithist(i,:)) end % Finite Difference Newton Method [x, ithist, iflag] = fdnewtnd( 'ex1', x0, tolf, tolx, maxit ); fprintf('\n Finite Difference Newton Method \n ') fprintf(' iter || x ||_2 || F(x) ||_2 || t*s ||_2 t \n ') for i = 1:size(ithist,1) fprintf('%4d &$ %13.8e $&$ %13.8e $&$ %13.8e $&$ %13.8e $\\\\ \n ', ithist(i,:)) end % Shamanskii's Method m = 5; [x, ithist, iflag] = shamnd( 'ex1', x0, m, tolf, tolx, maxit ); fprintf('\n Shamanskii''s Method \n ') fprintf(' iter || x ||_2 || F(x) ||_2 || s ||_2 \n ') for i = 1:size(ithist,1) fprintf('%4d &$ %13.8e $&$ %13.8e $&$ %13.8e $\\\\ \n ', ithist(i,:)) end