function defl_pol_newt_nc % look how short the program looks now, when all the comments removed a=[0 -2 0 1]; n = size(a); n = n(2); roots=[]; for i=1:1:n-1 p_old=2; p=1; while abs(p-p_old)>0.00001 p_old=p; [b0, b]=horners_method(a,p); [c0, c]=horners_method(b,p); p=p-b0/c0; end roots = [roots, p]; [a0, a] = horners_method(a,p); end roots function [b0, b] = horners_method(a, x0); n = size(a); n = n(2); b=[a(n)]; for i=n-1:-1:2 b=[a(i) + b(1)*x0, b] ; end if n>1 b0 = a(1) + b(1)*x0; else b0=a(n); b=[]; end