396 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Now 0 S a ∂ = ∂ ⇒ () () 2 1 20 n iii i i yaxbx x = −− −= ∑ or 23 111 nnn ii i i iii xy a x b x === =+ ∑∑∑ (1) and 0 S b ∂ = ∂ ⇒ 2 22 1 yaxbx x iiii i n –– – ejej = ∑ = 0 ⇒ 234 111 nnn ii i i iii xy a x b x === =+ ∑∑∑ (2) Dropping the suffix i from () 1 and () 2 , then the normal equations are, 23 xy a x b x=+ ∑∑∑ 234 xy a x b x=+ ∑∑∑ 9.2.6 Fitting of the Curve b y=ax+ x Error of estimate for ith point () , ii xy is iii i b eyax x =−− We have, 2 1 n i i Se = = ∑ 2 1 n ii i i b yax x = =−− ∑ By the principle of least square, the value of S is minimum ∴ 0 S a ∂ = ∂ and 0 S b ∂ = ∂ Now 0 S a ∂ = ∂ ⇒ 1 1 20 n ii ii i b yax xx = −− − = ∑ or 2 11 nn ii i ii xy a x nb == =+ ∑∑ (1) CURVE FITTING 397 and 0 S b ∂ = ∂ ⇒ 1 1 20 n ii ii i b yax xx = −− − = ∑ or 2 11 1 nn i i i ii y na b x x == =+ ∑∑ (2) Dropping the suffix i from () 1 and () 2 , then the normal equations are : 2 xy a x nb=+ ∑∑ 2 1 y na b x x =+ ∑∑ Where n is the number of pair of values of x and y. 9.2.7 Fitting of the Curve 0 1 c y= +c x x Error of estimate for i th point () , ii xy is 0 1ii i i c ey cx x =−− We have, 2 1 n i i Se = = ∑ 2 0 1 1 n ii i i c ycx x = =−− ∑ By the principle of least square, the value of S is minimum ∴ 0 0 S c ∂ = ∂ and 1 0 S c ∂ = ∂ Now 0 0 S c ∂ = ∂ ⇒ 0 1 1 1 2( ) 0 n ii ii i c ycx xx = −− −= ∑ ⇒ 01 2 11 1 11 nn n i i ii ii i y cc x xx == = =+ ∑∑∑ (1) and 1 0 S c ∂ = ∂ ⇒ () 0 1 1 20 n ii i i i c ycx x x = −− = − ∑ 398 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES or === =+ ∑∑∑ 01 111 1 nnn ii i i iii yx c c x x (2) Dropping the suffix i from () 1 and () 2 , then the normal equations are, 01 2 11 y cc x x x =+ ∑∑ ∑ 01 1 yx c c x x =+ ∑∑ Example 8. Find the curve of best fit of the type bx yae = to the following data by the method of least sqaures: x :157912 :y 10 15 12 15 21 Sol. The curve to be fitted is bx yae = or ,YABx++ where 10 log , Yy= 10 log , Aa= and 10 log . Bb e= Therefore the normal equations are: 5YABx=+ ∑∑ 2 xY A x B x=+ ∑∑∑ xyY = log 10 yx 2 xY 1 10 1.0000 1 1 5 15 1.1761 25 5.8805 7 12 1.0792 49 7.5544 9 15 1.1761 81 10.5849 12 21 1.3222 144 15.8664 x = ∑ 34 5.7536Y = ∑ x 2 300 = ∑ xY ∑ Substituting the values of x ∑ , etc. and calculated by means of above table in the normal equations. We get, 5.7536 = 5A + 34B and 40.8862 = 34A + 300B On solving these equations we obtain, A = 0.9766; B = 0.02561 Therefore a = anti log 10 A = 9.4754; b = B elog 10 = 0.059 Hence the required curve is y = 9.4754e 0.059x . Ans. Example 9. For the given data below, find the equation to the best fitting exponential curve of the form y = ae bx . x12 3 456 y 1.6 4.5 13.8 40.2 125 300 CURVE FITTING 399 Sol. y = ae bx On taking log both the sides, log y = log a + bx log e, which is of the form Y = A + Bx, where Y = log y, A = log a and B = b log e. x y Y = log y 2 x xY 1 1.6 0.2041 1 0.2041 2 4.5 0.6532 4 1.3064 3 13.8 1.1399 9 3.4197 4 40.2 1.6042 16 6.4168 5 12.5 2.0969 25 10.4845 6 300 2.4771 36 14.8626 21x = ∑ 8.1754Y = ∑ 2 91 x = ∑ 36.6941xY = ∑ Normal equations are: 6YABx=+ ∑∑ 2 xY A x B x=+ ∑∑∑ Therefore from these equations, we have, 8.1754 = 6A+21B 36.6941 = 21A+91B ⇒ A = – 0.2534, B = 0.4617 Therefore, log log( 0.2534) log(1.7466) 0.5580a anti A anti anti==−= = and 0.4617 1.0631 log 0.4343 B b e == = Hence required equation is 1.0631 0.5580 x ye = . Ans. Example 10. Given the following experimental values: x 01 2 3 y 241015 Fit by the method of least squares a parabola of the type 2 yabx=+ . Sol. Error of estimate for i th point (,) ii xy is () 2 ii i eyabx =−− By the principle of least squares, the values of a and b are such that () 44 2 22 11 iii ii Se yabx == == −− ∑∑ is minimum. Therefore normal equations are given by 2 0 S ynab x a ∂ =⇒ = + ∂ ∑∑ (1) 224 0 S xy a x b x b ∂ =⇒ = + ∂ ∑∑∑ (2) 400 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES x y 2 x 2 xy 4 x 02000 14141 2 10 4 40 16 3 15 9 135 81 Total 31y = ∑ 2 14 x = ∑ 2 179 xy= ∑ 4 98 x = ∑ Here 4n = From () 1 and () 2 , 31 4 14ab=+ and 179 14 98ab=+ Solving for a and b, we get a = 2.71 and b = 1.44 Hence the required curve is 2 2.71 1.44 yx=+ Example 11. By the method of least square, find the curve 2 yaxbx=+ that best fits the following data: x 12345 y 1.8 5.1 8.9 14.1 19.8 Sol. Error of estimate for ith point (,) ii xy is () 2 i iii eyaxbx =−− By the principle of least squares, the values of a and b are such that () 55 2 22 11 iiii ii Se yaxbx == == −− ∑∑ is minimum. Therefore normal equations are given by === ∂ =⇒ = + ∂ ∑∑∑ 555 23 111 0 ii i i iii S xy a x b x a and 555 234 111 0 ii i i iii S xy a x b x b === ∂ =⇒ = + ∂ ∑∑∑ Dropping the suffix i, normal equations are : 23 xy a x b x=+ ∑∑∑ (1) 234 xy a x b x=+ ∑∑∑ (2) x y 2 x 3 x 4 x xy 2 xy 1 1.8 1 1 1 1.8 1.8 2 5.1 4 8 16 10.2 20.4 3 8.9 9 27 81 26.7 80.1 4 14.1 16 64 256 56.4 225.6 5 19.8 25 125 625 99 495 Total 2 55 x = ∑ 3 225 x = ∑ 4 979 x = ∑ 194.1xy = ∑ 2 822.9 xy= ∑ CURVE FITTING 401 Substituting these values in equations () 1 and () 2 , we get 194.1 55 225ab=+ and 822.9 225 979ab=+ ⇒ 83.85 1.52 55 a =≈ and 317.4 0.49 664 b =≈ Hence required parabolic curve is 2 1.52 0.49 yxx=+ . Ans. Example 12. Fit an exponential curve of the form x yab = to the following data: x 12345678 y 1.0 1.2 1.8 2.5 3.6 4.7 6.6 9.1 Sol. x yab = takes the form ,YABx=+ where log ;Yy= logAa= and log .Bb= Hence the normal equations are given by Y nA B x=+ ∑∑ and =+ ∑∑∑ 2 xY A x x 2 log 1 1.0 0.0000 0.000 1 2 1.2 0.0792 0.1584 4 3 1.8 0.2553 0.7659 9 4 2.5 0.3979 1.5916 16 5 3.6 0.5563 2.7815 25 6 4.7 0.6721 4.0326 36 7 6.6 0.8195 4.7365 49 8 9.1 0.9590 7.6720 64 36 30. xyYyxY x xy = == ∑ 2 5 3.7393 22.7385 204 YxY x== = ∑∑ ∑ ∑ Putting the values in the normal equations, we obtain 3.7393 8 36AB=+ and 22.7385 36 204AB=+ ⇒ 0.1406B = and A = 1.8336 ⇒ log 1.38banti B== and log 0.68.aanti A== Thus the required curve of best fit is ()() 0.68 1.38 .yx = Ans. Example 13. Fit a curve x yab = to the following data: x 23456 y 144 172.8 207.4 248.8 298.5 Sol. Given equation x yab = reduces to Y = A + Bx where Y = log y, logAa= and log .Bb= 402 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES The normal equations are: log log logyn a b x=+ ∑∑ 2 log log log xy ax bx=+ ∑∑∑ The calculations of ,x ∑ log ,y ∑ 2 x ∑ and logxy ∑ are substitute in the following tabular form. x y 2 x log y x log y 2 144 4 2.1584 4.3168 3 172.8 9 2.2375 6.7125 4 207.4 16 2.3168 9.2672 5 248.8 25 2.3959 11.9795 6 298.5 36 2.4749 14.8494 20 90 11.5835 47.0254 Putting these values in the normal equations, we have 11.5835 5log 20logab=+ 2 47.1254 20 log 90 log abx=+ . Ans. Solving these equations and taking antilog, we have 100,a = b = 1.2 approximate. Therefore equation of the curve is () 100 1.2 .yx = Example 14. Derive the least square equations for fitting a curve of the type y = ax 2 + (b/x) to a set of n points. Hence fit a curve of this type to the data. x 1234 y –1.51 0.99 3.88 7.66 Sol. Let the n points are given by () 11 , xy , () 22 , xy , () 33 , xy , , () , nn xy . The error of estimate for the ith point () , ii xy is () 2 [/] iii i eyaxbx =− − . By the principle of least square, the values of a and b are such so that the sum of the square of error S, viz., 2 22 1 n iii i i b Se yax x = == −− ∑∑ is minimum. Therefore the normal equations are given by ∂∂ == ∂∂ 0, 0 SS ab or 24 11 nn ii i ii yx a x == = ∑∑ + b x i i n = ∑ and 2 111 1 nnn i i i i iii y axb x x === =+ ∑∑∑ These are the required least square equations. CURVE FITTING 403 x y 2 x 4 x 1 x 2 1 x 2 yx y x 1 –1.51 1 1 1 1 –1.51 –1.51 2 0.99 4 16 0.5 0.25 3.96 0.495 3 3.88 9 81 0.3333 0.1111 34.92 1.2933 4 3.66 16 256 0.25 0.0625 122.56 0.9150 10 354 1.4236 159.93 1.1933 Putting the values in the above least square equations, we get 159.93 354 10ab=+ and 2.1933 10 1.4236 .ab=+ Solving these, we get 0.509a = and 2.04.b =− Therefore the equation of the curve fitted to the above data is 2 2.04 0.509 yx x =− . Ans. Example 15. Fit the curve pv k γ = to the following data: () 2 / pkg cm 0.5 1 1.5 2 2.5 3 () v litres 1620 1000 750 620 520 460 Sol. Given pv k γ = 1/ 1/ 1/ k vkp p γ γ− γ == On taking log both the sides, we get 11 log log logvkp=− γγ This is of the form YABX=+ Where Y = log v, X = log p, 1 logAk= γ and 1 B =− γ 2 0.5 1620 0.30103 3.20952 0.96616 0 1 1000 0 3 0 1.5 750 0.17609 2.87506 0.50627 2 620 0.30103 2.79239 0.84059 2.5 520 0.39794 2.716 1.08080 3 460 0.47712 2.66276 1.27046 pv X Y XY X −− 2 .09062 0 0.03101 0.09062 0.15836 0.22764 Total 1.05115 17.25573 2.73196 0.59825 XY XYX== = = ∑∑ ∑ ∑ 404 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Here 6n = Normal equations are, 17.25573 6 1.05115AB=+ 2.73196 1.05115 0.59825AB=+ On solving these, we get 2.99911A = and 0.70298B =− ∴ 11 1.42252 0.70298B γ=− = = Again log 4.26629kA=γ = ∴ log(4.26629) 18462.48kanti== Hence the required curve is 1.42252 18462.48. pv = Ans. Example 16. For the data given below, find the equation to the best fitting exponential curve of the form bx yae = . x 12 3456 y 1.6 4.5 13.8 40.2 125 300 Sol. Given y = ae bx , taking log we get log y = log a + bx log 10 e which is of the Y = A + Bx, where Y = log y, A = log a and B = log 10 e. Put the values in the following tabular form, also transfer the origin of x series to 3, so that u = x – 3. 2 log 3 1 1.6 0.204 2 408 4 2 4.5 0.653 1 653 1 3 13.8 1.140 0 0 0 4 40.2 1.604 1 1.604 1 5 125.0 2.094 2 4.194 4 6 300 2.477 3 7.431 9 8.175 3 12.168 19 xy yYxuuYu Total =−= −− −− In case Y = A′ + B′.u, then normal equations are given by YnAB u ′′ =+ ∑∑ 8.175 6 3AB ′′ ⇒=+ (1) 2 12.168 3 19 uY A u B u A B ′′ ′′ =+ ⇒=+ ∑∑∑ (2) Solving (1) and (2), we get A′ = 1.13 and B′ = 0.46 This equation is Y = 1.13 + 0.46u, i.e., Y = 1.13 + 0.46(x – 3) CURVE FITTING 405 or Y = 0.46x – 0.25 which gives log a = –25 i.e., anti log(–25) = anti log(1.75) = 0.557 10 64 1.06 log 0.4343 B b e === Hence the required equation of the curve is () 1.06 0.557 . yex = Ans. PROBLEM SET 9.1 1. Fit a straight line to the given data regarding x as the independent variable: 123468 2.43.13.54.25.06.0 x y [Ans. 2.0253 0.502yx=+ ] 2. Fit a straight line yabx=+ to the following data by the method of least square: 01368 13254 x y [Ans. 1.6 0.38x+ ] 3. Find the least square approximation of the form y = a + bx 2 for the data: 0 0.1 0.2 0.3 0.4 0.5 1 1.01 0.99 0.85 0.81 0.75 x y [Ans. 2 1.0032 1.1081 yx=− ] 4. Fit a second degree parabola to the following data: 0.0 1.0 2.0 1.0 6.0 17.0 x y [Ans. 2 12 3 yxx=+ + ] 5. Fit a second degree parabola to the following data: 1.0 1.5 2.0 2.5 3.0 3.5 4.0 1.1 1.3 1.6 2.0 2.7 3.4 4.1 x y [Ans. 2 1.04 0.193 0.243 yxx=− + ] 6. Fit a second degree parabola to the following data by the least square method: 12345 1090 1220 1390 1625 1915 x y [Ans. 2 27.5 40.5 1024 yx x=++ ] . method of least squares a parabola of the type 2 yabx=+ . Sol. Error of estimate for i th point (,) ii xy is () 2 ii i eyabx =−− By the principle of least squares, the values of a and b are. .Bb= 402 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES The normal equations are: log log logyn a b x=+ ∑∑ 2 log log log xy ax bx=+ ∑∑∑ The calculations of ,x ∑ log ,y ∑ 2 x ∑ and logxy ∑ are. = ∑ x 2 300 = ∑ xY ∑ Substituting the values of x ∑ , etc. and calculated by means of above table in the normal equations. We get, 5.7536 = 5A + 34B and 40.8862 = 3 4A + 300B On solving these equations we obtain, A = 0.9766;