0% found this document useful (0 votes)
67 views

Euler's Method: Dy y y y y Fxy DX X X H y y H Fxy

Euler's method is a numerical method for approximating the solution to an ordinary differential equation (ODE) by incrementally calculating solutions at discrete time steps across the interval of integration. It works by extrapolating the solution at each step along the tangent line defined by the slope of the ODE. Specifically, given an approximate solution yk at time xk, Euler's method approximates the solution y(xk+1) at the next time step xk+1 = xk + hk as yk+1 = yk + hk * f(xk, yk), where f is the ODE. The document provides an example of using Euler's method to solve a sample differential equation and compares the
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Euler's Method: Dy y y y y Fxy DX X X H y y H Fxy

Euler's method is a numerical method for approximating the solution to an ordinary differential equation (ODE) by incrementally calculating solutions at discrete time steps across the interval of integration. It works by extrapolating the solution at each step along the tangent line defined by the slope of the ODE. Specifically, given an approximate solution yk at time xk, Euler's method approximates the solution y(xk+1) at the next time step xk+1 = xk + hk as yk+1 = yk + hk * f(xk, yk), where f is the ODE. The document provides an example of using Euler's method to solve a sample differential equation and compares the
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Eulers method

A numerical method for an ordinary differential equation (ODE) generates an approximate


solution step-by-step in discrete increments across the interval of integration, in effect producing
a discrete sample of approximate values of the solution function. Euler's method is the simplest
example of this approach, in which the approximate solution is advanced at each step by
extrapolating along the tangent line whose slope is given by the ODE. Specifically, from an
approximate solution value y
k
at time x
k
for an ODE y = f(x, y), Euler's method approximates the
solution y(x
k+1
) at time x
k+1
= x
k
+ h
k
by y
k+1
= y
k
+ h
k
f(x
k
, y
k
).



Fig-1Comparison of Approximate and Exact solution curve

Above solution curve is obtained from Eulers equation derived below and with the help of
recursive algorithm explained in next secessions.


1 0 1 0
1 0
1 0 0 0
( , )
( , )
dy y y y y
f x y
dx x x h
y y h f x y


Applying the Method
The differential equation given tells the formula for f(x, y) required by the Euler Method,
namely:
f(x, y) = x + 2y
and the initial condition tells the values of the coordinates of our starting point:
x
o
= 0 , y
0
= 0
Use the Euler method formulas to generate values for x
1
and y
1
.
The x-iteration formula, with n = 0 gives:
x
1
= x
o
+ h
or:
x
1
= 0 + 0.25
So:
x
1
= 0.25
And the y-iteration formula, with n = 0 gives:
y
1
= y
o
+ h f(x
o
, y
o
)
or:
y
1
= y
o
+ h (x
o
+ 2y
o
)
or:
y
1
= 0 + 0.25 (0 + 2*0)
Summarizing, the second point in our numerical solution is: x
1
=0.25 , y
1
=0
Above steps are repeated to get values of y at different instants.



Matlab implementation of eulers method:

func=input('Enter the Function You Want to Slove= ','s');
step_size=input('Input The step size= ');
initialx=input('initalx' );
final=input('Input the value of x upto which you want answer= ');
x=[initialx:step_size:final];

y=zeros(size(x));
y(1)=input('Initial Condition for y=');
f=inline(func);
i=2;
k=((final-initialx)/step_size) + 1;
while i<=k
y(i)=y(i-1)+ step_size*f(x(i-1),y(i-1));
i=i+1;
end
y(k)
clf
plot(x,y)
























Solution of Differential equation using
Eulers and Trapezoidal method

You might also like