function x = njutn(fs,a,eps) % program potencijalno divergira, jer nismo postavili uslove konv.
f = sym(fs);
f1 = diff(f);
xp = a;
xn = a+2*eps;
while abs(xn-xp)>eps
   t=xn;
   xn = xp -subs(f,'x',xp)/subs(f1,'x',xp);
   xp = t;
end
x = xn;
end

%primer primene: njutn('x^3+3*x^2+4',-5,0.00001)