Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.

Slides:



Advertisements
Similar presentations
Part 1 Chapter 4 Roundoff and Truncation Errors PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Advertisements

3- 1 Chapter 3 Introduction to Numerical Methods Second-order polynomial equation: analytical solution (closed-form solution): For many types of problems,
Roundoff and truncation errors
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Overview CNS 3320 – Numerical Software Engineering.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Introduction to Scientific Computing ICE / ICE 508 Prof. Hyuckjae Lee KAIST- ICC
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Fall 2006AE6382 Design Computing1 Numeric Representation in a Computer Learning Objectives Understand how numbers are stored in a computer and how the.
Approximations and Errors
Round-Off and Truncation Errors
Lecture 2: Numerical Differentiation. Derivative as a gradient
Computer-Aided Analysis on Energy and Thermofluid Sciences Y.C. Shih Fall 2011 Chapter 6: Basics of Finite Difference Chapter 6 Basics of Finite Difference.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
2 Systems Architecture, Fifth Edition Chapter Goals Describe numbering systems and their use in data representation Compare and contrast various data.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Chapter 1 Scientific Computing Approximation in Scientific Computing (1.2) January 12, 2010.
MMJ 1113 Computational Methods for Engineers Mohsin Mohd Sies Fakulti Kejuruteraan Mekanikal, Universiti Teknologi Malaysia.
Lecture 2 Number Representation and accuracy
MATH 685/CSI 700 Lecture Notes Lecture 1. Intro to Scientific Computing.
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
College of Engineering Representing Numbers in a Computer Section B, Spring 2003 COE1361: Computing for Engineers COE1361: Computing for Engineers 1 COE1361:
Numeric Processing Chapter 6, Exploring the Digital Domain.
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
ME 142 Engineering Computation I Computer Precision & Round-Off Error.
Round-off Errors.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University 1 Chapter 1 Mathematical.
Lecture 1 - Introduction June 3, 2002 CVEN 302. Lecture’s Goals General Introduction to CVEN Computer Applications in Engineering and Construction.
Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter.
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
Problems with Floating-Point Representations Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Sensitivity derivatives Can obtain sensitivity derivatives of structural response at several levels Finite difference sensitivity (section 7.1) Analytical.
Meeting 15 Introduction to Numerical Methods Error Analysis.
1 Approximation. 2 Taylor Series 3 Truncation Error  In general, the nth order Taylor series expansion will be exact for an nth order polynomial  In.
Numerical Analysis CC413 Propagation of Errors.
Ch13-1 Chap 13 Introduction to Matlab 13.1 Introduction MATLAB : The MATrix LABoratory program Not only is the MATLAB programming language exceptionally.
Errors in Numerical Methods
Spring 2006CISC101 - Prof. McLeod1 Announcements Assn 4 is posted. Note that due date is the 12 th (Monday) at 7pm. (Last assignment!) Final Exam on June.
ESO 208A/ESO 218 LECTURE 2 JULY 31, ERRORS MODELING OUTPUTS QUANTIFICATION TRUE VALUE APPROXIMATE VALUE.
Introduction to error analysis Class II "The purpose of computing is insight, not numbers", R. H. Hamming.
Module 2.2 Errors 03/08/2011. Sources of errors Data errors Modeling Implementation errors Absolute and relative errors Round off errors Overflow and.
1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Chapter 2 Errors in Numerical Methods and Their Impacts.
Machine arithmetic and associated errors Introduction to error analysis Class II.
Chapter 3 Data Representation
Today Variable declaration Mathematical Operators Input and Output Lab
ME 142 Engineering Computation I
Other Kinds of Arrays Chapter 11
Taylor series in numerical computations (review)
Chapter 2 ERROR ANALYSIS
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Errors in Numerical Methods
Class Notes 18: Numerical Methods (1/2)
Roundoff and Truncation Errors
Computers & Programming Languages
Errors in Numerical Methods
Approximations and Round-Off Errors Chapter 3
Numerical Analysis Lecture 2.
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Chapter 1 / Error in Numerical Method
Roundoff and Truncation Errors
Errors and Error Analysis Lecture 2
Presentation transcript:

Lecture 4 - Numerical Errors CVEN 302 June 10, 2002

Lecture’s Goals Understanding Computer Errors Uncertainty in Data and Input Well-defined problem Numerical Errors –Round-off Error –Truncation Error

Unavoidable Errors in Computing Hardware problems: Example: Pentium TM Chip Documentation is critical for any code that is not going to be used and immediately discarded. Documentation takes the form of comment statements that describe the input and output parameters of a function as well as the steps performed in the analysis.

Unavoidable Errors in Computing Some software bugs are caused by deterministic errors in the execution of the problem. Example: Problems in the built-in functions such as sine or cosine and a series of operational commands.

Matlab Numerical Problems example >format long e > ans = e+000 >ans ans = e+000 >ans ans = e+000 ^ Note The program has changed the value of ‘ans’

Matlab Numerical Problems Example Same method but different results. >format long e > ans = e+000 >ans ans = e+000 >ans ans = e+000 >ans ans = 5

Unavoidable Errors in Computing Numerical Errors are based on the mathematics of the problem. –Round-off Errors –Truncation Errors

Numerical Errors Round-off errors occur in computer calculation whenever digits to the right of the decimal are discarded.

Numerical Errors Example: > b = 1/3 > b = > b*3 - 1 = 0 or > b =4/3 - 1 > b = ???? > b*3 - 1 = e-16 ????

Numerical Errors Truncation error is introduced whenever a number computational uses a formula involving discrete values.

Numerical Errors Example: > x = tan(pi/6) > y = sin(pi/6)/cos(pi/6) where, ???? > x - y = e-16 ????

Computer Errors Why do you want to know about errors in computer programs? To recognize what is a good algorithm!

Digital Representation of Numbers Bits, Bytes and Words - the binary language of the computer programmer, and electrical engineer. –Bit is a single unit of information (0 or 1) –Byte is a combination of 8 bits –Word is 32, 64, or 128 bit pieces of information

Types of Variables Integer - two types a regular (16 bits) or a long (32 bits) Float - two types a single precision (32 bits) and double precision(64 bits) Complex - two single precision real numbers (64 bits)

Numerical Errors The type of variable determines the size of the under and overflow limits. –Underflow is the lowest value the computer can reach without major problems. –Overflow is the highest value the computer can reach without major problems. –Matlab commands to see the limits are: realmax or realmin

Example: Float Point The program: halfDif (x,y) Shows how the numbers converge by halving the difference and at what point does the delta term becomes insignificant.

Examples: Finite Precision Arithmetic An earlier example was the difference between a using 1/3 and 4/3 to show round-off errors. An example program (epprox) shows the convergence on the exponential term of 1. exp(1) = [ 1 + (1/n) ] n

Example: epprox The program has 2 round-off errors. The first error is a relatively minor one and second is catastrophic. The minor error is due to the inability to exactly represent 1/n with powers of 2. The major round-off error occurs due to round-off of (1 + 1/n) term at a high power.

Measuring Errors Absolute Error E abs = | x - x true | Relative Error E rel = | x - x true | / | x ref |

Convergence of Iterative Sequences Using the example problem we will look at four test cases for convergence for newtsqrt (program) Change: –NOT_CONVERGED change to r~=rold (comparison) –NOT_CONVERGED change to (r - rold)>  (error) –NOT_CONVERGED change to abs(r-rold)/rold >  abs (absolute error) –NOT_CONVERGED change to abs((r-rold)/rold)>  rel (relative error)

Testing example: newtsqrt.m The program newtsqrt has a driver ‘testSqrt’ program. The program will input data into the function and compare the results with the actual results.

Truncation Error in Algorithms Truncation error results from approximating continuous mathematical expressions with discrete algebraic formulas. Unlike round-off, which is controlled by the hardware and computer language being used, truncation error is under the control of the programmer.

Set of examples of truncation errors Sinser.m is a program for calculating sin(x) using a series expansion. expSeriesPlot shows the convergence of the absolute error for an exp() as a series expansion. demoTaylor shows a Taylor Series expansion for a simple equation with a variable delta step and different number of derivatives. fidiff is a finite difference program to test both round-off and truncation errors.

Sinser Example The program examines how the addition of more terms helps the sinusoid to converge. sin(x) =  (-1) k-1 (x 2k-1 /(2k-1)!)

expSeriesPlot The program shows how the solution converges on the true value of exp(x) as a series expansion. exp(x) = 1 +  ( x n / n!)

Taylor Series A series of Taylor series are used to represent the function at a location with each series containing an addition derivative. The function is:

demoTaylor The program looks at successive derivatives.

Round-off and Truncation with Finite Difference The program fidiff(x) is a simple finite difference program to calculate the first order derivative of an exponential function with variable stepsize.

Accuracy and Precision Accuracy - How closely a measured or computed value agrees with the true value Precision - How closely individual measured or computed values agree with each other More Accurate More Precise Precision is getting them close together. Accuracy is getting all your shots near the target.

Homework Modify demoTaylor program