%MATLAB version of FORTRAN program for Example 8.2 on pages 371f of conte/deboor
% DVERK is not a program in MATLAB; so, I used ode45 instead. Information
% about ode45 can be obtained by  help ode45.
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
global FCN

disp('Runge-Kutta45')
disp('      X        YX             FCN EVALS')

X = 1; Y = 1; TOL = 1e-7; 
for k=1:4
    XEND = 1 + k/4; FCN = 0;
    [XOUT,YOUT] = ode45(@F,[X,XEND],Y); 
    X = XOUT(end); Y = YOUT(end);
    fprintf(' %9.2f    %15.8e   %3d\n' ,[X, Y, FCN])
end

function y = F(x,y) 
global FCN
FCN = FCN+length(x); 
y =  (1./x - y)./x - y.*y;
return, end
