What is Rounding Error - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

What is Rounding Error

Description:

During the Gulf War, an Iraqi Scud got through the Patriot anti-missile system ... To track the Scud, the system had to determine the interval between tracking ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 15
Provided by: unkn936
Category:
Tags: error | rounding | scud

less

Transcript and Presenter's Notes

Title: What is Rounding Error


1
What is Rounding Error?
  • AiS Challenge
  • STI 2003
  • Richard Allen

2
What is Rounding Error?
  • As I was going up the stair
  • I met a man who wasnt there!
  • He wasnt there again today!
  • I wish, I wish hed stay away!

3
Floating-Point Numbers
  • Nearly all computation on a digital computer is
    done in floating-point arithmetic (FPA).
  • A floating-point number system (FPS) is a number
    system that uses a finite number of digits to
    represent the real number system that we use in
    exact computation.
  • Floating point numbers are generally represented
    in binary in a computer.

4
A Floating-Point Number System
  • Decimal example A FPS with 1-decimal digit
    ranging from -9.0 to 9.0 system contains only
    55 numbers.
  • 0.0
  • ?.01 ?.02 ?.03 ?.04 ?.05 ?.06 ?.07 ?.08 ?.09
  • ?0.1 ?0.2 ?0.3 ?0.4 ?0.5 ?0.6 ?0.7 ?0.8 ?0.9
  • ?1.0 ?2.0 ?3.0 ?4.0 ?5.0 ?6.0 ?7.0 ?8.0 ?9.0

5
Rounding Arithmetic
  • If pi 3.14156... were represented in our
    1-digit FPS, it would be 3.0.
  • In a 5-decimal system, pi could be represented by
  • 3.1416 (rounding)
  • 3.1415 (truncation or chopping)
  • Rounding error is the difference between the
    result in exact arithmetic and the result in our
    floating-point system.

6
Some Interesting Implications of Rounding Error
  • Check out the site http
  • http//gala.univ-perp.fr/langlois/rounding_error
    .html
  • for some interesting examples.
  • Three of these examples follow
  • The Patriot
  • Down and out in Vancouver
  • I shot an arrow in the air (The sad story of the
    Ariane 5)

7
The Patriot
  • During the Gulf War, an Iraqi Scud got through
    the Patriot anti-missile system and hit a
    barracks, killing 28 people.
  • To track the Scud, the system had to determine
    the interval between tracking times by
    subtracting two values of a timer.
  • The times in tenths of a second were stored as
    integers (4.2 was stored as 42) in the onboard
    computer.

8
The Patriot (cont.)
  • To compute the interval, timer values were
    con-verted to floating-point representation by
    multi-plying by 0.1.
  • 0.1 has a non-terminating binary expansion
    con-sequently, the interval was computed with
    error - the larger the value, the larger the
    error.
  • At the time of the incident, the missile battery
    had been operating for over 100 hrs, resulting in
    an error of 0.34 sec. in the timer causing the
    system to look in the wrong place for the
    incoming Scud.

9
Down and Out in Vancouver Stock Exchange
  • In 1982 the Vancouver Stock Exchange introduced
    an index with a nominal value of 1000.000.
  • After each transaction, the index was recomputed
    and truncated to three decimal places.
  • After 22 months of transactions, the index was
    524.881.
  • The true value was 1098.811.

10
The sad story of the Ariane 5
  • On June 4, 1996, Ariane was launched at Kourou
    and all went well for 36 sec.
  • At second 37, the rocket veered off course and
    self-destructed.
  • The problem was in the Inertial Reference System.

11
The sad story of the Ariane 5
  • The IRS tried to convert a 64-bit floating point
    number to a 16-bit integer.
  • The number was too large, which triggered an
    error and send a diagnostic message to the
    On-Board Computer.
  • The OBC interpreted the diagnostic word as flight
    data.
  • Finis!

12
Solution of a Quadratic Equation
  • The solution to the quadratic equation
  • x2 bx c 0
  • is
  • x -b /-sqrt(b2 4c)/2
  • Example b -0.125335, c 0.360551e-6,
    using 6-digit decimal arithmetic
  • r1 1.25333e-1 (1.253321232e-1)
  • r2 2.50000e-6 (2.876764477e-6)

13
Quadratic Equation (cont.)
  • r1 looks pretty good, but r2 does not. Why?
  • Cancellation occurred in forming
  • b sqrt(b2 4c)/2 0.125335 - 0.125330/2

    2.5e-6
  • However, death occurred when we formed
  • b2 4c 0.0157089 - .00000144220
  • 0.0157075
  • Cancellation and the addition/subtraction of
    floating-point numbers with differing magnitudes
    can cause problems.

14
Quadratic Equation the cure
  • We must restore the information that we dont
    have about the coefficient c.
  • A little algebra will tell us that if r1 and r1
    are real, distinct roots of x2 bx c 0,
    then
  • r1r2 c
  • So, we compute r1 as before and compute r2 as
  • r2 c/r1 3.60551e-6 / 1.25332e-1
  • 2.87677 (2.876764477e-6)
Write a Comment
User Comments (0)
About PowerShow.com