%EXS 3.9
clear, clc, close all;

x=-1:0.01:1;
y1=sqrt(-(2*x.^2+1-2*sqrt(((2*x.^2+1)/2).^2-(x.^4-x.^2))));
y2=x.^2-1/2;

plot(x,y1,x,-y1,x,y2)
hold on
axis equal

X0=[0.34 0.9];
Y0=[-0.4 0.33];

for i = 1:2
   x0=X0(i);
   y0=Y0(i);
   delta=inf;
   while norm(delta)>1e-5
       F=[(x0^2+y0^2/2)^2-x0^2+y0^2/2;
           y0-x0^2+1/2];
       J=[2*(x0^2+y0^2/2)*2*x0-2*x0 2*(x0^2+y0^2/2)*y0+y0;
           -2*x0 1];
       delta=-J\F;
       x0=x0+delta(1);
       y0=y0+delta(2);
   end
   plot(x0,y0,'g*',-x0,y0,'g*')
end