n=10;T=pi;k=T/n;
t=linspace(0,T,n+1);
u=zeros(1,n+1);
u(1)=1;
for i=1:n
    x=u(i);xold=u(i)+1;
    while abs(x-xold)>1e-8
        %x-xold
        xold=x;
        x=u(i)+k*cos(x);
    end
   u(i+1)=x;
end
plot(t,u)