% This program uses Euler's method to solve the D.E.
%    du/dt = u + t - 1
% where u(0)=2.
clear;

h = 0.1;
U(1) = 2;

k = 1;

for t = 0:h:2-h
   Uprime = U(k) + t - 1;
   U(k+1) = U(k) + h*Uprime;
   k = k+1;
end

t = 0:h:2;
Uexact = 2*exp(t) - t;

plot(t,U,t,Uexact,':');
