CHAPTER 3a. INTRODUCTION TO NUMERICAL METHODS A. J. Clark School of Engineering Department of Civil and Environmental Engineering by Dr. Ibrahim A. Assakkaf Spring 1 ENCE 3 - Computation in Civil Engineering II Department of Civil and Environmental Engineering University of Maryland, College Park 1. The solution procedure is iterative, with the accuracy of the estimated solution improving with each iteration.. The solution procedure provides only an approimation to true (eact), but unknown solution. 3. An initial estimate of the solution may be required. Slide No. 1 1
4. The solution procedure is conceptually simple, with algorithms representing the solution procedure that can be easily programmed on a digital computer. 5. The solution procedure may occasionally diverge from rather converge to the true solution. Slide No. Eample 1: Square Root This eample illustrates how to approach a solution for finding the square root of an arbitrary real number y using numerical methods. f ( y) = y Slide No. 3
Eample 1 (cont d): Square Root The square root of any real number can be found using any computational aid such as a calculator or a spread sheet. On a calculator, you simply enter the number and then press key. On a spread sheet, the function SQRT is used. Slide No. 4 Eample 1 (cont d): Square Root Strategy Let s assume an initial value of for the square root. Then will be in error by unknown amount. If we know, then + = y Slide No. 5 3
Eample 1 (cont d): Square Root + = If both sides of the above equation is squared, then + = y or ( ) y + + ( ) = y Slide No. 6 Eample 1 (cont d): Square Root ( ) y + + = If we assume that ( ) is much smaller than, then we have = y Slide No. 7 4
Eample 1 (cont d): Square Root The value of computed with the previous equation can be added to to get a revised estimate of. Thus the new estimate 1 of the true solution is given by 1 = + Slide No. 8 Eample 1 (cont d): Square Root Generalizing the notation, we have i+1 = i + where i +1 and i are the estimates of on trials i and i + 1, respectively, and = y i i (1) () Slide No. 9 5
Eample 1 (cont d): Square Root To illustrate the numerical use of Eqs. 1 and : Assume y = 15 We know that 1 = 144 So = 1, which is a reasonable estimate Therefore, the first iteration is given by Eq. as y = ( 1) ( ) = 15 = 1.5 Slide No. 1 Eample 1 (cont d): Square Root and by Eq. 1 as i+ 1 1 = = + = 1 +.5 = 1.5 A second iteration can now be applied in Eqs. and 1 to give, respectively i+ 1 y = 1 = + = 1 i i + ( 1.5) ( ) 1 = 15 = 1.5.55 + = 1.5.55 = 1.4745 Slide No. 11 6
Eample 1 (cont d): Square Root i+ 1 3 A third iteration, yields y 15 = = = 1.8598 1 1.4745 = = i + ( 1.4745) ( ) + = 1.4734.19 = 1.4744871 6 True Value = 15 = 1.4744871 For 7 digits, the solution converges to true value in 3 iterations. Slide No. 1 Eample 1 (cont d): Square Root y = 15 b i b y True Value ABS error.5 1. 15 1.474487.47448714 1 -.3 1.5 15 1.474487.55186-3E-7 1.47449 15 1.474487.65676E-7 3-3E-15 1.474487 15 1.474487 3.5571E-15 4 1.474487 15 1.474487 5 1.474487 15 1.474487 6 1.474487 15 1.474487 Slide No. 13 7
Eample : Root of a Polynomial This eample illustrates how to approach a solution for finding one root of a polynomial using numerical methods. 3 3 = 6 + 8 Slide No. 14 Eample (cont d): Root of a Polynomial Strategy Dividing both sides of the equation by, yields 8 3 6 + = Solving for using the term, gives 8 = 3 + 6 (3) Slide No. 15 8
Eample (cont d): Root of a Polynomial Eq. 3 can be solved iteratively as follows: 8 i+ 1 = 3i + 6 (4) i If an initial value of ( = ) is assumed for, then 8 8 1 = 3 + 6 = 3() + 6 =.8847 Slide No. 16 Eample (cont d): Root of a Polynomial Now 1 =.8847 A second iteration will yield 8 8 = 31 + 6 = 3(.8847) + 6 = 3.41413.8847 1 A third iteration results in 8 8 3 = 3 + 6 = 3(3.41413) + 6 = 3.78 3.41413 Slide No. 17 9
Eample (cont d): Root of a Polynomial The results of iteration are shown Table 1 of the net viewgraph. It is evident from the table that the solution converges to the true value of 4 after the the th iteration. Slide No. 18 Eample (cont d): Root of a Polynomial Table 1 b i b i True Value Abs Error b i b i True Value Abs Error 4 1 3.99917 4.87759 1.8847 4 1.17157875 11 3.999618 4.38186 3.41414 4.585786438 1 3.999833 4.16771 3 3.783 4.71797358 13 3.99997 4 7.3945E-5 4 3.877989 4.11596 14 3.999968 4 3.1979E-5 5 3.94616 4.53983839 15 3.999986 4 1.3999E-5 6 3.97665 4.373453 16 3.999994 4 6.111E-6 7 3.989594 4.14636 17 3.999997 4.67794E-6 8 3.995443 4.4557 18 3.999999 4 1.1716E-6 9 3.9985 4.1994519 19 3.999999 4 5.1576E-7 4 4 Slide No. 19 1
In view of Eamples 1 and, we conclude that The solution procedure is iterative, with the accuracy of the estimated solution improving with each iteration. The solution procedure provides only an approimation to true (eact), but unknown solution Slide No. An initial estimate of the solution may be required. The solution procedure is conceptually simple, with algorithms representing the solution procedure that can be easily programmed on a digital computer. Slide No. 1 11
Accuracy, Precision, and Bias Bias An estimate of a parameter θ made from sample statistic is said to be an unbiased estimate if the epected value of the sample quantity θˆ is θ; that is E( θˆ) = θ The bias is defined as [ E(θˆ) -θ] Slide No. Accuracy, Precision, and Bias Bias Definition: Bias is a systematic deviation of values from the true value Slide No. 3 1
Accuracy, Precision, and Bias Bias Consider four eperiments where each eperiment is repeated si times. The following table shows the results of the four eperiments: True (Population) Ep. A Ep. B Ep. C Ep D Mean 15 15 4 7 14 Slide No. 4 Slide No. 5 13
Accuracy, Precision, and Bias Bias Eperiment A is unbiased because its epected value (mean) equals the true mean. Eperiments B, C, and D show varying degrees of bias. Eperiment B has a positive bias of 9, whereas the bias of C and D are negative. Eperiment B tends to overestimate θ, while C and D tend to underestimate θ. Slide No. 6 Accuracy, Precision, and Bias Precision Definition: Precision is defined as the ability of an estimator to give repeated estimates that are very close to each other. Slide No. 7 14
Accuracy, Precision, and Bias Precision Precision can be epressed in terms of the variance of the estimator. Precision Var( θ) Var( θ) Var( θ) = Lack of precision High precision Absolute precision Slide No. 8 Accuracy, Precision, and Bias Precision Consider four eperiments where each eperiment is repeated si times. The following table shows the results of the four eperiments: Ep. A Ep. B Ep. C Ep D Var 1.6 1.6 1.6 6.8 Note: Variance is about the sample mean for each eperiment Slide No. 9 15
Slide No. 3 Accuracy, Precision, and Bias Precision Eperiment A and B show considerably more precision (i.e., they have lower variances). Eperiment C has the largest variation, therefore, it is the least precise. Eperiments A and B have the same level of variation, however, A is unbiased, whereas B is highly biased. Slide No. 31 16
Accuracy, Precision, and Bias Accuracy Definition: Accuracy is defined as the closeness or nearness of the measurements to the true or actual value of the quantity being measured. Slide No. 3 Accuracy, Precision, and Bias Accuracy Bias and Precision are considered elements of Accuracy. Bias + Precision Accuracy Inaccuracy can result from either a bias or a lack of precision. Slide No. 33 17
Accuracy, Precision, and Bias Accuracy Consider four eperiments where each eperiment is repeated si times. The following table shows the results of the four eperiments: Ep. A Ep. B Ep. C Ep D Var 1.6 98.8 87.6 8. Note: Variance is about the true mean of the population (i.e., 15) Slide No. 34 Slide No. 35 18
Accuracy, Precision, and Bias Bias, Precision, and Accuracy Consider the four dartboards of the following figure. Assuming that these shooting at the targets were aiming at the center, the person shooting at target A was successful. Slide No. 36 Accuracy, Precision, and Bias Bias, Precision, and Accuracy B A Increasing Precision D C Increasing Accuracy Slide No. 37 19
Accuracy, Precision, and Bias Bias, Precision, and Accuracy The holes in target B are similarly clustered as in target B, but they show large deviation from the center. The holes in target C are very different in character from the holes in either target A or B. They are not near the center, and they are not near each other. Slide No. 38 Accuracy, Precision, and Bias Bias, Precision, and Accuracy The holes in target A and B show a measure of precision, therefore, the shooters were precise. The shooters of targets C and D were imprecise since the holes show a lot of scatter. The holes in targets B and D are consistently to the left, that is, there is a systematic distortion of the hole with respect to the center of the target. Slide No. 39
Accuracy, Precision, and Bias Bias, Precision, and Accuracy B A Increasing Precision D C Increasing Accuracy Slide No. 4 Accuracy, Precision, and Bias Bias, Precision, and Accuracy The holes in targets B and D show a systematic deviation to the left. Targets A and C are considered to unbiased because there is no systematic deviation. In the figure, accuracy increases as precision increases, therefore, the shooter of target A is the most accurate. Slide No. 41 1