%% we are solving y'=3*y-4*exp(-x) with y(0)=1
y0=[1]; %y(0)=1  
xspan=[0,2]; 

fvec=@(x,y) 3*y(1)-4*exp(-x); 
% the fvec is scalar, there is no need to transpose it to make a column vector

Npoints=100;
[x,y] = odeeuler(fvec, xspan, y0, Npoints);

% general analytical solution is 
% y(x)= C*epx(3*x)+exp(-x), where C is some constant
% from y(0)=1  follows C=0
yanalytical=exp(-x);  

figure(1);
plot(x, y(:,1), '-', x, yanalytical, 'r-');
legend('numerical','analytical');
xlabel('x');
ylabel('y');
title('y vs x');


% The discrepancy is due to round off errors. We can say that y(0)=1+delta
% then C ~= 0 and solution diverges.
