𝒚𝟏 = 𝒚𝟎 + 𝒉.
𝒇(𝒙𝟎 , 𝒚𝟎 )
𝒚𝟐 = 𝒚𝟏 + 𝒉. 𝒇(𝒙𝟏 , 𝒚𝟏 )
𝒚𝟑 = 𝒚𝟐 + 𝒉. 𝒇(𝒙𝟐 , 𝒚𝟐 )
𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒉. 𝒇(𝒙𝒏 , 𝒚𝒏 )
Example 1
Apply Euler’s method to approximate the solution of the initial value problem:
𝒚′ = 𝒙𝟐 + 𝒚𝟐 ; 𝒚(𝟎) = 𝟏, 𝒉 = 𝟎. 𝟏; 𝒇𝒊𝒏𝒆𝒅 𝒚(𝟎. 𝟑)
Solution
Example 2
𝒅𝒚
𝑮𝒊𝒗𝒆𝒏 𝒕𝒉𝒂𝒕 = 𝒚 − 𝒙 𝒘𝒉𝒆𝒓𝒆 𝒚(𝟎) = 𝟐 . 𝒇𝒊𝒏𝒆𝒅 𝒚(𝟎. 𝟏); 𝒚(𝟎. 𝟐)
𝒅𝒙
𝒃𝒚 𝑬𝒖𝒍𝒆𝒓′ 𝒔𝒎𝒆𝒕𝒉𝒐𝒅 𝒖𝒑 𝒕𝒑 𝒕𝒘𝒐 𝒅𝒆𝒄𝒊𝒎𝒂𝒍 𝒑𝒍𝒂𝒄𝒆, 𝒄𝒐𝒏𝒔𝒊𝒅𝒆𝒓𝒊𝒏𝒈
𝒉 = 𝟎. 𝟏
Solution
𝒚𝟎 = 𝟐 , 𝒙𝟎 = 𝟎; 𝒙𝟏 = 𝟎. 𝟏; 𝒙𝟐 = 𝟎. 𝟐; 𝒉 = 𝟎. 𝟏
𝒚𝟏 = 𝒚𝟎 + 𝒉. 𝒇(𝒙𝟎 , 𝒚𝟎 ) ⟹ 𝒚𝟏 = 𝟐 + 𝟎. 𝟏. (𝟐 − 𝟎) = 𝟐. 𝟐
𝒚𝟐 = 𝒚𝟏 + 𝒉. 𝒇(𝒙𝟏 , 𝒚𝟏 ) ⟹ 𝒚𝟐 = 𝟐. 𝟐 + 𝟎. 𝟏. (𝟐. 𝟐 − 𝟎. 𝟏) = 2.41
𝒚𝟑 = 𝒚𝟐 + 𝒉. 𝒇(𝒙𝟐 , 𝒚𝟐 ) ⟹ 𝒚𝟑 = 𝟐. 𝟒𝟏 + 𝟎. 𝟏. 𝒇(𝟐. 𝟒𝟏 − 𝟎. 𝟐) = 𝟐. 𝟔𝟑
Example 3
𝒅𝒚
𝒈𝒊𝒗𝒆𝒏 = 𝟑𝒙 + 𝒚 ; 𝒚(𝟎) = −𝟏; 𝑨𝒑𝒑𝒓𝒐𝒙𝒊𝒎𝒂𝒕𝒆 ∶ 𝒚(𝟎. 𝟐) 𝒘𝒊𝒕𝒉 𝒔𝒕𝒆𝒑
𝒅𝒙
𝒔𝒊𝒛𝒆 𝟎. 𝟎𝟒; 𝒕𝒉𝒆 𝒆𝒙𝒂𝒄𝒕 𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 𝒊𝒔 𝒈𝒊𝒗𝒆𝒏 𝒃𝒚 𝒕𝒉𝒆 𝒆𝒒𝒖𝒂𝒕𝒊𝒐𝒏
𝒚(𝒙) = 𝟐𝒆𝒙 − 𝟑𝒙 − 𝟑; 𝒄𝒐𝒎𝒑𝒆𝒓 𝒚𝒐𝒖𝒓 𝒂𝒏𝒔𝒘𝒆𝒓 𝒘𝒊𝒕𝒉 𝒆𝒙𝒂𝒄𝒕 𝒐𝒏𝒆
Solution
𝑥0 = 0; 𝑦0 = −1 ; ℎ = 0.04
𝒚𝟏 = 𝑦0 + 𝒉. 𝒇(𝒙𝟎 , 𝒚𝟎 ) ⟹ 𝒚𝟏 = −𝟏 + 𝟎. 𝟎𝟒. (𝟑 ∗ 𝟎 + (−𝟏)) = −𝟏. 𝟎𝟒
𝒙𝟏 = 𝒙𝟎 + 𝒉 = 𝟎 + 𝟎. 𝟎𝟒 = 𝟎. 𝟎𝟒; 𝒚𝟏 = −𝟏. 𝟎𝟒
𝒚𝟐 = 𝒚𝟏 + 𝒉. 𝒇(𝒙𝟏 , 𝒚𝟏 ) ⟹ 𝒚𝟐 = −𝟏. 𝟎𝟒 + 𝟎. 𝟎𝟒. (𝟑 ∗ 𝟎. 𝟎𝟒 − 𝟏. 𝟎𝟒) = −𝟏. 𝟎𝟕𝟔𝟖
𝑥3 = 𝑥2 + ℎ = 0.08 + 0.04 = 0.12; 𝑦2 = −1.0768
𝒚𝟑 = 𝒚𝟐 + 𝒉. 𝒇(𝒙𝟐 , 𝒚𝟐 ) ⟹ 𝒚𝟑 = −𝟏. 𝟎𝟕𝟔𝟖 + 𝟎. 𝟎𝟒. (𝟑 ∗ 𝟎. 𝟎𝟖-1.0768) =-1.110272
𝒙𝟒 = 𝟎. 𝟏𝟐 + 𝟎. 𝟎𝟒 = 𝟎. 𝟏𝟔; 𝒚𝟑 = −𝟏. 𝟏𝟏𝟎𝟐𝟕𝟐
𝒚𝟒 = 𝒚𝟑 + 𝒉. 𝒇(𝒙𝟑 , 𝒚𝟑 ) ⟹ 𝒚𝟒 = −𝟏. 𝟏𝟏𝟎𝟐𝟕𝟐 + 𝟎. 𝟎𝟒(𝟑 ∗ 𝟎. 𝟏𝟐 − 𝟏. 𝟏𝟏𝟎𝟐𝟕𝟐)
= −𝟏. 𝟏𝟒𝟎𝟐𝟖𝟐𝟖𝟖
𝒙𝟓 = 𝟎. 𝟏𝟔 + 𝟎. 𝟒 = 𝟎. 𝟐
𝒚𝟓 = 𝒚𝟒 + 𝒉. 𝒇(𝒙𝟒 , 𝒚𝟒 ) = −𝟏. 𝟏𝟒𝟎𝟐𝟖𝟐𝟖𝟖 + 𝟎. 𝟎𝟒(𝟑 ∗ 𝟎. 𝟏𝟔 − 𝟏. 𝟏𝟒𝟎𝟐𝟖𝟐𝟖𝟖) =-
1.66694195
∴ 𝒚(𝟎. 𝟐) =-1.66694195
𝒕𝒉𝒆 𝒆𝒙𝒂𝒄𝒕 𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 = 𝟐𝒆𝟎.𝟐 + 𝟑(𝟎. 𝟐) − 𝟑 = −𝟏. 𝟎𝟓𝟕𝟏𝟗𝟒𝟒𝟖𝟒 ≅ −𝟏. 𝟎𝟓𝟕𝟐
n 𝒙𝒏 𝒚𝒏 𝒚𝒏 ≅
0 0 2 2
1 0.04 −𝟏. 𝟎𝟒 -1.04
2 0.08 −1.0768 -1.08
3 0.12 -1.110272 -1.11
4 0.16 -1.14028288 -1.14
5 0.2 -1.166694195 -1.1667
𝒆𝒓𝒓𝒐𝒓 = −𝟏. 𝟎𝟓𝟕𝟐 − (−𝟏. 𝟏𝟔𝟔𝟕) = 𝟎. 𝟏𝟎𝟗𝟓
Example 4
Apply Euler’s method to approximate the solution of the initial value problem:
𝑑𝑦
= 𝑠𝑖𝑛𝑥 + 2𝑦; 𝑦(0) = 1; ℎ = 0.02; 𝑦(0.08)
𝑑𝑥
Solution
𝑥0 = 0; 𝑦0 = 1; ℎ = 0.02
𝒚𝟏 = 𝑦0 + 𝒉. 𝒇(𝒙𝟎 , 𝒚𝟎 ) ⟹ 𝒚𝟏 = 1 + 0.02(𝑠𝑖𝑛0 + 2 ∗ 1) = 1.04
𝒙𝟏 = 𝒙𝟎 + 𝒉 = 𝟎 + 𝟎. 𝟎𝟐 = 𝟎. 𝟎𝟐 ; 𝒚𝟏 = 𝟏. 𝟎𝟒
𝒚𝟐 = 𝒚𝟏 + 𝒉. 𝒇(𝒙𝟏 , 𝒚𝟏 ) ⟹ 𝒚𝟐 = 1.04 + 0.02(𝑠𝑖𝑛0.02 + 2 ∗ 1.04) = 1.082.
𝒙𝟐 = 𝟎. 𝟎𝟐 + 𝟎. 𝟎𝟐 = 𝟎. 𝟎𝟒 ; 𝒚𝟐 = 𝟏. 𝟎𝟖𝟐
𝒚𝟑 = 𝒚𝟐 + 𝒉. 𝒇(𝒙𝟐 , 𝒚𝟐 ) ⟹ 𝒚𝟑 = 1.082 + 0.02(𝑠𝑖𝑛0.04 + 2 ∗ 1.082)
= 1.1261
𝑥3 = 0.04 + 0.02 = 0.06; 𝑦3 = 1.1261
𝒚𝟒 = 𝒚𝟑 + 𝒉. 𝒇(𝒙𝟑 , 𝒚𝟑 ) ⟹ 𝒚𝟒 = 1.1261 + 0.02(𝑠𝑖𝑛0.06 + 2 ∗ 1.1261)
= 1.722
𝑥4 = 0.06 + 0.02 = 0.08
n 𝒙𝒏 𝒚𝒏 𝒚𝒏 ≅
0 0 1 2
1 0.02 1.04 -1.04
2 0.04 1.082 -1.08
3 0.06 1.1261 -1.11
4 0.08 1.722 -1.14
Example 5
Use Euler's method with step size 0.4 to estimate y(2), where y(x) is
the solution of y'=4x+y2 ; y(0)=0
Solution
𝒙𝟎 = 𝟎; 𝒚𝟎 = 𝟎; 𝒉 = 𝟎. 𝟒
𝟐
𝒚𝟏 = 𝑦0 + 𝒉. 𝒇(𝒙𝟎 , 𝒚𝟎 ) ⟹ 𝒚𝟏 = 𝟎 + 𝟎. 𝟒 (𝟒 ∗ 𝟎 + 𝟎 ) = 𝟎
𝟐
𝒚𝟐 = 𝒚𝟏 + 𝒉. 𝒇(𝒙𝟏 , 𝒚𝟏 ) ⟹ 𝒚𝟐 = 𝟎 + 𝟎. 𝟒 (𝟒 ∗ 𝟎. 𝟒 + 𝟎 ) = 𝟎. 𝟔𝟒
𝟐
𝒚𝟑 = 𝒚𝟐 + 𝒉. 𝒇(𝒙𝟐 , 𝒚𝟐 ) ⟹ 𝒚𝟑 = 𝟎. 𝟔𝟒 + 𝟎. 𝟒 (𝟒 ∗ 𝟎. 𝟖 + 𝟎. 𝟔𝟒 ) = 𝟐. 𝟎𝟖𝟒
𝟐
𝒚𝟒 = 𝒚𝟑 + 𝒉. 𝒇(𝒙𝟑 , 𝒚𝟑 ) ⟹ 𝒚𝟒 = 𝟐. 𝟎𝟖𝟒 + 𝟎. 𝟒 (𝟒 ∗ 𝟏. 𝟐 + 𝟐. 𝟎𝟖 ) = 𝟓. 𝟕𝟒𝟏
𝟐
𝒚𝟓 = 𝒚𝟒 + 𝒉. 𝒇(𝒙𝟒 , 𝒚𝟒 ) ⟹ 𝒚𝟓 = 𝟓. 𝟕𝟒𝟏 + 𝟎. 𝟒 (𝟒 ∗ 𝟏. 𝟔 + 𝟓. 𝟕𝟒 ) =21.484
𝒚(𝟐) = 𝟐𝟏. 𝟒𝟖𝟒
n 𝒙𝒏 𝒚𝒏
0 0 0
1 0.4 0
2 0.8 0.64
3 1.2 2.084
4 1.6 𝟓. 𝟕𝟒𝟏
5 2 21.484
Example 6
حل باستخدام طريقة أويلر المعادلة التفاضلية االتية
𝟏
𝒚′ = (𝒙 − 𝒚)
𝟐
h=1/2 ثمh=1 وy (0) =1 :[ أخذ في االعتبار الشروط االتية0,3] على الفترة
الحل
𝒉=𝟏 𝒙𝟎 = 𝟎 𝒚𝟎 = 𝟏
𝒙𝒏+𝟏 = 𝒙𝒏 + 𝒉 , 𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒉(𝒙𝒏 − 𝒚𝒏 )
𝟏 𝟏 𝟏
𝒚𝟏 = 𝑦0 + 𝟏. (𝒙𝟎 − 𝒚𝟎 ) ⟹ 𝒚𝟏 = 𝟏 + (𝟎 − 𝟏) = = 𝟎. 𝟓
𝟐 𝟐 𝟐
𝟏 𝟏 𝟏 𝟏 𝟑
𝒚𝟐 = 𝑦1 + 𝟏. (𝒙𝟏 − 𝒚𝟏 ) ⟹ 𝒚𝟐 = + (𝟏 − ) = = 𝟎. 𝟕𝟓
𝟐 𝟐 𝟐 𝟐 𝟒
𝟏 𝟏 𝟏𝟏
𝒚𝟑 = 𝑦2 + 𝟏. (𝒙𝟐 − 𝒚𝟐 ) = 𝟎. 𝟕𝟓 + (𝟐 − 𝟎. 𝟕𝟓) = = 𝟏. 𝟑𝟕𝟓
𝟐 𝟐 𝟖
n 𝒙𝒏+𝟏 = 𝒙𝒏 + 𝟏 𝒚𝒏
0 𝒙𝟎 = 𝟎 𝒚(𝟎) = 𝟏
1 𝒙𝟏 = 𝟏 𝒚(𝟏) = 𝟎. 𝟓
2 𝒙𝟐 = 𝟐 𝒚(𝟐) = 𝟎. 𝟕𝟓
3 𝒙𝟑 = 𝟑 𝒚(𝟑) = 𝟏. 𝟑𝟕𝟓
𝟏
𝒉= 𝒙𝟎 = 𝟎 𝒚(𝟎) = 𝟏
𝟐
𝟏 𝟏 𝟏 𝟑
𝒚𝟏 = 𝑦0 + . (𝒙𝟎 − 𝒚𝟎 ) ⟹ 𝒚𝟏 = 𝟏 + (𝟎 − 𝟏) = = 𝟎. 𝟕𝟓
𝟐 𝟐 𝟒 𝟒
𝟏 𝟏 𝟑 𝟏 𝟏 𝟑 𝟏𝟏
𝒚𝟐 = 𝑦1 + . (𝒙𝟏 − 𝒚𝟏 ) ⟹ 𝒚𝟐 = + ( − ) = = 𝟎. 𝟔𝟖𝟕𝟓
𝟐 𝟐 𝟒 𝟒 𝟐 𝟒 𝟏𝟔
𝟏 𝟏 𝟏 𝟒𝟗
𝒚𝟑 = 𝑦2 + . (𝒙𝟐 − 𝒚𝟐 ) = 𝟎. 𝟔𝟖𝟕𝟓 + (𝟏 − 𝟎. 𝟔𝟖𝟕𝟓) = = 𝟎. 𝟕𝟔𝟓𝟔𝟐𝟓
𝟐 𝟐 𝟒 𝟔𝟒
𝟏 𝟏 𝟒𝟗 𝟏 𝟒𝟗 𝟐𝟒𝟑
𝒚𝟒 = 𝑦3 + . (𝒙𝟑 − 𝒚𝟑 ) = + (𝟏. 𝟓 − ) = = 𝟎. 𝟗𝟒𝟗𝟐𝟏𝟖𝟕𝟓
𝟐 𝟐 𝟔𝟒 𝟒 𝟔𝟒 𝟐𝟓𝟔
𝟏 𝟏 𝟐𝟒𝟑 𝟏 𝟐𝟒𝟑 𝟏𝟐𝟕𝟏
𝒚𝟓 = 𝑦4 + 𝟐 . 𝟐 (𝒙𝟒 − 𝒚𝟒 ) = 𝟐𝟓𝟔 + 𝟒 (𝟐 − 𝟐𝟓𝟔) = 𝟏𝟎𝟐𝟒 = 𝟏. 𝟐𝟏𝟏914063
𝟏 𝟏 𝟏𝟐𝟕𝟏 𝟏 𝟏𝟐𝟕𝟏
𝒚𝟔 = 𝑦5 + . (𝒙𝟓 − 𝒚𝟓 ) = + (𝟐. 𝟓 − ) = 𝟏. 𝟓𝟑𝟑𝟗𝟑𝟓𝟓
𝟐 𝟐 𝟏𝟎𝟐𝟒 𝟒 𝟏𝟎𝟐𝟒
n 𝒙𝒏+𝟏 = 𝒙𝒏 + 𝟎. 𝟓 𝒚𝒏
0 𝒙𝟎 = 𝟎 𝒚(𝟎) = 𝟏
1 𝒙𝟏 = 𝟎. 𝟓 𝒚(𝟎. 𝟓) = 𝟎. 𝟕𝟓
2 𝒙𝟐 = 𝟏 𝒚(𝟏) = 𝟎. 𝟔𝟖𝟕𝟓
3 𝒙𝟑 = 𝟏. 𝟓 𝒚(𝟏. 𝟓) = 𝟎. 𝟕𝟔𝟓𝟔
4 𝒙𝟒 = 𝟐 𝒚(𝟐) = 𝟎. 𝟗𝟒𝟗𝟐𝟏
5 𝒙𝟓 = 𝟐. 𝟓 𝒚(𝟐. 𝟓) = 𝟏. 𝟐𝟏𝟏9
6 𝒙𝟔 = 𝟑 𝒚(𝟑) = 𝟏. 𝟓𝟑𝟑𝟗
Example 7
Use the Euler algorithm with a step size h = 0.2 to find an approximate solution of the linear
first order initial value problem
Solution This is an initial value problem for the differential equation. Setting h = 0.2, n = 10,
and f (x, y) = sin x – y in the Euler algorithm leads to the following results. The column yexact
contains the analytical solution.
مثال