You are on page 1of 359
(ae erate} Dr. V. N. Vedamurthy Dye N. Ch. S. N. lyengar NUMERICAL METHODS Dr V N VEDAMURTHY Former Principal Vellore Engineering College Vellore Dr NChS N IYENGAR Assistant Professor Vellore Engineering College Vellore 0 VIKAS PUBLISHING HOUSE PVT LTD ‘VIKAS® PUBLISHING HOUSE PVT LTD A-22, Sector-4, Noida-201301 (UP) Phone: 0120-4078900 « Fax: 4078999 Regd. Office: 876, Masjid Road, Jangpura, New Delhi-110 014 E-mail: helpline@vikaspublishing.com —» — www.vikaspublishing.com «First Floor, N.S. Bhawan, 4th Cross, 4th Main, Gandhi Nagar, Bangalore-560 009 * Phone: 080-22204639 ‘+ Damodhar Centre, New No. 62, Old No. 59, Nelson Manickam Road, ‘Aminjikarai, Chennai-600 029 * Phone: 044-23744547, 23746090 + P-51/1, CIT Road, Scheme - 52, Kolkata-700014 = Ph. 033-22866995 / 9831047102 ‘+ 67168, 3rd Floor, Aditya Industrial Estate, Chincholi Bunder, Behind Balaji international School, Malad (West), Mumbai-400 064 Ph. 022-28772545 « Fax: 022-28768301 Distributors: UBS PUBLISHERS’ DISTRIBUTORS PVT LTD 5, Ansari Road, New Delhi-110 002 ‘= Ph, 011-23273601, 23266646 « Fax: 23276593, 23274261 + 10, First Main Road, Gandhi Nagar, Bangalore-S60 009 « Ph. 080-22253803 + 2-18, MP Nagar, Zone-1, Bhopal-462 011 + Ph. 0755-4203183, 4203193 ‘+ 60, Nelson Manickam Road, Aminjkarai, Chennal-600 029 « Ph. 044-23746222 ‘+ 407940, Convent Road, Ernakulam-682 036 + Ph. 0484-2353901, 2363905 + 3rd Floor, Alekhya Jagadish Chambers, H. No. 4-1-1058, Boggulkunta, Tilak Road, Hyderabad-500 001 + Ph, 040-24754472 / 73/74 * 8/1-B, Chowringhee Lane, Kolkata-700 016 + Ph. 033-22521821, 22522910 * 9 Ashok Nagar, Near Pratibha Press, Gautam Buddha Marg, Latush Road, Lucknow-226 001 * Ph. 0522-2294134, 3014010 + 2nd Floor, Apeejay Chambers, 5 Wallace Street, Fort, Mumbal-400 001 Ph. 022-66376822-3, 66102069 + Fax: 66376921 + GF, Westem Side, Annapooma Complex, Naya Tola, Patna-800 004 « Ph, 0612-2672856, 2673973 + 680 Budhwar Peth, 2nd Floor, Appa Balwant Chowk, Pune-411 002 # Ph, 020-24461653, 24433976 Reprinted in 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008 Reprint 2009 Copyright © Vikas® Publishing House Pvt Ltd., 1998 ‘All rights reserved. No part of this publication which is material protected by this copyright notice may be reproduced or transmitted or utlized or stored in any form or by any means now known or hereinafter invented, electronic, digital or mechanical, including photocopying, scanning, recording (by any information storage or retrieval system, without prior written permission from the publisher. [ information contained in this book has been published by VIKAS® Publishing House Pvt. Lid. and has | ‘been obtained by its Authors from sources believed to be reliable and are correct to the best of their knowiedge. However, the Publisher and its Authors shall inno event be lable for any errors, omissions ‘or damages arising out of use of this information and specifically disciaim any implied warranties or merchantabilty oF fitness for any particular use, Disputes if any are subject to Delhi Jurisdiction only. Printed at City Printers, Deihi- 110002 Contents Preface CHAPTER 1 Empirical Laws and Curve Fitting 1.1 Introduction 1.2 The Linear Law 1.3 Laws Reducible to Linear Law Exercise 1.1 Answers 1.4 Method of Group of Averages 1.5 Equations Involving Three Constants Exercise 1.2 Answers 1.6 Principles of Least Squares 1.7 Fitting a Straight Line 1.8 Fitting a Parabola 1.9 Fitting an Exponential Curve 1.10 Fitting the Curve y= ax? 1.11 Sum of Squares of Residuals Exercise 1.3 Answers 1.12 Method of Moments Exercise 1.4 Answers CHAPTER 2 Theory of Equations 2.1 Introduction 2.2 Relationships Between Roots and Coefficients 2.3 Equations with Real Coefficients and Imaginary Roots BRREE LE gs REBESEESS 8 PRPS BREBB X Contents CHAPTER 3 CHAPTER 4 24 25 27 28 29 Equations with Rational Coefficients and Irratir 28 =vercise 2.1 27 Answers 28 ‘Symmetric Functions of Roots 28 Formation of Equations Whose Roo! i 2.10 Tansiormaton of Eqaions 212 Multiple Roots 215 Exercise 22 216 Answers 247 Reciprocal Equations 2.18 Exercise 23 222 Answers 2.23 Solution to Numerical, Algebraic and ranscendental Equations a4 3.1 Introduction 34 3.2. Bisection Method 32 3.3 Method of Successive Approximation 35 3.4 Method of False Position 39 Exercise 3.1 3.13 Answers 3.14 3.5 Newton's Iteration Method 3.14 3.6 Geometrical Interpretation 3.15 3.7 Convergence of Newton 3.16 3.8 Rate of Convergence of Newton Raphson Method. 3.17 3.9 Horner's Method 3.22 3.10 Descarte's Rule of Signs 3.24 3.11 Graeffe's Root-Squaring Method 3.24 Exercise 3.2 3.29 Answers 3.30 Simultaneous Linear Algebraic Equations 44 4.1 Introduction 44 42 Gauss Elimination Method 44 4.3. Gauss Jordan Method 48 4.4 Inverse of a Matrix Using Gauss Elimination Method. 4.12 Exercise 4.1 4.16 Answers 417 4.5 Method of Factorisation or Triangularisation 4.18 4.8 Crout’s Method 4.23 4.7 Inverse of Matrix by Crout's Method 432 Exercise 42 434 Answers 435 4.8 Iterative Methods 4.36 4.9 Jacobi Method of Iteration 4.36 Contents, 4.10 Gauss Seidel Iteration Method 4.11 Relaxation Method Exercise_4.3 Answers CHAPTER 5 Finite Differences CHAPTER 6 CHAPTER 7 5.1__ Introduction 5.2__Finite Differences 5.3 Forward Differences 5.4 Backward Differences 5.5 Central Differences 5.6 __ Differences of Polynomial 5.7 _ Factorial Notation or Factorial Polynomial 5.8 Reciprocal Factorial 5.9 Polynomial in Factorial Notation 5.10 Error Propagation in Difference Table 5.11 Other Difference Operators 5.12 Summation of Series Exercise 5.1 Answers Interpolation with Equal Intervals 6.1_Introduction 6.2 Gregory Newton Forward Interpolation Formula 6.3 Gregory Newton Backward Interpolation Formula 64 Error in Polynomial Interpolation 6.5 Equidistant Terms with One or More Missing Values Exercise 6.1 Answers Central Difference Interpolation Formulae 7.1 Introduction 7.2. Gauss’s Forward Interpolation Formula 7.3. Gauss’s Backward Interpolation Formula 7.4 Stirling's Formula 7.5 Bessel’s Formula 7.6 Laplace Everett's Formula 7.7 _ Relation between Bessel's and Laplace Everett's Formulae 7.8 Advantages of Central Difference Interpolation Formulae Exercise 7.1 Answers xi 4.43 4.51 4.55 456 54 5.2 54 55 5.6 57 58 5.15 5.18 5.25 5.31 5.35 61 641 64 65 6.17 6.19 TA TA 72 73 15 76 WT 78 710 7.15 7.16 xii Contents CHAPTER 8 CHAPTER 9 CHAPTER 10 Interpolation with Unequal Intervals 8.1 Introduction 8.2 Properties of Divided Differences 8.3 Relation between Divided Differences and Forward Differences 8.4 Newton's Divided Difference Formula Exercise 8.1 ‘Answers 8.5 Lagrange's Interpolation Formula 8.6 Inverse Interpolation 87 Lagrange's Method 88 Iterative Method Exercise 8.2 Answers Numerical Differentiation and Integration 9.1__ Numerical Differentiation 9.2 Derivatives Using Newton's Forward Difference Formula 9.3 Derivatives Using Newton's Backward Difference Formula 9.4 Derivatives Using Stirling's Formula 8.5 Maxima and Minima of Tabulated Function Exercise 9.1 Answers 9.6 Numerical integration 8.7 General Quadrature Formula 9.8 Trapezoidal Rule 9.9 Simpson's 1/3 Rule 9.10 Simpson's 3/8 Rule 9.11, Weddle's Rule 9.12 Errors in Quadrature Formulae 9.13 Romberg's Method Exercise 9.2 Answers Difference Equations 10.1. Introduction 10.2. Order of Difference Equation 10.3 Degree of Difference Equation 10.4 Solution to Difference Equation 10.5 Formation of Difference Equations 10.6 Linear Difference Equations 10.7 Linear Homogeneous Difference Equations with Constant Coefficients 84 84 84 86 8.12 8.13 8.13 8.17 8.18 8.19 8.22 94 O41 9.3 9.6 9.13 9.15 9.16 9.16 9.17 9.18 9.19 9.19 9.21 9.27 9.30 9.33 10.4 10.4 10.2 10.2 10.2 10.2 10.3 10.4 Contents xiii 10.8 Non-Homogeneous Linear Difference Equations 108 Exercise 104 2. 10.14 Answers. 10.14 CHAPTER 11 Numerical Solution to Ordinary Differential Equations Wt 14.4 Introduction 11.2 Power Series Solution 14.2 11.3. Pointwise Methods 11.4 11.4. Solution by Taylor's Series 11.5 11.5. Taylor's Series Method for Simultaneous First Order Differential Equations W7 11.6 Taylor's Series Method for Higher Order Differential Equations 11.10 11.7 Picard’s Method of Successive Approximations WA 11.8. Picard’s Method for Simultaneous: First Order Differential Equations 11.16 11.9 Picard's Method for Second Order Differential Equations 11.18 Exercise 11.1 11.20 Answers 11.22 11.10 Euler's Method 11.22 11.11 Improved Euler's Method 11.24 11.12 Modified Euler's Method 11.25 Exercise 11.2 11.31 Answers 11,32 11,13 Runge’s Method 11.32 11.14 Runge-Kutta Methods 11.34 11.15 Higher Order Runge-Kutta Methods 11.36 11.16 Runge-Kutta Methods for Simultaneous First Order Equations 11.42 CHAPTER 12 11.17 Runge-Kutta Method for Second Order Differential Equation Exercise 11.3 Answers 11.18 Predictor-Corrector Methods 11.19 Milne’s Method 11.20 Adams-Bashforth Method Exercise 11.4 Numerical Solution to Partial Differential Equations 124 12.1__Introduction 12.4 12.2_Difference Quotients 124 xiv Contents 12.3 Geometrical Representation of Partial Difference Quotients 12.4 Classification of Partial Differential Equations 12.5 Elliptic Equations 12.6 Solution to Laplace's Equation by Liebmann’s Iteration Process 12.7 Poisson's Equation - Its Solution Exercise 12.1 Answers 12.8 Parabolic Equations Exercise 12.2 Answers 12.9 Hyperbolic Equations Exercise 12.3 Answers 12.10 Solution to Partial Differential Equations by Relaxation method Exercise 12.4 Answers Appendix A Appendix 8: Model Test Papers Index 124 12.6 12.7 12.23 12.26 12.29 12.29 12.37 12.37 12.39 12.42 12.42 12.43 12.46 12.47 Ad AG WW Empirical Laws and Curve Fitting 1.1. INTRODUCTION Very often, the students of Engineering and Science are required to obtain data involving two variables, say, x and y (y dependent on x) from experimental observations. The data obtained is required to be expressed in the form of a law connecting the two variables x and y. In such cases, the corresponding values (x, y,) of the given data are plotted on a graph paper and a smooth curve is drawn passing through the plotted points. Such a curve is called an approximating curve. Its equation, say, y= f(x) is known as an empirical equation. it is possible to draw a number of such curves through or near the points, different empirical equations can be obtained to express the data. Now the problem is to find the equation of the curve which is best suited to predicting the unknown values. The process of finding such an equation of the “best fit’ is known as curve fitting. 1.2 THE LINEAR LAW Let the empirical law between two variables, say, x and y, of certain data be linear, i.e. of the form y=mete qa where m and c are constants to be determined. Since Eqn (1.1) is a straight line, m is the slope and c is the y intercept. If we plot the corresponding values of the data (x,, y,) with a suitable scale, they should lie on a straight line. But in practice the values obtained from 1.2 Numerical Methods experimental observations may not lie exactly on a straight line. In such cases, draw the straight line of ‘best fit’ such that the points are evenly distributed about the line. Choose two points (x,, y,) and (x, y,) which are set apart on the line so that m = (y- y,)/(x, ~ x,). ¢ can be found by substituting any point on the line or by knowing the y-intercept (i.e. value of y when x = 0). Substituting m and c in Eqn (1.1), we get the required linear law. 1.3 LAWS REDUCIBLE TO LINEAR LAW Some laws which connect the two variables x and y, and which are non- linear can be reduced to linear form by suitable substitutions as explained below. (i) Law of the type y= ax", where a and n are constants. Taking logarithms on both sides, we get log,,y=logga+mlog,x or Y=A+nX (1.2) where log,,y = ¥, log,,@= A and log,,x = X. Here, Eqn (1.2) is tinear in XY and Y. A and n are constants to be determined. (ii) Law of the type y= ae", where a andb are constants, Taking logarithms on both sides, we get log,,y = log,,a = br loge or Y= A+ Br which is linear in X and ¥. Here, A= log, a and B= b log,,e. (iii) Law of the type y = ab, where aand b are constants. Taking logarithms on both sides, we get log,,y = log,,a +x log, or ¥=A + Bx which is linear in x and Y, where A = log,,a and B= log,,b. (iv) Law of the type xy = ax + by. Writing it as y = a+ b(y/x) and setting X= ylx, we get the linear form y= a+ bY. (v) Law of the type y = ax" + b. Taking x" = X, we get y= aX+ b which is linear in y and X. By choosing n=-1, 4 , 2 we get the particular cases of above as y=alx+b,y=a\xt+b and y=ar+b. Similarly, the laws of the type xy =ax+b, y=ax"+ blogx etc. can be reduced to the linear form. Empirical Laws and Curve Fiting 1.3 Example 1.1 The following values of y and x are possibly connected by a law of the type y= ax? + b. Test if this is so and find the law. 12 20 22 24 26 30 y 60 75 90 98 10.7 115 Solution The probable law is yraetb @ Taking x’ = X, Eqn (i) becomes y=aXtb Gi) Table for X and y is X 144 256 400 484 «©6576 = 676900 y 6.0 1S 9.0 98 10.7 ILS 14 eo & ®& & & & & These points are plotted and the line of ‘best fit’ is drawn as shown in Fig. 1.1. y Scale: 1 email division Fig 1.1 As these points are lying almost along a straight line, the given law is nearly accurate. Now the slope of this line is _AP 14-6 8 o> BA = 900-144 = 756 = 0.010582 1.4 Numerical Methods * P, (144, 6.0) lies on (2). 6 = (0.010582) (144) + or b= 4.48 (approx) which can also be observed from the graph. Hence, the curve of ‘best fit’ is y= 0.010582 X + 4.48 ie. Y= 0.010582 x? + 4.48 Example 1.2 The values of x and y obtained in an experiment are as follows: x 23 3.1 4 492 5.91 7.20 y 33 39.1 50.3 67.2 856 125 Find a law of the type y = ae™. Solution Given law type is ya aet Taking logarithms (to base 10) on both sides, we get log,,y = log,,a + bx log, e or Y=A+ Bx where Y=log,,y, A=log,, and B= blog, e Table for x and Yis as under : x 23 3.1 4 492 5.91 7.20 Y=log,y 1.52 159 1.7 1.83 1.93) 2.1 f) f) Cf) P) Cf) Pd wi) Gi), Plotting these points on the graph paper we can see that almost all the points are lying on or near the straight line (Fig 1.2). Now slope of this line is 3-4 = 2H 159 _ 9 tog © PAW 72-31 Since P, (3.1, 1.59) lies on (ii), 1,59 = A + (0.1244) (3.1) or A= 1.2044 Empirical Laws and Curve Fitting 1.5 Y ‘Scale: 1 small division B_ 01244 But O Togee ~ 0.4343 ~ 02864 and log,a=A -. a= anti log,,4 = 16.01 Hence the curve of “best fit’ is y= 16.01 2 EXERCISE 1.1 The law of machine is P = aW + b, where P is the effort and W, the load in 7b. Sketch a graph showing the relation between P and W, given P 60 78 100 125 145 Ww 225 300 430 560 600 Find P when W = 500. Ris the resistance to motion of a train at speed V. Find a law of the type R=aV? + b connecting R and V using the following data Rkgton 8 10 15 2130 Vkmhr) 10 20 30 40 50 Numerical Methods ‘The resistance R of a carbon filament lamp was measured at various values of voltage V and the following observations were made. 62 70 78 84 92 73 10.7 692 678 663 (Ranchi B.Tech 1986) Assuming a law of the form R = a/V + b, find by graphical method the best values of a and 6. Us the co-efficient of friction between a belt and pulley and v, the velocity of the belt in ft/min, are connected as shown in the following table: v 500 1000 2000 4000 +6000 # 0.29 033 038 045 0.51 The probable law is 4: = a+ Vv. Test graphically the accuracy of this law and if it is true, find the values of a and b. Fit a curve of the form y = ae" to the following data: x 2 3 4 5 6 y 14 27 40 55 68 300 The following observations are corresponding to pressure and specific volume of dry saturated steam. Fit a curve of the form PV" = k by graphical method. ve 384 «20 851 444 3.03 231 10 20 50 100 150 200 ANSWERS P=0.21W+ 12, P=117 2. a= 0.0085, b= 7.35 120, b= 55.1 4. a=0.2 b=0.0044 943 @ 08x 6. PV‘ =501 1. 3. 5. y Empirical Laws and Curve Fitting 1.7 1.4 METHOD OF GROUP OF AVERAGES. Let thé“straight line yratbx (1.3) fita set of n observations (x,,y)) i= 1,2,..., very closely. y Fig13 Now, from Fig. 1.3, when x= x,, the observed value of y= y, = P.M, and the expected value from Eqn (1.3) is y= a+ bx,=,M,. Then, d, = observed value at L, — expected value at L, =y,— (a+ bx,)= PM, ~L,M,= PL, which is called the residual or error at x,. Similarly, the residuals for remaining observations are : d= y,-(a+bx,) d,= y,—(a+ bx,) d= From Fig. (1.3) itis clear that some of these residuals may be positive while others are negative. The method of group of averages is based on the assumption that the sum of the residuals is zero, i.e. 4, =0. To find the constants @ and 5 in Eqn (1.3) we require two equations connecting them. Therefore, we divide the given data into two zroups: 1.8 Numerical Methods: (i) The first group containing k observations (x, ¥,). (X ¥,)s and (ii) the second group containing the remaining n — k observations Gar Ypds Spar Vege «== Oe Ye Assuming that the sum of the residuals in each group is zero, we get Sa, = SY py, -(a+5x]=0 iat ia and ¥a,- Sp -(a+bx)]=0 ei okt “Gp y) which gives on simplification, Yisa+by, (4) and Jp=a+byy as) where i¢ are the averages of x's, »’s of the second group. This shows that the Eqns (1.4) and (1.5) are obtained from Eqn (1.3) by replacing the averages of x's, y’s of the two groups in the places of x and y. Solving Eqns (1.4) and (1.5) we get a and b and hence, Eqn (1.3). Note: Since grouping of observations can be done in different ways the values of aand b are not unique. This is the main defect of this method. To overcome this drawback, we generally divide the data into two groups so that both contain approximately equal number of observations. Example 1.3 The following table gives corresponding values of x and y. Obtain an equation of the form y= a+ bx using the method of grouping. 0 5 10 15 20 25 Empirical Laws and Curve Fitting 1.9 Solution Let us divide the given data into two groups as follows : 15 The averages of Group I are ¥, = 3 =S;H= = _ 60 76 and for Group II, ¥; = 37 20; = 37 25.333 Substituting the averages of x’s , y’s of the two groups in the required line y = a+ bx, we get J, =a+by,, ie. 14.667 =a+ 5b and J, =a+bX, ie. 25.333=a+ 20b Solving these two equations, we get a = 11.1117 and 6 = 0.7111, approximately. Hence, the required line is y= 117 +0711 1x Example 1.4 The head H/(ft) and the quantity Q (ft?) of water flowing per second are related by the law Q= CH". Find the best values of C and n by the method of group averages for the following data. Solution The given law can be written in linear form as yratn . @ where y= log,,Q, a= log,,C and x= log, #7. Now considering the first four observations as one group and remaining three observations as second group, we have the following table: 1.10 Numerical Methods Group I Group II x= log, y= l08,,0 x= log gH y= log,0 0.07918 0.62325 0.30103 1.17319 0.14163 0.78533 0.38021 1.37107 0.20412 0.92942 0.41497 1.43297 0.25527 1.06070 De= 0.6802 Ly=3.3987 || Ex= 1.09621 Ey=3.97723 ~. The averages of Group I are = = 7 x 56m = 0.17005 ; y, ee = 0.84968 and for Group II, = 21 = _ 397723 m= 096 = 0.3654 5 ¥, = 3." 1.432574 Substituting the averages of x’s , y's of the two groups in (i), we get 0.84968 = a+ 0.17005 n and 1.32574 = a+ 0.3654 Solving these equations, we get a= 2.4369593; n= — 9.3342 (approximately) But C= antilog, a= 273.50124 which are the best values as per the method. Note : By taking three observations in first group and four observations in second group, we get different values of C and n. 1.5 EQUATIONS INVOLVING THREE CONSTANTS Sometimes, it is required to fit the observed data to the curves of the form @ y=at bx+cx*, (ii) y=ae’+cand (iii) y= ae™ +c which involve three constants a, b and c. In such cases, we reduce them to a linear form by reducing the number of constants from three to two. We will see below how these curves can be fitted. () The curve of the form y = a+ bx + cx. Let (x, y,) bea particular point on the curve satisfying the data. Then, y= at bx, + cx? “ y-y, = Bex) + 8 -x2) Empirical Laws and Curve Fitting 1.11 = b+e(x+x,) or Y=b+cX (1.6) yr x-% ‘Now Eqn (1.6) is linear in Y and X, and can be easily fitted. where Y = sand X=x+x, Example 1.5 Using the method of averages, fit a parabola y= a+ bx + cx? to the following data : 20 40 60 380 100 = 120 5.5 91° 149 228 33.3 46.0 (MU, BE., 1992) Solution Let point (20,5.5) lies on the parabola year beter? @ os 5.5=a+20b + 400c Gi) ()- Gi gives, us =b + c(x+20) Gi) or Y=b+eX (iv) =255 ye where y=223, xex+20 Choosing first three observations as one group and last three observatons as another group, we make the following table for the values of X and ¥. For Group I 20 5S xXext29 y=28 * , x yo? * x—20 2 «4550 0 - - 40 9:1 20 3.6 60 0.18 6 «6149 40 94 80 0.235 ExX=140 L¥=0.415 =. > 415 Fine 70; H = = 0.2075 For Group x y x-20 5. x Y 80 22.9 60 173 100 0.288 100 33.3, 80 2718 120 0.348 120 46 100 40.5 140 0.405 2Xx=360 0 EY= 1.041 -2 =120; Ya a = 0347 Substituting the averages in Eqn (iv) for the two groups, we get yy =b+eX1 ie. 0.2075 =b + c(70) and ¥,=b+cX2 ie. 0.347=5 + (120) Solving these two equations, b= 0.0122; c= 0.00279 Substituting in Eqn (iii), we get xs = 0.0122 + 0,00279 (x +20) or y= 0.00279x2 + 0.0122x+ 4.14 which is the required curve. (ii) The curve of the form y = ax’ + c. It can be written as y-c=at (7) or Y=A+0X (1.8) where Y= log,,(y—c), A = log,,a and X= log,x.” Now Eqn (1.8) is linear in X and ¥. Let (x,, ¥,) yp Y,) and (xy y,) be three particular points on the curve (1.7) such that x,, x, x, are in geometric progression, i.e. x,? = x,y. 1 yr e= ans y,-c= ar? and y,-c=ar, 2 G-W,—0) =F (XX) = (@,'F = 0, - cP and on simplication, _ Ws yi W+Ys- 22 Using this equation, values for ¥ can be determined and hence, the required curve. Empiical Laws and Curve Fiting 1.13 Example 1.6 In a magnetic arc at constant arc length, voltage v consumed by the arc is observed for values of the current i. i os 1 2 4 8 12 v 160 120 94 715 62 56 If v and i are connected by a relation of the form v= ai’ +c, find a, b and c and hence, the curve by the method of group averages. Solution Take i, = 1, i, = 2 and i, = 4 which are in GP to find c, Then 20, v, = 94 and v,=75 vyys—¥} __(1209(75)-(94)* © F4y,2y, 7 120+75—2008) ~ 4 *. v=ai+23.4 or v-23.4=ai @ or Y=A+bX (ii) where Y= log,,(v- 23.4), A= log, and X= log,,j. Choosing first three observations as one group and other three as second group, we have the following table: For Group I i v X= log, Y= log,, (v— 23.4) 05 160 1.6990 2.1354 1 120 0.0000 1.9850 2 24 0.3010 1.8488 Zx= 0.0000 Ly=5.9692 xrY eae 3M 3 1.9897 i v X= ogi Y= log,, (v— 23.4) 4 15 0.6021 1.7126 8g 62 0.9031 1.5866 12 56 1.0792 1.5132 LX=2.5844 CY=4.8124 1.14 Numerical Methods 7, = 254 agers, Yo = A8lD Substituting the averages of X’s , ¥’s of two groups in Eqn (ii), we get 1.9897 =A + (0) ». A= 1.9897 and 1.6041 = A+0.86156 « But a= antilog,,A = 97.6562 J. a=97.66, b=-0.45, c=23.4, approximately, = 1.6041 0.4476 and the curve is v = 97.66 7° + 23.4 (iii) The curve of the form y = ae + c. This equation can be written as yrc=ae as) and also in linear form as Y=A+Bx (1.10) where Y= log,(y—c), A=log,a and B= b log,.e. Let (x, y,), &p ¥,) and (x,, y,) be three particular points on the curve such that x,, x, and x, are in arithmetic progression, i.e. x, + x, = 2x,. Substituting these points in Eqn (1.9), we have y-c=ae™,y,-c =ae™,and y,-c=ae™ 0-9 0,-0) = abr) = azet2n) = are) =(y,-cF which gives on simplication, oe UH N+Y-2% Using this, values of Ycan be determined and hence, the required curve. Note : The same procedure can be adopted to the curve of the form y=ab,+c. Example 1.7 The variables s and 1 are connected by the relation =a +b e and their corresponding values are given in the following table: Fit the curve by the method of group averages. Solution The given curve can be written as. s-a=bem @ Empirical Laws and Curve Fitting 1.15 and in linear form as Y=B+Nt (ii) where Y= log,(s~a), B= log,,b and N=7n log,.¢. Take f,= 1, t,= 6 and ¢, = 11 such that x, + x, = 2x,. The ing values of s are s, = 12.71, 5, = 11.65 and s,= 10.99. 555-S3 _ (12.71)(10.99)- (11.65)? ~y+5,—25, ~ 12.71+1099—2(11.65) 3. = 3004 9901 ~ 04 Now choosing the first three observations as one group and other two observations as second group, we have the following table : Group I | Group IT t s Y= log,,(s— 9.901) | tos Y= log,,(s— 9.901) 1 1271 0.4486 8 1134 0.1581 2 1246 0.4081 11 10.99 0.0370 6 165 0.2428 rre9 L Y= 1.0995 Lr=19 LY=0.1951 .. Averages of the first group are 0995 —{— = 0.3665 = 0.0976 ‘Substituting the averages of fs and Y's of the two groups in (ii), we get 0.3665=B+3N and 0.0976=B+9.5N On solving, B= 0.4907 ; N=-—0.0414 N Now b= antilog,,B = 3.097 and n= jog ~~ = — 0.0953 Hence, the required curve is s = 9.901 + 3.097 «9 1.16 Numerical Methods EXERCISE 1 1. The weights of a calf taken at weekly intervals are given below. Fit a straight line using the method of group averages. [Age in weeks = 1 2 3 4 5 6 7 8 9 10 weight 52.5 58.7 65 70.2 75.4 81.1 87.2 95.5 102.2 108.4 2. Fitacurve of the form y= ar" to the following set of observations by the method of group averages: x 10 20 30 40 50 60 70 80 y 106 133 152 168 181 191 201 2.11 3. Fit a curve of the form y= ab" using the method of group averages for the following data: x 2 4 6 8 10 «12 y 7.32 8.24 9.20 10.19 11.01 12.05 4. Convert the equation y = Bix(x — a) to a linear form and hence, determine a and 6 which will fit the following data using the method of group averages: 130 14 184 16.3 17.2 17.8 5. The following data represent test values obtained while testing a centrifugal pump. Assuming the relation to be H= a+ bQ + c@?, where Q is the discharge in liter per second and H, head in meter of water, find the relation by the method of group averages. Q 2 2.5 3035 4 45 5 55 6 H 18 178 17.5 17) 158 148 133 11.7 9 (MU, B.E., 1971) 6. The temperature @ of a vessel of cooling water and the time ¢ in minutes since the beginning of observation are connected by the law of the form @= ae" + c. The corresponding values of t and @ are given by: 7 0 Tt 2 3 5S 7 eo 52. 0 43.5 39. \\ Empirical Laws and Curve Fiting 1.17 Find the best values of a, b and c using the method of group averages. 7. Fit a curve of the form y= a + bx * to the following data using the method of group averages. x 1 2 4 6 10 +16 y 15 45 165 364 + 1004 += 2564 8 Fit a curve of the form y = a+ bc* to the following data using the method of group averages. x 0 1 2 3 4 5 6 7 8 y 24 32 3.7 SA 18 13.2 236 448 ANSWERS 1. y= 46.048 + 6.104.x 2. y= 0.4851 2 3. y= (6.7468) (1.0505¥ 4. a= 0.2039, b= 0.051 5. H=158+2.1Q0-05@ 6. a=29,5393, b=— 0.09968, c=21.98 7. y= 5+ 102 8. y= 2.26 + (0.3) (2.07¥ 1.6 PRINCIPLES OF LEAST SQUARES So far we have studied the curve fitting by (i) Graphical method, and (ii) Method of group averages. The values of the constants in the first Fig 1.4 1.18 Numerical Methods method depends upon the choice of points on the line, and in the second method on grouping the observations. Hence, both the methods fail to give a unique curve of fit. So we require some other method to get the best values of the constants. Principle of least squares provides a unique set of values to the constants and hence, suggests a curve of best fit to the given data. Let (x,, y,), 7=1, 2, ..., me the 1 sets of observations and let y= f(x) be the relation suggested between x and y. When x= x,, the observed value of y, is y, = P, M, Expected value = Z, M,=f(x,) :. Residual (or error) at x = x, is e,= y,—f(x,) It is obvious that some of e,’s may be +ve or —ve. Thus by giving equal weightage to each residuals, consider E= Be = Ebr-seor (uy Now, if E = 0 then y, = f(x,) V i, ice. all the points lie on the curve. Otherwise, the minimum of E results the best fitting curve to the data. Thus the curve of best fit is that one for which the sum of squares of the residuals is minimum. Using this principle, we shall fit the following curves: (@) A straight line, y= ax +b (ii) A parabola, y= ax? + bx +c (iii) The exponential curve, y = ae™ and (iv) The curve, y= ax’ 1.7 FITTING A STRAIGHT LINE Let (x,, y,), #= 1, 2,..., be m sets of observations of related data and yrartb (1.12) be the straight line to be fitted. As explained in Section (1.6), the residual at x = x, is €,=¥,-S(%) =y,- (ax, +b), i= 1,2,...,0 E= Ee? = E0y,- (ar, +P By the principle of least squares, E is minimum. 5260, a Xx) =0 or E (rx, — ax? ~bx,)=0 Empirical Laws and Curve Fiting © 1.19 and £20, - a -8)-1)=0 or E0;-a 4) =0 Eva = abxi +x, (1.13) and Ey, = ad x, +nb ay Since x,, y, are known, Eqns (1.13) and (1.14) result in two equations in aand b. Solving these the best values for a and can be known and hence, Eqn (1.12). Note: 1. Dropping the suffix i, we can write Eqns (1.13) and (1.14) as Lxy=ale+b dx and Ly=alxtnb. These are known as normal equations to the curve y = ax + b. 2. Ifthe numbers in the given data are large, we can change the origin -A x and scale with the substitutions X= > of convenience and ease in calculation work. y-B Y= for the sake ' Example 1.8 By the method of least squares, find the straight line that best fits the following data: 1 2 3 4 3 y 4 27 40 «6558 (M.U, B.E,, 1993) Solution Let the straight line of best fit be yraxth @ The normal equations are Lay=ale+ brx di) and Ly=adx+ 5b ii) 1.20 Numerical Methods The values of © x, Ey, Dx’ and 5 xy are calculated as shown below: | DesiS Ip=208 Dea ss Dyn 748 <. Eqns (ii) and (iii) become 748 = 55a+ 15b and 204 = 15a+ 56 Solving these, we have a = 13.6 and b= 0. Putting these values in Eqn (i), we get the line of best fit as y= 13.6r. Aliter: Let X= x—-3, Y= y—40 and let the straight line in new variables be Y=Ar+B a Now the normal equations are UXY = AD + BUX “a LY=ADX+B Gi) — Lo y =x-3 x po: 4 2 26 4 52 2 27 -1 -13 1 13 3 40 0 0 0 0 | 4 55 1 15 1 15 | | s 8 2 28 4 56 ' Ex-0 0 Ey=4 I¥=10 Ex 136 L Substituting EX = 0, DY = 4, [XY = 136 and DX? = 10 in Eqns (ii) ana Gii), we get 136 = 104 and 4 = $B or A = 13.6 and B= 0.8 -. From Eqn (i), ¥ = 13.6X+0.8 (ie) y-40 = 13.6(¢-3) +08 ory = 13.6 x which is the same as seen before. 1.8 FITTING A PARABOLA Let yrartbxte (15) be a parabola to be fitted for the data (x,y), i= 1,2,- 0.7. As explaned in Section 1 6, the residual at x = x, is Empirical Laws and Curve Fitting 1.21 €=y.-f (x) =y,- (ax? + bx +e) E= be} = Dly,-(az} +x, +0)F Now E should be minimum for the best values of a, b and c (Principle of least squares). ie, 2 Ly,— (a7 + bx, + ol) = 0 Y2Ly,- (a+ bx, Ox! and Y21,- (ae? + 5x4 oD =0 ro which results, on simplification after dropping the suffix, as Lxey=adx'+ bos t+ cL? Laxy=alet+bde+cdy and Ly =adx?+bUr+ne where é. These are called the normal equations of the parabola (1.15). Solving these we get the best values of the constants a, b and c and hence, best fit for Eqn (1.15). Example 1.9 Fit a parabola y = ax* + bx + c in least square sense to the data: x 1 12 15) 230 20 y WW 17 23 25 2 Solution The normal equations to the curve are Ly=adx? + bEx+ Se Day=akx? + dU + cL and Dxy= abet + bEN + che The values of © x, Dx ete, are calculated by means of the following table: 1.22 Numerical Methods Ix oy x x x xy xy 10 14 100 1000 10000 140 1400 2 17144 1728 20736 204 2448 1s 23 225 3375 50625 345 S175 23 25529 12167 279841 57513228 20 21 400 8000 160000 420 8400 Ix ie ie = iy ay =80 ==100 = 1398 = 26270 = $21202 = 1684 == 30648 Substituting the obtained values from the table in normal equations we have 100 = 1398a + 806 + Se 1684 = 26270a + 1398 + 80c 30648 = 521202a + 262706 + 1398 On solving, a= -0.07, b = 3.03, c=-8.89. :. the required equation is y=—0.07x2 + 3.03x— 8.89 iter: Let x= x—16 and y= y— 20 and the parabola of fit be AX? + BX + C in the new variables, whose normal equations are EY =AEX?+BEX+ Se DAY =ADX? + BX? +CEY- TX?¥ =ALKt+ BEX? + CTX? The values of DX etc., are calculated as below: x oy xX ¥ x x XY XY 0 4 6 36 216 1296 36-216 | 12 17 4 3 16 64 «256 «12 aS} jis 2-13 i i i 3 3 23 2 #7 S$ 49 343-2401. 35245 2 2 4 #1 16 64 2564 16 my ry =yY =x xyy = myy =0 =0 =118 =128 =4120 =8 =0 <. The normal equations become 0 =1184+5C 84 = 1284+ 1188 0 =42104+ 128B+118C On solving, A= 0.07, B= 0.79 and C = 1.67 0.07%? + 0.79X + 1.67 Empirical Laws and Curve Fiting 1.23 or (9-20) = — 0.07(x-16)? + 0.79(x-16) + 1.67 which simplifies to y =—0.07x? + 3.03x — 8.89 as observed earlier. Example 1.10 Fit a second degree parabola to the following data using method of least squares. (M.U.,B.E., 1996) Solution Let y=ax+bx+e @ be the parabola. The normal equations are Ly=aLe +bEx +5c Dey =ale +bDe +cDx and Dey =adx +bYP +cLDe The values Dx, Ex’, - - - etc., are calculated by means of the following table: x 0 1 8 27 64 me 0 S s Substituting the obtained values in the normal equations, we get 129 =30a+10b+ Se 37.1 = 100a+30b+ 10c 130.3 =354a+ 100b + 30c On solving, we get a= 0.55, b=-1.07 and c= 1.42 2. The required parable is y= 0.55x2 — 1.07x + 1.42 1.24 Numerical Methods 1.9 FITTING AN EXPONENTIAL CURVE Consider the equation y = ae™, Taking logrithms on both sid log,,y = log,,a~ bxlog,.e ie, Y=A+ Bx (1.16) where Y= log,.y, A = log,,a and B= b log,,e The normal equations for (1.16) are UY=nd+BEx and Ux¥=ADx+ BEY Solving these, we get A and B. Then © a=antilogd and 6=B/log,e. we get 1.10 FITTING THE CURVE y= ax? Taking logarithms on both sides, we get log,.y = log,,a + blog,x ie. Y=A+bX (1.17) where Y= log,,y, A = log,,a and X= log,,x. The normal equations to (1.17) are LY=nA + BEX and EXY = ALK + HEX? which gives 4 and on solving and a= antilog A. Example 1.11 Find the curve of best fit of the type y= ae" to the following data by the method of least squares. x 1 5 7 9 12 fy 0 i 2 is 2m | Solution The curve to be fitted is y= ae or Y= A+ Bx, where ¥=og,,y, A= log, a and B= blog,,e. <. The normal equations are DY=SA+BYx and Yx¥=AYx+ BYE x Y=l08,,¥ 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 2 0 21 1.3222 144 15.8664 ix =34 LY =5.7536 — Ex7=300 LY = 40.8862 Empiical Laws and Curve Fitting 1 25 Substituting the values of Dx, etc., calculated by means of above iable in the normai equations, we get 5.7536=5A+34B and 40.8862 = 344 + 300B On solving, A = 0.9766; B = 0.02561 ©. a=antilog A = 9.4754; 6 = B/ log,e = 0.059 Hence, the required curve is y= 9.4754 e®™ Example 1.12 The method of least squares to determine the constants « and é such that y = ae” fits the following data 0.10 045 2.15 9.15 40.35 180.75 Solution The curve to be fitted is y= ae“ or Y= A + Bx, where Y= log... A= log,,a and B= dlog,.e. <. The normal equations are LY = 6A + BOx and Dx¥= ALe + BES x y Y=log,y F x} jo 0.10 -1 0 0 | 0. 0.45 -0.3468 0.25 0.1734 | 10 245 0.3324 10 0.3324 | . | 1s OAS 0.9614 2.25 1.4421 | 20 © 40.35 1.6058 40 3.2116 | 25 180.75 22571 6.28 5.6428 | ie=7.5 Ly =3.8099 Lr= 13.75 DaY= 10.4555 Substituting the values of Dx, De, -- - ,etc., in the normal equations, we get 3.8099 = 64 +7.5B and 10.4555 =7.5A + 13.75B On solving, A = -0.9916; B= 1.3013 1a antilog A= 0.1019; b= B/log,,e = 2.9963 and the curve is y = 0.1019 exp(2.9963x) Example 1.13. Obtain a relation of the form y = ab* for the following data by the method of least squares. y 83 154 331 652 1274

You might also like