+ All Categories
Home > Documents > Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf ·...

Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf ·...

Date post: 24-Mar-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
25
Unit 1 Unit 1 Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3 1 by Martin Mendez, UASLP, Mex
Transcript
Page 1: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Unit 1Unit 1

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter 3 1by Martin Mendez, UASLP, Mex

Page 2: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Approximations and Round-Off ErrorsppChapter 3

F i i bl t bt i l ti l• For many engineering problems, we cannot obtain analytical solutions.

• Numerical methods yield approximate results, results that are y pp ,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 O y a e y g ve data a e e act, s ce t ey o g ate o

measurements. Therefore there is probably error in the input information.

– 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.

• How confident we are in our approximate result?• The question is “how much error is present in our calculation

and is it tolerable?”

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 2

and is it tolerable?

Page 3: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

• Accuracy. How close is a computed or measured value to the true valuemeasured value to the true value

• Precision (or reproducibility). How close is a computed or measured value to previously computed or measured values.p

• Inaccuracy (or bias). A systematic deviation from the actual valuefrom the actual value.

• Imprecision (or uncertainty). Magnitude of scatter.

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 3

Page 4: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Fig. 3.2

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 4

Page 5: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Significant FiguresSignificant FiguresN mber of significant fig res indicates precision Significant digits of a• 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,800 How many significant figures?

5 38 x 104 35.38 x 104 35.380 x 104 45.3800 x 104 5

Zeros are sometimes used to locate the decimal point not significant figures.

0.00001753 40.0001753 4

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 50.001753 4

Page 6: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 6

Page 7: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Error DefinitionsError Definitions

True Value = Approximation + Error

Et = True value – Approximation (+/-)

errortrueTrue error

valuetrueerrortrue error relativefractional True =

%100lt

error true error, relativepercent True t ×=ε

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 7valuetruet

Page 8: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

• For numerical methods, the true value will be known only when we deal with functions that ycan be solved analytically (simple systems). In real world applications, we usually not know pp , ythe answer a priori. Then

erroreApproximat %100ionApproximaterroreApproximat a ×=ε

• Iterative approach, example Newton’s method

%100ii tC t

ionapproximat Previous -ion approximatCurrent a ×=εionapproximatCurrent a

(+ / -)

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 8

Page 9: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

• Use absolute value.• Computations are repeated until stopping criterion is

satisfiedsatisfied.

⟨ P ifi d % t l b dsa εε ⟨ Pre-specified % tolerance based

on the knowledge of your solution

• If the following criterion is met

)%10 (0.5 n)-(2s ×=ε

you can be sure that the result is correct to at least n significant figures.

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 9

Page 10: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 10

Page 11: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 11

Page 12: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 12

Page 13: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 13

Page 14: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Round off ErrorsRound-off Errors

• Numbers such as π, e, or cannot be expressed by a fixed number of significant figures.

7

• Computers use a base-2 representation, they cannot precisely represent certain exact base-10 numbers.p y p

• Fractional quantities are typically represented in computer using “floating point” form, e.g.,computer using floating point form, e.g.,

em b exponentInteger part

m.bBase of the number system used

mantissa

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 14

Page 15: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Figure 3.3

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 15

Page 16: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Figure 3.4

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 16

Page 17: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 17

Page 18: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Figure 3 5Figure 3.5

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 18

Page 19: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

156.78 0.15678x103 in a floating point base-10 system

Suppose only 402941176501 = Suppose only 4 decimal places to be stored111002940

029411765.034

0 <≤× m 1100294.0 0 <≤× mb

• Normalized to remove the leading zeroes. Multiply the mantissa by 10 and lower the exponent by 1

0.2941 x 10-1

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 19Additional significant figure is retained

Page 20: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Th f

11<≤ m

bTherefore

for a base-10 system 0.1 ≤m<1for a base-2 system 0.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.– Take longer to process than integer numbers.– Round-off errors are introduced because mantissa

holds only a finite number of significant figures

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 20

holds only a finite number of significant figures.

Page 21: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 21

Page 22: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 22

Page 23: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 23

Page 24: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 24

Page 25: Unit 1Unit 1 - galia.fc.uaslp.mxgalia.fc.uaslp.mx/~mmendez/lecturenotes/NM/Slides/UNIT1.pdf · Round-off Errorsoff Errors • Numbers such as π, e, or cannot be expressed by a fixed

ChoppingChoppingE lExample:π=3.14159265358 to be stored on a base-10 system

i 7 i ifi di icarrying 7 significant digits.π=3.141592 chopping error εt=0.00000065If roundedπ=3.141593 εt=0.00000035t• Some machines use chopping, because rounding adds

to the computational overhead. Since number of significant figures is large enough, resulting chopping error is negligible.

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

by Martin Mendez, UASLP, Mex

Chapter 3 25


Recommended