Numerical Analysis by Dr. Anita Pal Assistant Professor Department of Mathematics National Institute of Technology Durgapur Durgapur-73209 email: anita.buie@gmail.com
. Chapter Numerical Errors Module No. Errors in Numerical Computations
...................................................................................... Two major techniques are used to solve any mathematical problem analytical and numerical. The analytical solution is obtained in a compact form and generally it is free from error. On the other hand, numerical method is a technique which is used to solve a problem with the help of computer or calculator. In general, the solution obtained by this method contains some error. But, for some class of problems it is very difficult to obtain an analytical solution. For these problems we generally use numerical methods. For example, the solutions of complex non-linear differential equations cannot be determined by analytical methods, but these problems can easily be solved by numerical methods. In numerical method there always be a scope to occur errors and hence it is important to understand the source, propagation, magnitude, and rate of growth of these errors. To solve a problem with the help of computer, a special method is required and this method is known as numerical method. Analytical methods are not suitable to solve a problem by computer. Thus, the numerical methods are highly appreciated and extensively used by scientists and engineers. Let us discuss sources of error.. Sources of error It is well known that the solution of a problem obtained by numerical method contains some errors. But, our intension is to minimize the error. To minimize it, the most essential thing is to identify the causes or sources of the error. Three sources of errors, viz. inherent errors, round-off errors and truncation errors occur to find a solution of a problem by using numerical method. They are discussed below. (i) Inherent errors: These type of errors occur due to the simplified assumptions made during mathematical modelling of the problem. These errors also occur when the data is obtained from certain physical measurements of the parameters of the proposed problem. (ii) Round-off errors: Generally, the numerical methods are performed using computer. In numerical computation, all the numbers are represented as decimal fraction. Again, a computer can store finite number of digits for a number. Some numbers viz. /3, /6, /7 etc. can not be represented by decimal fraction in finite numbers of digits.
............................................. Errors in Numerical Computations Thus, to represent these numbers some digits must be discarded and hence the numbers should be rounded-off into some finite number of digits. So in arithmetic computation, some errors will occur due to the finite representation of the numbers; these errors are called round-off errors. These errors depend on the word length of the used computer. (iii) Truncation errors: These errors occur due to the finite representation of an inherently infinite process. These types of errors are explained by an example. Let us consider the cosine series. The Taylor s series expansion of cos x is cos x = x2 2! + x4 4! x6 6! +. This is well known that this series s infinite. If we consider the first five terms to calculate the value of cos x for a given x, then we obtained an approximate value. The error occurs due to the truncation of the remaining terms of the series and it is called the truncation of error. Note that the truncation error is independent of the computational machine..2 Exact and approximate numbers In numerical computation, a number is consider as either exact or approximate value of a solution of a problem. Exact number represents the true value of a result while the approximate number represents the value which is closed to the true value. For example, in the statements a book has 34 pages, the population of a locality is 5000 the numbers 34, 5000 are exact numbers. But, in the assertions the time taken to fly from Kolkata to New Delhi is 2 hrs, the number of leaves of a mango tree is 50000, the numbers 2 and 50000 are approximate numbers, as time to fly from Kolkata to New Delhi is approximately 2 hrs and similarly, the number of leaves of the tree is approximately 50000, because it is not possible to count exact number of leaves of a big tree. These approximations are coming either from the imperfection of measuring instruments or the measurement depends on other parameters. There are no absolutely exact measuring instruments; each of them has its own accuracy. 2
...................................................................................... It may be noted that same number may be exact as well as approximate. For example, the number 3 is exact when it represents the number of rooms of a house and approximate when it represents the number π. The accuracy of a solution is defined in terms of number of digits used in the computation. The significant digits or significant figures of a number are all its digits, except for zeros which appear to the left of the first non-zero digit. But, the zeros at the end of a number are always significant digit. The numbers 0.000342 and 892.2300 have 3 and 8 significant digits respectively. Some times we need to cut off usable digits. The number of digits to be cut off depends on the problem. This process to cut off digits from a number is called rounding-off of numbers. That is, in rounding process the number is approximated to a very close number consisting of a smaller number of digits. In that case, one or more digits are kept with the number, taken from left to right, and all other digits are discarded. Rules of rounding-off (i) If the discarded digits constitute a number which is larger than half the unit in the last decimal place that remains, then the last digit that is left is increased by one. If the discarded digits constitute a number which is smaller than half the unit in the last decimal place that remains, then the digits that remain do not change. (ii) If the discarded digits constitute a number which is equal to half the unit in the last decimal place that remains, then the last digit that is half is increased by one, if it is odd, and is unchanged if it is even. This rule is often called a rule of an even digit. In Table., we consider different cases to illustrate the round-off process. In this table the numbers are rounded-off to the six significant figures. But, computer kept more number of digits during round-off. It depends on the computer and the type of the number declared in a programming language. Note that the round-off numbers contain errors and this errors are called round-off errors. 3
............................................. Errors in Numerical Computations Exact number Round-off number to six significant figures 26.023728 26.024 (added in the last digit) 23.243265 23.243 (last digit remains unchanged) 30.455354 30.4554 (added in the last digit) 9.652456 9.6525 (added in the last digit) 26.3545 26.344 (last digit remains unchanged) 34.4275 34.4280 (added in the last digit to make even digit) 8.999996 9.00000 (added in the last digit) 9.999997 0.0000 (added in the last digit) 0.0023456573 0.00234566 (added in the last digit) 6.237 6.23700 (added two 0 s to make six figures) 6754259 675422 0 2 (integer is rounded to six digits) Table.: Different cases of round-off numbers.3 Absolute, relative and percentage errors Let x A be the approximate value of the exact number X T. The difference between the exact value x T and its approximate value x A is an error. But, by principle it is not possible to determine the value of the error x T x A and even its sign, when the exact number x T is unknown. The errors are designated as absolute error, relative error and percentage error. Absolute error: Let x A be the approximate value of the exact number x T. Then the absolute error is denoted by ( x) and satisfies the relation x x T x A. Note that the absolute error is the upper bound of the difference between x T and x A. This definition is applicable when there are many approximate values of the exact number x T. Otherwise, x = x T x A. 4
...................................................................................... Also, the exact value x T lies between x A x and x A + x. It can be written as x T = x A ± x. (.) The upper bound of the absolute error is absolute error 2 0 m, (.2) when the number is rounded to m decimal places. Note that the absolute error measures the total error and hence this error measures only the quantitative side of the error. It does not measure the qualitative, i.e. how much the measurement is accurate. For example, the length and the width of a pond are determined by a tape in meter. Suppose that width w = 50 ± 2 m and the length l = 250 ± 2 m. In both the measurements the absolute error is 2 m, but it is obvious that the second measure is more accurate. To determine the quality of measurements, we introduced a new concept called relative error. Relative error: The relative error is denoted by δx and is defined by δx = x x A or This expression can also be written as x x T, x T 0 and x A 0. x T = x A ( ± δx) or x A = x T ( ± δx). Note that the absolute error is the total error when whole thing is measured, while relative error is the error when we measure unit. That is, the relative error is the error per unit measurement. In case of above example, the relative errors are δw = 2 50 0.008. Thus, the second measurement is more accurate. = 0.04 and δl = 2 250 = In general, the relative error measures the quantity of error and quality of the measurement. Thus, the relative error is a better measurement of error than absolute error. Percentage error: The relative error is measured in unit scale while the percentage error is measured 5
............................................. Errors in Numerical Computations in 00 unit scale. The percentage error is measured by δx 00%. This error is sometimes called relative percentage error. Percentage error measures both the quantity and quality. Generally, when relative error is very small then the percentage error is determined. Note that the relative and percentage errors are free from the unit of measurement, while absolute error depends on the measuring unit. Example x A = 0.429.. Find the absolute, relative and percentage error in x A when x T = 7 and Solution. The absolute error x = x T x A = 7 0.429 =.0003 7 = 0.0003 = 0.000043 rounding up to two significant figures. 7 The relative error δx = x = 0.000043 = 0.000329 0.0003. x T /7 The percentage error is δx 00% = 0.0003 00% 0.03%. Example.2 Find the absolute error and the exact number corresponding to the approximate number x A = 7.543. Assume that the percentage error is 0.%. Solution. The relative error is δx = 0.% = 0.00. Therefore, the absolute error is x = x A δx = 7.543 0.00 = 0.007543 0.0075. Thus, the exact value is = 7.543 ± 0.0075. Example.3 Suppose two exact numbers and their approximate values are given by Find out which approximation is better. x T = 7 9 0.8947 and y T = 7 8.426. Solution. To find the absolute error, we take the numbers x A and y A with a larger number of decimal digits as x A 0.894736, y A = 7 8.42649. Therefore, the absolute error in x T is x = 0.894736 0.8947 0.000036, and y = 8.42649 8.426 0.000049. 6
...................................................................................... Thus, δx = 0.000036/0.8947 0.000040 = 0.0040% δy = 0.000049/8.426 = 0.0000058 = 0.00058%. The percentage error in second case is 0.00058 while in first case it is 0.0040. Thus the second measurement is more better than the first one..4 Valid significant digits A decimal integer can be represented in many ways. For example, the number 7600000 can be written as 760 0 4 or 76.0 0 5 or 0.7600000 0 7. Note that each number has two parts, the first part is called mantissa and second part is called exponent. In last form, the mantissa is a proper fraction and first digit after decimal point is non-zero. This form is known as normalize form and it is commonly used in computer. Every positive decimal number a can be expressed as a = d 0 m + d 2 0 m + + d n 0 m n+ +, where d i are the digits constituting the number (i =, 2,...). The digit d 0 and 0 m i+ is the value of the ith decimal place starting from left. Let d n be the nth digit of the approximate number x. This digit is called valid significant digit (or simply a valid digit) if it satisfies the following condition x 0.5 0 m n+. (.3) If the inequality of (.3) does not satisfied, the digit d n is said to be doubtful. If d n is a valid digit then all the digits preceding to d n are also valid. Theorem. If a number is correct up to n significant figures and the first significant digit is k, then the relative error is less than k 0 n. Proof. Let x A and x T be the approximate and exact values. Also, assume that x A is correct up to n significant figures and m decimal places. There are three cases arise: (i) m < n (ii) m = n and (iii) m > n. 7
............................................. Errors in Numerical Computations From (.2) it is known that the absolute error x 0.5 0 m. (i) When m < n. In this case, the total number of digits in integral part is n m. Let k be the first significant digit in x T. Therefore, Thus, the relative error x 0.5 0 m and x T k 0 n m 0.5 0 m. δx = x x T 0.5 0 m k 0 n m 0.5 0 m = 2k 0 n. Since, n is a positive integer and k is an integer lies between and 9, for all k and n except k = n =. Hence, (ii) When m = n. 2k 0 n > k 0 n δx < k 0 n. In this case, the first significant digit is same as first digit after decimal point, i.e. the number is proper fraction. As in previous case, (iii) When m > n. 0.5 0 m δx = k 0 n m 0.5 0 m = 2k 0 n < k 0 n. In this case, the first significant digit k is at the (n m+) = (m n )th position and the integer part is zero. Then x 0.5 0 m and x T k 0 (m n+) 0.5 0 m. Thus, Hence the theorem. 8 0.5 0 m δx = k 0 (m n+) 0.5 0 m = 2k 0 n < k 0 n.