Can You Count on Your Computer?

Similar documents
Numerical Analysis. Yutian LI. 2018/19 Term 1 CUHKSZ. Yutian LI (CUHKSZ) Numerical Analysis 2018/19 1 / 41

Introduction to Scientific Computing Languages

Introduction to Scientific Computing Languages

Notes for Chapter 1 of. Scientific Computing with Case Studies

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

Arithmetic and Error. How does error arise? How does error arise? Notes for Part 1 of CMSC 460

Introduction to Scientific Computing

ACM 106a: Lecture 1 Agenda

Numerical Methods - Lecture 2. Numerical Methods. Lecture 2. Analysis of errors in numerical methods

Today s Lecture. Mars Climate Orbiter. Lecture 21: Software Disasters. Mars Climate Orbiter, continued

ECS 231 Computer Arithmetic 1 / 27

MATH20602 Numerical Analysis 1

Lecture 7. Floating point arithmetic and stability

Elements of Floating-point Arithmetic

5.1 Polynomial Functions

MATH20602 Numerical Analysis 1

Mathematical preliminaries and error analysis

Polynomial Functions and Their Graphs

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

How do computers represent numbers?

1 Floating point arithmetic

Linear Algebra Linear Algebra : Matrix decompositions Monday, February 11th Math 365 Week #4

Matrix decompositions

Elements of Floating-point Arithmetic

Solving Quadratic Equations

Errors. Intensive Computation. Annalisa Massini 2017/2018

Chapter 1: Introduction and mathematical preliminaries

Chapter 1 Mathematical Preliminaries and Error Analysis

Numerical Algorithms. IE 496 Lecture 20

BARUCH COLLEGE MATH 1030 Practice Final Part 1, NO CALCULATORS. (E) All real numbers. (C) y = 1 2 x 5 2

Binary floating point

Algebra II with Trig 3 rd Nine Weeks Pacing Guide Grade 11

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

Can a Machine Think?

Equations in Quadratic Form

9. Scientific Computing. Introduction to Computer Science Sedgewick and Wayne Copyright

Unit 1 Vocabulary. A function that contains 1 or more or terms. The variables may be to any non-negative power.

Round-off Errors and Computer Arithmetic - (1.2)

Math 128A: Homework 2 Solutions

1 Backward and Forward Error

Introduction CSE 541

Lecture Notes 7, Math/Comp 128, Math 250

Chapter 1 Error Analysis

Introduction of Computer-Aided Nano Engineering

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

Chapter 1 Computer Arithmetic

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Summer Prep Packet for students entering Algebra 2

Chapter 4 Number Representations

Solving Algebraic Equations in one variable

Chapter 1 Mathematical Preliminaries and Error Analysis

Algebra II Unit #2 4.6 NOTES: Solving Quadratic Equations (More Methods) Block:

Notes on floating point number, numerical computations and pitfalls

Numerical Methods - Preliminaries

Linear System of Equations

27 Wyner Math 2 Spring 2019

History & Binary Representation

Summer Work for students entering PreCalculus

Tropical Polynomials

Number Representation and Waveform Quantization

9. Scientific Computing

11.2 The Quadratic Formula

Course Outcome Summary

Summer Work for students entering PreCalculus

Introduction and mathematical preliminaries

Tu: 9/3/13 Math 471, Fall 2013, Section 001 Lecture 1

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 5. Ax = b.

Floating-point Computation

Complex Numbers: Definition: A complex number is a number of the form: z = a + bi where a, b are real numbers and i is a symbol with the property: i

Multiplication and Division

Accurate Multiple-Precision Gauss-Legendre Quadrature

Final Exam Review: Study Guide Math 3

2 If ax + bx + c = 0, then x = b) What are the x-intercepts of the graph or the real roots of f(x)? Round to 4 decimal places.

Semester Review Packet

Algebra Quadratics Applications HW#54

Number Systems III MA1S1. Tristan McLoughlin. December 4, 2013

QUADRATIC PROGRAMMING?

Algebra II. A2.1.1 Recognize and graph various types of functions, including polynomial, rational, and algebraic functions.

Contents. Introduction... 5

Solving Equations Quick Reference

Basic Fraction and Integer Operations (No calculators please!)

Round-off error propagation and non-determinism in parallel applications

80 Wyner PreCalculus Spring 2017

Students will be able to simplify numerical expressions and evaluate algebraic expressions. (M)

CHMC: Finite Fields 9/23/17

Unit 3A: Factoring & Solving Quadratic Equations After completion of this unit, you will be able to

Essential Mathematics

Index I-1. in one variable, solution set of, 474 solving by factoring, 473 cubic function definition, 394 graphs of, 394 x-intercepts on, 474

A.0 SF s-uncertainty-accuracy-precision

Introduction to Computer Systems

Quadratic Formula: - another method for solving quadratic equations (ax 2 + bx + c = 0)

5.3 SOLVING TRIGONOMETRIC EQUATIONS

Function Junction: Homework Examples from ACE

2. Motivation and Introduction: Numerical Algorithms in CSE Basics and Applications

ECE260: Fundamentals of Computer Engineering

Numerical Computation for Deep Learning

Matrix decompositions

Quiz 07a. Integers Modulo 12

Honors Advanced Mathematics November 4, /2.6 summary and extra problems page 1 Recap: complex numbers

Transcription:

Can You Count on Your Computer? Professor Nick Higham School of Mathematics University of Manchester higham@ma.man.ac.uk http://www.ma.man.ac.uk/~higham/ p. 1/33

p. 2/33

Counting to Six I asked my computer to count to six: 1.00000000000000 2.00000000000011 2.99999997414701 1.00000000000000 NaN Inf Is this a FLOP? p. 3/33

FLOPs FLOP = Floating point Operation. Example: (3 + 7)/2 12 costs 3 FLOPs. National Physical Laboratory, 1946 Fox, Goodwin, Turing and Wilkinson with desk-top calculating machines. Worked on a maths problem for 2 weeks. Averaged 300 seconds for one FLOP. (0.003 FLOPs per sec.) Current technology, FLOPs per second 1950 s Pilot Ace 1 Up to date PC (Pentium 4) Earth Simulator (NEC) 4 Thousand Million 35 Million Million p. 4/33

Pilot ACE (1950) p. 5/33

Pilot ACE (1950) p. 6/33

Earth Simulator p. 7/33

Earth Simulator p. 8/33

Floating Point Numbers Floating point number system F R: f = ±.d 1 d 2...d }{{} t β e, 0 d i β 1, d 1 0. mantissa β: base, t: precision, e exponent range s.t. e min e e max. Floating point numbers are not equally spaced. If β = 2, t = 3, e min = 1, and e max = 3, the nonnegative floating point numbers are. 0 0.5 1.0 2.0 3.0 4.0 5.0 6.0 7.0 p. 9/33

Two Kinds of Error: Computers in Mathematics Bugs in Programs: unintentional. The first American Venus probe was lost due to a program fault caused by the substitution of DO 3 I = 1.3 for DO 3 I = 1,3 Limitations of the Computer: intentional. The average of two numbers lies between the two numbers. But if we work to three decimal digits, 5.01 + 5.02 2 = 10.03 2 = 10.0 2 = 5.0. p. 10/33

Vancouver Stock Exchange Index January 1982: Index established at 1000. November 1983: Index was 520. But exchange seemed to be doing well. Explanation: Index rounded down to three digits at each recomputation. E.g. 678.35 678. Errors always in same direction thousands of small errors add up to a large error. Upon correct recalculation, the index doubled! p. 11/33

Ariane 5 Rocket Failure Report by the Inquiry Board. Paris, 19 July 1996.... 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. p. 12/33

Ariane Continued...... 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. p. 13/33

Limitations of the Computer My calculator displays 8 digits. E.g. 1/3 = 0.3333333 Error is roughly 0.00000003 = 3 10 8 ). 1/3 * 3 = 0.9999999 Error is 0.0000001 = 1 10 7. We are doing inexact arithmetic. Every flop may produce a small error. (Small 10 16 on a Pentium.) Also, some rules of arithmetic are lost: a*(b+c) = a*b + a*c (a*b)*c = a*(b*c) ( x) 2 = x. p. 14/33

Solving a Quadratic Equation The quadratic equation ax 2 + bx + c = 0 has two solutions: x = ( b ± b 2 4ac)/(2a). Use the formula to solve x 2 10,000 x + 1 = 0. True solutions: x 1 = 9999.999899999998, x 2 = 0.000100000001000. In 8-digit arithmetic, formula gives x 1 = 10,000.0, x 2 = 0. Better: compute x 1 from the formula and x 2 from x 1 x 2 = c/a. This gives an accurate x 2. p. 15/33

Computing the Sample Variance Sample variance of x 1,...,x n defined as s 2 n = 1 n 1 n (x i x) 2, where x = 1 n i=1 n i=1 x i. (1) or s 2 n = 1 ( n x 2 i 1 ( n ) 2 ) x i n 1 n i=1 i=1 (2) For x = (10000, 10001, 10002) using 8-digit arithmetic, (1) gives: 1.0, (2) gives 0.0. Are either of these reasonable? p. 16/33

Casio fx-992vb p. 17/33

Patriot Missile Software Problem Official Report from United States: On February 25, 1991, a Patriot missile defense system operating at Dhahran, Saudi Arabia, during Operation Desert Storm failed to track and intercept an incoming Scud. This Scud subsequently hit an Army barracks, killing 28 Americans p. 18/33

Patriot Missile Cont... Patriot missile s computer: 1970s design, 24 bit arithmetic. Patriot tracks targets by measuring the time for radar pulses to reflect back. Time recorded by system clock in tenths of a second, but stored as an integer. For calculations, time converted to a 24 bit floating point number. Note: 0.1 10 = (.000 1100 1100 1100...) 2. p. 19/33

Patriot: More Detail Hours Calculated Inaccuracy Approx. shift in Time (secs) (secs) range gate (m) 0 0 0 0 1 3599.9966.0034 7 20 71999.9313.0687 137 48 172799.8352.1648 330 100 359999.6567.3433 687 Target outside range gate after 20 hours. On February 25, 1991, Alpha Battery, which was protecting Dhahran Air Base, had been in continuous operation for over 100 hours. On February 26, modified software to correct the problem arrived in Dhahran. p. 20/33

Summation In computer arithmetic, a + (b + c) (a + b) + c. In 2-digit arithmetic, (5.9 + 5.5) + 0.4 = 11.0, 5.9 + (5.5 + 0.4) = 12.0. p. 21/33

Summation Cont... I do hate sums. There is no greater mistake than to call arithmetic an exact science. There are... hidden laws of Number which it requires a mind like mine to perceive. For instance, if you add a sum from the bottom up, and then again from the top down, the result is always different. MRS. LA TOUCHE. Quoted in The Mathematical Gazette, 1924. p. 22/33

Analysing Computer Arithmetic Early work in the 1940s by some renowned mathematicians (Hotelling, von Neumann,... ) led to very pessimistic predictions about the effectiveness of computers for systems of equations. The English mathematicians Alan Mathison Turing (1912 1954) James Hardy Wilkinson (1919 1986) were the first to understand the correct way to analyze the effects of inexact computer arithmetic. p. 23/33

Alan Mathison Turing (1912 1954) 1912 Born, London 1931 34 King s College, Cambridge, with scholarship 1939 43 Works at Bletchley Park for Foreign Office 1941 Breaks the Enigma code 1945 Goes to NPL as Senior Scientific Officer. Proposal for Development... of ACE 1946 Receives OBE 1948 Goes to Univ. Manchester to work on prototype computer. Rounding-Off Errors in Matrix Processes 1950 Computing Machinery and Intelligence 1951 Elected Fellow of the Royal Society 1952 The Chemical Basis of Morphogenesis 1954 Commits suicide at home in Wilmslow Hugh Whitemore. Breaking the Code: The Story of Alan Turing. 1987. Robert Harris. The Enigma Connection. 1995. p. 24/33

Turing p. 25/33

James Hardy Wilkinson (1919 1986) 1919 Born, Stroud, Kent 1936 Scholarship in Mathematics, Trinity College, Cambridge 1940 Joins Ordnance Board of Ministry of Supply 1946 Joins NPL working half time each with Turing and Desk Computing Group 1948 51 Head of Pilot ACE group 1951 56 Works on exploitation of Pilot ACE for solving scientific problems 1963 Rounding Errors in Algebraic Processes 1965 The Algebraic Eigenvalue Problem 1969 Elected Fellow of the Royal Society 1971 Handbook for Automatic Computation: Linear Algebra 1986 Dies of heart attack in his garden p. 26/33

Wilkinson p. 27/33

Backward Error Analysis The key idea introduced by Turing and Wilkinson is backward error analysis. Example Find the n roots x 1,x 2,...,x n of p(x) = a n x n + + a 1 x + a 0. Let x 1,..., x n be the computed roots. Forward error: max i x i x i. Backward error analysis says that the computed roots are the exact roots of another polynomial q, q( x i ) = 0, i = 1, 2,...,n. Backward error: min p q. p. 28/33

IEEE Arithmetic Institute of Electrical and Electronics Engineers (IEEE) standard, 1985: specifies how numbers are stored on a computer and how arithmetic operations are performed. E.g., computing a + b must produce (a + b)(1 + e), where e has size less than 10 16. e is called a rounding error. This standard allows mathematical analysis to keep track of the (small) errors that are made whenever two numbers are added, subtracted, multiplied or divided on a computer. p. 29/33

Rounding Errors Although Charlie Brown does not realize it, there is a big difference between nothing and a small rounding error. p. 30/33

Counting to Six 1.000000000000000 2.00000000000011 2.99999997414701 1.00000000000000 NaN Inf p. 31/33

One, Two, Three 2 1 = 1 ( 1 cos(100π + π/4) ) 2 = 2.00000000000011 3 cos(arccos(10000)) 10000 = 2.99999997414701 p. 32/33

Four, Five, Six ( 4 )2 2 2 = 1 5 { } (1 + exp( 100)) 1 (1 + exp( 100)) 1 =NaN log (exp(6000)) 1000 =Inf p. 33/33