clc ; clear all
warning('off')
r1 = [-0.672 ;-0.6074] ;
r2 = [0 ;0] ;
r3 = [0.672 ;0.6074] ;
x = linspace(-1,1,200) ;
y = linspace(-1,1,200) ;
Xr1 = [] ; Xr2 = [] ; Xr3 = [] ; Xr4 = [] ;
Tolerance = 0.1;
for i = 1:length(x)
for j = 1:length(y)
X0 = [x(i);y(j)] ;
X = NewtonRaphson(X0) ;
if norm(X-r1)<Tolerance
Xr1 = [X0 Xr1] ;
elseif norm(X-r2)<Tolerance
Xr2 = [X0 Xr2] ;
elseif norm(X-r3)<Tolerance
Xr3 = [X0 Xr3] ;
else
Xr4 = [X0 Xr4] ;
end
end
end
display(Xr1)
figure
set(gcf,'color','w')
hold on
plot(Xr1(1,:),Xr1(2,:),'.','color','m') ;
plot(Xr2(1,:),Xr2(2,:),'.','color','b') ;
plot(Xr3(1,:),Xr3(2,:),'.','color','g') ;
plot(Xr4(1,:),Xr4(2,:),'.','color','k') ;
title('Basin of attraction for f(x,y) = 2x^3-y = 0 and 3y^3-x=0')
warning('on')