Matakuliah Tahun : S0262-Analisis Numerik : 2010 Introduction and Analysis of Error Pertemuan 1 Material Outline • Introduction to Numerical Methods • Approximation and Errors • Propagation of Errors Numerical Analysis: Methods for providing numerical answer when analytic procedures are either computationally difficult or nonexistent. Numerical Analysis: Always involving complicated arithmetic computations Need the help of computing machines (computers) Numerical Analysis Numerical Methods 28-Jun-16 DR. Paston Sidauruk 4 Why Numerical methods are important: In real life many problems can not be solved analytically. Numerical Analysis is a universal procedure (It can be applied to many different engineering fields such as CE, ME, EE, and IT) The fast growing development of computing machines (computers) 28-Jun-16 DR. Paston Sidauruk 5 INTRODUCTION It is a fact that many mathematical or engineering problems or or physics phenomena can not be solved analytically (exact solution) For this type of problems or phenomena, numerical analysis can give the solution. Numerical Work in general will cover the following steps: Modeling : formulating a given work (problem) into mathematical equations. Choosing appropriate Numerical methods. Developing a program Executing the program Analyzing the results Note: Numerical Methods is always involving serious arithmetical calculation Need the help of computer. 28-Jun-16 6 Some Concerns About Numerical Analysis: – Numerical Value: is an approximation of true value that never known, hence we have to concern about the errors that may occur. 28-Jun-16 7 ERRORS In numerical solution, the results we get is the best approximation to true value. Hence the numerical solution is always associated to certain degree of errors. For this purpose, a true value of any parameter can be written as : a ã - Et In which : a = true value (exact) ã = approximation (derived from measurements, calculations etc) Et = total error Numerical Errors: arise from the use of approximations to represent exact mathematical operations and quantities. 28-Jun-16 8 RELATIVE ERRORS It is sometimes desired to normalize the error with the true value such as to account the magnitudes of the quantities being evaluated, such error called relative error. Relative error t=true error/true value Relative error of approximation: a= approximation error/approximation In the approximation of using iteration ( current approximation is based on the previous approximation), then the relative error of approximation is given below: a= (current approximation – previous approximation)/ current 28-Jun-16 approximation In numerical computations or iteration process, it is sometimes to pre specify the tolerance (s) such that the following eq is satisfied, | a|< tolerance (s) =(0,5 x 102-n) % n= significant figure 9 Errors sources 1. Experimental errors (errors arise from experiments, measurements etc) 2. Round off errors (errors because of rounding) 3. Truncation errors (errors arise from a process of simplification an algorithms, computations, steps in algorithms) 4. Programming errors 28-Jun-16 10 Example: A MacLaurin series of ex is given below: 2 3 x x ex 1 x .......... 2! 3! If the 1st term is considered as 1st estimate, the first 2 terms as the second estimate of ex, how many do you have to include in the series such that the relative errors | a|< s. In which a pre specified tolerance conforming to 3 significant figures. Find the true error and approximation errors. Note: e0,5= 1.648721271 Solution: s =(0,5 x 102-3)%= 0,05 % 28-Jun-16 11 • Example (Cont.): e0,5= 1,648721271 Solution: s =(0,5 x 102-3)%= 0,05 % 28-Jun-16 Ith tern Result t (%) a (%) 1. 1 39,3 2 1,5 9,02 33,3 3 1,625 1,44 7,69 4 1,645833333 0,175 1,27 5 1,648437500 0,0172 0,158 6 1,648697917 0,00142 0,0158 Therefore, the minimum of the first 6 terms have to be used to estimate ex such that the error of approximation is less than the pre-specified tolerance. 2nd column: Series value for x= 0.5, 3rd column= (2nd column)/1.648721271. 12 FINITE NUMBERS: can be written in two ways 1. fixed- point system ( is written according to the specified number of decimal place) Example: 62.358; 0.013; and 1.000 (3 decimal place) 2. floating- point system is written according to certain significant figures Example: 0.6238 * 103; 1.7130 * 10-13; 2000 * 104 28-Jun-16 13 Significant Figures The concept of significant figures designate the reliability of a numerical value. All digits that can be used with confidence. Example: 4 digit significant figures 1.360 ; 1360 ; 0.001360 All zeros that are needed only to locate the decimal point are not counted as significant figures: Example: all of the following numbers are in 4 significant figures 0.01845; 0.0001845; 0.001845 Also: 4.53 * 104 (3 significant figures) 4.530 * 104 (4 significant figures) 4.5300 * 104 (5 significant figures) 28-Jun-16 14 Rounding a number to certain significant figures 1. 2. 3. 28-Jun-16 Those digits that are not significant will be omitted. The last digit that is saved will rounded up if the first digit in the omitted digits >5 and if the 1st in the omitted digits =5 and the last digit in the saved digits is odd number. The final results of summation or subtraction will be rounded to the most significant figures of all the numbers (quantities) that are being operated. The final results of multiplication or division will be rounded such that the number of significant figures will be equivalent with the least number of significant figures of all the numbers (quantities) that are being operated. 15 • Rounding a number to certain significant figures Examples: – – Rounding 5.6723 5.67 (3 significant figures) 10.406 10.41 (4 significant figures) 7.3500 7.4 (2 significant figures) 88.21650 88.216 (5 significant figures) 1.25001 1.2 (2 significant figures) Summation/Subtraction Evaluate: 2.2 – 1.768 2.2-1.768= 0.432 0.4 4.68 x 10-7+8.3x10-4-228x10-6= ….? ……. – 28-Jun-16 (6.0x10-4) Multiplication/Division 0.0642x 4,8= 0.30816 0.31 945/0.3185= 2967.0329672970 16 Error Propagation The purpose is to study how errors in numbers propagates through mathematical functions • Function of single Variable y f ( x) f ( ~ x ) f ' (~ x ) ~ x f ( ~ x ) estimate of error of f ( ~ x ) f ( x) f ( ~ x) ~ x approximat ion value x true value ~ x estimate of error of ~ x x~ x 28-Jun-16 17 Error Propagation • Function of single Variable Example: Given a value of ~ x 2.5 with an error ~ x 0.01, estimate the resulting error in the function f ( x) x 3 Answer: f ( x) x 3 f ' ( x) 3x 2 f ( ~ x ) f ' (~ x ) ~ x 3(2.5) 2 (0.01) 0.1875 f (2.5) 15.625 0.1875 15.4375 f (2.5) 15.8125 28-Jun-16 18 Error Propagation • Function of more than one variable y f ( x1 , x2 ,, xn ) f ~ f ~ f ~ ~ f ( x ) x1 x2 xn x1 x2 xn f ( ~ x ) estimate of error of f ( ~ x1 , ~ x2 , , ~ xn ) ~ x ,~ x ,, ~ x approximat ion values 1 2 n ~ x1 , ~ x2 ,, ~ xn estimate of error of ~ x1 , ~ x2 , , ~ xn 28-Jun-16 19 Error Propagation • Function of more than one variable Example/Exercises: xy4 y f ( x, y , z , t ) 8 zt estimate the resulting error in y given that ~ x 50 ~ x 2 ~y 30 ~y 0.1 ~z 1.5 ~z 0.01 ~t 0.6 ~t 0.006 28-Jun-16 20 Error Propagation Estimated Error for common mathematical operations Operation Addition Subtraction Multiplication Division 28-Jun-16 Estimated Error ( ~ x~ y) ( ~ x~ y) ( ~ x~ y) ~x ~ y ~ x ~ y ~ x ~ y ~ x ~ y ~ y ~ x ~ x ~ y ~ y ~ x 2 ~ y 21