clear;
% Forward Euler Method
% Coefficients of equation y'=b y + c t; y(0)=1

b=-2.;
c=1.;

% Initial and final times
tinit= 0.;
tmax=5.; 

% Number of time steps
Nt = 3000;
dt = (tmax-tinit)/Nt;

% Initial condition
y(1)=1.;
t(1)=tinit;

% Time Loop
for j=1:Nt
y(j+1)=y(j)+dt*(b*y(j)+c*t(j));
t(j+1)=tinit+j*dt;
end

plot(t,y)
title('Forward Euler Method')
xlabel('T')
ylabel('y(t)')