function T2 = taylor2(df,a,b,ya,N)

% Input   - df=[y' y''] entered as a string 'df'
%           where y'=f(t,y), y''=df(t,y)/dt
%         - a and b are the left and right endpoints
%         - ya is the initial condition y(a)
%         - N is the number of steps
% Output  - T2=[T' Y'] where T is the vector of abscissas and
%           Y is the vector of ordinates

%  NUMERICAL METHODS: Matlab Programs
% (c) 2004 by John H. Mathews and Kurtis D. Fink
%  Complementary Software to accompany the textbook:
%  NUMERICAL METHODS: Using Matlab, Fourth Edition
%  ISBN: 0-13-065248-2
%  Prentice-Hall Pub. Inc.
%  One Lake Street
%  Upper Saddle River, NJ 07458

h=(b-a)/N;
T=zeros(1,N+1);
Y=zeros(1,N+1);
T=a:h:b;
Y(1)=ya;

for j=1:N
   D=feval(df,T(j),Y(j));
   Y(j+1)=Y(j)+h*(D(1)+h*(D(2)/2));
end

T2=[T' Y'];

