function xx = newt(f, x0, eps, maxi) syms x; fp = diff(f,x); stp = 0; for i = 1:maxi ff = subs( f, x, x0); dd = subs(fp, x, x0); x0 = x0 - ff/dd; if abs(ff) < eps stp = 1; break; end end if stp == 1 xx = x0; else xx = 'too many iterations'; end