x1=-10; %a very rough guess, needed to start the iterations

x2=-8; % for abs(x1-x2)>=dx to be true, to start the ?while? loop

dx=0.0000000000000000001; %accuracy

i=0; %initial number of iterations

while (abs(x1-x2)>=dx) % iterations start here

x1=x2;

y1=x1*x1-3*x1-2; % f(x)

y1der=2*x1-3; %f?(x)

x2=x1-y1/y1der;

i=i+1; % counts the number of iterations

% display(i);

% display(x1);

% display(x2);

end % iterations end here

display(x1);

y1=x1*x1-3*x1-2;

display(y1);