% Zadatak 7.8: U okolini (3.4, 2.2) naci resenje Njutnovom metodom, tol=1e-4
% x+3logx-y^2=0
% 2x^2-xy-5x+1=0


x=3.4;
y=2.2;
Xs=[x, y]';
tol=1e-4;

F=[x+3*log10(x)-y^2; 2*x^2-x*y-5*x+1];

J=[1+3/(x*log(10)), -2*y; 4*x-y-5, -x];

Xn=Xs-inv(J)*F;

while norm(Xn-Xs)>tol
    Xs=Xn;
    x=Xn(1);
    y=Xn(2);
    F=[x+3*log10(x)-y^2; 2*x^2-x*y-5*x+1];

    J=[1+3/(x*log(10)), -2*y; 4*x-y-5, -x];

    Xn=Xs-inv(J)*F;
end

disp('Resenje je')
disp('x=')
disp(Xn(1))
disp('y=')
disp(Xn(2))