Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 10, 2004 Lecture Number: 31.

Similar presentations


Presentation on theme: "1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 10, 2004 Lecture Number: 31."— Presentation transcript:

1 1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 10, 2004 Lecture Number: 31

2 2 Announcements

3 3 Review Real numbers –Representation Single precision Double precision

4 4 Outline Real numbers –Limitations

5 5 Real (Decimal) Number Storage Numbers have limited precision Compute 1

6 6 Real (Decimal) Number Storage #include void main() { cout << "precision example" << endl; cout << "Number of bytes in a float: " << sizeof(float) << endl; float epsilon = 1.0f, value; int iteration = 0; int maxIteration = 100; while(iteration < maxIteration) { epsilon /= 2.0; value = 1.0f + epsilon; if (value == 1) break; iteration++; } // end while(...) cout << "Iteration: " << iteration << " Epsilon: " << epsilon <<" Value: " << value << endl << endl; iteration = 0; double epsilonD = 1.0, valueD; cout << "Number of bytes in a double: " << sizeof(double) << endl; while(iteration < maxIteration) { epsilonD /= 2.0; valueD = 1.0 + epsilonD; if (valueD == 1) break; iteration++; } // end while(...) cout << "Iteration: " << iteration << " Epsilon: " << epsilonD <<" Value: " << valueD << endl; }

7 7 Real (Decimal) Number Storage Numbers have limited precision –Most real numbers have an infinite decimal expansion 1/3 10 = 0.33333333… 10 –Clearly, the floating point representation will also be infinite

8 8 Real (Decimal) Number Storage –Real numbers with a finite number of digits may require an infinite number of bits for a binary representation 1/10 10 = 0.1 10 0.1 10 = 0.0001100110011001100110011… 2 1.1001100110011001100110011… 2 * 2 -4 s = 0, e = -4 10 + 127 10 = 123 10 = 0111 1011 2 f = 0.10011001100110011… 2 0011 1101 1100 1100 1100 1100 1100 1100 0x3DCCCCCC

9 9 Real Number Storage Limited Range and Precision There are three categories of numbers left out when floating point representation is used –Numbers out of range because their absolute value is too large (similar to integer overflow) –Numbers out of range because their absolute value is too small (numbers too near zero to be stored given the precision available –Numbers whose binary representations require either an infinite number of binary digits or more binary digits than the bits available

10 10 Real Number Storage Limited Range and Precision Illustrated With one bit to the right of the decimal point, only the real number 0.5 can be represented.

11 11 Real Number Storage Limited Range and Precision Illustrated real numbers that can be represented with two bits 0.25, 0.5, 0.75 real numbers that can be represented with three bits 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 The holes correspond to all the unrepresented numbers: 0.126, 0.255, 0.3, …

12 12 Limited Range and Precision Some Consequences Limited range will invalidate certain calculations –If integers are involved, this can often be avoided by switching to real numbers –For real number calculations, this problem arises infrequently and in those cases can sometimes be handled by special methods –It is not a common occurrence in non- scientific work

13 13 Limited Range and Precision Some Consequences Limited precision for real numbers is very pervasive –Assume that most decimal calculations will, in fact, be in error! –Evaluate and use computer calculations with this in mind

14 14 Risks in Numerical Computing Almost all computer calculations involve roundoff error (limited precision error) If not monitored and planned for carefully, such errors can lead to unexpected and catastrophic results –Arianne 5 Rocket Failure –Patriot Missile Failure during Gulf War

15 15 Risks in Numerical Computing On 4 June 1996, the maiden flight of the Ariane 5 launcher ended in a failure. Only about 40 seconds after initiation of the flight sequence, at an altitude of about 3700 m, the launcher veered off its flight path, broke up and exploded. Engineers from the Ariane 5 project teams of CNES and Industry immediately started to investigate the failureOn 4 June 1996

16 16 Risks in Numerical Computing Based on the extensive documentation and data on the Ariane 501 failure made available to the Board, the following chain of events, their inter-relations and causes have been established, starting with the destruction of the launcher and tracing back in time towards the primary cause. The launcher started to disintegrate at about H0 + 39 seconds because of high aerodynamic loads due to an angle of attack of more than 20 degrees that led to separation of the boosters from the main stage, in turn triggering the self-destruct system of the launcher. This angle of attack was caused by full nozzle deflections of the solid boosters and the Vulcain main engine. These nozzle deflections were commanded by the On-Board Computer (OBC) software on the basis of data transmitted by the active Inertial Reference System (SRI 2). Part of these data at that time did not contain proper flight data, but showed a diagnostic bit pattern of the computer of the SRI 2, which was interpreted as flight data. The reason why the active SRI 2 did not send correct attitude data was that the unit had declared a failure due to a software exception. The OBC could not switch to the back-up SRI 1 because that unit had already ceased to function during the previous data cycle (72 milliseconds period) for the same reason as SRI 2. The internal SRI software exception was caused during execution of a data conversion from 64-bit floating point to 16-bit signed integer value. The floating point number which was converted had a value greater than what could be represented by a 16-bit signed integer. This resulted in an Operand Error. The data conversion instructions (in Ada code) were not protected from causing an Operand Error, although other conversions of comparable variables in the same place in the code were protected. The error occurred in a part of the software that only performs alignment of the strap-down inertial platform. This software module computes meaningful results only before lift-off. As soon as the launcher lifts off, this function serves no purpose. The alignment function is operative for 50 seconds after starting of the Flight Mode of the SRIs which occurs at H0 - 3 seconds for Ariane 5. Consequently, when lift-off occurs, the function continues for approx. 40 seconds of flight. This time sequence is based on a requirement of Ariane 4 and is not required for Ariane 5. The Operand Error occurred due to an unexpected high value of an internal alignment function result called BH, Horizontal Bias, related to the horizontal velocity sensed by the platform. This value is calculated as an indicator for alignment precision over time. The value of BH was much higher than expected because the early part of the trajectory of Ariane 5 differs from that of Ariane 4 and results in considerably higher horizontal velocity values.

17 17 Risks in Numerical Computing The Patriot battery at Dhahran failed to track and intercept the Scud missile because of a software problem in the system's weapons control computer. This problem led to an inaccurate tracking calculation that became worse the longer the system operated. At the time of the incident, the battery had been operating continuously for over 100 hours. By then, the inaccuracy was serious enough to cause the system to look in the wrong place for the incoming Scud.Patriot The Patriot had never before been used to defend against Scud missiles nor was it expected to operate continuously for long periods of time. Two weeks before the incident, Army officials received Israeli data indicating some loss in accuracy after the system had been running for 8 consecutive hours. Consequently, Army officials modified the software to improve the system's accuracy. However, the modified software did not reach Dhahran until February 26, 1991--the day after the Scud incident.

18 18 Software for Numerical Work Software Libraries Spreadsheets Mathematical Software –symbolic manipulation –data analysis –data visualization


Download ppt "1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 10, 2004 Lecture Number: 31."

Similar presentations


Ads by Google