function velRatio = integrateRG2(ka,N,beta0)
beta = NaN(N+1,2);
beta(1,:) = beta0;
dt = 2*pi/N;
t = (0:N)*dt;
for n = 1:N
  betaMid    = beta(n,:) +vel(ka*beta(n,:),t(n))*dt/2;
  tMid       = t(n)+dt/2;
  beta(n+1,:)= beta(n,:) +vel(ka*betaMid,tMid)*dt;
end
figure(1)
plot(beta(:,1),beta(:,2))
axis equal
texText('$r_x/a$','x')
texText('$r_z/a$','y')
texText(sprintf('$ka = %0.3f$',ka),'t')
dBeta = beta(end,1)-beta(1,1);
velRatio = ka*dBeta/(2*pi);
end

function u = vel(ab,t)
    x = ab(1)-t;
    z = ab(2);
    u = exp(z)*[-sin(x),cos(x)];
end