ERRORS IN NUMERICAL METHODS • Approximations and Roundoff errors • Truncation errors SIGNIFICANT FIGURES • Whenever we employ a number in a computation, we must have assurance that it can be used with confidence. • They correspond to the number of certain digits plus one estimated digit. • For example, Zeros are not always significant figures because they may be necessary just to locate a decimal point. The numbers 0.00001845, 0.0001845, and 0.001845 all have four significant figures. At face value the number 45,300 may have three, four, or five significant digits, depending on whether the zeros are known with confidence. If we use the scientific notation, where 4.53x104 , 4.530 x 104 , 4.5300 x 104 then, it have three, four, and five significant figures, respectively. 2 Although quantities such as π and e represent specific quantities, they cannot be expressed exactly by a limited number of digits. For example, π =3.141592653589793238462643……. ad infinitum. Because computers retain only a finite number of significant figures, such numbers can never be represented exactly. 3 ACCURACY AND PRECISION • • • Accuracy refers to how closely a computed or measured value agrees with the true value. Precision refers to how closely individual computed or measured values agree with each other. Inaccuracy (also called bias) is defined as systematic deviation from the truth. Numerical methods should be sufficiently accurate or unbiased to meet the requirements of a particular engineering problem. They also should be precise enough for adequate engineering design. 4 These concepts can be illustrated graphically using an analogy from target practice. The bullet holes on each target in Figure can be thought of as the predictions of a numerical technique, whereas the bull’s-eye represents the truth. 5 ERROR DEFINITIONS • True value = approximation + error • The numerical error is equal to the discrepancy between the truth and the approximation, Et = true value - approximation where Et is used to designate the exact value of the error. The subscript t designate that this is the “true” error. Note:- It takes no account of the order of magnitude of the value under examination. For example, an error of a centimeter is much more significant if we are measuring a rivet rather than a bridge. One way to account for the magnitudes of the quantities being evaluated is to normalize the error to the true value. 6 n actual situations such information is rarely available. For numerical methods, the true value will be known only when we deal with functions that can be solved analytically. 7 In real-world applications, we don’t know the true answer a priori. For these situations, we normalize the error using the best available estimate of the true value to the approximation itself. where the subscript a signifies that the error is normalized to an approximate value. Certain numerical methods use an iterative approach to compute answers. In such an approach, a present approximation is made on the basis of a previous approximation. This process is performed repeatedly, or iteratively, to successively compute better and better approximations. For such cases, the error is often estimated as the difference between previous and current approximations. Thus, percent relative error is determined according to 8 Certain numerical methods use an iterative approach to compute answers. In such an approach, a present approximation is made on the basis of a previous approximation. This process is performed repeatedly, or iteratively, to successively compute better and better approximations. For such cases, the error is often estimated as the difference between previous and current approximations. Thus, percent relative error is determined according to 9 Suppose that you have the task of measuring the lengths of a bridge and a rivet and come up with 9999 and 9 cm, respectively. If the true values are 10,000 and 10 cm, respectively, compute (a) the true error and (b) the true percent relative error for each case. • The error for measuring the bridge is Et= 10,000 -9999 = 1 cm and for the rivet it is et = 10 -9 = 1 cm • The percent relative error for the bridge is Et= (1/10,000)x 100% = 0.01% and for the rivet it is et= (1 /10)x 100% = 10% 10 When performing computations, we may not be concerned with the sign of the error, but we are interested in whether the percent absolute value is lower than a prespecified percent tolerance . For such cases, the computation is repeated until < If this relationship holds, our result is assumed to be within the prespecified acceptable level . Also, if the following criterion is met, we can be assured that the result is correct to at least n significant figures. 𝑛 11 Error Calculation • The absolute error is defined as the absolute value (or magnitude) of the difference between the measured value and the true value. • The formula for computing absolute error is • The relative error is defined as the absolute error relative to the size of the measurement. 12 ROUNDOFF ERROR • Roundoff error is the difference between an approximation of a number used in computation and its exact (correct) value. • Round-off Error the error incurred when representing a number with fewer digits than are required to completely capture its exact numerical value. • Round-off errors originate from the fact that computers retain only a fixed number of significant figures during a calculation. • Numbers such as π, e, or cannot be expressed by a fixed number of significant figures. Therefore, they cannot be represented exactly by the computer. • Since computers use a base-2 representation, they cannot precisely represent certain exact base-10 numbers. The discrepancy introduced by this omission of significant figures is called round-off error. 13 ROUNDOFF ERROR • We know that Roundoff Error =0.000003333 14 TRUNCATION ERRORS Truncation errors are those that result from using an approximation in place of an exact mathematical procedure. Truncation errors are those that result from using an approximation in place of an exact mathematical procedure. For instance, we know that ! ! ! ! we may approximate by the cubic We see that approximating ex with the cubic gives an inexact answer. The error is due to truncating the series and has nothing to do with the computer or calculator. For iterative methods, this error can usually be reduced by repeated iterations, but because life is finite and computer time is costly, we must be satisfied with an approximation to the exact analytical answer 15 Truncation error • We calculate truncation error for the function . =3.3201169227… • when x=1.2, No of terms used n . Approximate Error = True percent relative error = . 1 1 - - 2 2.2 1.2 54.5% 3 2.92 0.72 24.658% 6 3.3151 0.020736 0.62255% 16 Discretization of Equations As engineers, many of the mathematical expressions we are interested in are differential equations 🞑 We know how to evaluate derivatives analytically 🞑 Need an approximation for the derivative operation in order to solve numerically Discretization – conversion of a continuous function, e.g. differentiation, to a discrete approximation for numerical evaluation 18 Total Numerical Error 19 Total Numerical Error Total numerical error is the sum of roundoff and truncation error Roundoff error is largely out of your control, and, with double precision arithmetic, it is not typically an issue 🞑 Truncation error can be a significant problem, but can be reduced by decreasing step size 🞑 Reducing step size reduces truncation error, but may also result in subtractive cancellation, thereby increasing roundoff error Choose step size to minimize total error 🞑 Or, more typically, to reduce truncation error to an acceptable level Total Numerical Error 39 Reducing step size reduces truncation error, but may also result in subtractive cancellation, thereby increasing roundoff error Could choose step size to minimize total error But, more typically, reduce step size just enough to reduce truncation error to an acceptable level Truncation error increases with step size Roundoff error decreases with step size 22 23