% newton2,  Litet ickelinjärt system med Newtons metod     
  clear
   x=[1 0.5]'            % startgissning 1       
 % x=[-3  3]'            % startgissning 2
   iter=0;  dxnorm=1;      
   while dxnorm>0.5e-4 & iter<10
     f=[2*x(1)+x(2)-x(1)*x(2)/2-2
         x(1)+2*x(2)-cos(x(2))/2-1.5];
     J=[2-x(2)/2   1-x(1)/2
          1      2+sin(x(2))/2];
     dx=-J\f;  x=x+dx;  dxnorm=norm(dx,inf)
     iter=iter+1;
   end
   x, iter


