Lecture 7. Floating point arithmetic and stability

Similar documents
ECS 231 Computer Arithmetic 1 / 27

Lecture Notes 7, Math/Comp 128, Math 250

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

AMS526: Numerical Analysis I (Numerical Linear Algebra)

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

Notes for Chapter 1 of. Scientific Computing with Case Studies

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

Introduction to Scientific Computing Languages

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

Notes on floating point number, numerical computations and pitfalls

Floating Point Number Systems. Simon Fraser University Surrey Campus MACM 316 Spring 2005 Instructor: Ha Le

Numerical Algorithms. IE 496 Lecture 20

Mathematical preliminaries and error analysis

ACM 106a: Lecture 1 Agenda

Introduction to Scientific Computing Languages

Binary floating point

Elements of Floating-point Arithmetic

Elements of Floating-point Arithmetic

Chapter 1 Error Analysis

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

1 Floating point arithmetic

Floating-point Computation

Errors. Intensive Computation. Annalisa Massini 2017/2018

Chapter 1 Computer Arithmetic

Outline. Math Numerical Analysis. Errors. Lecture Notes Linear Algebra: Part B. Joseph M. Mahaffy,

1 Backward and Forward Error

Mathematics for Engineers. Numerical mathematics

MAT 460: Numerical Analysis I. James V. Lambers

Applied Mathematics 205. Unit 0: Overview of Scientific Computing. Lecturer: Dr. David Knezevic

Numerical Methods - Preliminaries

1 Finding and fixing floating point problems

Chapter 1 Mathematical Preliminaries and Error Analysis

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

1 ERROR ANALYSIS IN COMPUTATION

Linear Algebra Massoud Malek

Accurate polynomial evaluation in floating point arithmetic

How do computers represent numbers?

Math 471. Numerical methods Introduction

4.2 Floating-Point Numbers

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

Math 411 Preliminaries

Introduction to Scientific Computing

1.1 COMPUTER REPRESENTATION OF NUM- BERS, REPRESENTATION ERRORS

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

Introduction CSE 541

Round-off Errors and Computer Arithmetic - (1.2)

Numerical Linear Algebra Notes

Compute the behavior of reality even if it is impossible to observe the processes (for example a black hole in astrophysics).

Chapter 1: Introduction and mathematical preliminaries

Lecture 1. Introduction to Numerical Methods. T. Gambill. Department of Computer Science University of Illinois at Urbana-Champaign.

MATH ASSIGNMENT 03 SOLUTIONS

Binary Floating-Point Numbers

8/13/16. Data analysis and modeling: the tools of the trade. Ø Set of numbers. Ø Binary representation of numbers. Ø Floating points.

ESO 208A: Computational Methods in Engineering. Saumyen Guha

Numerics and Error Analysis

Lecture 28 The Main Sources of Error

Lecture notes to the course. Numerical Methods I. Clemens Kirisits

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 9

QUADRATIC PROGRAMMING?

Math 128A: Homework 2 Solutions

An Introduction to Numerical Analysis. James Brannick. The Pennsylvania State University

Applications of Mathematics MA 794

BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination December, 2015 BCS-054 : COMPUTER ORIENTED NUMERICAL TECHNIQUES

1 Error analysis for linear systems

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

An Introduction to Numerical Analysis

Lecture 9. Errors in solving Linear Systems. J. Chaudhry (Zeb) Department of Mathematics and Statistics University of New Mexico

Scientific Computing Numerical Computing

Chapter 1 Mathematical Preliminaries and Error Analysis

Chapter 4 Number Representations

Introduction, basic but important concepts

Numerical Analysis and Computing

Numerical Mathematical Analysis

The answer in each case is the error in evaluating the taylor series for ln(1 x) for x = which is 6.9.

Lecture Notes on Essential Numerical Analysis *** DRAFT *** *** UNDER CONSTRUCTION *** please keep checking for new changes.

Conditioning and Stability

The numerical stability of barycentric Lagrange interpolation

Numerical Methods I Numerical Computing

Homework 2 Foundations of Computational Math 1 Fall 2018

CS227-Scientific Computing. Lecture 4: A Crash Course in Linear Algebra

Lecture 2 MODES OF NUMERICAL COMPUTATION

INTRODUCTION TO SCIENTIFIC COMPUTING - DRAFT -](DRAFT)

Math 56 Homework 1 Michael Downs. ne n 10 + ne n (1)

Introduction to Finite Di erence Methods

Contents Experimental Perturbations Introduction to Interval Arithmetic Review Questions Problems...

AMS 147 Computational Methods and Applications Lecture 17 Copyright by Hongyun Wang, UCSC

Identification, Assessment and Correction of Ill-Conditioning and Numerical Instability in Linear and Integer Programs

Review Questions REVIEW QUESTIONS 71

Math 502 Fall 2005 Solutions to Homework 3

Topics. Review of lecture 2/11 Error, Residual and Condition Number. Review of lecture 2/16 Backward Error Analysis The General Case 1 / 22

Numerical Methods. King Saud University

Notes: Introduction to Numerical Methods

Bindel, Fall 2016 Matrix Computations (CS 6210) Notes for

Dense LU factorization and its error analysis

The Euclidean Division Implemented with a Floating-Point Multiplication and a Floor

Lineare Algebra. Endliche Arithmetik. Walter Gander. ETH Zürich

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 2

THE REAL NUMBERS Chapter #4

printing Three areas: solid calculus, particularly calculus of several

Transcription:

Lecture 7 Floating point arithmetic and stability 2.5 Machine representation of numbers Scientific notation: 23 }{{} }{{} } 3.14159265 {{} }{{} 10 sign mantissa base exponent (significand) s m β e A floating point number system is a (finite) subset F of R: A more common way: ( 1) s m β e t x = ( 1) s (0.a 1 a 2 a t ) β e = ( 1) s ( a 1 β + a 2 β 2 + + a t β t) Exponent range [e min, e max ] Normalized if a 1 0. Use e = e min 1 to represent 0. Floating points are not evenly spaced. For example β = 2, t = 3, e min = 1 and e max = 3. The 21 nonnegative floating point numbers are 0, 0.25, 0.3125, 0.3750, 0.4375, 0.5, 0.625, 0.750, 0.875, 1.0, 1.25, 1.50, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0 Spacing of the floating point numbers jumps by a factor 2 at each power of 2. 1

Machine precision Machine epsilon: ɛ M ɛ M = distance between 1 and the next larger floating point number ɛ M = β 1 t It is the spacing of the floating point numbers between 1.0 and β. The spacing between 1.0 and 1/β is β t = O(ɛ M )/β. roundoff unit u = 1 2 ɛ M, the most useful quantity in error analysis. Rounding In converting x R to fl (x) F. Rounding: fl (x) rounds up if (t+1)st digit is β/2 and down otherwise. error due to the finite representation in floating point form of real (and complex) numbers in digital computers. The main causes of error are round-off error and data error. Property 2.1 If x R lies in the range of F, then fl (x) = x(1 + ɛ), ɛ u 2

IEEE Standards (rounding): single precision, β = 2, t = 24, ɛ M 10 8, e min = 125, e max = 128 double precision, β = 2, t = 53, ɛ M 10 16, e min = 1021, e max = 1024 MATLAB s eps gives ɛ M 2.220446049250313 10 16 with format long. single(x) to convert x to single precision. Single precision: 0 00000000 00000000000000000000000 s e m Overflow and underflow IEEE floating point data types Single precision Double precision t 24 bits 53 bits e 8 bits 11 bits s 1 bit 1 bit e max 127 1023 e min 126 1022 Smallest normalized 2 126 10 38 2 1022 10 308 Largest normalized e 127 10 38 2 1023 308 ɛ M 2 24 6 2 8 2 53 10 16 Read p.47-55 3

Special Quantities is returned when an operation overflows x/ ± = 0 for any number x, x/0 = ± for any nonzero number x Operations with infinity are defined as limits, e.g. 4 = lim 4 x = x NaN (Not a Number) is returned when the an operation has no well-defined finite or infinite result. Examples:, /, 0/0, 1, NaN 4. 4

Two fundamental issues: stability and conditioning 1. Stability pertains to the perturbation behavior of an algorithm. 2. Conditioning pertains to the perturbation behavior of a mathematical problem. Algorithms A mathematical problem may be defined as a function f : X Y from a vector space X of data to a vector space Y of solutions. An algorithm f for a problem f can be viewed as another map f : X Y. The problem of solving Ax = b: input data A and b and the solution is x. The computed solution is denoted by x Accuracy An algorithm f for a problem f is accurate if (for each x) f(x) f( x) f(x) = O(ɛ M ) If the problem f is ill-conditioned, the goal of accuracy is unreasonably ambitious. Rounding of the input data is unavoidable on a computer. The perturbation alone might lead to a significant change in the result. 5

Stability An algorithm f for a problem f is stable if (for all x) f(x) f( x) f( x) = O(ɛ M ) for some x with x x x = O(ɛ M ) Nearly the right answer to nearly the right question The definitions of stability given here are useful in many parts of numerical linear algebra, the condition O(ɛ M ) is probably too strict to be appropriate for all numerical problems in other areas such as differential equations. Backward stable An algorithm f for a problem f is backward stable if (for all x) f(x) = f( x) for some x with x x x = O(ɛ M ) exactly the right answer to nearly the right question Stronger and simpler than stability: a tightening of the definition of stability. 6

Conditioning and condition number Well condition problem means small perturbations of x lead to only small changes in f(x). An ill-conditioned problem means some small perturbation of x leads to a large change in f(x). The relative condition number is defined by ( / ) δf δx K = sup δx f(x) x Example 2.3 (condition of a system of equations) Let b R n be fixed. The condition number of computing the solution Ax = b where A is nonsingular is Conditioning vs. Stability K(A) = A A 1. Condition = sensitivity of the solution to perturbations in the data Backward stable algorithm produces accurate results on well conditioned problems. Backward stable algorithm could produce inaccurate answers for sensitive (ill-conditioned) problems, but the inaccuracy is proportional to the sensitivity. We concentrate on designing backward stable algorithms! 7

Accuracy of a backward stable algorithm If a backward stable algorithm is used to solve a problem f with condition number K, then f(x) f(x) f(x) = O(K(x)ɛ M ) It is accurate if the problem is well conditioned. Rule of thumb: forward error condition number x backward error Stability of floating point arithmetic x fl (x) is backward stable. For each x R, there is ɛ ɛ M such that fl (x) = x(1 + ɛ) For all floating points x, y, (x, y) x y is backward stable. There exists ɛ ɛ M such that fl (x y) = (x y)(1 + ɛ) For all floating points x, y, (x, y) fl (x + y) = fl (x) + fl (y) is backward stable Inner product (x, y) fl (x T y) is backward stable, x, y R n. Outer product (x, y) fl (xy T ) is not backward stable, x, y R n. x fl (x + 1) is not backward stable (consider x 0) 8