%Illustrates Newton's method with the polynomial x^3-x. Does 8 iterations.

close
clear all
p=[1 0 -1 0];
x=linspace(-2,2,600);
z(1)=input('z(1)=')
q=polyder(p);
hold off
y=polyval(p,x);
plot(x,y,'r')
hold on
for j=1:8
	z(j+1)=z(j)-polyval(p,z(j))/polyval(q,z(j));
	plot(z(j),0,'*')
	pause(3)
end
z'
