Curve Fitting For Gtu Amee
Curve Fitting For Gtu Amee
for the data to satisfy as accurately as possible and such an equation in called
the "best fitting equation" or the "curve of best fit". Tte following procedure
Gauss, called the least square approximation is described as below.
Let y = f{x) be an approximate relation that fits into a given data (Xi, Yi)s
i = 1, 2, n, y;'sare called values and Y = f(x;) are called
the observed
the expected values. Their difference Ri yY are= called the residuals or
estimated errors. The method of least squares provides a relationship y = f(3)
is the difference between the observed and estimated values of y. The method
of least squares is to find the parameters a and b such that the sum of squares
of the residuals is minimum (least).
n
Let S R?
1
Simplyfying, we have
xy + ax + bx =0
150
Numerical and
StatisticalMMethods
and
y +
ax + b =0
n
( 1+ l+ ... n times = n)
But b =b El =bn
above equations becomes
aExb2x = Exy
ax+nb =2y 2)
These equations are called the normal equations and on solving we e
the values of a and b so that y = ax + b is the equation of the best fitting
get
straight line.
Note 1: (Direct method) : If the numbers in the given data are large
-1
y f1 0
SOLUTION Let y =
ax + b be the desired line
Here n= 4, Zx = 2, Zx' =
6, Zy =
6, Exy =
8
The normal equations are
y = alx + nb
2a+ 4b =6
Exy ax + bLx 6a+ 2b 8
Solving we get a = b = 1, giving the required straight line y x +
Ciurve
line at
EXAMPLE 2 By the method of least squares, find the straight
best
fits the following data.
2 3 5
X
y 14 27 40 55 68
SOLUTION First Method Let the straight line of best fit be
y a x +b ), Heren = 5
Lxy =
aXx + bEx
and y = azx + nb i)
The values of 2x, 2y, Lx and Exy are calculated as shown below
Y xy
14 14
2 27 4 54
40 120
55 16 220
68 25 340
2x= 15 y 204 Ex = 55 Zxy =748
of best fit
Putting these values in Eqn. (1), we get the line 13.6x.
=
as y
Second Method Let X x - 3, Y = y - 40 and let the straight line
EY = ALX + nB .ii)
y X =x - 3 Y = y -40 XY
1 14 -2 -26 4 52
2 27 -1 -13 1 13
3 40 0 0 0
4 55 1 15 1 15
5 68 2 28 4 56
EX = 0 EY = 4
X =10 LXY= 136
c a l Met
Substituting 2X
Methods
we get 0, EY =
4, EXY =136, LX* =
and n= 5 in Eon
10 and n =
qn. (Gi),
136 = 10A
and 4 5B
Solving we get A = 13.6 and B =
0.8
From Eqn. (i), Y =
13.6X + 0.8
i.e. y 40 13.6 (x - 3) + 0.8
Or y13.6x
EXAMPLE
for the data.
3 Fit a
straight line y = a + bx in the least
square sense
6 8 99 11 14
y1 4 5 _78 9
SOLUTION The values of x are not
X. y are small in equally spaced and the values
normal magnitude. We shall solve the
problem by direct method. The
of
equations for y =
a + bx are
given by
y na + bEx
and Exy alx
=
+
bEx, Here n= 8
X
xy x2
1
1
3 1
2
9
4
16 16
6
24
8 36
5 40
9 64
63
11
8 81
88
14 9 121
126
Ex = 56 y= 40 196
Exy =
364 x
The normal =524
equations becomes
8a + 56b =
40
56a +524b =
364
Solving we get a =
0.52 and b
The
=
0.64
equation y a* bx
becomes y =
0.52 + 0.64x.
Least Squares Linear d n a
CurveP i Fitting
Ly 12 1521 25
and so we can
The values of x
equally spaced are not
big enough we
SOLUTION
S O L U T I O N
n05e X
Y= x
-
X, y -
choo
for c o n v e n i e n c e .
We have
18.25
= 340 y n
= =
18.
We choose y=
Thus we have X =x 85, Y =
y - 18
aX + b are
line of fit Y
The normal equations for the straight
EY aXX + nb
=
a.0+4b =
aX + b, becomes y
-
18 = 0.19 (x -
y 0.19x + 2.1
EXAMPLE 5 A simply supported beam carTies a concentrated load P
Hence we
choose p=
P- (140 + 160) P- 150
20/2 10
Also we have Y = 2Y = 39 -
0.65 and for convenience
y Y
6 we choose
oose
Y =Y - 0.65.
The relevant table is
given below.
P Y P 1 50
10 y Y - 0.65 PY
100
p
0.45
-0.20 1
120 0.55 25
-3 -0.10 0.3
140 0.60 -1
-0.05 0.05
160 0.70 1
1
0.05
180 0.80 3
0.05
200
0.15 0.45
0.85 5 9
5.20 1 23
Ep 0 Ey 0.05
The normal
py =
2.85 p? =70
equations for y =
a +
bp are
Zy =
na +
bZp
Epy ap +bLp*, (n 6)
6a + b.0 =0.05
a
= 0.05
6
=
0.0083
a.0b.70 2.85 b b = 2.85
The 70 0.041
equation y a+ bp bcomes
Y -
0.65 =
0.0083 +
0.041P=10
i.e. Y =
0.65 +
0.0083 +
or Y 0.0041P +
0.0041 (P -
150)
0.0433
When P =
150, Y =
0.0041 x 150 +
0.0433 =
0.66
Curve Anear and
Polynomial Regression 155
EXAMPLE 6 IfP is the
pull required to lift a load W by means of pulley
lack, find a linear law of the form P
mW + = c connecting P and W using
following data J
P: 12 15 21 25
W:500
50L 70 100 120
Where P ánd W are taken in kg-wt. Compute P when W 150kg.
[G.T.U., Sem.V(IT), Dec. 2010]
SOLUTION Heren =4
The corresponding normal equations are
P =4c + m LW
73 4 c + 340m
.e 2c + 170m = 365
(2)
34c+3180m 675 ..(3)
Multiplying (2) by 17 and subtracting from (3), we get
m = 0.1879
data (1 to 8).
following
to the
straight line
Fit ne
least square
1. x
2
y 0.5
3
2. 0 27
0
y 9 11
3. x 2 9
10
2
6
y 4
2 3
4. x 0 9.35 12.05
6.50
1.00 3.85
51.0 73.2 95.7
5. 20.5 32.7 1032
765 826 873 942
8 10 12
6. 2 4 6
9.20 10.19 11.01 12.05
7.32 8.24
-3 1 0 2 4
7.
y: 0.4 -0.1 -02-0.3 -0.3 0.1 04
8. x:-1 0
y: 1 5
Find the equation of the best fitting straight line for the following data
(9 to 14).
9. x 1 2
y:14 13
10. x : 0|
3 5
9 8 24 28 26 20
11. x L 0
4
y: 2
2
6
4
12. x 62 64 65 69 70
65.7 66.8 71 72
67.2 69.3
13. x 1 2
69.8 70.5 70.5 70.9
70.9
V : 80 90 6
92 83 94 99 92
14. Year (x):_
Production (y) 19111921 1931 1941 1951
(in thousand tons) 8 10 12 10 6
Curve F i n g
y ax c such that
the
and estimated values of y. We have to find a, b,
the observed
sum of the squares of the residuals is minimum (least).
...(1)
Let S E y (ax +bx + c)1
conditiOns
S function of three variables a, b, c the necessary
Treating as a
dS d S d 0. Hence
for S to be minimum are
da ob dc
(- x) 0
2 Iy -
(ax bx + c)] =
2 (y -
(ax + bx +
c) ( x) =
0
bx c)] (- 1) = 0
2 y -
(ax + +
Simplifying we have
x'y + ax+ bx + cx = 0
n
n
xy +
E ax +
bx + cx = 0
n
ax+ bx + c 0
- y*2
but c c l= Cn [ l+1+... n times=n
1
The above equations becomes
aEx+bEx3 + cEx =
Zx*y
+ bEx + c2x =
Lxy
ax
ax+ bEx + nc = 2y
These equations are called normal equations and on solving we get the
Values of a, b, c so that
y ax2 + bx + c is the best fitting (parabola) curve of second degree.
and Statistical Met
Numerical
hods
158
to the data
square
parabola
AAMPLE 1 Fit the least 2
0
X
2
2x= 2, Zx2 =
6, Ex' = 8, Xx =
4c+ 2b + 6a = 5
2c + 6b + 8a = 12
6c+ 8b + 8a = 0
0.55, b =
2.15, a = -0.25
Solving we get c =
Hence y = 0.55 + 2.15x - 0.25x
y na + bEx + cEx*
Exy = ax + bLx +cEx3
Exy = aEx + bEx3 + cEx
(n 5)
The relevant table is given below
xy x'y
0 0
0 0
1 1.8 1.8 1.8 1 1
1.3 2.6 5.2 4 8 16
3 2.5 7.5 22.5 9 27 81
4 2.3 9.2 36.8 16 64 256
Ex =10 Ey =8.9
21.1| Exy= Exy=6.3 x=30| Ex= 100
the normnal equations becomes x=354
5a +10b + 30c = 8.9
10a + 30b + 100c i)
=21.1
30a + 100b + 354c ...(ii)
66.3 =
c 0.021
Curve Pfting
0.84 = -3.3
Substituting the value of c in (iv), -10b +
i.e.-10b =
4.14 b =
0.414
Sa = 5.39 a = 1.078
i.e.
0.021x*
1.078 +0.414x
-
= bx + Cx2 is y
Hence the required parabola y
a +
in the least
3 Fit a second degree parabola y ax + bx +c
EXAMPLE = 6.
estimate y at x
Square sense
for the following data and hence
2 3 4
13 16 19
10 12
y
We have y == =14
and let Y = y - y = y-14
= aX+ bX + c are
The normal equations for Y
EY = aEX+ bLX + nC
aEX + bLX2 + CLX
EXY =
n 5
EXY = aLX4 + bLX3 + CEXx
below :
The relevant table in as
xyXX=x-3|Y=y-14
XY xY X x X
4 8 -16 4 -8 16
10 -2
2 -2 -1 1
2 12 -1 -2
0 0 0
3 13 0 1
2 2 1 1
4 16 1 2
5 10 20 4 8 16
5 19 2
EY EXY XxY X EX EX
LX
= 0 = 0 22 =4 = 10 =0 = 34
becomes
The normal equations
10a 5 c = 0 (i)
. b = 2.2 .(ii)
10b = 22
ii) 2 x
nods
0 c = -0.58
Substituting in ), 10 (0.29) 5c +
3)- 0.588
y 14 + 0.29 (x2 6 x + 9) + 2.2 (x - 3) - 0.58
EXERCISES 5.2
i. X 0
14
2 3 5 6
18 23 29 36 40 46
22. x : 1 0 20 30 40 50 60
157 179 210 252 302 361
3. 0 2
3
Ly:1 10
22 38
x: 2 3 4
Ly:25 28 33 39 46
5. x:2 4 6 8 10
y:3.07 12.85 31,47 57.38 91.29
Fit the least
square parabola to the
6.
following data (6 to 10).
x 2
Ly:2 1
-2
7.
2
y: -1 0 5
8.x T 2
y 3.07 8 10
12.85 31.47 57.3891.29
9.
x| 2 -1 0
0.17 0.53 0.57 0.58 0.33
10. x : | 0.78
2.34 3.12
|y:2.50 1.20 1.12 2.25 3.81
4.25
Curve .
hfain (i)
Obtain (i) the least square straight line and (ii) the least square parabola
following data
to the
2 3 4
11.
y 1.7 1.8 2.3 3.2
12. x 2
0
y:
Fit the least square straight line of the form y = ox to the data
13.
3 4
2.13 2.86 3.60 4.29 4.95
x 2 4 6 8 10
y : 0.973 3.839| 8.641 15.987 23.794
in
15. Apply the. method of least squares to find the constants
y ay + a]x + a2x to fit the data
2 3 4. 6
linear
linear
reduced
to
log y log a
=
a =, A,
Y and log =
line.
Y A + Bx, which is a straight
data:
1 Determine a and b so that y
=
ae% fits the
EXAMPLE
X 2 3 4
y 7 11 17 27
SOLUTION y = ae yields on taking logarithm,
log y log a + bx
Now n =4, Ex =
10, Lx* =
30, ZY =10.48, ExY =28.44 yielding uhe
normal equations
4A + 10b =
10.48
10A+ 30b = 28.44
Solving, we get A =
1.5, b =
0.45
Hence A =log a =
1.5 a =
e =
4.48, b 0.45
Fitting.Least Squares
Curve Linear and Polynomial Regression 163
EXAMPLE 2
EXAMPLE Fit
curve of the form
y
a
= ab for the data and hence
find the estimation for y when x = 8.
2 3 4 5 6 7
y 87 97 113 129 202 195 193
[G.T.U., Sem.VIT), Jan. 2012]
sOLUTION Taking logarithm on both sides of y =ab*i
log y= log a + x log b
Denoting Y =
log y, A =
log a, B = log b, we have
Y =A + Bx, which is a
straight line.
The normal equations are
EY = nA + BEx
ExY =
ALx + BXx', n = 7
X Y loge y XY x
87 4.46 4.47 1
97 4.57 9.14 4
113 4.73 14.19 9
129 4.86 19.44 16
5 202 5.31 26.55 25
6 195 5.27 31.62 36
7 193 5.26 36.82 49
4.35 B =
0.1554
()-4 x ) » 28B =
73.9 (1.1681)°
= 256.14
, when x = 8, y =
164
pressure P and the
the
EXAMPLE 3 At constant
temperature,
the
constant.
volume
Find the best e
are connected by the relation PV
=
hen PP== 4
V when
fitting
V of a gas data and
estimate
Denoting log.P =
y, log.C a,
-
Y
We have y =a + bx which is a straight line
The normal equations are
2y = na + bEx
Exy = aEx + bEx, n = 6.
P V x = logeV y log.P xy x
0.5 1620 7.39 -0.69 -5.0991 54.6121
PVl42= 18144
Fitting
Fiiing
: LLeast Squares Linear and Polynomial Regression
Curve
18144 Vl42=8144
P = 4, 4V
=
or
When 4
yl42 4536 V 375.94288 376.
i.e.
When P= 4, V =
376.
EXAMPLE 4 Fit a curve of the type y = C eAx for the five data points
(4, 7.5)
(0, 1.5), (1.2.5), (2, 3,.5), (3, 5.0)
and
Nov./Dec. 2011]
[G.T.U., Sem.V(IT),
.(1)
SOLUTION y C eAx
Taking logarithm on both sides
.(2)
logy logC + Ax
=
Y AX + B
.(4)
the original points and obtain
Apply the transformation (3) to
In(3.5), (3, In(5, 0)) (4, n(7.5))}
X, Y)}= {(0, In(1.5), (1, n(2.5), (2,
.(5)
1.25276), (3, 1.60944), (4, 2.01490)}
{(0, 0.40547), (1, 0.91629), (2,
Calculation of the coefficients for
the normal equations for (4) is shown in
the following table.
Y in(y X X,Yk
Yk X
0.405465 0.0 0.000000
0.0 1.5 0.0
0.916291 1.0 0.916291
1.0 2.5 1.0
1.252763 4.0 2.505526
2.0 3.5 2.0
9.0 4.828314
3.0 5.0 3.0 1.609438
2.014903 16.0 8.059612
4.0
4.07.5 X EX,Y
CX LY
= 10.0
= 6.198860 =
30.0 =
16.309743
and B is
for determining A
he resulting linear system
30A+ 1OB 16.309742
=
10A+ 5B
= 6.198860 .(6)
0.3912023 andB =0457367.
ne solution is A
=
y:133 55 23 7 2 2
Determine the constants in y = ae fitting the data
1 2 3
y:60 30 20 15
5. Determine the constants in y =
ax fitting the
:2.2 2.7 4.1 3.5
65 605350
6. Find a and b so that y =
ae"* fits the data
x 0.2 0.3 04 0.5 0.6 0.7 0.8
y : | 3.16 2.38 1.75 1.34 1.00 0.74 0.56
7. Find the constants in acx
y =
fitting the data
x 77 100 185 239 285
y:2.4 3.4 7.0 11.1 19.6
8. Fit a curve of the type y =
ab" to the
following data
X
50 450
780 1200 4400 4800 5300
5300
y 28 30 32 36 51 58 69
Hint: Proceed as
[G.T.U., Sem.V(IT), Summer 2014)
per solved Ex. 2 page
174.]
mial Kegre
ression 167
ANSWERS
EXERCISES 5.1
2. y =-4.2 8.8x
3. y = 0.9431x - 0.0244
4. y = 1.03 + 2.76x
5. y = 702 + 3.39x
6. y =
6.37 + 0.47x
7. y0
8. y =
0.4 -
1.8x
9. y-3.2x + 18.2
10. y =
3.23x + 11.096
11. y = 0.5x + 1.336
12. y =
0.52x + 33.46
13. y =2x + 82 14. y = 0.16x - 302.56
EXERCISES 5.2
1. y =
0.083x + 4.96x + 13.46 2. y =
0.046x- 0.84x + 143.67
3. y =
2.23x + 0.18x + 146 4. 0.64x
y = + 1.46x + 2.78
5. y =
0.9925x2 0.86x 0.7 6. 1.15
-
+ y -
1.05x 0.25x
7. y =
1.3x + 0.5x2 8. y 0.696 0.855x
= -
+ 0.992x
9. y 0.66314 +0.037x 0.10357x
10. y =
5.045 4.043x + 1.009x
. 2 0.5x
(i) y = 1 + 0.5x (ii) y = +
0.2x
22x 29
12. i) y = 22x-29 Gi) y =
26 26
13. y =
0.713x
Statistical
Numerical
and
Method
168
14. y = 0.24125x2
= 11.499 1.755x +
0.181x
l. y 10.857 + 2.657x, y
1.00299x (ü) y
= 0.98856- 0.96013x - 0.010712
17. (i) y = 1.00999 -
EXERCISES 5.3
5. a =
91.8, b =
-0.434 6. a =
5.63, b =
-2.89
7. a =
1.2, b =0.0096