% Sample MATLAB session with Newton's method.
% Download codes
% newton.m and myfunc.m into your directory
% from where your run MATLAB.
%

clear all;
[x,xiter,ithist,iflag] = newton(@myfunc,[1;1]);
'the solution x is'
x
'the iteration history is'
ithist
'iflag is'
iflag
'x value in the 7th iteration is'
xiter{3}

hold on
for i=2:length(ithist)
    plot([xiter{i}(1) xiter{i-1}(1)], [xiter{i}(2) xiter{i-1}(2)],'o-');
end

hold off

