% Newton for a 2x2 system - an example
% for finding F(t_1, t_2) = 0 
% Math 657 demo 3/14/13
t=[2;2];  % initial guess
itno=7;   % number of Newton iterations
t_newt=zeros(2,itno+1);
t_newt(:,1)=t;
F = [0;0];
for k=1:itno
 F(1)=t(1)^2 + t(2)^2 - 2;
 F(2)= t(1) - t(2);
 J= [2*t(1) 2*t(2); 1 -1];  % Jacobian of F
 s = - J\F;
 t = t +s;
 t_newt(:,k+1)=t;
 norm(t_newt(:,k+1)-t_newt(:,k)) % prints 2-norm error between 
                                 % successive steps to screen
end 
