Errors and Error Analysis Lecture 2

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.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Numerical Computation
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Approximations and Errors
NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers
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.
NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
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.
Introduction and Analysis of Error Pertemuan 1
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Chapter 1 Infinite Series, Power Series
Lecture 2 Number Representation and accuracy
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
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:
Introduction to Numerical Analysis I
Round-off Errors.
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.
NUMERICAL ERROR Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Elliptic PDEs and the Finite Difference Method
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
Introduction to computing
Numerical Analysis CC413 Propagation of Errors.
Numerical Analysis. Numerical Analysis or Scientific Computing Concerned with design and analysis of algorithms for solving mathematical problems that.
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.
Numerical Methods and Optimization C o u r s e 1 By Bharat R Chaudhari.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
Introduction to Numerical Analysis I
Machine arithmetic and associated errors Introduction to error analysis Class II.
EEE 431 Computational Methods in Electrodynamics
ME 142 Engineering Computation I
Floating-Point and High-Level Languages
Machine arithmetic and associated errors Introduction to error analysis (cont.) Class III.
Numerical Differentiation
Chapter 6 Floating Point
Taylor series in numerical computations (review)
Chapter 2 ERROR ANALYSIS
Recall our hypothetical computer Marc-32
Errors in Numerical Methods
Class Notes 18: Numerical Methods (1/2)
Roundoff and Truncation Errors
Numerical Solutions of Ordinary Differential Equations
Errors in Numerical Methods
Solution of Equations by Iteration
Computers in Civil Engineering 53:081 Spring 2003
Approximations and Round-Off Errors Chapter 3
SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2, 27-1 CISE301_Topic8L2.
Numerical Analysis Lecture 2.
Mathematical Preliminaries
SKTN 2393 Numerical Methods for Nuclear Engineers
Chapter 1 / Error in Numerical Method
Roundoff and Truncation Errors
ESO 208A: Computational Methods in Engineering
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Pivoting, Perturbation Analysis, Scaling and Equilibration
Presentation transcript:

Errors and Error Analysis Lecture 2

Define Error: True Value (a) = Approximate Value 𝑎 + Error (ε) Absolute Error: ε= 𝑎− 𝑎 Relative Error: 𝑒= 𝜀 𝑎 = 𝑎− 𝑎 𝑎 Relative error is often expressed as (%) by multiplying (e) with 100. Absolute error can have sign as well as | . | If the error is computed with respect to the true value (if known), a prefix ‘True’ is added. For an iterative process, the true value ‘a’ is replaced with the previous iteration value and a prefix ‘approximate’ is added. This is used for testing convergence of the iterative process.

Sources of Error in computation? Errors in the Input data: initial and boundary conditions, measured values of the parameters and constants in the model Round-off error: irrational numbers, product and division of two numbers, limited by the machine capability Truncation error: truncation of an infinite series, often arises in the design of the numerical method through approximation of the mathematical problem.

Summary Typically, true error is never known Significant digits/figures are the numbers that one can use with confidence Example: d = 100 ± 1 m, t = 3.0 ± 0.1 s, v = d/t = ? True error = True value – Measured/Computed value approximate error error bound Typically, true error is never known

Summary Types of error Model error Data error: y =𝑓(𝑥) Truncation error: error committed when a limiting process is truncated before one has reached the limiting value e.g. 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 ~ lim 𝑛→∞ 𝑖=1 𝑛 𝑓( 𝑥 𝑖 )Δ 𝑥 𝑖 Taylor series expansion of a function Round-off error because of finite nature of computer storage capacity

Error Analyses: Forward Error Analysis: Backward Error Analysis: How an error in the given input propagates through the system model. (Robustness of the model) Backward Error Analysis: Quantification of error resulting from interaction between round-off error and truncation error in the algorithm. (Robustness of the algorithm) Error in the Input Error in the Output Both computations are using the original Mathematical Model Error in the Output Computation using numerical algorithm Computation using mathematical problem

Forward Error Analysis: Single Variable Function: y = f(x) Forward Error Analysis: Single Variable Function: y = f(x). If an error is introduced in x, what is the error in y? ∆𝑥=𝑥− 𝑥 ∆𝑦=𝑦− 𝑦 =𝑓 𝑥 −𝑓 𝑥 𝑓 𝑥 =𝑓 𝑥 +∆𝑥 =𝑓 𝑥 +∆𝑥 𝑓 ′ 𝑥 + ∆𝑥 2 2! 𝑓 ′′ 𝑥 +.. Assuming the error to be small, the 2nd and higher order terms are neglected. (a first order approximation!) ∆𝑦=𝑓 𝑥 −𝑓 𝑥 ≈∆𝑥 𝑓 ′ 𝑥

Propagation of Errors: For any x, and a corresponding y = f(x) e. g Propagation of Errors: For any x, and a corresponding y = f(x) e.g., 𝑥=1.5 ±0.05 and y =3.4 ±0.04 (x + y)max = 1.55 + 3.44 = 4.99 (x + y)min = 1.45 + 3.36 = 4.81 Thus, 4.81 ≤ (x + y) ≤ 4.99 𝑂𝑡ℎ𝑒𝑟 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛𝑠 𝑚𝑎𝑦 𝑎𝑙𝑠𝑜 ℎ𝑎𝑣𝑒 𝑒𝑟𝑟𝑜𝑟 𝑝𝑟𝑜𝑝𝑎𝑔𝑎𝑡𝑖𝑜𝑛 𝑠𝑢𝑐ℎ 𝑎𝑠 𝑥𝑦; 𝑥 𝑦 ; or a function of n variables f(x1, x2, …, xn) ∆ 𝑓 x1, x2, …, xn = 𝜕𝑓 𝜕 𝑥 1 ∆ 𝑥 1 + 𝜕𝑓 𝜕 𝑥 2 ∆ 𝑥 2 +…

Condition Number of the Problem (Cp): 𝐶 𝑝 = 𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝐸𝑟𝑟𝑜𝑟 𝑖𝑛 𝑦 𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝐸𝑟𝑟𝑜𝑟 𝑖𝑛 𝑥 = ∆𝑦 𝑦 ∆𝑥 𝑥 ≈ ∆𝑥 𝑓 ′ 𝑥 𝑓 𝑥 ∆𝑥 𝑥 = 𝑥𝑓 ′ 𝑥 𝑓 𝑥 Also: 𝐶 𝑝 = ∆𝑦 𝑦 ∆𝑥 𝑥 = 𝑓 𝑥 −𝑓 𝑥 𝑓 𝑥 ∆𝑥 𝑥 = 𝑥 𝑓 𝑥 𝑓 𝑥 +∆𝑥 −𝑓 𝑥 ∆𝑥 As Δx → 0, 𝐶 𝑝 = 𝑥𝑓 ′ 𝑥 𝑓 𝑥 Cp < 1: problem is well-conditioned, error is attenuated Cp > 1: problem is ill-conditioned, error is amplified Cp = 1: neutral, error is translated

Examples of Forward Error Analysis and Cp: Problem 1: 𝑦= 𝑒 𝑥 ; ∆𝑦=∆𝑥 𝑒 𝑥 ; 𝐶 𝑝 = ∆𝑦 𝑦 ∆𝑥 𝑥 =𝑥. The problem is well-conditioned for 0 ≤ | x | < 1; neutral at | x | = 1 and ill- conditioned for | x | > 1. Problem 2: Solve the following system of equations: x + αy = 1; αx + y = 0 Solving: 𝑥= 1 1− 𝛼 2 =𝑥 𝛼 ; 𝑥 ′ 𝛼 = 2𝛼 1− 𝛼 2 2 𝐶 𝑝 = 𝛼 𝑥 ′ 𝛼 𝑥 = 𝛼 2𝛼 1− 𝛼 2 2 1 1− 𝛼 2 = 2 𝛼 2 1− 𝛼 2 well-conditioned for │α│<< 1 and ill-conditioned for α ≈ 1.

Forward Error Analysis: Function of Multiple Variables: y = f(X), where X is a vector, X = {x0, x1, ….. xn}. If error is introduced in the xi’s, what is the error in y? ∆𝑋=𝑋− 𝑋 = 𝑥 0 − 𝑥 0 𝑥 1 − 𝑥 1 ⋮ 𝑥 𝑛 − 𝑥 𝑛 = ∆ 𝑥 0 ∆ 𝑥 1 ⋮ ∆ 𝑥 𝑛 𝑓 𝑋 =𝑓 𝑋 + 𝑖=1 𝑛 ∆ 𝑥 𝑖 𝜕𝑓 𝜕 𝑥 𝑖 𝑋 +𝐻𝑂𝑇 ∆𝑦=𝑦− 𝑦 =𝑓 𝑋 −𝑓 𝑋 ≈ 𝑖=1 𝑛 ∆ 𝑥 𝑖 𝜕𝑓 𝜕 𝑥 𝑖 𝑋 An upper bound of ∆𝑦= 𝑖=1 𝑛 ∆ 𝑥 𝑖 𝜕𝑓 𝜕 𝑥 𝑖 𝑋

Backward Error Analysis: What is the perturbation required in the input in order to explain the error in the output if the computation is carried out by true mathematical function without any error? Error in the Output Computation using numerical algorithm Computation using mathematical problem Hypothetical error in the Input computed using backward error analysis Error in the Output Both computations are using the original Mathematical Model

Floating point representation of a number = σ × m × bq σ contains the sign of a number (+1, -1) m = mantissa; 1/b ≤ m < 1 b = base; 2 for binary, 10 for decimal, 16 for hexadecimal 𝑞∈ℚ (set of rationals) If a machine (computer) rounds a number off to ‘t’ decimal places, for a positive number 𝑎 : 𝑎=𝑚× 10 𝑞 ; 𝑎 = 𝑚 × 10 𝑞 𝑚− 𝑚 ≤0.5× 10 −𝑡 Machine round-off unit (u) is the upper bound of the relative error in one round- off operation 𝑎− 𝑎 𝑎 ≤ 0.5× 10 −𝑡 × 10 𝑞 𝑚× 10 𝑞 ≤0.5× 10 1−𝑡 =𝑢 Condition Number of Algorithm (Ca): change necessary in the input data in order to explain the error in the final result expressed in terms of u. Upon dividing Ca by u, CN of problem can be made machine independent IEEE-754 code is used to store single and double-precision numbers in computers for base 2

fl(x × y) = x × y(1 + δ) ≤ x × y(1 + u) where | δ | ≤ u Consider one floating point operation fl(x op y). ‘op’ can be any of +, -, ×, /. By definition of u: 𝑓𝑙 𝑥 op 𝑦 − 𝑥 op 𝑦 𝑥 op 𝑦 ≤𝑢 Let’s consider the op as × : fl(x × y) = x × y(1 + δ) ≤ x × y(1 + u) where | δ | ≤ u Example: A machine with t = 2, Machine round-off unit u = 0.5× 10 1−𝑡 (derived earlier) = 0.5 ×101-2 = 0.05 For x = 0.30 and y = 0.51, x × y = 0.153; fl (x × y) = 0.15 Relative error = |(0.15-0.153)/0.153| = 0.02 ≤ u (= 0.05) For this operation: δ = -0.01; | δ | = 0.01 ≤ u (= 0.05)

Multiple Floating Point Operations: 𝑓𝑙 𝑥 1 × 𝑥 2 × 𝑥 3 ×…× 𝑥 𝑛 = 𝑥 1 × 𝑥 2 1+ 𝛿 1 × 𝑥 3 1+ 𝛿 2 ×… 𝑥 𝑛 1+ 𝛿 𝑛−1 𝛿 𝑖 ≤𝑢 𝑓𝑜𝑟 𝑖=1, 2, … 𝑛−1 Relative error in the final computed value: 𝑒= 𝑓𝑙 𝑥 1 × 𝑥 2 × 𝑥 3 ×…× 𝑥 𝑛 − 𝑥 1 × 𝑥 2 × 𝑥 3 ×…× 𝑥 𝑛 𝑥 1 × 𝑥 2 × 𝑥 3 ×…× 𝑥 𝑛 = 1+ 𝛿 1 1+ 𝛿 2 … 1+ 𝛿 𝑛−1 −1 ≤ 1+𝑢 𝑛−1 −1 The quantity 1+𝑢 𝑛−1 −1 may be approximated as 1.06(n-1)u for (n-1)u < 0.1 using binomial expansion (Try!)

Compute 𝑦= 1+ sin 𝑥 −1 for x = 1° Example: Using a machine with 4-decimal place precision, t = 4, u = 0.5 ×101-4 = 0.5 ×10-3 Compute 𝑦= 1+ sin 𝑥 −1 for x = 1° 𝑓𝑙 𝑥 = 𝜋 180 =0.1745× 10 −1 𝑓𝑙 sin 𝑥 =0.1745× 10 −1 𝑓𝑙 1+sin 𝑥 =0.1017× 10 1 𝑓𝑙 1+ sin 𝑥 =0.1008× 10 1 𝑓𝑙 1+ sin 𝑥 −1 =0.8000× 10 −2 True value of y using infinite precision is 0.8688×10-2 Solve the remaining problem to find the condition number of the algorithm