function rk2_test1

% Initial conditions
x0 = [1,0];  % State is expected to be a row vector.
t0 = 0;

% Set up for the integration with coarse steps
tfinal = 2*pi;
Nsteps = 10;

% Integrate
[xa,ta] = ode_fixed(@rk2, @Harmonic, x0, t0, tfinal, Nsteps);


% Set up for the integration with fine steps
Nsteps = 100;

% Integrate
[xb,tb] = ode_fixed(@rk2, @Harmonic, x0, t0, tfinal, Nsteps);

% Plots
figure(1)
plot(xa(:,1), xa(:,2), 'r-x',...
     xb(:,1), xb(:,2), 'b-',...
     cos(tb), sin(tb), 'g-' )
legend('10 steps rk2','100 steps rk2','Analytic soln')
xlabel('x(1)','fontsize',18)
ylabel('x(2)','fontsize',18)
axis equal  % isotropy is desirable.
% hold on
% for n = 1:numel(ta)
%    plot([0, xa(n, 1)], [0, xa(n,2)], 'r-')
% end
% hold off

figure(2)
plot (ta, xa(:,2), 'r', tb, xb(:,2), 'b', tb, sin(tb), 'g')
legend('10 steps rk2','100 steps rk2','Analytic soln')
xlabel('t','fontsize',18)
ylabel('x(2)','fontsize',18)
legend('location','southwest')