Euler Method

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Euler’s Method

Euler’s method is the most elementary approximation technique for solving initial-
value problems. Although it is seldom used in practice, the simplicity of its derivation
can be used to illustrate the techniques involved in the construction of some of the
more advanced techniques. Some IVPs are:
𝑑𝑦 𝑦 − 𝑥𝑦
= , 𝑦(−1) = −1
𝑑𝑥 𝑥2
𝑑𝑦 5
= 1 − 2𝑦 , 𝑦(0) =
𝑑𝑥 2
𝑑𝑦 √1 − 𝑦 2 √3
= , 𝑦(0) =
𝑑𝑥 √1 − 𝑥 2 2

We also examine the nth-order initial value problem of the form

The object of Euler’s method is to obtain approximations to the initial-value problem


𝑑𝑦
= 𝑓(𝑥, 𝑦) , 𝑦(𝑥0 ) = 𝑦0
𝑑𝑥
We know that
𝑦1 − 𝑦0 𝑑𝑦
𝑆𝑙𝑜𝑝𝑒 = = = 𝑓(𝑥0 , 𝑦0 )
𝑥1 − 𝑥0 𝑑𝑥
Or 𝑦1 − 𝑦0 = 𝑓(𝑥0 , 𝑦0 )(𝑥1 − 𝑥0 )
Therefore 𝑦1 = 𝑦0 + ℎ 𝑓(𝑥0 , 𝑦0 ) for 𝑥1 − 𝑥0 = ℎ
Similarly 𝑦2 = 𝑦1 + ℎ 𝑓(𝑥1 , 𝑦1 ), for 𝑦1 = 𝑦(𝑥1 ), 𝑥1 = 𝑥0 + ℎ
Hence 𝑦𝑖+1 = 𝑦𝑖 + ℎ 𝑓(𝑥𝑖 , 𝑦𝑖 ), 𝑖 = 0, 1, 2, … is the Euler’s Formula.
Graphical Meaning

Example 1
Solve the initial -value problem 𝑦 𝑦 ′ = 𝑥, 𝑦(0) = 1, using the Euler method in 0 ≤
𝑥 ≤ 0.8, with ℎ = 0.2. If the exact solution of the differential equation is y = √(𝑥 2 +
1). Compare the result with the exact solution at 𝑥 = 0.8.
Solution: We know that the Euler method is given by
𝑦𝑖+1 = 𝑦𝑖 + ℎ 𝑓(𝑥𝑖 , 𝑦𝑖 ), 𝑖 = 0, 1, 2, …
𝑦(0) = 1 implies 𝑥0 = 0, 𝑦0 = 1
𝑥 𝑥𝑖
And 𝑦′ = = 𝑓(𝑥, 𝑦), 𝑓(𝑥𝑖 , 𝑦𝑖 ) = ,
𝑦 𝑦𝑖
𝑥𝑖 𝑥𝑛 −𝑥0 0.8−0
So 𝑦𝑖+1 = 𝑦𝑖 + ℎ for 𝑛= = =4
𝑦𝑖 ℎ 0.2
𝑥0 0
𝑖 = 0, 𝑦1 = 𝑦0 + ℎ 𝑓(𝑥0 , 𝑦0 ) = 𝑦0 + ℎ = 1 + (0.2) = 1, 𝑥1 = 𝑥0 + ℎ = 0.2
𝑦0 1
𝑥1 0.2
𝑖 = 1, 𝑦2 = 𝑦(𝑥2 ) = 𝑦1 + ℎ = 1 + (0.2) = 1.04 , 𝑥2 = 𝑥0 + 2ℎ = 0.4
𝑦1 1

𝑖 = 2, 𝑦3 = 𝑦(𝑥3 ) = 1.11692, 𝑥3 = 0.6,


𝑖 = 3, 𝑦4 = 𝑦(𝑥4 ) = 1.22436 , 𝑥4 = 0.8 .
At 𝑥 = 0.8, the exact solution is y(0.8) = √(0.82 + 1)=1.28062
Error = |1.28062-1.22436|=0.05626

Example 2
Repeat Exampl𝑒 1 using ℎ = 0.1 and compare the result with the exact solution at
𝑥 = 0.8.
Solution: We know that the Euler method is given by
𝑦𝑖+1 = 𝑦𝑖 + ℎ 𝑓(𝑥𝑖 , 𝑦𝑖 ), 𝑖 = 0, 1, 2, …
𝑥
𝑦′ = = 𝑓(𝑥, 𝑦), 𝑦(0) = 1 implies 𝑥0 = 0 and 𝑦0 = 1.
𝑦
𝑥𝑖 𝑥𝑛 −𝑥0 0.8−0
So 𝑦𝑖+1 = 𝑦𝑖 + ℎ , 𝑛= = =8
𝑦𝑖 ℎ 0.1
𝑥0 0
𝑖 = 0, 𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + ℎ = 1 + (0.1) = 1, 𝑥1 = 𝑥0 + ℎ = 0.1
𝑦0 1
𝑥1 0.1
𝑖 = 1, 𝑦2 = 𝑦(𝑥2 ) = 𝑦1 + ℎ = 1 + (0.1) = 1.01 , 𝑥2 = 𝑥0 + 2ℎ = 0.2
𝑦1 1

𝑖 = 2, 𝑦3 = 𝑦(𝑥3 ) = 1.02980, 𝑥3 = 0.3,


𝑖 = 3, 𝑦4 = 𝑦(𝑥4 ) = 1.05893 , 𝑥4 = 0.4,
𝑖 = 4, 𝑦5 = 𝑦(𝑥5 ) = 1.09670, 𝑥5 = 0.5,
𝑖 = 5, 𝑦6 = 𝑦(𝑥6 ) = 1.14229, 𝑥6 = 0.6,
𝑖 = 6, 𝑦7 = 𝑦(𝑥7 ) = 1.19482, 𝑥7 = 0.7,
𝑖 = 7, 𝑦8 = 𝑦(𝑥8 ) = 1.25341, 𝑥8 = 0.8
At 𝑥 = 0.8, the exact value is y(0.8) = √(0.82 + 1)=1.28062
Therefore, Error = |1.28062- 1.25341 |= 0.02721
Practice Questions
Q. Use Euler method to approximate the solutions for the initial value problem 𝑦 ′ =
𝑡𝑒 3𝑡 − 2y, 𝑦(0) =0, in 0 ≤ 𝑡 ≤ 1, with ℎ = 0.2. If the exact solution of the
1 1 1
differential equation is y(t) = 𝑡𝑒 3𝑡 − 𝑒 3𝑡 + 𝑒 −2𝑡 , find error at 𝑡 = 1.
5 25 25

Solution: We know that the Euler method is given by


𝑦𝑖+1 = 𝑦𝑖 + ℎ 𝑓(𝑡𝑖 , 𝑦𝑖 ), 𝑖 = 0, 1, 2, 3, 4.
𝑦(0) = 0 implies 𝑡0 = 0 and 𝑦0 = 0
And 𝑦 ′ = 𝑡𝑒 3𝑡 − 2y = 𝑓(𝑡, 𝑦),
𝑡𝑛 −𝑡0 1−0
So 𝑦𝑖+1 = 𝑦𝑖 + ℎ(𝑡𝑖 𝑒 3𝑡𝑖 − 2𝑦𝑖 ), 𝑛= = =5
ℎ 0.2

𝑖 = 0, 𝑦1 = 𝑦(𝑡1 ) = 𝑦0 + ℎ(𝑡0 𝑒 3𝑡0 − 2𝑦0 ) = 0, 𝑡1 = 𝑡0 + ℎ = 0.2


𝑖 = 1, 𝑦2 = 𝑦(𝑡2 ) = 𝑦1 + ℎ(𝑡1 𝑒 3𝑡1 − 2𝑦1 ) = 0.0729 , 𝑡2 = 𝑡1 + ℎ = 0.4
𝑖 = 2, 𝑦3 = 0.3094, 𝑖 = 3, 𝑦4 = 0.9116 ,
𝑖 = 4, 𝑦5 = 𝑦(𝑡5 ) = 2.3107.
At 𝑥 = 1, the exact solution is y(1) = 3.2191
Error = |3.2191-2.3107| = 0.9084

Q. Use Euler method to approximate the solutions for the initial value problem 𝑦 ′ =
1 + y/t, 𝑦(1) = 2, in 1 ≤ 𝑡 ≤ 2, with ℎ = 0.25. Find error at 𝑡 = 2 if the exact
solution of the differential equation is y(t) = 𝑡 ln 𝑡 + 2𝑡.
Solution: We know that the Euler method is given by
𝑦𝑖+1 = 𝑦𝑖 + ℎ 𝑓(𝑡𝑖 , 𝑦𝑖 ), 𝑖 = 0, 1, 2, 3, 4.
𝑦(1) = 2 implies 𝑡0 = 1 and 𝑦0 = 2 and 𝑦 ′ = 1 + y/t = 𝑓(𝑡, 𝑦),
𝑡𝑛 −𝑡0 2−1
So 𝑦𝑖+1 = 𝑦𝑖 + ℎ(1 + 𝑦𝑖 /𝑡𝑖 ), 𝑛= = =4
ℎ 0.25

𝑖 = 0, 𝑦1 = 𝑦(𝑡1 ) = 𝑦0 + ℎ(1 + 𝑦0 /𝑡0 ) = 2.750, 𝑡1 = 𝑡0 + ℎ = 1.25


𝑖 = 1, 𝑦2 = 𝑦(𝑡2 ) = 𝑦1 + ℎ(1 + 𝑦1 /𝑡1 ) = 3.550, 𝑡2 = 𝑡1 + ℎ = 1.5
𝑖 = 2, 𝑦3 = 𝑦(𝑡3 ) = 4.39167,
𝑖 = 3, 𝑦4 = 𝑦(𝑡4 ) = 5.26905.
At t = 2, the exact solution is y(2) = 5.38629
Error = |5.38629 - 5.26905| = 0.11724

Q. Use Euler method to approximate the solutions for the initial value problem 𝑦 ′ =
−y + t𝑦1/2 , 𝑦(2) = 2, in 2 ≤ 𝑡 ≤ 3, with ℎ = 0.25. If the exact solution of the
differential equation is y(t) = (𝑡 − 2 + √2𝑒𝑒 −𝑡/2 )2 , then find error at 𝑡 = 3.
Solution:
𝑦1 = 2.20711, at 𝑡1 = 2.25, using 𝑡0 = 2 and 𝑦0 = 2
𝑦2 = 2.4910, at 𝑡2 = 2.5
𝑦3 = 𝑦(𝑡3 ) = 2.8547, 𝑦4 = 𝑦(𝑡4 ) = 3.3026.
The exact solution is y(3) = 3.4513
Error = |3.4513 −3.3026| = 0.1487

Task
In a circuit with impressed voltage 𝐸 having resistance 𝑅, inductance 𝐿, and
capacitance 𝐶 in parallel, the current 𝑖 satisfies the differential equation
𝑑𝑖 𝑑 2 𝐸 1 𝑑𝐸 1
=𝐶 2 + + 𝐸
𝑑𝑡 𝑑𝑡 𝑅 𝑑𝑡 𝐿
Suppose 𝐶 = 0.3 𝑓𝑎𝑟𝑎𝑑𝑠, 𝑅 = 1.4 𝑜ℎ𝑚𝑠, 𝐿 = 1.7 ℎ𝑒𝑛𝑟𝑖𝑒𝑠, and the voltage is
given by
𝐸(𝑡) = 𝑒 −0.06𝜋𝑡 sin(2𝑡 − 𝜋).
If 𝑖(0) = 0, find the current 𝑖 for the values 𝑡 = 0.1 𝑗, where 𝑗 = 0, 1, . . . , 20.

You might also like