MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 6.

Slides:



Advertisements
Similar presentations
Roundoff and truncation errors
Advertisements

2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 18 Sit in your groups.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Round-Off and Truncation Errors
1 CSE1301 Computer Programming Lecture 30: Real Number Representation.
Lecture 2: Numerical Differentiation. Derivative as a gradient
CSE1301 Computer Programming Lecture 33: Real Number Representation
Floating-Point and High-Level Languages Programming Languages Spring 2004.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
Floating Point Numbers
Floating Point Computation
FW364 Ecological Problem Solving Lab 4: Blue Whale Population Variation [Ramas Lab]
Information Representation (Level ISA3) Floating point numbers.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Lecture 2 Number Representation and accuracy
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
College of Engineering Representing Numbers in a Computer Section B, Spring 2003 COE1361: Computing for Engineers COE1361: Computing for Engineers 1 COE1361:
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
CSC 221 Computer Organization and Assembly Language
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Problems with Floating-Point Representations Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright.
IEEE Arithmetic UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
MA/CS 375 Fall 2002 Lecture Summary Week 1  Week 7.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 7.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 8.
Numerical Analysis CC413 Propagation of Errors.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Errors in Numerical Methods
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 23.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 5.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Floating Point. Binary Fractions.
Introduction to Numerical Analysis I
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Machine arithmetic and associated errors Introduction to error analysis Class II.
Backgrounder: Binary Math
Introduction To Computer Science
Floating-Point and High-Level Languages
Machine arithmetic and associated errors Introduction to error analysis (cont.) Class III.
MA/CS 375 Fall 2002 Lecture 9 MA/CS375 Fall 2002.
Chapter 6 Floating Point
Topic 3d Representation of Real Numbers
Chapter 2 ERROR ANALYSIS
Luddy Harrison CS433G Spring 2007
Chapter 2 Bits, Data Types & Operations Integer Representation
Roundoff and Truncation Errors
CSCI206 - Computer Organization & Programming
CSE Differentiation Roger Crawfis.
Floating Point Representation
Approximations and Round-Off Errors Chapter 3
CSE Differentiation Roger Crawfis.
Fundamentals of Data Representation
Storing Negative Integers
Starter Using the fingers on only one hand, what is the highest number you can count to? Rules: You must start at 1 You must count sequentially (i.e.
Topic 3d Representation of Real Numbers
Roundoff and Truncation Errors
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 6

MA/CS375 Fall Exercise: Blending Two Images Find one partner to work with (i.e. your neighbor) Write a script which reads in two images. Use the min function to find the minimum number of rows for both pictures (MINrows) Use the min function to find the minimum number of columns for both pictures (MINcolumns) Crop the images using > pic1 = pic1(1:MINrows,1:MINcols,1:3) > pic2 = pic2(1:MINrows,1:MINcols,1:3) Create a third picture (pic3) which is the average of pic1 and pic2 Plot pic1,pic2,pic3 in the same figure using subplot Put your names on the title, print it out and hand it in.

MA/CS375 Fall Finite Precision Effects Recall that we are computing in a finite precision computing paradigm. i.e. all non integer numbers are represented by a finite approximation. e.g. 1/2 is represented exactly, but 1/3 is not.

MA/CS375 Fall Non-Special IEEE Floating Point Double Precision A double precision (Matlab default) number is represented by a 64 bit binary number: Here s is the sign bit m is the mantissa (length to be determined) e is the exponent and 0 < e < 2047

MA/CS375 Fall A Convergent Binary Representation of Any Number Between 0 and 1 a similar representation in base 10: Volunteer ?

MA/CS375 Fall Finite Binary Approximations of a Real Number We can easily show that T N is bounded as: (think of Zeno’s paradox)

MA/CS375 Fall Definition of a Derivative Suppose we are given a function: – where f is smooth and well defined at every point on the real numbers. –we can define the derivative of f at a point x as: –later on today we will try to use this definition (and see what goes wrong ) Review

MA/CS375 Fall Monster Functions Due to some of these finite precision effects there are some odd behaviors of Matlab documented in: “Numerical Monsters”, Christopher Essex, Matt Davison and Christian Schulzky.

MA/CS375 Fall Team Tasks We are going to investigate several examples from: “Numerical Monsters”, Christopher Essex, Matt Davison and Christian Schulzky. A.K.A “When Good Formulas Go Bad in Matlab”

MA/CS375 Fall Teams Form teams of four Choose one of the following monster exercises Remember to put your names in the titles

MA/CS375 Fall Monster #1 Consider: What should its behavior be as: Use subplots for the following 2 plots Plot this function at 1000 points in: Label everything nicely, include your name in the title. In a text box explain what is going on, print it out and hand it in

MA/CS375 Fall Monster #2 Consider: What should its behavior be as: Plot this function at 1000 points in: Explain what is going on in a text box, label everything, print it out and hand it in.

MA/CS375 Fall Consider: What should its behavior be as: Plot this function at 1000 points in: Explain what is going on in a text box and in particular what happens at x=54, label everything, print it out and hand it in. Monster #3

MA/CS375 Fall Consider: What should its behavior be as: Plot four subplots of the function at 1000 points in: for Now fix x=0.5 and plot this as a function of for Explain what is going on, print out and hand in. Monster #4

MA/CS375 Fall Explanations of Team Examples

MA/CS375 Fall Consider: What should its behavior be as: Plot this function at 1000 points in: Explain what is going on. Recall Monster #1

MA/CS375 Fall Monster #1 ((large+small)-large)/small

MA/CS375 Fall when we zoom in we see that the large+small operation is introducing order eps errors which we then divide with eps to get O(1) errors !. Monster #1 ((large+small)-large)/small

MA/CS375 Fall when we zoom in we see that the large+small operation is introducing order eps errors which we then divide with eps to get O(1) errors !. Each stripe is a region where 1+ x is a constant ( think about the gaps between numbers in finite precision ) Then we divide by x and the stripes look like hyperbola. The formula looks like (c-1)/x with a new c for each stripe. Monster #1 ((large+small)-large)/small

MA/CS375 Fall Recall Monster #2 Consider: What should its behavior be as: Plot this function at 1000 points in: Explain what is going on in a text box, label everything, print it out and hand it in.

MA/CS375 Fall Limit of

MA/CS375 Fall Monster #2 (finite precision effects from large*small) As x increases past 30 we see that f deviates from 1 !!

MA/CS375 Fall As x increases past ~=36 we see that f drops to 0 !! Monster #2 cont (finite precision effects from large*small)

MA/CS375 Fall Consider: What should its behavior be as: Plot this function at 1000 points in: Explain what is going on. What happens at x=54? Recall Monster #3

MA/CS375 Fall Monster 3 (finite precision large*small with binary stripes)

MA/CS375 Fall As we require more than 52 bits to represent 1+2^(-x) we see that the log term drops to 0. Monster 3 (finite precision large*small with binary stripes)

MA/CS375 Fall Consider: What should its behavior be as: Plot four subplots of the function at 1000 points in: for Now fix x=0.5 and plot this as a function of for Explain what is going on, print out and hand in. Recall Monster #4

MA/CS375 Fall Monster 4 cont Behavior as delta  0 : or if you are feeling lazy use the definition of derivative, and remember: d(sin(x))/dx = cos(x)

MA/CS375 Fall Monster 4 cont ( parameter differentiation, delta=1e-4) OK

MA/CS375 Fall Monster 4 cont ( parameter differentiation, delta=1e-7) OK

MA/CS375 Fall Monster 4 cont ( parameter differentiation, delta=1e-12) Worse

MA/CS375 Fall Monster 4 cont ( parameter differentiation, delta=1e-15) When we make the delta around about machine precision we see O(1) errors !. Bad

MA/CS375 Fall Monster 4 cont ( numerical instablitiy of parameter differentiation) As delta gets smaller we see that the approximation improves, until delta ~= 1e-8 when it gets worse and eventually the approximate derivate becomes zero.

MA/CS375 Fall Approximate Explanation of Monster #4 1) Taylor’s thm: 2) Round off errors 3) Round off in computation of f and x+delta 4) Put this together:

MA/CS375 Fall i.e. for or equivalently approximation error decreases as delta decreasesize. BUT for round off dominates!.

MA/CS375 Fall Summary Ok – so in the far limits of the range of finite precision really dodgy things happen. But recall, the formula for the derivative of sine worked pretty well for a large range of numbers. Try to avoid working with two widely separated numbers.

MA/CS375 Fall Summary of Lecture 6 Today’s lecture was all about the way Matlab (and in fact almost all languages) store representations of real numbers We found out: – because the set of possible double precision numbers only covers a discrete subset of points on the real line there are finite gaps between consecutive numbers –If A is “large” and B is very “small” the sum A+B actually results in A+B ~= A –and so on..