% ====================================================================================
% =====   Discritized Approximation of The Exact Solution of: dy/dx = exp(x)     =====
% ===== The Exact Solution of The Ordinary Differential Equation is: y(x)=exp(x) =====
% =====                           << The Euler Method >>                         =====
% ====================================================================================

clc
clear

dt=0.1;			%The Time Step
Time=0:dt:1;	%The Time Interval

EulerApproximation(1)=1;	%The Initial Condition

for i=1:length(Time)-1
   %Derivative Calculation
   TheFunction=exp(Time(i));
   %Estimation of The New Value for y(x);
  	EulerApproximation(i+1)=EulerApproximation(i)+(dt*TheFunction); 
end

ExactSolution=exp(Time); %The Exact Solution

plot(Time,ExactSolution,'b',Time,EulerApproximation,'r');
legend('The Exact Solution','The Approximate Solution');
title('Euler Approximation Method, dt=1');
xlabel('Time');
ylabel('Y');
grid on