Euler's Method
Euler's Method
Euler’s Method
Engineering Computations
Numerical Ordinary Differential Equations
Dr.Wisam Haitham
July/2020
Agenda
1 Introduction
2 Euler’s Method
Introduction
Many problems in science and engineering when formulated mathe-
matically are readily expressed in terms of ordinary differential equa-
tions (ODE) with initial and boundary condition.
Consider the problem of solving the first-order differential equation
dy
= f(t, y)
dt
such that we know the rate of change of a quantity as a function
of time and the quantity itself. The problem is to obtain a solution
for y(t), possibly in a general form, but in practical problems usually
where an initial condition y(t0 ) = y0 is known. In many problems
this can be solved analytically. In general such an integration is not
possible, for example, the differential equation dy/dt = −y2 − t,
and we have to solve the equation numerically, which usually means
obtaining a sequence of numerical values y1 , y2 , ... corresponding to
specified values t1 , t2 , ....
Al-Mustansiriyah University, College of Engineering NUMERICAL ORDINARY DIFFERENTIAL EQUATIONS 3 / 11
Introduction
Euler’s Method
Agenda
1 Introduction
2 Euler’s Method
Euler’s Method
Euler method is one of the oldest numerical methods used for inte-
grating the ordinary differential equations. Though this method is
not used in practice, its understanding will help us to gain insight
into nature of predictor-corrector method.
To find the solution of the given Differential Equation in the form
of a recurrence relation
ym+1 = ym + hf(tm , ym ) Is called Euler Method
FORMULA DERIVATION
Consider the differential Equation of the first order
dy
dx = f(t, y) and y(t0 ) = y0
Let (t0 , y0 ) and (t1 , y1 ) be two points of approximation curve. Then
y1 − y0 = m(x1 − x0 ) ....... (i)(point Slope form)
Given That dy dx = f(t, y)
y1 − y0 = f(t0 , y0 )(x1 − x0 )
So y1 = y0 + f(t0 , y0 )(x1 − x0 )
Similarly
y2 = y1 + f(t1 , y1 )(x2 − x1 )
y3 = y2 + f(t2 , y2 )(x3 − x2 )
. . .
. . .
. . .
ym+1 = ym + f(tm , ym )(xm+1 − xm )
Example 1 :
Use Euler’s method with h = 0.1 to solve the initial value problem
dy 2 2
dx = x + y with y(0)=0 in the range 0 6 x 6 0.5.
Solution:
Here
f(x, y) = x2 + y2 , x0 = 0, y0 = 0, h = 0.1
Hence
x1 = x0 + h = (0 + 0.1) = 0.1, x2 = x1 + h = (0.1 + 0.1) = 0.2,
x3 = x2 + h = 0.3, x4 = x3 + h = 0.4, x5 = x4 + h = 0.5
ym+1 = ym + hf(tm , ym )
y1 = y0 + 0.1(x20 + y20 ) = 0 + 0.1(0 + 0) = 0
y2 = y1 + 0.1(x21 + y21 ) = 0 + 0.1((0.1)2 + 0) = 0.001
y3 = y2 + 0.1(x22 + y22 ) = 0.001 + 0.1((0.2)2 + (0.001)2 ) = 0.005
y4 = y3 + 0.1(x23 + y23 ) = 0.005 + 0.1((0.3)2 + (0.005)2 ) = 0.014
y5 = y4 +0.1(x24 +y24 ) = 0.014+0.1((0.4)2 +(0.014)2 ) = 0.0300196
Hence
y(0)=0 y(0.1)=0 y(0.2)=0.001 y(0.3)=0.005
y(0.4)=0.014 y(0.5)=0.0300196
Example 2 :
Using Euler method solve the equation dy dx = 2xy + 1 with y(0)=0,
h = 0.02, for x=0.1
Solution:
Here
f(x, y) = 2xy + 1, x0 = 0, y0 = 0, h = 0.02
Hence
x1 = x0 + h = (0 + 0.02) = 0.02,
x2 = x1 + h = (0.02 + 0.02) = 0.04, x3 = x2 + h = 0.06,
x4 = x3 + h = 0.08, x5 = x4 + h = 0.1
ym+1 = ym + hf(tm , ym )
y1 = y0 + 0.02(2x0 y0 + 1) = 0 + 0.02(0 + 1) = 0.02
y2 = y1 + 0.02(2x1 y1 + 1) = 0.02 + 0.02(2 ∗ 0.02 ∗ 0.02 + 1) = 0.04
y3 = y2 + 0.02(2x2 y2 + 1) = 0.04 + 0.02(2 ∗ 0.04 ∗ 0.04 + 1) = 0.06
Al-Mustansiriyah University, College of Engineering NUMERICAL ORDINARY DIFFERENTIAL EQUATIONS 9 / 11
Introduction
Euler’s Method
Example 4 :
dy
Given dx = y−x
y+x , with y=1 for x=0 . Find y approximately for
x=0.1 by Euler’s method in five steps, choosing h=0.002.
Solution:
Here
f(x, y) = y−x
y+x , x0 = 0, y0 = 1, h = 0.002
y1 = y0 + 0.002( yy00 −x
+x0 ) = 1.02
0
y2 = y1 + 0.002( yy11 −x
+x1 ) = 1.0392
1
y3 = y2 + 0.002( yy22 −x
+x2 ) = 1.0577
2
y4 = y3 + 0.002( yy33 −x
+x3 ) = 1.0756
3
y5 = y4 + 0.002( yy44 −x
+x4 ) = 1.0928
4
Hence
y=1.0928 and x=0.1