% Igor Yanovsky
% Teaching Assistant
% Math 151B
% 04/18/07
%
%#####################################################################
%
% This program solves the ordinary differential equation
% 
%  dy/dt = f(t,y)
%  y(t_0) = y_0
% 
% using EULER's method. The function defining the ODE is defined in a
% separate Matlab function.
%
%#####################################################################

clear all

format long

t0 = 0.0;
tF = 2.0;
y0 = -1.0;

N = 100;     % number of timesteps

h = (tF - t0)/N

t = t0;
wn = y0;

for(i=1:N)
    wnp1 = wn + h*f(t,wn); % advances the ODE one step using Euler's method
    wn = wnp1;
    t = t + h;
end

wn
t

yexact = findExact( t )
error = wn - yexact

clear all

