Chapter 4-11007 PDF
Chapter 4-11007 PDF
Chapter 4-11007 PDF
𝐸 = ∑(𝑦𝑖 − 𝑎 − 𝑏 𝑥𝑖 )2
𝑖=1
To minimize the error
𝑛
𝜕𝐸
=0 ⟹ −2 ∑(𝑦𝑖 − 𝑎 − 𝑏 𝑥𝑖 ) = 0
𝜕𝑎
𝑖=1
𝑛 𝑛 𝑛
∑ 𝑦𝑖 = ∑ 𝑎 + ∑ 𝑏 𝑥𝑖
𝑖=1 𝑖=1 𝑖=1
29
𝑛 𝑛
𝑜𝑟 ∑ 𝑦𝑖 = 𝑛 𝑎 + 𝑏 ∑ 𝑥𝑖 ⟶ (1)
𝑖=1 𝑖=1
𝑛
𝜕𝐸
𝐴𝑙𝑠𝑜 =0 ⟹ −2 ∑(𝑦𝑖 − 𝑎 − 𝑏 𝑥𝑖 ) 𝑥𝑖 = 0
𝜕𝑏
𝑖=1
𝑛 𝑛 𝑛
∑ 𝑥𝑖 𝑦𝑖 = ∑ 𝑎 𝑥𝑖 + ∑ 𝑏 𝑥𝑖 2
𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛
𝑜𝑟 ∑ 𝑥𝑖 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 ⟶ (2)
𝑖=1 𝑖=1 𝑖=1
Example 1
Fit a straight line 𝑦 = 𝑎 + 𝑏 𝑥 to the data
x 0 5 10 15 20 25
y 100 111 119 132 140 151
Solution
To use equation (1) , (2) above we construct the table
) نحتاج لتكوين الجدول التالى2( ) و1( الستخدام المعادلة
x y 𝑥2 xy
0 100 0 0
5 111 25 555
10 119 100 1190
15 132 225 1980
20 140 400 2800
25 151 625 3775
∑ 𝑥𝑖 ∑ 𝑦𝑖 ∑ 𝑥2 ∑ 𝑥𝑦
𝑖 𝑖 𝑖 𝑖
= 75 = 753 = 1375 = 10300
30
Substitute in equation (1), (2) above
753 = 6 𝑎 + 75 𝑏 → (1)
يمكن التحقق من صحة الدالة السابقة بالحصول منها على الجدول المعطى
Fitting to a parabola
Sometimes the data is known to be fitted by a parabola
احيانا تكون البيانات يمثلها دالة تربيعية
𝑦 = 𝑎 + 𝑏 𝑥 + 𝑐𝑥 2
∑ 𝑦𝑖 = 𝑛𝑎 + 𝑏 ∑ 𝑥𝑖 + 𝑐 ∑ 𝑥𝑖 2 ⟶ (3)
𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛 𝑛
∑ 𝑥𝑖 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 + 𝑐 ∑ 𝑥𝑖 3 ⟶ (4)
𝑖=1 𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛 𝑛
∑ 𝑥𝑖 2 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 2 + 𝑏 ∑ 𝑥𝑖 3 + 𝑐 ∑ 𝑥𝑖 4 ⟶ (5)
𝑖=1 𝑖=1 𝑖=1 𝑖=1
Example 2
Fit a parabola 𝑦 = 𝑎 + 𝑏 𝑥 + 𝑐𝑥 2 to the data
x 0 1 2 4 6
y 3 1 0 1 4
Solution:
31
To use equation (3), (4), (5) above we construct the table
x y 𝑥2 𝑥3 𝑥4 xy 𝑥 2𝑦
0 3 0 0 0 0 0
1 1 1 1 1 1 1
2 0 4 8 16 0 0
4 1 16 64 256 4 16
6 4 36 216 1296 24 144
∑ 𝑥𝑖 ∑ 𝑦𝑖 ∑ 𝑥 2 ∑ 𝑥 3 ∑ 𝑥4 ∑ x y ∑ 𝑥 2𝑦
𝑖 𝑖 𝑖 𝑖 𝑖 𝑖 𝑖
= 13 = 9 = 57 = 289 = 1569 = 29 = 161
9 = 5 𝑎 + 13 𝑏 + 57 𝑐
29 = 13 𝑎 + 57 𝑏 + 289 𝑐
32
Example 3
Fit a function 𝑦 = 𝑎 𝑒 𝑏𝑥 to the data
∑ 𝑌𝑖 = 𝑛 𝐴 + 𝑏 ∑ 𝑥𝑖 ⟶ (1)
𝑖=1 𝑖=1
𝑛 𝑛 𝑛
∑ 𝑥𝑖 𝑌𝑖 = 𝐴 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 ⟶ (2)
𝑖=1 𝑖=1 𝑖=1
The required table is
x y Y=lny 𝑥2 xY
1.2 7.5 2.015 1.44 2.418
2.8 16.1 2.779 7.84 7.781
4.3 38.9 3.661 18.49 15.742
5.4 67 4.205 29.16 22.707
6.8 146.6 4.988 46.24 33.918
7.9 266.2 5.584 62.41 44.114
∑ 𝑥𝑖 ∑ 𝑌𝑖 ∑ 𝑥 2𝑖 ∑ 𝑥𝑖 𝑌𝑖
𝑖 𝑖 𝑖 𝑖
=28.4 =23.232 =165.58 =126.68
33
Substitute in (1), (2)
23.232 = 6 A + 28.4 b
and b = 0.537
Example 4
𝑏
Fit a function 𝑦 = 𝑎 + to the data
𝑥
Solution:
The required function الدالة المطلوبة
𝑏
𝑦= 𝑎+
𝑥
𝑦 = 𝑎+𝑏𝑋
∑ 𝑦𝑖 = 𝑛 𝑎 + 𝑏 ∑ 𝑋𝑖 ⟶ (1)
𝑖=1 𝑖=1
𝑛 𝑛 𝑛
∑ 𝑋𝑖 𝑦𝑖 = 𝑎 ∑ 𝑋𝑖 + 𝑏 ∑ 𝑋𝑖 2 ⟶ (2)
𝑖=1 𝑖=1 𝑖=1
34
The required table is
x y 1 𝑋2 Xy
𝑋=
𝑥
0.5 7.1 2 4 14.2
0.8 4.4 1.25 1.563 5.5
1.1 3.2 0.909 0.826 2.909
1.8 1.9 0.556 0.309 1.056
4 0.9 0.25 0.063 0.225
∑𝑦 ∑𝑋 ∑ 𝑋2 ∑ 𝑋𝑦
17.5 = 5 𝑎 + 4.965 b
3.559
𝑦 = −0.034 +
𝑥
Example 5
Fit a function 𝑦 = 𝑎 𝑏 𝑥 to the data
x 1 2 3 4
y 0.97 4.09 17.28 72.94
Solution:
The required function الدالة المطلوبة
𝑦 = 𝑎 𝑏𝑥
35
نحولها لشكل دالة الخط المستقيم .بادخال اللوغارتم على الطرفين
𝑏𝑛𝑙 𝑥 𝑙𝑛 𝑦 = 𝑙𝑛𝑎 +
المعادلة بعد التحويل تصبح
𝐵𝑥𝑌 = 𝐴+
𝐵 = 𝑏𝑛𝑙 𝑤ℎ𝑒𝑟𝑒 𝑙𝑛 𝑦 = 𝑌 , 𝑙𝑛𝑎 = 𝐴 ,
)∑ 𝑥𝑖 𝑌𝑖 = 𝐴 ∑ 𝑥𝑖 + 𝐵 ∑ 𝑥𝑖 2 ⟶ (2
𝑖=1 𝑖=1 𝑖=1
The required table is
x y 𝑦 𝑛𝑙 = 𝑌 𝑥2 xY
1 0.97 -0.03 1 -0.03
2 4.09 1.41 4 2.82
3 17.28 2.85 9 8.55
4 72.94 4.29 16 17.16
36
Example 6
Fit a function 𝑦 = 𝑎 𝑥 𝑏 to the data
)∑ 𝑋𝑖 𝑌𝑖 = 𝐴 ∑ 𝑋𝑖 + 𝑏 ∑ 𝑋𝑖 2 ⟶ (2
𝑖=1 𝑖=1 𝑖=1
The required table is
x y X=lnx 𝑦 𝑛𝑙 = 𝑌 𝑋2 XY
1 2.54 0 0.93 0 0
2 5.79 0.69 1.76 0.48 1.21
4 13.22 1.39 2.58 1.93 3.59
6 21.42 1.79 3.06 3.2 5.48
10 39.34 2.3 3.67 5.29 8.44
37
بالتعويض فى المعادالت ( )1و ()2
يمكن التحقق من صحة الدالة السابقة بالحصول منها على الجدول المعطى
Example 7
𝑥
= 𝑦 Fit a function to the data
𝑥 𝑏𝑎+
Solution:
The required function الدالة المطلوبة
𝑥
=𝑦
𝑥𝑏𝑎+
نحولها لشكل دالة الخط المستقيم
مقلوب الطرفين
𝑥𝑏1 𝑎+ 𝑎
= 𝑏= +
𝑦 𝑥 𝑥
38
𝑌 =𝑎 𝑋+𝑏
1 1
𝑤ℎ𝑒𝑟𝑒 𝑌 = , 𝑋=
𝑦 𝑥
)2( ) و1( يمكن االن استخدام معادالت الدالة الخطية
𝑛 𝑛
∑ 𝑌𝑖 = 𝑛 𝑏 + 𝑎 ∑ 𝑋𝑖 ⟶ (1)
𝑖=1 𝑖=1
𝑛 𝑛 𝑛
∑ 𝑋𝑖 𝑌𝑖 = 𝑏 ∑ 𝑋𝑖 + 𝑎 ∑ 𝑋𝑖 2 ⟶ (2)
𝑖=1 𝑖=1 𝑖=1
Finally we get
𝑥
𝑦=
4.352 + 1.845 𝑥
Example 8
Fit a function 𝑦 = 𝑎 sin 𝑥 + 𝑏 cos 𝑥 to the data
39
Solution:
The required function الدالة المطلوبة
𝑥 𝑦 = 𝑎 sin 𝑥 + 𝑏 cos
)∑ 𝑋𝑖 𝑌𝑖 = 𝑏 ∑ 𝑋𝑖 + 𝑎 ∑ 𝑋𝑖 2 ⟶ (2
𝑖=1 𝑖=1 𝑖=1
40
)2( ) و1( بالتعويض فى معادلة
47.52 = 6 b + 14.1 a
Solving we get
𝑏 = 0.4 , 𝑎 = 3.199
41
Exercise 2
To fit a straight line 𝑦 = 𝑎 + 𝑏 𝑥 to the data
x 0 5 10 15 20 25
y 100 111 119 132 140 151
using the least square method to find a , b
𝑎) ∑ 𝑥𝑖 𝑦𝑖 = 6 𝑎 + 𝑏 ∑ 𝑥𝑖 𝑏) ∑ 𝑦𝑖 = 6 𝑎 + 𝑏 ∑ 𝑥𝑖
𝑖 𝑖 𝑖 𝑖
𝑐) ∑ 𝑦𝑖 = 5 𝑎 + 𝑏 ∑ 𝑥𝑖 𝑑) ∑ 𝑥𝑖 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖
𝑖 𝑖 𝑖 𝑖 𝑖
2 − ∑ 𝑥𝑖 2 =
𝑖
a) 75 b)753 c) 10300 d) 1375
3 − ∑ 𝑥𝑖 𝑦𝑖 =
𝑖
4 − 𝑎, 𝑏 equal
𝑎) 𝑎 = 2.03, 𝑏 = 100.14 𝑏) 𝑎 = 2.12, 𝑏 = 100.31
42
To fit a parabola 𝑦 = 𝑎 + 𝑏 𝑥 + 𝑐𝑥 2 to the data
x 0 1 2 4 6
y 3 1 0 1 4
𝑎) ∑ 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 + 𝑐 ∑ 𝑥𝑖 3
𝑖=1 𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛 𝑛
𝑏) ∑ 𝑥𝑖 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 + 𝑐 ∑ 𝑥𝑖 3
𝑖=1 𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛
𝑐) ∑ 𝑥𝑖 𝑦𝑖 = 5 𝑎 + 𝑏 ∑ 𝑥𝑖 2 + 𝑐 ∑ 𝑥𝑖 3
𝑖=1 𝑖=1 𝑖=1
𝑛 𝑛 𝑛
𝑑) ∑ 𝑥𝑖 𝑦𝑖 = 5 𝑎 + 𝑏 ∑ 𝑥𝑖 + 𝑐 ∑ 𝑥𝑖 2
𝑖=1 𝑖=1 𝑖=1
7 − ∑ 𝑥𝑖 3 =
𝑖
𝑎) 57 𝑏)289 𝑐) 29 𝑑) 161
8 − ∑ 𝑥𝑖 2 𝑦 =
𝑖
𝑎) 57 𝑏)289 𝑐) 29 𝑑) 161
9−𝑎 =
𝑎) 2.831 𝑏)2.246 𝑐) 2.054 𝑑) 0.378
10 − 𝑐 =
𝑎) 2.831 𝑏)2.246 𝑐) 2.054 𝑑) 0.378
43
To fit a curve 𝑦 = 𝑎 𝑒 𝑏𝑥 to the data
𝑏)𝑌 = 𝑎 + 𝑏𝑥 , 𝑌 = 𝑙𝑛𝑦
12) ∑ 𝑌𝑖 = ∑ lny =
𝑖 i
44
𝑏
To fit a curve 𝑦 = 𝑎 + to the data
𝑥
18 − ∑ 𝑋 2 =
19 − ∑ 𝑋𝑦 =
x 1 2 3 4
y 0.97 4.09 17.28 72.94
45
21) ∑ 𝑌𝑖 = ∑ lny =
𝑖 i
22) ∑ 𝑥𝑖 𝑌𝑖 =
𝑖
c) 10 = 28.5 a + 30 B d) 28.5 = 10 a + 30 B
46