Lecture Notes 7, Math/Comp 128, Math 250

Similar documents
Lecture 7. Floating point arithmetic and stability

Notes on floating point number, numerical computations and pitfalls

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

Mathematical preliminaries and error analysis

Chapter 1 Mathematical Preliminaries and Error Analysis

ECS 231 Computer Arithmetic 1 / 27

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

Numerical Algorithms. IE 496 Lecture 20

Binary floating point

Floating-point Computation

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

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

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

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

Errors. Intensive Computation. Annalisa Massini 2017/2018

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

Chapter 4 No. 4.0 Answer True or False to the following. Give reasons for your answers.

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

Chapter 1: Introduction and mathematical preliminaries

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

ACM 106a: Lecture 1 Agenda

AMS526: Numerical Analysis I (Numerical Linear Algebra)

Introduction CSE 541

1 Backward and Forward Error

Introduction and mathematical preliminaries

Introduction to Scientific Computing Languages

1 ERROR ANALYSIS IN COMPUTATION

Chapter 1 Computer Arithmetic

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

1 Floating point arithmetic

Elements of Floating-point Arithmetic

Homework 2 Foundations of Computational Math 1 Fall 2018

MAT 460: Numerical Analysis I. James V. Lambers

1.1 COMPUTER REPRESENTATION OF NUM- BERS, REPRESENTATION ERRORS

An Introduction to Numerical Analysis

Elements of Floating-point Arithmetic

MATH ASSIGNMENT 03 SOLUTIONS

ESO 208A: Computational Methods in Engineering. Saumyen Guha

ALU (3) - Division Algorithms

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

Introduction to Scientific Computing Languages

Chapter 4 Number Representations

Lecture 28 The Main Sources of Error

QUADRATIC PROGRAMMING?

Math 128A: Homework 2 Solutions

Chapter 1 Mathematical Preliminaries and Error Analysis

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

Math 471. Numerical methods Introduction

Fractions. Review R.7. Dr. Doug Ensley. January 7, Dr. Doug Ensley Review R.7

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

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

Math 411 Preliminaries

MTH303. Section 1.3: Error Analysis. R.Touma

Chapter 4 No. 4.0 Answer True or False to the following. Give reasons for your answers.

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

Lecture 12 (Tue, Mar 5) Gaussian elimination and LU factorization (II)

Intermediate Algebra

Numerical Linear Algebra Notes

2 Systems of Linear Equations

14.2 QR Factorization with Column Pivoting

Round-off Errors and Computer Arithmetic - (1.2)

Numerical Analysis and Computing

INTRODUCTION TO COMPUTATIONAL MATHEMATICS

CHAPTER 11. A Revision. 1. The Computers and Numbers therein

11 Adjoint and Self-adjoint Matrices

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

1 Finding and fixing floating point problems

What Every Programmer Should Know About Floating-Point Arithmetic DRAFT. Last updated: November 3, Abstract

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

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

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

ROUNDOFF ERRORS; BACKWARD STABILITY

4.2 Floating-Point Numbers

Chapter 1 Error Analysis

Ch 3.2: Direct proofs

How do computers represent numbers?

Exponents and Polynomials. (5) Page 459 #15 43 Second Column; Page 466 #6 30 Fourth Column

Binary Floating-Point Numbers

Math 348: Numerical Methods with application in finance and economics. Boualem Khouider University of Victoria

Unit 9 Study Sheet Rational Expressions and Types of Equations

Computation of dot products in finite fields with floating-point arithmetic

LU Factorization. Marco Chiarandini. DM559 Linear and Integer Programming. Department of Mathematics & Computer Science University of Southern Denmark

Remainders. We learned how to multiply and divide in elementary

Numerical Methods in Physics and Astrophysics

CH 59 SQUARE ROOTS. Every positive number has two square roots. Ch 59 Square Roots. Introduction

Essential Mathematics

John L. Lehet

Exam 2 Review Chapters 4-5

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

Chapter 3 Math Toolkit

Sherman-Morrison-Woodbury

Chapter 1: Preliminaries and Error Analysis

MA580: Numerical Analysis: I. Zhilin Li

NUMERICAL METHODS C. Carl Gustav Jacob Jacobi 10.1 GAUSSIAN ELIMINATION WITH PARTIAL PIVOTING

Chapter 5: Exponents and Polynomials

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 2

Numerical Methods - Preliminaries

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

Accurate and Efficient Matrix Computations with Totally Positive Generalized Vandermonde Matrices Using Schur Functions

Transcription:

Lecture Notes 7, Math/Comp 128, Math 250 Misha Kilmer Tufts University October 23, 2005

Floating Point Arithmetic We talked last time about how the computer represents floating point numbers. In a floating point number system, the numbers are not equidistant. x = ±0.d 1 d 2...d t ) β e where t is precision, β is the base, e is the exponent, d 1 d 2...d t is the mantissa. System can use chopping or rounding. 1

Chopping vs. Rounding A method of converting x R to fl(x) in F. Chopping: ignore all digits after tth digit Rounding: fl(x) rounds up if t + 1st digit is 1/2β and down otherwise. 2

Rounding Examples β = 10, x = 3.141596 t = 2, fl(x) =.31 10 1 t = 4, fl(x) =.3142 10 1 3

Errors The Absolute error between x and ˆx is x ˆx The Relative error is x ˆx x. Relative error makes more sense when working with floating point numbers. 4

Machine Precision fl(x) x x ɛ mach = {.5β 1 t rounding β 1 t chopping ] You should be able to prove this, using the definition of fl(x)! 5

This says that the difference between a real number and its closest floating point approximation is always smaller than ɛ mach in a relative sense! This also means the difference between 2 adjacent numbers in F is no more than 2ɛ mach. 6

Machine Precision IEEE Standards (rounding): single precision, β = 2, t = 24, ɛ mach 6 10 8, double precision, β = 2, t = 53, ɛ mach 1.1 10 16. 7

Machine Precision Roughly, ɛ mach is the smallest number such that when added to 1, the floating point equivalent is greater than 1. That is, fl(1 + ɛ mach ) > 1, but fl(1 + ɛ) where ɛ < ɛ mach is 1. Check this in Matlab. 8

Adding 2 numbers If x,y R, x + y gets computed as fl(x) fl(y). Similar for other arithmetic operations. 9

Adding/Subtracting Last time, we saw rounding/truncation error due to shifting of the exponent when adding or subtracting. Addition/subtraction with a guard digit Example: β = 10,t = 3 x =.101 10 2,y =.9941 10 1 10

Align exponents, keep 4th digit Add (incl. 4th digit) Put in normalized form 11

x =.101 0 10 2 y =.099 4 10 2 fl(x + y) =.16 10 1 12

Multiplication For x,y F, multiply mantissas together add exponents round/normalize 13

Example: β = 10,t = 2 x =.11 10 2,y =.31 10 1.11.31 = 0.0341; 2 + ( 1) = 1; 0.0341 10 1 ;.34 10 0 14

Division Example β = 10,t = 2 x =.11 10 2,y =.26 10 3 Find fl(x/y). round(.11/.26) =.42; 2 3 = 1;.42 10 1. 15

Significant Digits Roughly: How many digits in the number have meaning. x = (.d 1 d 2...d t ) β e, d 1 0. The most significant digits are the leftmost, the least significant are the rightmost. 16

Dfn: ˆx approximates x to s significant digits (in base 10) if s is the largest nonnegative integer such that x ˆx x < 5(10 s ) Example: x 1 = 1.31, ˆx = 1.30 agree to 2 significant digits Example: x 2 =.012, ˆx =.11 agree to 1 significant digit. 17

Cancellation vs. Rounding When you round, you lose the least significant digits. Cancellation occurs when you subtract 2 numbers of nearly equal magnitude - you loose the most significant digits. For β = 10,t = 2.54617.54601 =.00016 but fl(.54617) fl(.54601) =.0002, and the relative error is.25! 18

The rounding error was magnified following the subtraction. One should avoid subtracting numbers of nearly equal magnitude if possible. x > 0 e x = 1 x + x 2 /2! x 3 /3! +... But e x = 1/e x, and e x doesn t have any subtractions! 19

Backward Error and Accuracy Let f(x) represent a math problem for input x, f(x) represents the computed version. Algorithm produces accurate soln. f(x) f(x) / f(x) = O(ɛ mach ) 20

Algorithm is backward stable if for every x f(x) = f( x), for some x with x x x = O(ɛ mach ) Conditioning has to do with the nature of the mathematical problem. 21

Conditioning vs. Stability Backward stable algorithms produce accurate results on wellconditioned problems. Backward stable algorithms produce inaccurate answers for sensitive (ill-conditioned) problems, but the inaccuracy is proportional to the sensitivity. 22

Example: Back Substitution Let algorithm 17.1 be applied to the backsubstituion problem consisting of floating point numbers on a computer satisfying (13.7). Then (R + δr) x = b for some upper triangular δr with δr / R = O(ɛ mach ) 23

Examples: Least Squares Theorem 19.3 The solution of the full-rank least squares problem (11.2) via normal equations (Alg. 11.1) is unstable. Theorem 19.4 The solution of the full-rank least squares problem (11.2) by the SVD (alg 11.3) is backward stable. 24

Backward Stable Algorithms We concentrate on designing backward stable algorithms! 25