What is The Error ?How did it happen ?                      1
Definition• The Error in a computed quantity is defined  as:     Error = True Value – Approximate Value                   ...
Examples:a. True Value : phi = 3.14159265358979    Appr. Value : 22/7 = 3.14285714285714    Error = phi-22/7= -0.001264489...
Kind of Error• The Absolute Error is measure the  magnitude of the error              Ea     Error• The Relative Error is ...
Examples• True value : 10      Ea = 10-9 = 1  Appr. Value : 9      Er = Ea/ 10 = 0.1           Ea    1,     Er    0 .1• Tr...
Sources of Errora.Truncation Errorb.Rounding Error                         6
a. Truncation Error• errors that result from using an approximation  in place of an exact mathematical procedure          ...
Example of Truncation ErrorTaking only a few terms of a Maclaurin series toapproximate    e                 x             ...
Example 1 —Maclaurin seriesCalculate the value of e with an absolute                                                      ...
Example 2 —Differentiation                                                                                            f (x...
Example 3 — IntegrationUse two rectangles of equal width to approximatethe area under the curve for        x over the inte...
Integration example (cont.)Choosing a width of 3, we have     9          2           2                                    ...
b. Rounding Errors• Round-off / Chopping Errors• Recognize how floating point arithmetic operations  can introduce and amp...
There are discrete points on the     number lines that can be     represented by our computer.     How about the space bet...
Implication of FP representations• Only limited range of quantities may be  represented.  – Overflow and underflow• Only a...
Round-off / Chopping Errors              (Error Bounds Analysis)Let   z be a real number we want to represent in a compute...
Chopping Errors (Error Bounds Analysis)Suppose the mantissa can only support n digits.                                    ...
Chopping Errors (Error Bounds Analysis) Because               0 .a n 1a n 2 a n     3                                     ...
Round-off Errors (Error Bounds Analysis)                                                    ez            0 .a 1 a 2  a n...
Round-off Errors (Error Bounds Analysis)Absolute error of fl(z)When rounding down                                         ...
Round-off Errors (Error Bounds Analysis)Relative error of fl(z)                   1     e n  z   fl ( z )                 ...
Summary of Error Bounds Analysis                 Chopping Errors                 Round-off errors Absolute                ...
Upcoming SlideShare
Loading in …5
×

Chap 1

299 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
299
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chap 1

  1. 1. What is The Error ?How did it happen ? 1
  2. 2. Definition• The Error in a computed quantity is defined as: Error = True Value – Approximate Value 2
  3. 3. Examples:a. True Value : phi = 3.14159265358979 Appr. Value : 22/7 = 3.14285714285714 Error = phi-22/7= -0.00126448926735b. True Value : 12 Appr. Value: 11.78 Error = 12-11.78 = 0.22c. True Value : 100 Appr. Value: 95.5 Error = 100-95.5 = 4.5 3
  4. 4. Kind of Error• The Absolute Error is measure the magnitude of the error Ea Error• The Relative Error is a measure of the error in relation to the size of the true value Ea Er True Value 4
  5. 5. Examples• True value : 10 Ea = 10-9 = 1 Appr. Value : 9 Er = Ea/ 10 = 0.1 Ea 1, Er 0 .1• True value : 1000 Ea = 1000-999= 1 Appr. Value : 999 Er =Ea/1000=0.001 Ea 1, Er 0 . 001• True value : 250 Ea =250-240= 10 Appr. Value : 240 Er = Ea/250= 0.04 Ea 10 , Er 0 . 04 5
  6. 6. Sources of Errora.Truncation Errorb.Rounding Error 6
  7. 7. a. Truncation Error• errors that result from using an approximation in place of an exact mathematical procedure 7
  8. 8. Example of Truncation ErrorTaking only a few terms of a Maclaurin series toapproximate e x 2 3 x x x e 1 x .......... .......... 2! 3! If only 3 terms are used, 2 x x Truncation Error e 1 x 2! 8
  9. 9. Example 1 —Maclaurin seriesCalculate the value of e with an absolute 1 .2relative approximate error of less than 1%. 2 3 1 .2 1 .2 1 .2 e 1 1 .2 .......... ......... 2! 3! n 1 .2 Ea % e a 1 1 __ ___ 2 2.2 1.2 54.545 3 2.92 0.72 24.658 4 3.208 0.288 8.9776 5 3.2944 0.0864 2.6226 6 3.3151 0.020736 0.62550 6 terms are required. 9
  10. 10. Example 2 —Differentiation f (x x) f ( x)Find for using 2 f ( 3) f ( x) x f ( x) xand x 0 .2 f (3 0 .2 ) f (3) f (3) 0 .2 2 2 f (3 .2 ) f (3) 3 .2 3 10 . 24 9 1 . 24 6 .2 0 .2 0 .2 0 .2 0 .2The actual value is f ( x) 2 x, f (3) 2 3 6Truncation error is then, 6 6 .2 0 .2 10
  11. 11. Example 3 — IntegrationUse two rectangles of equal width to approximatethe area under the curve for x over the interval [ 3,9 ] 2 f ( x) y 90 9 y = x2 2 60 x dx 30 3 0 x 0 3 6 9 12 11
  12. 12. Integration example (cont.)Choosing a width of 3, we have 9 2 2 2 x dx (x ) (6 3) (x ) (9 6) x 3 x 6 3 2 2 (3 )3 ( 6 )3 27 108 135Actual value is given by 9 9 3 3 3 2 x 9 3 x dx 234 3 3 3 3Truncation error is then 234 135 99 12
  13. 13. b. Rounding Errors• Round-off / Chopping Errors• Recognize how floating point arithmetic operations can introduce and amplify round-off errors• What can be done to reduce the effect of round-off errors 13
  14. 14. There are discrete points on the number lines that can be represented by our computer. How about the space between ?14
  15. 15. Implication of FP representations• Only limited range of quantities may be represented. – Overflow and underflow• Only a finite number of quantities within the range may be represented. – round-off errors or chopping errors 15
  16. 16. Round-off / Chopping Errors (Error Bounds Analysis)Let z be a real number we want to represent in a computer, and fl(z) be the representation of z in the computer.What is the largest possible value of ? z fl ( z ) zi.e., in the worst case, how much data are we losing due to round-off or chopping errors? 16
  17. 17. Chopping Errors (Error Bounds Analysis)Suppose the mantissa can only support n digits. ez 0 .a1a 2  a n a n 1a n 2  , a1 0 efl ( z ) 0 .a1a 2  a nThus the absolute and relative chopping errors are e e nz fl ( z ) ( 0 .00 ... 0 a n 1 a n    2 ) ( 0 .a n 1a n 2 ) n zeroes ez fl ( z ) ( 0 . 00 ... 0 a n 1 a n 2 ) e z ( 0 .a 1a 2  a n a n 1a n 2 )Suppose ß = 10 (base 10), what are the values of ai such thatthe errors are the largest? 17
  18. 18. Chopping Errors (Error Bounds Analysis) Because 0 .a n 1a n 2 a n 3  1 e n e n e n z fl ( z ) 0 .a n 1a n 2  z fl ( z ) e z fl ( z ) 0 . 00 ... 0 a n 1 a n 2  e z 0 .a 1a 2  a n a n 1a n 2  e n e 0 .a1a 2  a n a n 1a n 2  e n e 0 .100000 a n 1 a n  2  n digits e n e n e n ( e 1) 1 n z fl ( z ) 1 n e 1 e 0 .1 z 18
  19. 19. Round-off Errors (Error Bounds Analysis) ez 0 .a 1 a 2  a n a n 1  , a1 0 1 ( sign ) base e exponent e ( 0 .a 1 a 2  a n ) 0 an 1 2fl ( z ) Round down e [( 0 .a 1 a 2  a n ) ( 0 ) ] 00 ... . 01 an 1 n 2 Round upfl(z) is the rounded value of z 19
  20. 20. Round-off Errors (Error Bounds Analysis)Absolute error of fl(z)When rounding down e z fl ( z ) 0 . 00  0 a n 1 a n a 2 n 3  e n 0 .a n 1 a n a 2 n 3  e n z fl ( z ) 0 .a n 1 a n a 2 n 3  1 1 e nan 1 (. a n 1 ) z fl ( z ) 2 2 2Similarly, when rounding up 1i.e., when an 1 z fl ( z ) e n 2 2 20
  21. 21. Round-off Errors (Error Bounds Analysis)Relative error of fl(z) 1 e n z fl ( z ) 2 n z fl ( z ) 1 e z 2 z n 1 e because z (. a 1 a 2  ) 2 (. a 1 a 2  ) n 1 because (. a 1 ) ( 0 . 1) 2 (. 1) n 1 2 1 z fl ( z ) 1 1 n z 2 21
  22. 22. Summary of Error Bounds Analysis Chopping Errors Round-off errors Absolute e n 1 e n z fl ( z ) z fl ( z ) 2 Relative z fl ( z ) 1 n z fl ( z ) 1 1 n z z 2 β base n # of significant digits or # of digits in the mantissaRegardless of chopping or round-off is used to round the numbers,the absolute errors may increase as the numbers grow in magnitudebut the relative errors are bounded by the same magnitude. 22

×