1 ep=10^(-8);dx=1;x0=0.5;k=0;
2 while dx>ep
3     k=k+1;
4     x=exp(-x0);
5     dx=abs(x-x0)/(1+abs(x));
6     x0=x;
7 end


关键是4-6句,这就是迭代法的精华部分。