function data = studyFunc(f,tstep,x0,h0,N)
% studyFunc runs the VarStep algorithm with tolerances 2^-i, i=1..N
% it displays the endpoints, the number of evaluations of f and 
% the local estimate of the order of convergence
% INPUT: Function, interval of integration, intial value, initial step, and orders of tolerance
% OUTPUT: Matrix containing the tolerances, the resulting endpoints, the local rates of convergence
% that maximum step size and the number of evaluations of the differential equation in the computation

% Generate initial vectors
tol=2.^-(1:N)';
data(:,1)=(1:N)';


warning off;

for i = 1:N

[t x n]=VarStep(f,tstep,x0,h0,tol(i));
data(i,2)=x(end);
data(i,4)=max(t(2:length(t))-t(1:length(t)-1));
data(i,5)=n;

if(i<3)
    disp([data(i,2),0,n]);
else
    disp([data(i,2), (log( abs( (data(i-1,2)-data(i-2,2))/(data(i,2)-data(i-1,2))) ) )/log(2), n]);
end;
    
end;

% Put zeros into output matrix for first two iterations of the local estimate of
% the order of convergence since it takes three iterations to compute

data(:,3)=zeros(N,1);
data(3:N,3)=orderErr(data(:,2));
warning on;