ieuler[f_,{x_,x0_,xn_},{y_,y0_},steps_]:=Block[{xold=x0,yold=y0,outlist={{x0,y0}},x,y,h},h=N[(xn-x0)/steps];
Do[xnew=xold+h;
k1=f/.{x->xold,y->yold};
       k2=f/.{x->xold+h,y->yold+h*k1};
ynew =yold+(h/2)*(k1+ k2);
xold=xnew;
yold=ynew,steps];
Return[ynew]]

impeulertol[f_,{x_,x0_,xn_},{y_,y0_}, tol_]:=Block[{xold=x0,yold=y0,t = tol,outlist={{y0,y0}},x,y,h},steps=1;
y1=ieuler[f,{x,x0,xn},{y,y0},steps/2];
y2=ieuler[f,{x,x0,xn},{y,y0},steps];
While[Abs[y2-y1]> t,
y1=ieuler[f,{x,x0,xn},{y,y0},steps];
steps=2*steps;
y2= ieuler[f,{x,x0,xn},{y,y0},steps];
outlist=Append[outlist,{y1,y2}];
Print[outlist]]]