x0=pi/4 f(x)=2*x-cos(x) df(x)=2+sin(x) function g(x) return x-f(x)/df(x) end x=x0 for n=1:10 global x x=g(x) println("x=$x") end