RK23[f_,u0_,t0_,T_, h0_, tol_]:=(
h=h0;
t=t0;
y={0};
y[[1]]=u0;
i=1;
t={0};
While[t[[i]]<T,
k1=h f[t[[i]],y[[i]]];
k2=h f[t[[i]]+h,y[[i]]+k1];
k3=h f[t[[i]]+(h/2),y[[i]]+(1/4)k1+(1/4)k2];
While[Abs[(1/3)(k1+k2-2k3)]>tol,
h=h((((tol/(Abs[(1/3)(k1+k2-2k3)]))))^(1/3));
If[h<(10^(-5)),Print["The step size is too small. Stiff equation suspected"]; Return[]];
k1=h f[t[[i]],y[[i]]];
k2=h f[t[[i]]+h,y[[i]]+k1];
k3=h f[t[[i]]+(h/2),y[[i]]+(1/4)k1+(1/4)k2];
];
y=Append[y,y[[i]]+(1/6)k1+(1/6)k2+(2/3)k3];
t=Append[t,t[[i]]+h];
h=h((((tol/((1/3)Abs[(k1+k2-2k3)]))))^(1/3));
i++
];
{t,y}
)