Lecture 9
Lecture 9
Dina Sami
A differential equation is an equation, which contains one or more terms, which involve
the derivatives of one variable (i.e., dependent variable) with respect to the other variable
(i.e., independent variable). The general form of n-order ODE is
) بإمكانها تحقيق المعادلة التفاضلية وكذلك بامكان هذهFunction( المقصود بحل اي معادلة تفاضلية هو إيجاد دالة
ويتمثل الحل هذا بايجاد حل عام لهذه المعادلة حاويا ً على ثوابت.المعادلة تحقيق بعض الشروط االبتدائية والحدودية
فكثيرا ً ما تكون المعادالت التفاضيلة غير المعادالت الخطية وبالتالي.يمكن ايجاد قيمها من الشروط االبتدائية والحدودية
.تستوجب الحالة وجود شروط ابتدائية عند الدرجة العليا والتي قلما تكون متوفرة
114
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
ونستنتج من ذلك بان الحل التحليلي قد ال يكون مهيئا ً لمثل هذا النوع من المعادالت التفاضلية بسبب المحددات في الحل.
سوف نتعرف على حل المعادالت التفاضلية االعتيادية بالطرق العددية .وان هذه الطرق ال تحدد بصيغة قياسية .ويتم
التطرق الى طريقة حل المعادلة التفاضلية من الدرجة االولى ومن ثم كيف تستخدم نفس الطريقة في حل المعادالت
التفاضلية من الدرجة االولى ودرجات اعلى منها.
دراستنا ستكون لطريقة تعتمد على اساس القيمة االبتدائية ( )Initial Value Problemsوالتي تتواجد فيها قيمة
y(xo) = yoحيث يمكن تصنيفها الى صنفين اساسيين:
يتم هنا استخدام المعلومات المتوفرة للمنحني بنقطة واحدة فقط لحساب قيمة تقريبية للنقطة القادمة.
في هذه الطرق يمكن ايجاد قيمة الدالة في نقطة ما وذلك باستخدام معلومات عن عدد من النقاط التي سبقتها ويمكن
تحسين قيمة دالة الحل وذلك باستخدام العالقات التكرارية حيث نحصل على القيمة التقريبية ذات الدقة المطلوبة .وتعرف
هذه الطرق بالمخمن الصحيح (. ) predictor-correct
115
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
1. Euler’s method
𝑑𝑦
The general form of 1st order equation is given by = f(x, y) with condition y(xo) = yo
𝑑𝑥
𝑑𝑦
Slope = ∅ = ý =
𝑑𝑥
Xn+1= Xn + h
By geometric:
Y1 – Yo = ∅ h Y1 ∅ ∅h
Y1= Yo + ∅ h Yo h
Y1= Yo + h ýo X0 X1
This formula is referred to as Euler’s (or the Euler-Cauchy or the point-slope) method. The
new value of y is predicted using the slope (equal to the first derivative at the original
value of x) to extrapolate linearly over the step size h.
116
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
By Tayler series:
........ (1)
Where: ℎ = 𝑥𝑛+1 − 𝑥𝑛 .
For small values of h (h2, h3, h4, are small and may be neglected)
𝑦𝑎𝑐𝑡𝑢𝑎𝑙 −𝑦𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒
𝜀𝑎 = | | × 100%
𝑦𝑎𝑐𝑡𝑢𝑎𝑙
Example 1:
Sol:
𝑦𝑛+1 = 𝑦𝑛 + h 𝑦𝑛′ ➔ 𝑦𝑛+1 = 𝑦𝑛 +0.5 [(𝑥𝑛 − 1)2 − 𝑦𝑛2 ]
𝑥𝑛 𝑦𝑛
0 𝑦0 = 0.5
0.5 𝑦1 =𝑦0 +0.5 [(𝑥0 − 1)2 − 𝑦02 ] = 0.5 +0.5 [(0 − 1)2 − 0.52 ] = 0.875
1 𝑦2 =𝑦1 +0.5 [(𝑥1 − 1)2 − 𝑦12 ] = 0.875 +0.5 [(0.5 − 1)2 − 0.8752 ] = 0.6172
1.5 𝑦3 =𝑦2 +0.5 [(𝑥2 − 1)2 − 𝑦22 ] = 0.6712 +0.5 [(1 − 1)2 − 0.67122 ] = 0.4267
2 𝑦4 =𝑦3 +0.5 [(𝑥3 − 1)2 − 𝑦32] = 0.4267+0.5 [(1.5 − 1)2 − 0.42672 ] = 0.4607
2.5 𝑦5 =𝑦4 +0.5 [(𝑥4 − 1)2 − 𝑦42] = 0.4607+0.5 [(2 − 1)2 − 0.46072 ] = 0.8546
117
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
Sol:
tn (s) 𝜃𝑛 (𝑘)
0 𝜃0 = 1200
240 𝜃1 = 𝜃0 + h [-2.2067×10-12 (𝜃04 − 81 × 108 )]
= 1200 + 240 [-2.2067×10-12 (12004 − 81 × 108 )] = 106.09
480 𝜃2 = 𝜃1 + h [-2.2067×10-12 (𝜃14 − 81 × 108 )]
= 106.09 + 240 [-2.2067×10-12 (106.094 − 81 × 108 )] = 110.32
118
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
Predictor-Corrector Method :
∗
𝑦𝑛+1 = yn + h 𝑦 ′𝑛 → 𝑦𝑛 + h f (xn, yn) … (1)
ℎ ∗
𝑦𝑛+1 = yn + [f (𝑥𝑛 , 𝑦𝑛 ) + f (xn+1, 𝑦𝑛+1 )] … (2)
2
119
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
Example 4: Apply the modified Euler method with h = 0.1 to determine an approximation to the
solution to the initial-value problem, at x = 1
Sol:
∗
𝑦𝑛+1 = yn + h 𝑦 ′𝑛
∗
𝑦𝑛+1 = yn + 0.1(𝑦𝑛 − 𝑥𝑛 ) = 𝑦𝑛 + 0.1 𝑦𝑛 − 0.1 𝑥𝑛
∗
𝑦𝑛+1 = 1.1 𝑦𝑛 −0.1 𝑥𝑛 …… (1)
ℎ ∗
𝑦𝑛+1 = yn + [f (xn, yn) + f (xn+1, 𝑦𝑛+1 )]
2
120
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
Example 5: Use the Euler’s modified method to solve the following of differential
equation.
𝑑𝑦 1
= x2 + 4x - y
𝑑𝑥 2
With y (0) = 4, for x = 0 (0.05) 0.2
Sol:
∗
𝑦𝑛+1 = 𝑦𝑛 + h 𝑦 ′𝑛
∗ 1
𝑦𝑛+1 = 𝑦𝑛 + 0.05 (𝑥𝑛2 + 4 𝑥𝑛 - 𝑦𝑛 ) = 𝑦𝑛 + 0.05 𝑥𝑛2 + 0.2 𝑥𝑛 - 0.025 𝑦𝑛
2
∗
𝑦𝑛+1 = 0.975 𝑦𝑛 + 0.2 𝑥𝑛 + 0.05𝑥𝑛2 ….. (1)
ℎ ∗
𝑦𝑛+1 = yn + [f (xn, yn) + f (xn+1, 𝑦𝑛+1 )]
2
0.05 1 2
= yn + [𝑥𝑛2 + 4 𝑥𝑛 - 𝑦𝑛 + 𝑥𝑛+1 + 4 𝑥𝑛+1 – 0.5 (0.975 𝑦𝑛 + 0.2 𝑥𝑛 + 0.05𝑥𝑛2 )]
2 2
2
= yn + 0.0244 𝑥𝑛2 + 0.0975 𝑥𝑛 + 0.025 𝑥𝑛+1 + 0.1 𝑥𝑛+1 – 0.025 𝑦𝑛
2
𝑦𝑛+1 = 0.975 yn + 0.0244 𝑥𝑛2 + 0.0975 𝑥𝑛 + 0.025 𝑥𝑛+1 + 0.1 𝑥𝑛+1 …… (2)
121
Numerical and Engineering Analysis – 3rd Stage M. Sc. Dina Sami
6 x dx
3
Using Euler’s method of solving an ordinary differential equation at y (5) = 0. Use a step size of h = 1.5
8
Hint: Given 6 x 3 dx , we can rewrite the integral as the solution of an ordinary differential
5
8
= 6 x 3 , y (5) = 0 , and
dy
6 x dx = y(8) − y(5)
3
equation
dx 5
H.w 2: The concentration of salt x in a homemade soap maker is given as a function of time by
dx
= 37.5 − 3.5 x
dt
At the initial time, t = 0 , the salt concentration in the tank is 50 g/L. Using Euler’s method and a step size of
h = 1.5 min , what is the salt concentration after 3 minutes?
H.w3: solve the following differential equation numerically using Euler method and
modified Euler method. Find y (0.5) when 𝑦´ = 2 x + y, y (0) = 1. Take h = 0.1
122