function euler1(eps,N)
% integrates a 1st order ODE via Euler's method
% problem 1.5.11, Nagle et al.
% to use:
% run  matlab6
% then type: euler1(.05,20)
% it will produce a plot of the solution as well as a table of values
disp(' ')
   disp(        '  i           t      x(t)        xe(t) ')
   disp(        '--------------------------------------------')
x(1)=0; t(1) = 0; xe(1) = tan(t(1));i = 0;
   disp(sprintf(' %2.0f        %5.2f   %8.5f    %8.5f',i,t(1),x(1),xe(1)))
for i = 1:N
    x(i+1) = x(i) + eps*(1+x(i)^2);
    t(i+1) = t(i) + eps;
    xe(i+1)= tan(t(i+1));
   disp(sprintf(' %2.0f        %5.2f   %8.5f    %8.5f',i,t(i+1),x(i+1),xe(i+1)))
end
   disp(        '--------------------------------------------')
figure; axis([-2, 2 , -2, 2])
plot(t,x,t(1:N/10:N+1),xe(1:N/10:N+1),'ro')
title(sprintf('graph of numerical vs. exact (o) solution to dx/dt=1+x^2, x0=0 with eps = %6.2f',eps));
%>> euler1(.05,20)
%
%  i           t      x(t)        xe(t) 
%--------------------------------------------
%  0         0.00    0.00000     0.00000
%  1         0.05    0.05000     0.05004
%  2         0.10    0.10013     0.10033
%  3         0.15    0.15063     0.15114
%  4         0.20    0.20176     0.20271
%  5         0.25    0.25380     0.25534
%  6         0.30    0.30702     0.30934
%  7         0.35    0.36173     0.36503
%  8         0.40    0.41827     0.42279
%  9         0.45    0.47702     0.48306
% 10         0.50    0.53840     0.54630
% 11         0.55    0.60289     0.61311
% 12         0.60    0.67106     0.68414
% 13         0.65    0.74358     0.76020
% 14         0.70    0.82123     0.84229
% 15         0.75    0.90495     0.93160
% 16         0.80    0.99589     1.02964
% 17         0.85    1.09548     1.13833
% 18         0.90    1.20549     1.26016
% 19         0.95    1.32815     1.39838
% 20         1.00    1.46635     1.55741
%--------------------------------------------