function newton(x,n) for i=1:n x=x-f(x)/fd(x) endfor endfunction