Professional Documents
Culture Documents
Methods
Lecture-12
[MA-200]
ARISHA ALI
Curve Fitting
ARISHA ALI 2
Curve Fitting
It is a process of finding “best fit”
curve, since different approximation
curves can be obtained for the same
data.
ARISHA ALI 3
Least Square Method
ARISHA ALI 4
Straight Line Fitting
ARISHA ALI 5
Curve Fitting by Method of Least
Square for Straight Line
Let the point (𝑥1 , 𝑦1 ) (𝑥2 , 𝑦2 )… (𝑥𝑛 , 𝑦𝑛 )
Let 𝑦 = 𝑎 + 𝑏𝑥 ---------- (1)
Is the equation of straight line to fitted above data here
σ 𝑦𝑖 = 𝑛𝑎 + 𝑏 σ 𝑥𝑖 ------- (2)
σ 𝑥𝑖 𝑦𝑖 = 𝑎 σ 𝑥𝑖 + 𝑏 σ 𝑥𝑖2 ---------- (3)
Eq (3) and Eq (2) are called the normal equations.
ARISHA ALI 6
Working Rule
▪ Let the point 𝑥1 , 𝑦1 , (𝑥2 , 𝑦2 )… (𝑥𝑛 , 𝑦𝑛 ) are the given data
▪ Find σ 𝑥 , σ 𝑦 , σ 𝑥𝑦 , σ 𝑥 2
▪ Construct the normal equation for 𝑎 and 𝑏
σ 𝑦𝑖 = 𝑛𝑎 + 𝑏 σ 𝑥𝑖
σ 𝑥𝑖 𝑦𝑖 = 𝑎 σ 𝑥𝑖 + 𝑏 σ 𝑥𝑖2
▪ Solve the normal equations and find 𝑎 and 𝑏
▪ Put them into equation of line i.e., 𝑦 = 𝑎 + 𝑏𝑥
ARISHA ALI 7
Example # 1
Using the method of least square, find the straight line 𝑦 = 𝑎 + 𝑏𝑥, that fit the
following data. Also calculate the Deviation.
ARISHA ALI 9
Cont…
Put values in normal equation
𝑛=6
σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥 ⟹ 82 = 6𝑎 + 10.5𝑏------ (1)
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2 ⟹ 127 = 10.5𝑎 + 22.75𝑏------- (2)
6𝑎 + 10.5𝑏 = 82
82−10.5𝑏
𝑎=
6
ARISHA ALI 10
Cont…
127 = 10.5𝑎 + 22.75𝑏
82−10.5𝑏
127 = 10.5 + 22.75𝑏
6
ARISHA ALI 13
Curve Fitting by Method of Least
Square for Parabola
Let the point (𝑥1 , 𝑦1 ) (𝑥2 , 𝑦2 )… (𝑥𝑛 , 𝑦𝑛 )
Let 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 ---------- (1)
Is the equation of parabola to fitted above data here
σ 𝑦𝑖 = 𝑛𝑎 + 𝑏 σ 𝑥𝑖 + 𝑐 σ 𝑥𝑖2 ------- (2)
σ 𝑥𝑖 𝑦𝑖 = 𝑎 σ 𝑥𝑖 + 𝑏 σ 𝑥𝑖2 + 𝑐 σ 𝑥𝑖3 ---------- (3)
σ 𝑥𝑖2 𝑦𝑖 = 𝑎 σ 𝑥𝑖2 + 𝑏 σ 𝑥𝑖3 + 𝑐 σ 𝑥𝑖4 --------- (4)
Eq (2), (3) and Eq (4) are called the normal equations.
ARISHA ALI 14
Working Rule
▪ Let the point 𝑥1 , 𝑦1 , (𝑥2 , 𝑦2 )… (𝑥𝑛 , 𝑦𝑛 ) are the given data
▪ Find σ 𝑥 , σ 𝑦 , σ 𝑥𝑦 , σ 𝑥 2 , σ 𝑥 2 𝑦, σ 𝑥 3 , σ 𝑥 4
▪ Construct the normal equation for 𝑎, 𝑏 and 𝑐
σ 𝑦𝑖 = 𝑛𝑎 + 𝑏 σ 𝑥𝑖 + 𝑐 σ 𝑥𝑖2
σ 𝑥𝑖 𝑦𝑖 = 𝑎 σ 𝑥𝑖 + 𝑏 σ 𝑥𝑖2 + 𝑐 σ 𝑥𝑖3
ARISHA ALI 15
Example # 2
Applying the method of least square to find an equation of the form
𝑦 = 𝑎𝑥 + 𝑏𝑥 2 that fit the following data
x 1 2 3 4 5 6
y 2.6 5.4 8.7 12.1 16.0 20.2
Solution:
𝑦 = 𝑎𝑥 + 𝑏𝑥 2 ⟹ 𝑦 = 𝑥(𝑎 + 𝑏𝑥)
𝑦
= 𝑎 + 𝑏𝑥 ⟹ 𝑌 = 𝑎 + 𝑏𝑥
𝑥
ARISHA ALI 16
x Y xY 𝑥2
1 2.6 2.6 1
2 2.7 5.4 4
3 2.9 8.7 9
4 3.025 12.1 16
5 3.2 16.0 25
6 3.367 20.2 36
𝑥 = 21 𝑌 = 17.792 𝑥𝑌 = 65.0 𝑥 2 = 91
ARISHA ALI 17
Cont…
Put values in normal equation
𝑛=6
σ 𝑌 = 𝑛𝑎 + 𝑏 σ 𝑥 ⟹ 17.792 = 6𝑎 + 21𝑏------ (1)
σ 𝑥𝑌 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2 ⟹ 65.0 = 21𝑎 + 91𝑏------- (2)
𝑎 = 2.41973, 𝑏 = 0.15589
𝑌 = 0.15589 + 2.41973𝑥
𝑦
𝑌= = 0.15589 + 2.41973 𝑥
𝑥
𝑦 = 0.15589𝑥 + 2.41973𝑥 2
ARISHA ALI 18
Example # 3 (quadratic fit)
Solution:
Let the equation of the parabolic fit is 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2
The corresponding normal equations are
σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥 + 𝑐 σ 𝑥 2
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2 + 𝑐 σ 𝑥 3
σ 𝑥2𝑦 = 𝑎 σ 𝑥2 + 𝑏 σ 𝑥3 + 𝑐 σ 𝑥4
ARISHA ALI 19
x y 𝑥2 𝑥3 𝑥4 xy 𝑥2y
𝑥 = 9 𝑦 = 𝑥2 = 𝑥3 = 𝑥4 = 𝑥𝑦 = 𝑥2𝑦 =
ARISHA ALI 21