function t=rk2(x0,y0,h,xf)
%
% integrates an initial value problem using Runge-Kutta 2nd order
%
j=1;
Y(j)=y0;
y(j)=y0;
x(j)=x0;
n=(xf-x0)/h;
for j=2:n
   x(j)=x(j-1)+h;
   t=f(x(j-1),Y(j-1));
   Y(j)=Y(j-1)+.5*h*t+.5*h*f(x(j-1)+h,Y(j-1)+h*t);
end
t=Y(j);
%plot(x,Y)