function [ thetaRK, vRK, t, dt ] = ODE2_2RK( tin, tfin, N, theta0, v0, f )
%UNTITLED4 Summary of this function goes here
%   Detailed explanation goes here

t=linspace(tin,tfin,N); dt=t(2)-t(1);
% initial conditions
thetaRK(1)=theta0; vRK(1)=v0;

for i=1:N-1
   thetac(i)=thetaRK(i)+vRK(i)*dt/2;
   vc(i)=vRK(i)+f(thetaRK(i))*dt/2;
   
   thetaRK(i+1)=thetaRK(i)+vc(i)*dt;
   vRK(i+1)=vRK(i)+f(thetac(i))*dt;
end

end

