%  This is X1rke.m
%  Example of the use of Rke.  
%  REQUIRES Rke.m and X1rkef.m.

%  Set initial values and tolerances.
x = 0;
y = [1; 1];
xout = 1;
h = 0.1;
tol = 1e-5;
threshold = [0; 1e-5];

%  Integration loop: call Rke repeatedly until xout is reached.
nasteps = 0;
k0 = zeros(2,1);
while x < xout
  if x+h > xout
    h = xout - x;
  end
[x,y,k0,h,flag,step,ycoeff,nasteps] =...
Rke('X1rkef',x,y,k0,h,tol,threshold,nasteps);
     
  if flag ~= 0
    error(['flag = ',int2str(flag),' at x = ',num2str(x),'.']);
  end
end

%  Print the results.
fprintf('At xout = %f\n',xout);
fprintf('The numerical solution is %f %f\n',y(1),y(2));
fprintf('The true solution is      %f %f\n',exp(xout),exp(-xout));

