Euler Method
Euler 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
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
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
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
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.