CSC 4250 Computer Architectures September 12, 2006 Appendix H. Computer Arithmetic.

Slides:



Advertisements
Similar presentations
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Advertisements

CENG536 Computer Engineering department Çankaya University.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Software Engineering Disasters
What is Rounding Error? AiS Challenge STI 2003 Richard Allen.
Chapter 8 Representing Information Digitally.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
Floating-Point and High-Level Languages Programming Languages Spring 2004.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
Scientific Computing Algorithm Convergence and Root Finding Methods.
February 26, 2003MIPS floating-point arithmetic1 Question  Which of the following are represented by the hexadecimal number 0x ? —the integer.
USS Yorktown (1998) A crew member of the guided-missile cruiser USS Yorktown mistakenly entered a zero for a data value, which resulted in a division by.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Chapter 1 Measurement F. Morales.
2.2 Errors. Why Study Errors First? Nearly all our modeling is done on digital computers (aside: what would a non-digital analog computer look like?)
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Computer Organization and Design Floating-Point Arithmetic
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
To many people, accuracy and precision mean the same thing: to someone involved in measurement, the two terms should have very different meanings. Accuracy.
Physics 521 Math Review SCIENTIFIC NOTATION Scientific Notation is based on exponential notation (where decimal places are expressed as a power of 10).
Computing Systems Basic arithmetic for computers.
Software Engineering Background Dr. David A. Gaitros.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
ME 142 Engineering Computation I Computer Precision & Round-Off Error.
5.2 Errrors. Why Study Errors First? Nearly all our modeling is done on digital computers (aside: what would a non-digital analog computer look like?)
Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.
CSC 221 Computer Organization and Assembly Language
Floating Point Arithmetic
Lecture 08 – Documentation, debugging.  docstring  A special kind of string (text) used to provide documentation  Appears at the top of a module 
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
Chapter 1 Physical Quantities, Units, Measurements and Estimation In the quest to understand nature, scientists use physical quantities to describe the.
Problems with Floating-Point Representations Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
To many people, accuracy and precision mean the same thing: to someone involved in measurement, the two terms should have very different meanings. Accuracy.
“I am not in the office at the moment. Send any work to be translated.”
1 Approximation. 2 Taylor Series 3 Truncation Error  In general, the nth order Taylor series expansion will be exact for an nth order polynomial  In.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Machine arithmetic and associated errors Introduction to error analysis Class II.
Dr. Clincy Professor of CS
ME 142 Engineering Computation I
CS 105 “Tour of the Black Holes of Computing!”
Floating Point Numbers: x 10-18
Machine arithmetic and associated errors Introduction to error analysis (cont.) Class III.
Chapter 6 Floating Point
Floating Point.
Topic 3d Representation of Real Numbers
The Top 10 bugs
CS201 - Lecture 5 Floating Point
Numeric Accuracy and Precision
CS 105 “Tour of the Black Holes of Computing!”
Dr. Clincy Professor of CS
Approximations and Round-Off Errors Chapter 3
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS213 Floating Point Topics IEEE Floating Point Standard Rounding
Topic 3d Representation of Real Numbers
Sources of Error Major: All Engineering Majors
CS 105 “Tour of the Black Holes of Computing!”
Software Engineering Disasters
CS 105 “Tour of the Black Holes of Computing!”
Presentation transcript:

CSC 4250 Computer Architectures September 12, 2006 Appendix H. Computer Arithmetic

Five Real Stories on Computer Arithmetic 1. Insufficient Accuracy 2. Truncation Errors 3. Numerical Overflow 4. Divide by Zero 5. Wrong Units of Measurement

1. Insufficient Accuracy First Iraq War Feb 25, 1991; Dhahran, Saudi Arabia Iraqi Scud Missile American Patriot Missile failed to intercept 28 American soldiers died in the attack:  20% of the 148 total deaths

Fixed Point Data Patriot system contains an internal clock, a counter that is incremented every 0.1 seconds Time in seconds is determined by multiplying the counter value by 0.1 (24 bit approximation)

Approximation Base 10Base 2 0.1= [1100]… ≈ ← 23 bits → Let x= Then 0.1 − x = [1100]…× 2 –23 = [1001]…× 2 –20 Thus, (0.1 − x)/0.1 =2 –20 ←relative error

Patriot System Mobile system Designed to avoid detection Should run for only a few hours at each site Ran for 100 hours in Dhahran: 100 hrs = 360,000 sec = 3.6×10 5 sec Accumulated error equals (3.6×10 5 ) × 2 –20 = seconds > Clock step size

Software System Upgrade Software (assembly language) written in 1970s Modified to cope with high speed of missiles → Clock time more accurately converted Not all function calls replaced by new code Patriot likely confused by different clock times Patriot did not track the Scud → No Patriot missile was fired

2. Truncation Errors Dow Jones Industrial Average equals a multiple of the total prices of the 30 underlying stocks Present multiple is about 8.00 If IBM ($79.40, closing price on 9/7) goes up $1, then DJI average goes up 8.00 points If Microsoft ($25.43, closing price on 9/7) goes up $1, then DJI average goes up 8.00 points If GE ($34.04, closing price on 9/7) goes up $1, then DJIA goes up 8.00 points Is DJIA a good measure of the market? What happens to DJIA when IBM goes up 10%? MSFT? Faster to update index than to compute it from definition

Market Cap CompanyPriceMarket Cap IBM$79.40$121.96B MSFT$25.43$255.53B GE$34.04$350.17B

Effect on DJIA If the market cap of IBM goes up $12.196B, the DJIA will go up ?? points If the market cap of MSFT goes up $25.553B, the DJIA will go up ?? points If the market cap of GE goes up $35.017B, the DJIA will go up ?? points The S&P 500 index is generally regarded as a better measure of the market because it takes market cap into account (it is float weighted)

Truncation Errors (2) Vancouver Stock Exchange introduced new stock index in 1982 Updated and truncated (three decimal digits) after each transaction After 22 months, index fell from 1000 to 525 ─ , to be precise Correct value is ─based on underlying stocks

Truncation Error (3) Assume 2500 transactions a day Average error per transaction is Average error per day is 1.25 Assume 21 trade days a month Total estimated error is 22×21×1.25 = Correct value is →Estimated wrong value = Observed index value =

3. Numerical Overflow European Space Agency Ariane 5 rocket; June 4, 1996 $500 million communication satellites on board Off course and exploded 37 seconds after liftoff Overflow when 64-bit floating-point number converted to 16-bit signed integer Value measured horizontal velocity of rocket 16 bit integer sufficient for Ariane 4 Part of Ariane 4 software reused in Ariane 5

Divide by Zero US Navy missile cruiser USS Yorktown September 1997; off coast of Virginia A zero was entered by mistake into data field of Remote Database Manager Program A divide by zero → Database overflow → Propulsion system shut down Ship dead in water for 2 hours 45 minutes

5. Wrong Units of Measurement Mars Climate Orbiter; $125 million September 23, 1999 Lockheed Martin built & operated the orbiter LM engineers gave navigation commands for the Orbiter’s thruster in English units NASA use metric units Navigation information did not transfer to JPL Orbiter got to within 60km of Mars, 100 km closer than planned Orbiter’s propulsion system overheated and became disabled

Four Rounding Rules 1.Round to even: 1.25 → 1.2; 1.35 → 1.4; −1.35 → −1.4 2.Round toward zero (= truncate): 1.25 → 1.2; 1.35 → 1.3; −1.35 → −1.3 3.Round toward plus infinity: 1.25 → 1.3; 1.35 → 1.4; −1.35 → −1.3 4.Round toward minus infinity: 1.25 → 1.2; 1.35 → 1.3; −1.35 → −1.4

Important Rule on Accuracy (p. H-35) If x and y have p-bit significands, and x+y is computed exactly and then rounded to q places, a second rounding to p places will not change the answer if q ≥ 2p+2. This is true not only for addition, but also for multiplication, division, and square root.

IEEE Arithmetic Double precision,q=53 Single precision,p=24 So,q ≥ 2p+2 Accurate single precision can be implemented by computing in double precision, and then rounded to single precision

Double Rounding (p. H-34) Want to compute 1.9 × 0.66 Exact result is Say extended precision is 3 digits Rounded to extended precision, the result is 1.25 Further rounded to single precision, the result is1.2 Correctly rounded result is 1.3, obtainable by directly rounding once What went wrong? We have:q = 3; p = 2; q < 2p+2.

Objective Computed result should be accurate to last bit (as if calculated in exact arithmetic, and then rounded correctly).

Cray-1 Computation not accurate Cray division: a/b=a × (1/b) Take b=10(Recall Patriot System). Last three bits could be wrong on Cray divides Read p. H-64 and p. H-65

Floating Point Operations Not Associative We have ( ) −10 10 =0 But (10 10 −10 10 )=3.14 Also, (10 20 × ) ×10 −20 =Overflow × ( ×10 −20 )=10 20

Euclidean Length of Vector √[ v v v … + v n 2 ] May overflow or underflow with v i 2, even though final result is a normal number. Try v i = 10 40, or v i = 10 −40

Better Way to Compute Euclidean Length Let v max = max │v i │ Thencompute v max √[ (v 0 / v max ) 2 + … + (v n / v max ) 2 ] Replace v max by an easier-to-handle quantity?