CAAM 353 -Errors and Floating Point Notation 17pp
-
Upload
jemmettdwyer1033 -
Category
Documents
-
view
217 -
download
0
Transcript of CAAM 353 -Errors and Floating Point Notation 17pp
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
1/17
CAAM 353
Errors and Floating Point Notation
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
2/17
Types of Errors
Data Error vs. Computational Error
,
, Error =
= + ()
Computational Data
(Sine Example)
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
3/17
Types of Computational Errors
Rounding
Truncation
Accumulation Cancelation
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
4/17
Floating Point System
Real numbers can have infinite decimal
representations, but computer memory is finite
+
+
+ +
+
+
+
+ +
base of the number system
precision (# of digits) Lower Bound on Exponent e
Upper Bound on Exponent e
0 . . 1, 0
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
5/17
Chopping and Rounding
How do you cut off the infinite decimal
representation to write fl(x)?
Chop: Drop the (t, t+1, t+2, .) last Digits
Round: If < /2 then chop
else if > /2, last digit gets
modified to be: +1else /2, round to nearest even
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
6/17
Rounding Unit and Error
When we round, the WORST weve done is to
create a relative error of:
||
Quantity:
known as Machine Precision MATLAB: eps = 2.2204e-016
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
7/17
IEEE System
Many computer systems (including MATLAB)
run on this system
Base is 2
Single Precision = 32 bit word
Double Precision = 64 bit word
1 bit for sign (0 = +, 1 = -) 11 bits for exponent, e = 2^11 possibilities
52 bits for the number (d0 to d51)
Eps = * 2^(1-52) = 2^(-52)
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
8/17
IEEE System
Exponent possibilities 2^11 = 2048
exponent = b 1023
b = 11 bit number
Infinity = 11111111111 = 2047-1023 = 1024
0 = 00000000000 = 0-1023 = -1023
Normal Numbers are in the exponent range
1023 -1022
1024 reserved for infinity, -1023 reserved for 0
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
9/17
How many numbers?
How many numbers can you represent with a, , , system?
p 1 + 1 2 + 1
How are these numbers spaced?
Ex. 2, 2, 1, 1
+
2 2
(floatgui.m)
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
10/17
Floating Point Arithmetic
Add 4.567 10 and 4.567 10
Real answer:
0.4567 + 0.004567 0.46127
Rounded real answer: 0.4613
Answer in system with t = 4, with chop
0.4567 + 0.0045 0.4612
Most computer systems have guard digits to
avoid this (allow leading zeros that dont
count in the precision)
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
11/17
Floating Point Arithmetic
Multiplication:
4.567 10times 4.567 10
Real Answer: 2.0857489 10
Chopped Answer for t=4:
2.085 10
If you use this number for anothercomputation in your code, the error propagates
called Error Accumulation
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
12/17
Another Interesting Example
From calculus, you should remember that the
following series is the Taylyer series of exp(x)
!
=
Lets look at this sum in MATLAB for:
x = 10 and x = -10
Can you foresee a problem?
(exptest.m)
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
13/17
Cancelation Error
Previous slides error for x = -10 can also be
called cancelation error (loss of digits due to
canceling of the beginning digits)
Sometimes you can avoid cancellation error,
by being smart with your arithmetic
Example: 1 +
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
14/17
Subtracting Close Numbers
Back to our
derivative example
Solution should
improve as h 0,
right? WRONG
Total Error:
(sinapprox.m)
+ ()
+
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
15/17
Patriot Missile Failure
On February 25, 1991, during the Gulf War, an
American Patriot Missile battery in Dharan,
Saudi Arabia, failed to track and intercept an
incoming Iraqi Scud missile.
28 people died, 100 injured
The cause was an inaccurate calculation of the
time since boot due to computer arithmetic
errors
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
16/17
Patriot Missile Disaster
The time in tenths of second as measured by
the system's internal clock was multiplied by
1/10 to produce the time in seconds
Calculations done with 24-bit (base 2 numbers)
1/10 has a non-terminating rep. in base 2
Chop error, multiplied by the large time (in
tenths of seconds) produced a time in seconds
that was inaccurate
-
7/28/2019 CAAM 353 -Errors and Floating Point Notation 17pp
17/17
Patriot Missile Disaster
Detector had been on 100 hours = 3600000
tenths of seconds
Multiply by base 2 (24-bit, roughly 6 digits of
accuracy) version of 1/10 and you are off by
about 0.34 sec
A Scud travels at about 1,676 meters per
second, and so travels more than half a
kilometer in 0.34 sec!
http://www.ima.umn.edu/~arnold/disasters/patriot.html