%example of Newton's method in 2D with 
%the function F(x1,x2) = (x1*x2+1,x1+x2)

n = 10;            %number of iterations
x = [1.5;2];       %initial guess
                   %the components of x must be different; 
                   %otherwise the matrix A below is singular

for i=1:n
    A = [x(2),x(1);1,1];             %A = F'(x)
    b = [x(1)*x(2)+1;x(1)+x(2)];     %b = F(x)
    z = linsolve(A,b);               %solves using LU factorization
    x = x-z;
end

disp('estimate of the root is...')
x
    

