Presentation is loading. Please wait.

E. T. S. I. Caminos, Canales y Puertos1 Lecture 1 Engineering Computation.

Presentation on theme: "E. T. S. I. Caminos, Canales y Puertos1 Lecture 1 Engineering Computation."— Presentation transcript:

E. T. S. I. Caminos, Canales y Puertos1 Lecture 1 Engineering Computation

E. T. S. I. Caminos, Canales y Puertos2 Introduction Numerical analysis is a part of mathematics, but it works on questions that are strongly related to the use of computers and to applications from Science and Engineering. Using numerical analysis we will be able, for instance, to handle large systems of equations, non-linearities, complicated geometries and solving engineering problems which have no analytical solution.

E. T. S. I. Caminos, Canales y Puertos3 Introduction Roots of equations : –We will be interested in methods for solving –These methods are very useful in engineering projects, because in many occasions it is not possible to solve the design equations analytically.

E. T. S. I. Caminos, Canales y Puertos4 Introduction Systems of linear equations: –We will study methods for computing the set of values that simultaneously satisfy a system of algebraic equations. –Applications: calculus of structures, electric circuits, supply networks, fit of curves, etc.

E. T. S. I. Caminos, Canales y Puertos5 Introduction Optimization: –Determine the value x 0 leading to the optimal value of f(x). –These problems can be subject to constraints.

E. T. S. I. Caminos, Canales y Puertos6 Introduction Fitting curves. Fitting techniques can be divided into two groups: –Regression. It is used when one has errors in the experimental data. One looks for the curve showing the trend of the data. –Interpolation. It is used to fit tabulated data and predict intermediate values or extrapolated data.

E. T. S. I. Caminos, Canales y Puertos7 Introduction Integration: –Determine the area below a given curve. –It has many applications in engineering. Calculus of centers of gravity. Calculus of areas, volumes, etc. –It can also be used to solve differential equations.

E. T. S. I. Caminos, Canales y Puertos8 Introduction Ordinary differential equations : –They are very important because many problems can be stated in terms of variations and not in terms of magnitudes. –There are two types of problems: Initial value problems, and boundary value problems.

E. T. S. I. Caminos, Canales y Puertos9 Introduction Partial differential equations: –Used for characterizing engineering problems where the behavior of the physical magnitude can be expressed in terms of speed change with respect to two or more variables. –Approximation by finite differences or the finite element method.

E. T. S. I. Caminos, Canales y Puertos10 Mathematical Models A mathematical expression of a given model can be Analytic solution (t=0, v=0): Approximate solution (“Euler method (forward)”):

E. T. S. I. Caminos, Canales y Puertos11 Mathematical Models To solve the problem numerically, one replaces the derivative by a finite difference, thus transforming the problem into a very simple one containing only simple algebraic operations:

E. T. S. I. Caminos, Canales y Puertos12 Numerical Differentiation Forward: Centered:  How big a step size should we select?  One- or two-sided formula: What are the advantages of each?  How is optimal step size affected by: - precision of numerical calculations? - precision with which f is computed? - choice of formula?

E. T. S. I. Caminos, Canales y Puertos13 Numerical Methods Instead of solving for the exact solution we solve math problems with a series of arithmetic operations. analytical solution: ln(b) – ln(a) numerical solution e. g., Trapezoidal Rule Error Analysis (a) identify the possible sources of error (b) estimate the magnitude of the error (c) determine how to minimize and control error Example: dx APPROXIMATION AND ERRORS

E. T. S. I. Caminos, Canales y Puertos14 Mathematical Models Comparing solutions:

E. T. S. I. Caminos, Canales y Puertos15 Approximations and Rounding Errors Unfortunately, computers introduce errors in the calculations. However, since many engineering problems have not analytical solution, we are forced to use numerical methods (approximations). The only option we have is to accept the error and try to reduce it up to a tolerable level. The only way of minimizing the errors is by knowing and understanding why they occur and how we can diminish them. The most frequent errors are: –Rounding errors, due to the fact that computers can work only with a finite representation of numbers. –Truncation errors, due to differences between the exact and the approximate (numeric) formulations of the mathematical problem being dealt with. Before analyzing each one of them, we will see two important concepts on the computer representation of numbers.

E. T. S. I. Caminos, Canales y Puertos16 Approximations and Rounding Errors Significant figures of a number: –The significant figures of a number are those which can be used with confidence. –This concept has two important implications: 1. An approximation is acceptable when it is exact for a given number of significant figures. 2. There are magnitudes or constants that cannot be represented exactly:

E. T. S. I. Caminos, Canales y Puertos17 Accuracy closeness of measured/computed values to the "true" value (vs. inaccuracy or bias) Biassystematic deviation from truth, "general trend" Precisioncloseness of measured/computed values with each other (spread or scatter), relates to the number of significant figures (vs. imprecision or uncertainty) Approximations and Rounding Errors

E. T. S. I. Caminos, Canales y Puertos18 Approximations and Rounding Errors Accuracy and precision: –The errors associated with measurements can be characterized observing their accuracy and precision. –Accuracy refers to how close the value is to the true value. –Precision refers to how close are different measured values using the same method. Numerical methods must be sufficiently exact (without bias) and precise to satisfy the requirements of engineering problems. From now on we will refer to error to refer to the inaccuracy and lack of precision of our predictions.

E. T. S. I. Caminos, Canales y Puertos19 (a) inaccurateimprecise (b) accurateimprecise (c) Inaccurate precise (d) Accurate precise Approximations and Rounding Errors

E. T. S. I. Caminos, Canales y Puertos20 Approximations and Rounding Errors Error definitions: –True value = approximation + absolute error. –Absolute error = true value - approximation. –Relative error = absolute error / true value. –In real cases not always one can know the true value, thus: –In many occasions, the error is calculated as the difference between the previous and the actual approximations.

E. T. S. I. Caminos, Canales y Puertos21 Approximations and Rounding Errors –Thus, the stopping criterium of a numerical method can be: –It is convenient to relate the errors with the number of significant figures.If the following relation holds, one can be sure that at least n significant figures are correct.

E. T. S. I. Caminos, Canales y Puertos22 Approximations and Rounding Errors Numerical systems: –A numerical system is a convention to represent quantities. Since we have 10 fingers in our hands, the most popular numerical system has basis 10. It uses 10 different digits. –However, computers, due to the memory structure, can only store two digits: 0 and 1. Thus, they use the binary system of numeric representation.

E. T. S. I. Caminos, Canales y Puertos23 Background: How are numbers stored in a computer? The fundamental unit, a "word," consists of a string of "bits" (binary digits). Because computers are made up of gates or switches which are either closed or open, we work in binary or base 2 system. A number in base q will be denoted by (a n a n-1...a 1 a 0.b 1 b 2..b k..) q The conversion to base 10 is, by definition (a n a n-1...a 1 a 0.b 1 b 2..b k..) q =a n q n +a n-1 q n-1 +...+a 1 q+a 0 q 0 +b 1 q -1 +b 2 q -2 +... Example: (1011.01) 2 =1x2 3 +0x2 2 +1x2+1x2 0 +0x2 -1 +1x2 -2 =11.25 Round-off Errors

E. T. S. I. Caminos, Canales y Puertos24 Conversion from base 10 to base q. This is the recipe for conversion: Integer part: we have to divide the integer part by 2 (successively) and to retain the fractional part in each step. Fractional part: we have to multiply by 2 and to retain the integer part in each step. Example: (26.1) 10 =(11010.00011) 2 Round-off Errors

E. T. S. I. Caminos, Canales y Puertos25 Example: An 8 bit word representation of the integer "35" is 00100011 or 00100011 ±2 6 2 5 2 4 2 3 2 2 2 1 2 0 +0x2 6 1x2 5 0x2 4 0x2 3 0x2 2 1x2 1 1x2 0 =35 3221 Note: We can only represent a finite # of numbers; for our case: –127 to +127 (127 = 2 7 – 1) or a total of 255 numbers (including 0) Round-off Errors

E. T. S. I. Caminos, Canales y Puertos26 Approximations and Rounding Errors Representation of integer numbers: –To represent base 10 numbers in binary form the signed magnitude method is used. The first digit stores the sign (0, positive and 1, negative). The remaining bits are used to store the number. –A computer working with words of 16 bits can store integer numbers in the range -32768 to 32767.

E. T. S. I. Caminos, Canales y Puertos27 Approximations and Rounding Errors Floating point representation: –This representation is used for fractional quantities. It has the fraction part, called mantissa, and an integer part, called exponent or characteristic. –The mantissa is usually normalized, so that the value of m is limited (b=2 in binary):

E. T. S. I. Caminos, Canales y Puertos28 Approximations and Rounding Errors IEEE-floating point formats: there are two types of “precision” (simple and double). They differ in the number of digits available for storing the numbers: Simple precision (32 bits): 1 bit for the sign, 8 bits for the exponent, 23 bits for the mantissa. Double precision (64 bits, two words of 32 bits): 1 bit for the sign, 11 bits for the exponent, 52 bits for the mantissa. The number of bits for the exponent and the mantissa determine the “underflow” and “overflow” numbers.

E. T. S. I. Caminos, Canales y Puertos29 Subtractive Cancellation (subtracting numbers of almost equal size) – too few significant figures left. Examples: 1.Use of the “standard” formulas for solving P(x)=0, being P(x) a polynomial of degree 2. 2.Computation of f(x)=(x+1) 1/2 -x 1/2 for large x. 3.Computation of g(x)=(1-cos(x))/x 2. Round-off Error due to Arithmetic Operations

Download ppt "E. T. S. I. Caminos, Canales y Puertos1 Lecture 1 Engineering Computation."

Similar presentations

Ads by Google