Curve Fitting: Fitting A Straight Line
Curve Fitting: Fitting A Straight Line
Curve fitting means an exact relationship between two variables by algebraic equations; in fact
this relationship is the equation of the curve. Therefore curve fitting means to form an equation
of the curve from the given data (or) The method of finding an exact mathematical relationship
between the two variables is given by simple algebraic expression is called curve fitting.
LEAST – SQUARES CURVE FITTING PROCEDORES: Let the set of data points be
(xi,yi), i= 1,2,3,…..,m, and let the curve y = f(x) is fitted to this data. At x = xi, the observed value
yi and the corresponding value on the fitting curve is f(xi). If ei is the error of approximation at x
= xi, then we have
ei = yi – f(xi), i = 1,2,3,…….,m
2 2 2
If we have S = [ y 1−f ( x 1) ] + [ y 2−f ( x 2 ) ] +… … … … …+ [ y m−f ( x m ) ]
2 2 2
= e 1 + e2 +… … … … … ..+e m
∂S
For S to be minimum, we have =0
∂a
⇨−2 [ y 1−( a+b x 1) ]−2 [ y 2−( a+b x 2 ) ]−… … … … …−2 [ y m−( a+bx m ) ]=0….(2)
∂S
And =0
∂b
⇨ −2 x1 [ y 1−( a+b x 1 ) ]−2 x 2 [ y 2− ( a+b x 2 ) ] −… … … …−2 x m [ y m−( a+bx m ) ] =0..(3)
m a0 +a ( x 1 + x 2+ … … … … …+ x m )= y 1 + y 2 +… … … … .+ y m ………..(4)
And a ( x 1 + x 2+ … … … … …+ x m ) +b ( x 1 + x 2 +… … … … ..+ x m )
2 2 2
¿ x 1 y 1 + x 2 y 2 +… … .+ x m y m ……………………(5)
m m m
And a ∑ x i +b ∑ x i =∑ x i y i … … … ( 7 )
2
Equations (6) and (7) can be solved for the two unknowns a0 and a1
∑ yi =na+b ∑ x i
∑ x i y i=a ∑ x i +b ∑ x i2
Fitting of a parabola:
Let y = a+ bx+ cx2 be the parabola to be fitted to the data points (xi,yi), i= 1,2,3,…..,m, then we
have
[ ] [ ] [ ]
2 2 2
S = y 1 −( a+ b x1 +c x12 ) + y 2−( a+b x 2 +c x 22 ) +. …+ y m−( a+bx m + c x m2 )
∂S ∂S ∂ S
For S to be minimum, we have =0 , = =00 ,
∂a ∂b ∂c
∂S
=0 ⇨
∂a
[ ] [ ]
−2 y 1−( a+b x 1 +c x 1 ) −2 y 2−( a+b x 2+ c x 2 ) −… … … … …−2 y m−( a+bx m +c x m ) =0
2 2
[ 2
]
∂S
=0⇨
∂b
[ ] [
−2 x1 y 1−( a+b x 1 +c x1 ) −2 x2 [ y 2−( a+b x 2 ) +c x 2 ] −… … … …−2 x m y m−( a+bx m + c x m ) =0
2 2 2
]
∂S
=0 ⇨⇨
∂c
[ ] [
−2 x12 y 1−( a+b x 1 +c x 12 ) −2 x 22 [ y 2−( a+b x 2) + c x 22 ]−… … … …−2 x m2 y m−( a+bx m +c x m2 ) =0 ]
We get the following normal equations are
m m m
ma+b ∑ x i +c ∑ x i =∑ y i
2
i=1 i=1 i =1
m m m m
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i
2 3
And
m m m m
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i
2 3 4 2
(OR)
na+ b ∑ xi + c ∑ x i =∑ y i
2
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i
2 3
And
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i
2 3 3 2
∑ Y i=nA+ B ∑ X i … … … (4)
∑ X i Y i =A ∑ X i + B ∑ X i2 … … …..(5)
Solving equations (4) and (5), we get the value of A and b
Exponential function:
Fitting of the curve of the form y=a e bx be fitted to the given data.
Problems
1. By the method of least squares find the straight line that best fits the following data.
x 1 2 3 4 5
y 14 27 40 55 68
∑ yi =na+b ∑ x i ……………..(1)
∑ x i y i=a ∑ x i +b ∑ x i2 ……………..(2)
xi yi xiyi xi2
1 14 14 1
2 27 54 4
3 40 120 9
4 55 220 16
5 68 340 25
5a+15b =204…………….(3)
2. Fit a straight line to the following data by the method of least squares.
x 0 1 2 3 4
∑ yi =na+b ∑ x i ……………..(1)
∑ x i y i=a ∑ x i +b ∑ x i2 ……………..(2)
xi yi xiyi xi2
0 1 0 0
1 1.8 1.8 1
2 3.3 6.6 4
3 4.5 13.5 9
4 6.3 25.2 16
5a+10b =16.9…………….(3)
10a+20b = 33.8
10a+30b = 47.1
x 0 1 2 3 4
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i ………..(4)
2 3 3 2
0 1.0 0 0 0 0 0
Here n = 5
4. Fit a second degree polynomial to the following data by the method of least squares.
x 10 12 15 23 20
y 14 17 23 25 21
na+ b ∑ xi + c ∑ x i =∑ y i…………..(2)
2
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i………(3)
2 3
a ∑ x i +b ∑ x i + c ∑ x i =∑ x i y i ………..(4)
2 3 3 2
xi yi xi2 xi3 xi4 xiyi xi2 yi
Here n = 5
5. By the method of least squares, fit a second degree curve y = a+bx+cx2 to the following
data.
x 1 2 3 4 5 6 7 8 9
y 2 6 7 8 10 11 11 10 9
Ans: y = -1+3.35x-0.27x2
6. Find the curve of best fit of the type y=a e bx to the following data by the method of least
squares.
x 2 4 6 8 10
Here n = 5
From equation (4) and (5), we get
7. Using the method of least squares determine the constant a and b such that y=a e bx fits
the following data.
0 0.10 -2.3026 0 0
Here n = 6
From equation (4) and (5), we get
8. Fit a curve of the form y=a b x to the following data by the method of least squares.
x 2 3 4 5 6
Here n = 5
From equations (3) and (4), we get
5A+20B = 26.6719 ………………(5)
20A+90B = 108.5101 …………… (6)
Solving equations (5) and (6), we get
A = 4.6054, B = 0.1822
Hence a=e A=e 4.6054 =100.023∧b=e B =e 0.1822=1.1998=1.2
⸫ The required curve is y= (100.023 )( 1.2 )x .
9. Find a relation of the form y=a b x for the following data by the method of least squares.
x 2 3 4 5 6
10. Fit a curve of the form y=a xb to the following data by the method of least squares.
x 2 4 7 10 20 40 60 80
y 43 25 18 13 8 5 3 2
Which is of the form Y = A +BX … .(2) where A=log a , B=b , X =log x ,∧Y =log y
∑ Y i=nA+ B ∑ X i … … … (3)
∑ X i Y i =A ∑ X i + B ∑ X i2 … … …..(4)
Here n = 8