%Lahendan Newtoni meetodiga
%def. vektrofun. F, F(z)=(f_(z), f_2(z)),
F=@(z) [z(1).^2+3*z(2)-1;2*z(1)+5*z(2).^2+9];
%def. tuletise
Ftuletis=@(z) [2*z(1),3;2,-10*z(2)];
%leiame alglähendile (-2,-1) vastava lahendi
z=[-2;-1];
i=0;
while (norm(F(z),1))>10^-3
z=z-inv(Ftuletis(z))*F(z);
i=i+1;
end
lahend1N=z
sammud1N=i
%leiame alglähendile (2.5,-1.7) vastava lahendi
z=[2;-1];
i=0;
while (norm(F(z),1))>10^-3
z=z-inv(Ftuletis(z))*F(z);
i=i+1;
end
lahend2N=z
sammud2N=i