Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.

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

Roundoff and truncation errors
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Approximations and Errors
Round-Off and Truncation Errors
Assembly Language and Computer Architecture Using C++ and Java
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors.
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
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
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
Computer Science 210 Computer Organization Floating Point Representation.
Binary Representation and Computer Arithmetic
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Information Representation (Level ISA3) Floating point numbers.
Computer Science 111 Fundamentals of Programming I Number Systems.
IT253: Computer Organization
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Lecture 2 Number Representation and accuracy
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University.
ME 142 Engineering Computation I Computer Precision & Round-Off Error.
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
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Engineering Analysis – Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Meeting 15 Introduction to Numerical Methods Error Analysis.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Numerical Analysis CC413 Propagation of Errors.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Errors in Numerical Methods
14/02/ Floating Point Representation Major: All Engineering Majors Authors: Autar Kaw, Charlie Barker Presented.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
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.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
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.
Introduction to Numerical Analysis I
Machine arithmetic and associated errors Introduction to error analysis Class II.
ME 142 Engineering Computation I
Integer Division.
Floating Point Numbers: x 10-18
Floating Point Number system corresponding to the decimal notation
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
Chapter 6 Floating Point
Chapter 2 ERROR ANALYSIS
Errors in Numerical Methods
Roundoff and Truncation Errors
Number Representations
Floating Point Representation
Errors in Numerical Methods
Approximations and Round-Off Errors Chapter 3
COMS 361 Computer Organization
Chapter 1 / Error in Numerical Method
Roundoff and Truncation Errors
Number Representations
Errors and Error Analysis Lecture 2
Presentation transcript:

Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00

2 Lecture 6 Last time:  Internal representations of numbers and characters in a computer.  Arrays in Matlab  Matlab program for solving a quadratic equation Today:  Roundoff and truncation errors  More on Matlab Next Time  More on approximations.

3 Accuracy versus Precision Accuracy  how closely a computed or measured value agrees with the true value, Precision  how closely individual computed or measured values agree with each other. a) inaccurate and imprecise b) accurate and imprecise c) inaccurate and precise d) accurate and precise

4 Errors when we know the true value True error (E t )  the difference between the true value and the approximation. Absolute error (|E t |)  the absolute difference between the true value and the approximation. True fractional relative error  the true error divided by the true value. Relative error (  t )  the true fractional relative error expressed as a percentage. For iterative processes, the error can be approximated as the difference in values between successive iterations.

5 Stopping criterion Often, we are interested in whether the absolute value of the error is lower than a pre-specified tolerance  s. For such cases, the computation is repeated until |  a |<  s

6 Roundoff Errors Roundoff errors arise because  Digital computers have size and precision limits on their ability to represent numbers.  Some numerical manipulations are highly sensitive to roundoff errors.

7 Floating Point Representation By default, MATLAB has adopted the IEEE double-precision format in which eight bytes (64 bits) are used to represent floating-point numbers: n=±(1+f) x 2 e The sign is determined by a sign bit The mantissa f is determined by a 52-bit binary number The exponent e is determined by an 11-bit binary number, from which 1023 is subtracted to get e

8 Floating Point Ranges Values of and for e are reserved for special meanings, so the exponent range is to The largest possible number MATLAB can store has  f of all 1’s, giving a significand of , or approximately 2  e of , giving an exponent of =1023  This yields approximately = x The smallest possible number MATLAB can store with full precision has  f of all 0’s, giving a significand of 1  e of , giving an exponent of =-1022  This yields =2.2251x

9 Floating Point Precision The 52 bits for the mantissa f correspond to about 15 to 16 base-10 digits. The machine epsilon - the maximum relative error between a number and MATLAB’s representation of that number, is thus = x

10 Roundoff Errors in Arithmetic Operrations Roundoff error occur :  Large computations - if a process performs a large number of computations, roundoff errors may build up to become significant  Adding a Large and a Small Number - Since the small number’s mantissa is shifted to the right to be the same scale as the large number, digits are lost  Smearing - Smearing occurs whenever the individual terms in a summation are larger than the summation itself. (x )-x = mathematically, but x=1; (x+1e-20)-x gives a 0 in MATLAB!

11 Truncation Errors Truncation errors result from using an approximation in place of an exact mathematical procedure. Example 1: approximation to a derivative using a finite- difference equation: Example 2: The Taylor Series

12 The Taylor Series

13

14 Truncation Error In general, the nth order Taylor series expansion will be exact for an nth order polynomial. In other cases, the remainder term R n is of the order of h n+1, meaning:  The more terms are used, the smaller the error, and  The smaller the spacing, the smaller the error for a given number of terms.

Functions Function [out1, out2,...] = funname(in1, in2,...) function funname that  accepts inputs in1, in2, etc.  returns outputsout1, out2, etc.  Example: function [r1,r2,i1,i2] = quadroots(a,b,c) Before calling a function you need to  Use the edit window and create the function  Save the edit window in a.m file e.g., quadroots.m Example function [mean,stdev] = stat(x) n = length(x); mean = sum(x)/n; stdev = sqrt(sum((x-mean).^2/n)); 15

Subfunctions A function file can also contain a primary function and one or more subfunctions The primary function  is listed first in the M-file - its function name should be the same as the file name. Subfunctions  are listed below the primary function.  only accessible by the main function and subfunctions within the same M-file and not by the command window or any other functions or scripts.

Example of a subfunction function [mean,stdev] = stat(x) n = length(x); mean = avg(x,n); stdev = sqrt(sum((x-avg(x,n)).^2)/n); function mean = avg(x,n) mean = sum(x)/n; avg is a subfunction within the file stat.m: 17