function [t,W]=my_trig(int,w0,h)
% my_trig - solves initial value problem for the system of 
%          ordinary differential equations w'=Aw, A=[0 1;-1 0] 
%   Syntax: 
%           [t,W]=my_trig(int,w0,h)
%   Arguments: 
%           int - 1x2 matrix specifying a time interval int=[a,b]
%           w0  - 2x1 matrix specifying an initial value
%           h   - positive number, the stepsize
%   Returns: 
%           t - nx1 matrix containg the time points with t(1)=a
%           W - nx2 matrix containing the approximate solution
%   Description:
%           The program computes an approximate solution of the intial 
%           value problem  w'=Aw, a<t<b; w(a)=w0, A=[0 1;-1 0].  Here w
%           and w0 are column vectors of dimension 2x1.  
%           The program returns the nx1 matrix t of time points with 
%           t(1)=a and the nx2 matrix W with row number i containing 
%           the transposed solution vector at time t(i).  
%           The program uses the Euler forward method. 
%   Examples: 
%          [t,W]=my_trig([0,pi], [0;1], 1e-3);
%          computes half a period of sin(t)
%          plot(t,W)             plots the solution curves
%          plot(W(:,1),W(:,2))   plots the phase portrait
%           

%----------------------------------------------------------------------
%
%   Date created: 
%          
%   Author:
%          
%------------------------------+---------------------------------------+

a=int(1);
b=int(2);

A=[0 1;-1 0];

i=1;
t(1)=a;
W(:,1)=w0;

while t(i)<b
  i=i+1;
  t(i)=t(i-1)+h; 
  W(:,i)=W(:,i-1)+h*A*W(:,i-1); 
end

t=t';
W=W';
