function r = Newton(g, H, x1)

while 1
    x2 = x1 - inv(H(x1))* g(x1);
    if norm((x1-x2)./x2) < 0.0001 break;
    else x1 = x2;
    end;
end;
r = x2;