Presentation is loading. Please wait.

Presentation is loading. Please wait.

MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo

Similar presentations


Presentation on theme: "MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo"— Presentation transcript:

1 MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu http://www.bc.inter.edu/facultad/omeza Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus

2 Lecture 3 MECN 3500 Inter - Bayamon 2 Tentative Lectures Schedule TopicLecture Mathematical Modeling and Engineering Problem Solving 1 Introduction to Matlab 2 Numerical Error 3 Root Finding 3 System of Linear Equations Least Square Curve Fitting Polynomial Interpolation Numerical Integration Ordinary Differential Equations

3 Lecture 3 MECN 3500 Inter - Bayamon Accuracy and Precision Approximations and Round- Off Errors 3

4 Lecture 3 MECN 3500 Inter - Bayamon  To understand the concept of error and its importance to the effective use of numerical methods. 4 Course Objectives

5 Lecture 3 MECN 3500 Inter - Bayamon  For many engineering problems, we cannot obtain analytical solutions.  Numerical methods yield approximate results, results that are close to the exact analytical solution. We cannot exactly compute the errors associated with numerical methods. Only rarely given data are exact, since they originate from measurements. Therefore there is probably error in the input information. Only rarely given data are exact, since they originate from measurements. Therefore there is probably error in the input information. Algorithm itself usually introduces errors as well, e.g., unavoidable round-offs, etc … Algorithm itself usually introduces errors as well, e.g., unavoidable round-offs, etc … The output information will then contain error from both of these sources. The output information will then contain error from both of these sources.  How confident we are in our approximate result?  The question is “how much error is present in our calculation and is it tolerable?” 5 Introduction

6 Lecture 3 MECN 3500 Inter - Bayamon Accuracy and Precision  Accuracy. How close is a computed or measured value to the true value  Precision (or reproducibility). How close is a computed or measured value to previously computed or measured values.  Inaccuracy (or bias). A systematic deviation from the actual value.  Imprecision (or uncertainty). Magnitude of scatter. 6

7 Lecture 3 MECN 3500 Inter - Bayamon Accuracy and Precision 7

8 Lecture 3 MECN 3500 Inter - Bayamon Significant Figures  Number of significant figures indicates precision. Significant digits of a number are those that can be used with confidence, e.g., the number of certain digits plus one estimated digit. 53,800How many significant figures? 5.38 x 10 4 3 5.380 x 10 4 4 5.3800 x 10 4 5  Zeros are sometimes used to locate the decimal point not significant figures. 0.000017534 0.00017534 0.0017534 8

9 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions 9 True Value = Approximation + Error E t = True value – Approximation (+/-) True error

10 Lecture 3 MECN 3500 Inter - Bayamon 10

11 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions Example 3.1: Calculation of Errors Problem Statement: 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 10000 and 10 cm, respectively, compute (a) the true error and (b) the true percent relative error for each case. Problem Statement: 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 10000 and 10 cm, respectively, compute (a) the true error and (b) the true percent relative error for each case. Solution: Solution: The error for measuring the bridge E t =10000-9999=1cm And for the rivet it is E t =10-9=1cm 11

12 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions The percent relative error for the bridge is And for the rivet it is Thus, although both measurements have an error of 1 cm, the relative error for the rivet is much greater. Thus, although both measurements have an error of 1 cm, the relative error for the rivet is much greater. 12

13 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions For numerical methods, the true value will be known only when we deal with functions that can be solved analytically (simple systems). In real world applications, we usually not know the answer a priori. Then For numerical methods, the true value will be known only when we deal with functions that can be solved analytically (simple systems). In real world applications, we usually not know the answer a priori. Then Iterative approach, example Newton’s method Iterative approach, example Newton’s method 13 (+ / -)

14 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions Use absolute value. Use absolute value. Computations are repeated until stopping criterion is satisfied. Computations are repeated until stopping criterion is satisfied. If the following Scarborough criterion is met If the following Scarborough criterion is met you can be sure that the result is correct to at least n significant figures. you can be sure that the result is correct to at least n significant figures. 14 Pre-specified % tolerance based on the knowledge of your solution

15 Lecture 3 MECN 3500 Inter - Bayamon 15

16 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions Example 3.2: Error Estimates for Iterative Methods Problem Statement: In mathematics, functions can often be represented by infinite series. For example, the exponential function can be computed using Maclaurin Series Expansion. Starting with the simplest version, e x =1, add terms one at a time to estimate e 0.5. Note that the true value e 0.5 = 1.648721 Problem Statement: In mathematics, functions can often be represented by infinite series. For example, the exponential function can be computed using Maclaurin Series Expansion. Starting with the simplest version, e x =1, add terms one at a time to estimate e 0.5. Note that the true value e 0.5 = 1.648721 Solution: Solution: 16

17 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions First to determine the error criterion that ensures a result is correct to at least three significant figures: First to determine the error criterion that ensures a result is correct to at least three significant figures: First term First term The True error: Et= 1.648721 – 1= 0.648721 The True error: Et= 1.648721 – 1= 0.648721 17

18 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions Second term Second term The True error: Et= 1.648721 – 1.5= 0.148721 The True error: Et= 1.648721 – 1.5= 0.148721 18

19 Lecture 3 MECN 3500 Inter - Bayamon Error Definitions The entire computation can be summarized as The entire computation can be summarized as Thus, after the six terms are included, the approximate error falls below ε s =0.05% and the computation is terminated Thus, after the six terms are included, the approximate error falls below ε s =0.05% and the computation is terminated 19 TermsResultsε t (%)ε a (%) 1139.3 21.59.0233.3 31.6251.447.69 41.6458333330.1751.27 51.6484375000.01720.158 61.6486979170.001420.0158

20 Lecture 3 MECN 3500 Inter - Bayamon Round-Off Error Round-off errors originate from the fact that computers retain only a fixed number of significant figures during a calculation. Number such as pi, e, or sqrt(7) cannot be expressed by a fixed number of significant figures. Therefore they cannot be represented exactly by the computer. Round-off errors originate from the fact that computers retain only a fixed number of significant figures during a calculation. Number such as pi, e, or sqrt(7) cannot be expressed by a fixed number of significant figures. Therefore they cannot be represented exactly by the computer. Computer use a base-2 representation, they can not precisely represent certain exact base-10 numbers. Computer use a base-2 representation, they can not precisely represent certain exact base-10 numbers. The discrepancy introduced by this omission of significant figures is called round-off error. The discrepancy introduced by this omission of significant figures is called round-off error. 20

21 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers Numerical round-off error is related to the manner in which number are stored. Numerical round-off error is related to the manner in which number are stored. “Word” is the fundamental unit of information storage. It consist of a string of binary digits or bits. “Word” is the fundamental unit of information storage. It consist of a string of binary digits or bits. Number Systems: Number Systems:  Decimal-Base-10 System: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9  Binary-Base-2 System: 0, 1 21

22 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers 22

23 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers Integer Representation: The previous slides show how to represent 10-based numbers to binary form. Integer Representation: The previous slides show how to represent 10-based numbers to binary form. The most straightforward approach to represent integers on a computer is called signed magnitude method. It employs the first bit of a word to indicate the sign, with o for positive and a 1 for negative. The most straightforward approach to represent integers on a computer is called signed magnitude method. It employs the first bit of a word to indicate the sign, with o for positive and a 1 for negative. Representation of the decimal integer -173 on a 16-bit computer. Representation of the decimal integer -173 on a 16-bit computer. 23

24 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers Floating-Point Representation: Fractional quantities are typically represented in computer using floating-point form. In this approach, the number is expressed as a fractional part, called a mantissa or significand, and a integer part, called an exponent or characteristic, as in Floating-Point Representation: Fractional quantities are typically represented in computer using floating-point form. In this approach, the number is expressed as a fractional part, called a mantissa or significand, and a integer part, called an exponent or characteristic, as in 24 exponent Base of the number system used mantissa Integer part

25 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers 156.78  0.15678x10 3 in a floating point base-10 system. 156.78  0.15678x10 3 in a floating point base-10 system. 25

26 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers Normalized to remove the leading zeroes. Multiply the mantissa by 10 and lower the exponent by 1. Normalized to remove the leading zeroes. Multiply the mantissa by 10 and lower the exponent by 1. 0.2941 x 10 -1 0.2941 x 10 -1 26 Suppose only 4 decimal places to be stored Additional significant figure is retained

27 Lecture 3 MECN 3500 Inter - Bayamon Computer Representation of Numbers Therefore for a base-10 system 0.1 ≤m<1 for a base-2 system0.5 ≤m<1  Floating point representation allows both fractions and very large numbers to be expressed on the computer. However, Floating point numbers take up more room. Floating point numbers take up more room. Take longer to process than integer numbers. Take longer to process than integer numbers. Round-off errors are introduced because mantissa holds only a finite number of significant figures. Round-off errors are introduced because mantissa holds only a finite number of significant figures. 27

28 Lecture 3 MECN 3500 Inter - Bayamon Chopping Example:  π =3.14159265358 to be stored on a base-10 system carrying 7 significant digits.  π =3.141592chopping error e t =0.00000065  π =3.141593 rounded error e t =0.00000035  Some machines use chopping, because rounding adds to the computational overhead. Since number of significant figures is large enough, resulting chopping error is negligible. 28

29 Lecture 3 MECN 3500 Inter - Bayamon Homework2  www.bc.inter.edu/facultad/omeza www.bc.inter.edu/facultad/omeza Omar E. Meza Castillo Ph.D. 29


Download ppt "MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo"

Similar presentations


Ads by Google