% Labuppgift 2 a och b, sök nollställen x=0:.05:1.5; y=-1.5:.05:.5; [X,Y] = meshgrid(x,y); F1=X.*exp(X.*Y+0.8)+exp(Y.^2)-3; F2=X.^2-Y.^2-0.5*exp(X.*Y); figure(1) contour(X,Y,F1,[0,0],'r') hold on contour(X,Y,F2,[0,0],'g') G=ginput(2); format long for j=1:2 disp(['Nollställe ', num2str(j)]) A=G(j,:)'; for i=1:10 F=[A(1)*exp(A(1)*A(2)+0.8)+exp(A(2)^2)-3; A(1)^2-A(2)^2-0.5*exp(A(1)*A(2))]; %funktionsmatris J=[exp(A(1)*A(2)+.8)+A(1)*exp(A(1)*A(2)+.8)*A(2) A(1)^2*exp(A(1)*A(2)+.8)+2*A(2)*exp(A(2)^2) 2*A(1)-.5*A(2)*exp(A(1)*A(2)) 2*A(2)-.5*A(1)*exp(A(1)*A(2))]; A=A-J\F; disp([A' norm(F)]) end end figure(2) colormap jet surfc(X,Y,F1) hold on contour(X,Y,F1,[0,0],'r') surfc(X,Y,F2) contour(X,Y,F2,[0,0],'g') axis([0.5 1.5 -1.5 .5 -10 10])