You are on page 1of 9

Author: Dr. Md.

Golam Hafez
Consider the differential equation as Euler’s Method
𝑑𝑦
= 𝑓 𝑥, 𝑦 , 𝑦 𝑥0 = 𝑦0 (1)
𝑑𝑥
Suppose that we wish to solve Eq. (1) for the values of y at 𝑥𝑟 = 𝑥0 + 𝑟ℎ 𝑟 = 1,2,3, … … . .
Integrating (1) by taking only the first subinterval,
𝑦1 𝑥1 𝑦1 𝑥1
𝑑𝑦 = 𝑓 𝑥, 𝑦 𝑑𝑥 ⇒ 𝑑𝑦 = 𝑓 𝑥0 , 𝑦0 𝑑𝑥
𝑦0 𝑥0 𝑦0 𝑥0

𝑦1 𝑥1
⇒ 𝑦 𝑦0 = 𝑓 𝑥0 , 𝑦0 𝑥 𝑥0 ⇒ 𝑦1 − 𝑦0 = 𝑓 𝑥0 , 𝑦0 𝑥1 − 𝑥0

This gives us the following formula:


Here we have used
𝑦1 = 𝑦0 + ℎ𝑓 𝑥0 , 𝑦0
𝑓 𝑥, 𝑦 = 𝑓(𝑥0 , 𝑦0 )
Similarly,
in [𝑥0 , 𝑥1 ].
𝑦2 = 𝑦1 + ℎ𝑓 𝑥1 , 𝑦1
Thus the general form of Euler’s method can be written as

𝑦𝑛+1 = 𝑦𝑛 + ℎ𝑓 𝑥𝑛 , 𝑦𝑛 .
Procedure to easily solve mathematical problems:

𝑥 𝑦 𝑑𝑦 𝑑𝑦
= 𝑓 𝑥, 𝑦 𝑂𝑙𝑑 𝑦 + ℎ = 𝑛𝑒𝑤 𝑦
𝑑𝑥 𝑑𝑥
Modified Euler’s Method
Instead of approximating 𝑓 𝑥, 𝑦 by 𝑓 𝑥0 , 𝑦0 in the integral, we
now approximate the integral of Eq. (1) by means of trapezoidal
role to obtain the following formula:

𝑦1 = 𝑦0 + 𝑓 𝑥0 , 𝑦0 + 𝑓 𝑥1 , 𝑦1
2
We thus obtain the following iteration formula:
𝑛+1 ℎ 𝑛
𝑦1 = 𝑦0 + 𝑓 𝑥0 , 𝑦0 + 𝑓 𝑥1 , 𝑦1
2
Used the following formula to solve ODE with initial condition using the modified Euler’s method:

𝑥 𝑑𝑦 Mean Slope 𝑜𝑙𝑑 𝑦 + ℎ 𝑚𝑒𝑎𝑛 𝑠𝑙𝑜𝑝𝑒 = 𝑛𝑒𝑤 𝑦


= 𝑓 𝑥, 𝑦
𝑑𝑥
Runge-Kutta Method of Fourth-Order
Working Rule:
For finding the increment of 𝑘 of 𝑦 corresponding to an increment ℎ of 𝑥 by
Runge-Kutta method from
𝑑𝑦
= 𝑓 𝑥, 𝑦 , 𝑦 𝑥0 = 𝑦0 (1)
𝑑𝑥
is as follows:
𝑘1 = ℎ𝑓 𝑥0 , 𝑦0
ℎ 𝑘1
𝑘2 = ℎ𝑓 𝑥0 + , 𝑦0 +
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 𝑥0 + , 𝑦0 +
2 2
𝑘4 = ℎ𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘3
1
Finally compute 𝑘 = 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 , which gives the required
6
approximate value 𝑦1 = 𝑦0 + 𝑘.
Examples for solutions
𝑑𝑦 𝑦−𝑥
Problem 1: Given = , with initial condition 𝑦 = 1 at 𝑥 = 0; find 𝑦 for
𝑑𝑥 𝑦+𝑥
𝑥 = 0.1 by Euler’s method.
Solution: We divide the interval (0, 0.1) into five steps, that is, 𝑛 = 5. This
0.1−0
implies that ℎ = = 0.02. The various calculations are arranged as follows:
5

𝑥 𝑦 𝑑𝑦 𝑦 − 𝑥 Old 𝑦+ℎ
𝑑𝑦
=new 𝑦
= 𝑑𝑥
𝑑𝑥 𝑦 + 𝑥
0.00 1.0000 1.0000
1.0000+0.02(1.0000)=1.0200
0.02 1.0200 0.9615
1.0200+0.02(0.9615)=1.0392
0.04 1.0392 0.926
1.0392+0.02(0.926)=1.0577
0.06 1.0577 0.893
1.0577+0.02(0.893)=1.0756
0.08 1.0756 0.862
1.0756+0.02(0.862)=1.0928
0.10 1.0928
Hence the required approximate value is 𝒚 = 𝟏. 𝟎𝟗𝟐𝟖.
Examples for solutions
𝑑𝑦
Problem 2: Given = 𝑒 𝑥 + 𝑦, with 𝑦 0 = 0 find 𝑦 0.2 and 𝑦(0.4) by
𝑑𝑥
modified Euler’s method.
Solution: We have 𝑥 = 0, 𝑦 = 0 and ℎ = 0.2. The various calculations are arranged
as follows:
𝑥 𝑑𝑦 Mean Slope 𝑦0 +ℎ 𝑚𝑒𝑎𝑛 𝑠𝑙𝑜𝑝𝑒 =new 𝑦
= 𝑒𝑥 + 𝑦
𝑑𝑥
0.0 1 0.0+0.2(1)=0.2
0.2 0.2 + 𝑒 0.2 = 1.4214 1 0.0+0.2(1.2107)=0.2421
1 + 1.4214 = 1.2107
2
0.2 0.2421 + 𝑒 0.2 = 1.4635 1 0.0+0.2(1.2317)=0.2463
1 + 1.4635 = 1.2317
2
0.2 0.2463 + 𝑒 0.2 = 1.4677 1 0.0+0.2(1.2338)=0.2468
1 + 1.4677 = 1.2338
2
0.2 0.2468 + 𝑒 0.2 = 1.4682 1 0.0+0.2(1.2341)=0.2468
1 + 1.4682 = 1.2341
2
Hence the required approximate value is 𝒚(𝟎. 𝟐) =
𝟎. 𝟐𝟒𝟔𝟖.
Examples for solutions
𝑑𝑦
Problem 2: Given = 𝑒 𝑥 + 𝑦, with 𝑦 0 = 0 find 𝑦 0.2 and 𝑦(0.4) by
𝑑𝑥
modified Euler’s method.
Solution: We have 𝑥 = 0, 𝑦 = 0 and ℎ = 0.2. The various calculations are arranged
as follows:
𝑥 𝑑𝑦 Mean Slope 𝑦0 +ℎ 𝑚𝑒𝑎𝑛 𝑠𝑙𝑜𝑝𝑒 =new 𝑦
= 𝑒𝑥 + 𝑦
𝑑𝑥
0.0 1 0.0+0.2(1)=0.2
0.2 0.2 + 𝑒 0.2 = 1.4214 1 0.0+0.2(1.2107)=0.2421
1 + 1.4214 = 1.2107
2
0.2 0.2421 + 𝑒 0.2 = 1.4635 1 0.0+0.2(1.2317)=0.2463
1 + 1.4635 = 1.2317
2
0.2 0.2463 + 𝑒 0.2 = 1.4677 1 0.0+0.2(1.2338)=0.2468
1 + 1.4677 = 1.2338
2
0.2 0.2468 + 𝑒 0.2 = 1.4682 1 0.0+0.2(1.2341)=0.2468
1 + 1.4682 = 1.2341
2
Hence the required approximate value is 𝒚(𝟎. 𝟐) =
𝟎. 𝟐𝟒𝟔𝟖.
Examples for solutions
𝑑𝑦 𝑦 2 −𝑥 2
Problem 2: Apply Runge-Kutta method of fourth order, solve = , with
𝑑𝑥 𝑦 2 +𝑥 2
𝑦 0 = 1 at 𝑥 = 0.2.
𝑦2 −𝑥2
Solution: We have 𝑥, 𝑦 = . To find 𝑦(0.2):
𝑦2 +𝑥2

Here 𝑥0 = 0, 𝑦0 = 1, ℎ = 0.2.

12 − 02
𝑘1 = ℎ𝑓 𝑥0 , 𝑦0 = 0.2𝑓 0,1 = 0.2 × 2 = 0.2
1 + 02
ℎ 𝑘1 (1.1)2 − (0.1)2
𝑘2 = ℎ𝑓 𝑥0 + , 𝑦0 + = 0.2𝑓 0.1,1.1 = 0.2 × = 0.19672
2 2 (1.1)2 + (0.1)2
ℎ 𝑘2 (1.09836)2 − (0.1)2
𝑘3 = ℎ𝑓 𝑥0 + , 𝑦0 + = 0.2𝑓 0.1,1.09836 = 0.2 × = 0.1967
2 2 (1.09836)2 + (0.1)2
(1.1967)2 − (0.2)2
𝑘4 = ℎ𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘3 = 0.2𝑓 0.2,1.1967 = 0.2 × = 0.1891
(1.1967)2 + (0.2)2
1
𝑘= 0.2 + 2 × 0.19672 + 2 × 0.1967 + 0.1891 = 0.19599
6

Hence the required value is


𝒚 𝟎. 𝟐 = 𝐲𝟎 + 𝐤 = 𝟏 + 𝟎. 𝟏𝟗𝟔 = 𝟏. 𝟏𝟗𝟔.
Challenging questions for solutions
Problem 1: A raindrop of mass m has speed v after falling for
time t. Suppose the equation of motion to be
𝑑𝑣 𝑐 2
= 32 − 𝑣 ,
𝑑𝑡 𝑚
Where c is a measure of air resistance. Apply one of our
methods to find the velocity 𝑣 by taking only first two steps
𝑐
with size ℎ = 0.1 for the case = 1. Use any initial speed.
𝑚
𝑑𝑦
Problem 2: Apply one of our methods, solve = 𝑦 + 𝑥, with
𝑑𝑥
𝑦 0 = 1 by taking only first two steps with size ℎ = 0.1.

You might also like