Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.



Similar documents
CS321. Introduction to Numerical Methods

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Numerical Matrix Analysis

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

CHAPTER 5 Round-off errors

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Computer Science 281 Binary and Hexadecimal Review

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

CSI 333 Lecture 1 Number Systems

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

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

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

Principles of Scientific Computing. David Bindel and Jonathan Goodman

Numerical Analysis I

The string of digits in the binary number system represents the quantity

DNA Data and Program Representation. Alexandre David

This document has been written by Michaël Baudin from the Scilab Consortium. December 2010 The Scilab Consortium Digiteo. All rights reserved.

Number Representation

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Lecture 11: Number Systems

1.3 Algebraic Expressions

Useful Number Systems

What Every Computer Scientist Should Know About Floating-Point Arithmetic

Review of Scientific Notation and Significant Figures

Lecture 8: Binary Multiplication & Division

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Solution of Linear Systems

Zuse's Z3 Square Root Algorithm Talk given at Fall meeting of the Ohio Section of the MAA October College of Wooster

Addition Methods. Methods Jottings Expanded Compact Examples = 15

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

Figure 1. A typical Laboratory Thermometer graduated in C.

NUMBER SYSTEMS. William Stallings

Chapter 7D The Java Virtual Machine

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Precision & Performance: Floating Point and IEEE 754 Compliance for NVIDIA GPUs

Systems I: Computer Organization and Architecture

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Python for Scientific Computing.

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

FAST INVERSE SQUARE ROOT

Contrôle dynamique de méthodes d approximation

Data Storage 3.1. Foundations of Computer Science Cengage Learning

MTH 437/537 Introduction to Numerical Analysis I Fall 2015

EVALUATING ACADEMIC READINESS FOR APPRENTICESHIP TRAINING Revised For ACCESS TO APPRENTICESHIP

Answer Key for California State Standards: Algebra I

ADDITION. Children should extend the carrying method to numbers with at least four digits.

A NEW REPRESENTATION OF THE RATIONAL NUMBERS FOR FAST EASY ARITHMETIC. E. C. R. HEHNER and R. N. S. HORSPOOL

Vocabulary Words and Definitions for Algebra

Chapter 1. Binary, octal and hexadecimal numbers

Number Systems and Radix Conversion

Linear Equations and Inequalities

Attention: This material is copyright Chris Hecker. All rights reserved.

Some Functions Computable with a Fused-mac

Floating point package user s guide By David Bishop (dbishop@vhdl.org)

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Chapter 5. Binary, octal and hexadecimal numbers

MATH 0110 Developmental Math Skills Review, 1 Credit, 3 hours lab

Continued Fractions and the Euclidean Algorithm

JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

26 Integers: Multiplication, Division, and Order

8 Square matrices continued: Determinants

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

Lecture 2. Binary and Hexadecimal Numbers

Numerical Analysis. Gordon K. Smyth in. Encyclopedia of Biostatistics (ISBN ) Edited by. Peter Armitage and Theodore Colton

RN-Codings: New Insights and Some Applications

Introduction to Xilinx System Generator Part II. Evan Everett and Michael Wu ELEC Spring 2013

MEP Y9 Practice Book A

FRACTIONS COMMON MISTAKES

YOU CAN COUNT ON NUMBER LINES

RN-coding of Numbers: New Insights and Some Applications

5.3 SOLVING TRIGONOMETRIC EQUATIONS. Copyright Cengage Learning. All rights reserved.

Mathematics. Mathematical Practices

Q-Format number representation. Lecture 5 Fixed Point vs Floating Point. How to store Q30 number to 16-bit memory? Q-format notation.

Lectures 5-6: Taylor Series

Solution for Homework 2

Free Pre-Algebra Lesson 55! page 1

Binary Numbering Systems

0.8 Rational Expressions and Equations

Math 115 Spring 2011 Written Homework 5 Solutions

THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0

A new binary floating-point division algorithm and its software implementation on the ST231 processor

Precalculus Orientation and FAQ

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Monday January 19th 2015 Title: "Transmathematics - a survey of recent results on division by zero" Facilitator: TheNumberNullity / James Anderson, UK

THE BINARY NUMBER SYSTEM

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Operation Count; Numerical Linear Algebra

Sequence of Mathematics Courses

Transcription:

ERRORS and COMPUTER ARITHMETIC Types of Error in Numerical Calculations Initial Data Errors: from experiment, modeling, computer representation; problem dependent but need to know at beginning of calculation. Truncation Error: from stopping algorithm with infinite number of steps; algorithm dependent, but need to be aware of for algorithm design. Roundoff error: from finite representation of numbers in computer during arithmetic computations; need to be aware of for algorithm design and interpretation of results. Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x. 1

ERRORS and COMPUTER NUMBERS Computer Numbers, Roundoff Error Floating Point Number Representation: any real number y can be put in floating point form y = ±.d 1 d 2... d k... b ±n for base b, with 0 < d 1 < b, 0 d i < b, i > 1. E.g. (.1) 10 = +(.1100) 2 2 3. Conversion from decimal to binary? Integer part: repeatedly divide by 2, saving remainder digits d i. Fraction: repeatedly multiply by 2, saving remainder digits d i. E.g. (4.1) 10 = +(.1000001100) 2 2 3. E.g. (3.1) 10 = +(.110001100) 2 2 2. Computer numbers: computers use y fl(y) = ±.d 1d 2... d k b ±e 1e 2...e m where b, k, m are machine dependent, 0 e i < b. Digits d 1... d k are mantissa, e 1e 2... e m exponent. Note: real computer arithmetic uses only a finite subset of (, ). 2

COMPUTER NUMBERS CONTINUED IEEE Standard for b = 2 number representation: single precision (SP) with ±, (k, m) = (23, 8); double precision (DP) with ±, (k, m) = (52, 11); long double with ±, (k, m) = (64, 15). Normalized IEEE form: fl(y) = ±1.b 1 b 2... b k 2 p. E.g. for DP, 1 2 = +1.000... 000 2 0, with 52 zeros; next DP number is (51 zeros) (1 + 2 52 ) 2 = +1.000... 001 2 0. Special representations for ±0, ± and NAN (e.g. 0 0 ), using special values for p (= -1023 or 1024 for DP). Overflow occurs if p > largest +e 1 e 2... e m ; with DP p 1023, note 2 1023 9 10 307. Underflow occurs if p < smallest e 1 e 2... e m ; with DP p 1022, note 2 1022 2 10 308, but p = 1023 allows subnormal numbers 2 1074. 3

COMPUTER NUMBERS CONTINUED Machine Epsilon: macheps or unit roundoff or ɛ mach is the smallest number ɛ mach for which fl(1 + ɛ mach ) > 1. IEEE SP has ɛ mach = 2 23 10 7 ; IEEE DP has ɛ mach = 2 52 2 10 16 (MATLAB). Matlab Checks: format short g, disp([1+2^(-52) 1+2^(-53)]) 1 1 disp([1+2^(-52)-1 1+2^(-53)-1]) 2.2204e-16 0 disp(sprintf( %20.17f,[1+2^(-52) 1+2^(-53)])) 1.00000000000000022 1.00000000000000000 disp(sprintf( %20.17f,[1+2^(-52)-1 1+2^(-53)-1])) 0.00000000000000022 0.00000000000000000 4

COMPUTER NUMBERS CONTINUED Rounding: if y does not have exact f l(y) representation, we need a method for choosing last digit(s). E.g. SP fl(.1) = +1.1001100110011001100110? 2 4. chopping discards all b i, i > k, so that SP fl(.1) = +1.10011001100110011001100 2 4 ; DP fl(.1) = +1.100110011001... 10011001 2 4, DP fl(4.1) = +1.000001100110... 01100110 2 2, DP fl(3.1) = +1.100011001100... 11001100 2 1. rounding (to nearest) adds 1 to b k if b k+1 = 1; so SP fl(.1) = +1.10011001100110011001101 2 4. DP fl(.1) = +1.100110011001... 10011010 2 4, DP fl(4.1) = +1.000001100110... 01100110 2 2, DP fl(3.1) = +1.100011001100... 11001101 2 1. Special case: if b k+1 b k+2 b k+3... = 1 0..., then add 1 to b k if and only if b k = 1. Relative rounding error: rounding to nearest (IEEE, MATLAB)) ensures fl(y) y y 1 2 ɛ mach. 5

COMPUTER NUMBERS CONTINUED Computer Arithmetic : assume denotes computer implementation of +,, / or. Model for sequence of operations: for x y, computer a) takes stored values fl(x) and fl(y), b) accurately computes fl(x) fl(y), c) then rounds the result to get fl(fl(x) fl(y)). E.g. Rounded DP for 4.1 3.1: fl(4.1) = +1.000001100110... 01100110 2 2 fl(3.1) = 0.1100011001100... 11001101 2 2 = (2 2 2 53 ) 2 2 = 1 2 51 = +.1111... 1110 = +1.1111... 11100 2 1. Matlab Checks: format long g, disp(4.1-3.1) 1 disp(sprintf( %20.16g,4.1-3.1)) 0.9999999999999996 disp( (4.1-3.1)-1 ) -4.440892098500626e-16 disp( 4.1-(3.1+1) ) 0 Computer addition is only approximately associative. IEEE requires fl(x y) (x y) x y ɛ mach, for IEEE standard computer hardware. 6

LOSS of SIGNIFICANT DIGITS Significant Digits : x approximates x to t significant digits if t is the largest nonegative integer with x x x < 5 10 t. Subtractive Cancellation : when significant digits are lost during the subtraction of two = numbers. Examples in decimal: 123.4567-123.4566 4.01 2 with 3 digits: 4.01 2 2.0025 2 2 2 = 0; Algebraic rearrangment: if is often possible to use algebraically equivalent formulas to avoid LSD calculations. Examples: a) x 2 + bx + c = 0, has x = ( b ± b 2 4c)/2, with LSD for small c/b. 7

LSD EXAMPLES b) 1/(1 + x) 1/(1 x) for small x. c) (1 sec(x))/tan 2 (x) for small x. disp([x (1-sec(x))/tan(x)^2 -cos(x)/(1+cos(x))]) Matlab Check: for x = 10.^[-2:-2:-8] end 0.01-0.499987499790956-0.499987499791664 0.0001-0.499999993627931-0.49999999875 1e-06-0.500044450290837-0.499999999999875 1e-08 0-0.5 d) (e x 1)/x for small x (Taylor series sometimes helps). 8

NUMERICAL SOFTWARE Numerical algorithms in texbook and written for class will be short algorithms, designed to illustrate primary algorithm features and problems. Software Libraries: numerical methods described and analyzed in textbook and class have been placed in software libraries. Software libraries contain carefully documented software for algorithms carefully implemented as language dependent functions and procedures: e.g. CACM, NAG, IMSL, STATLIB, WWW, for standard computer languages, and environments: e.g. MATLAB, MAPLE, MATHEMATICA, R, GAUSS for interactive work; e.g. FORTRAN, C, C++, JAVA, PYTHON for high performance computation. 9