You are on page 1of 1

clear

close
clc

x0 = 0;
es = 0.001;
imax = 50;
xr = x0;
iter = 0;
ea = 100;

for i=1:imax
xro = xr;
xr =(xro^2+2*xro-6);
x(i)=xr;
iter = iter + 1;
if xr ~= 0
ea=abs((xr-xro)/xr*100);
end
if ea < es
break;
end
end

You might also like