0% found this document useful (0 votes)
32 views5 pages

Euler's Method Explained with MATLAB

Euler's Method approximates solutions to differential equations using the first two terms of a Taylor series. The document provides a MATLAB implementation example, including the setup of parameters and the application of Euler's formula to compute values. It also demonstrates how to plot the results alongside the analytical solution derived from the differential equation.

Uploaded by

mariariasat566
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Euler's Method Explained with MATLAB

Euler's Method approximates solutions to differential equations using the first two terms of a Taylor series. The document provides a MATLAB implementation example, including the setup of parameters and the application of Euler's formula to compute values. It also demonstrates how to plot the results alongside the analytical solution derived from the differential equation.

Uploaded by

mariariasat566
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Euler's Method

Euler's Method assumes our solution is written in the form


of a Taylor's Series. That is, we'll have a function of the
form:

For Euler's Method, we just take the first 2 terms only.

or simply
Continue..
Continue…
Euler Method on MATLAB
f=@(x,y)(x/y)
a=0;
b=2;
ya=1;
n=10;

h=(b-a)/n; % h is the step


y=zeros(+1,1); % memory allocation, zero column vector
y(1)=ya;
for j=1:n
y(j+1)=y(j)+h*f(x(j),y(j)); % Euler's formula
x(i+1)=x(i)+h;
end
plot(x,y,'-b')
hold on
syms y(x)
ode= diff(y,x)== x/y ;
cond=y(0)==1;
S=dsolve(ode,cond)
F=matlabFunction(S)
fplot(F,[0,2],'r',"LineWidth",2);
hold off

You might also like