ESO 208A: Computational Methods in Engineering. Saumyen Guha

Similar documents
Numerical Methods FOR ENGINEERING AND SCIENCE SAUMYEN GUHA. Professor Department of Civil Engineering IIT Kanpur RAJESH SRIVASTAVA

Notes on floating point number, numerical computations and pitfalls

Errors. Intensive Computation. Annalisa Massini 2017/2018

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Floating Point Number Systems. Simon Fraser University Surrey Campus MACM 316 Spring 2005 Instructor: Ha Le

Lecture 7. Floating point arithmetic and stability

Notes for Chapter 1 of. Scientific Computing with Case Studies

Floating-point Computation

Arithmetic and Error. How does error arise? How does error arise? Notes for Part 1 of CMSC 460

Today s class. Numerical differentiation Roots of equation Bracketing methods. Numerical Methods, Fall 2011 Lecture 4. Prof. Jinbo Bi CSE, UConn

Chapter 1: Introduction and mathematical preliminaries

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

1 ERROR ANALYSIS IN COMPUTATION

Chapter 1 Mathematical Preliminaries and Error Analysis

Numerical Algorithms. IE 496 Lecture 20

Introduction and mathematical preliminaries

Lecture Notes 7, Math/Comp 128, Math 250

Tu: 9/3/13 Math 471, Fall 2013, Section 001 Lecture 1

ACM 106a: Lecture 1 Agenda

Chapter 1 Error Analysis

An Introduction to Differential Algebra

Chapter 1 Computer Arithmetic

ECS 231 Computer Arithmetic 1 / 27

INTRODUCTION TO COMPUTATIONAL MATHEMATICS

MATH ASSIGNMENT 03 SOLUTIONS

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination December, 2015 BCS-054 : COMPUTER ORIENTED NUMERICAL TECHNIQUES

Elements of Floating-point Arithmetic

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

FLOATING POINT ARITHMETHIC - ERROR ANALYSIS

Numerical Methods - Lecture 2. Numerical Methods. Lecture 2. Analysis of errors in numerical methods

Elements of Floating-point Arithmetic

Chapter 4 Number Representations

Mathematical preliminaries and error analysis

Numerical Methods - Preliminaries

Homework 2 Foundations of Computational Math 1 Fall 2018

2.2. Methods for Obtaining FD Expressions. There are several methods, and we will look at a few:

Mathematics for Engineers. Numerical mathematics

Introductory Numerical Analysis

Theme 1: Solving Nonlinear Equations

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 5. Ax = b.

MATHia Unit MATHia Workspace Overview TEKS

1 Backward and Forward Error

Lies My Calculator and Computer Told Me

Compute the behavior of reality even if it is impossible to observe the processes (for example a black hole in astrophysics).

Introduction CSE 541

MAT 460: Numerical Analysis I. James V. Lambers

NUMERICAL METHODS C. Carl Gustav Jacob Jacobi 10.1 GAUSSIAN ELIMINATION WITH PARTIAL PIVOTING

1.5 First Order PDEs and Method of Characteristics

CHAPTER 3. Iterative Methods

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations

Number Systems III MA1S1. Tristan McLoughlin. December 4, 2013

AIMS Exercise Set # 1

TABLE OF CONTENTS INTRODUCTION, APPROXIMATION & ERRORS 1. Chapter Introduction to numerical methods 1 Multiple-choice test 7 Problem set 9

Example 1 Which of these functions are polynomials in x? In the case(s) where f is a polynomial,

NUMERICAL SOLUTION OF ODE IVPs. Overview

Errors Intensive Computation

Math 471. Numerical methods Introduction

Round-off error propagation and non-determinism in parallel applications

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

1.1 COMPUTER REPRESENTATION OF NUM- BERS, REPRESENTATION ERRORS

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

Midterm Review. Igor Yanovsky (Math 151A TA)

4.1 Exponential Functions

Introduction to Scientific Computing Languages

Binary floating point

Introduction to Initial Value Problems

Numbers. Dr Hammadi Nait-Charif. Senior Lecturer Bournemouth University United Kingdom

CHAPTER 1 REAL NUMBERS KEY POINTS

Mathematics Pacing. Instruction: 9/7/17 10/31/17 Assessment: 11/1/17 11/8/17. # STUDENT LEARNING OBJECTIVES NJSLS Resources

Chapter 1 Mathematical Preliminaries and Error Analysis

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Analysis of Finite Wordlength Effects

Applied Mathematics 205. Unit 0: Overview of Scientific Computing. Lecturer: Dr. David Knezevic

Seunghee Ye Ma 8: Week 2 Oct 6

Introduction to Finite Di erence Methods

1 Floating point arithmetic

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

An Introduction to Numerical Analysis. James Brannick. The Pennsylvania State University

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

CSE 1400 Applied Discrete Mathematics Definitions

Fall 2014 MAT 375 Numerical Methods. Numerical Differentiation (Chapter 9)

Round-off Errors and Computer Arithmetic - (1.2)

WE SAY THAT A SQUARE ROOT RADICAL is simplified, or in its simplest form, when the radicand has no square factors.

How do computers represent numbers?

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers

Numerical Differentiation & Integration. Numerical Differentiation III

Applications of Mathematics MA 794

AMS 147 Computational Methods and Applications Lecture 17 Copyright by Hongyun Wang, UCSC

Chapter 4 No. 4.0 Answer True or False to the following. Give reasons for your answers.

Scientific Computing: An Introductory Survey

Numerical Methods in Physics and Astrophysics

Numerical Analysis. Yutian LI. 2018/19 Term 1 CUHKSZ. Yutian LI (CUHKSZ) Numerical Analysis 2018/19 1 / 41

Chapter 1. Numerical Errors. Module No. 1. Errors in Numerical Computations

Day 6: 6.4 Solving Polynomial Equations Warm Up: Factor. 1. x 2-2x x 2-9x x 2 + 6x + 5

Introduction to Numerical Analysis

Math 128A Spring 2003 Week 12 Solutions

q t = F q x. (1) is a flux of q due to diffusion. Although very complex parameterizations for F q

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1

Transcription:

ESO 208A: Computational Methods in Engineering Introduction, Error Analysis Saumyen Guha Department of Civil Engineering IIT Kanpur

What is Computational Methods or Numerical Methods in Engineering? Formulation of mathematical problems in such a way that numerical answers can be computed using arithmetic operations in a computer Computer can only perform: + - / All kinds of problems can be solved: linear and non-linear systems of equations; approximation and interpolation of data; differentiation and integration, ODE, PDE

What is Numerical Analysis? Mathematical method to analyze whether the solution obtained from a Numerical Method represents the solution of the original mathematical problem! A way to test for convergence! Convergence can be conditional or unconditional! A method cannot be used for a given problem without the analysis!

Example 1: Calculate the square root of 2. Mathematical Problem: x 2 = 2, x =? or Calculate the root of x 2 2 = 0 Square root of 2 (an irrational number) cannot be computed using simple arithmetic operations! Generate a Cauchy sequence that converges to the square root of 2. Some Numerical Methods: x n+1 = 2 x n x n+1 = 1 x 2 n + 2 x n x n+1 = x n+2 x n +1

Let s start all the methods with x 0 = 1 and compute for five iterations: x n+1 = 2 x n : x 1 = 2, x 2 = 1, x 3 = 2, x 4 = 1, x 5 = 2 x n+1 = 1 2 x n + 2 x n : x 1 = 1.5, x 2 = 1.416667, x 3 = 1.414216, x 4 = 1.414214, x 5 = 1.414214 x n+1 = x n+2 x n +1 : x 1 = 1.5, x 2 = 1.4, x 3 = 1.416667, x 4 = 1.413793, x 5 = 1.414286 Could we have predicted this without having to perform computations?

Test for convergence of sequence (MTH 101): Sequence: x n+1 = 1 2 x n + 2 x n 2 + 2 = 2x n x n+1 x n Since the root is real, x n 2 2 0 Therefore, x n 2 + 2 = 2x n x n+1 2 2x n x n+1 2, the sequence is bounded! for n 2, x n x n+1 = x n 1 2 x n + 2 1 2 x n 2 2 x n x n = 0, monotonically decreasing sequence! Monotonically decreasing sequence and bounded:- a Cauchy sequence that converges to the lower bound 2

Example 2: Solve the problem of the radioactive decay: dn dt = λn at t = 0, N = N 0 True Solution: N = N 0 e λt A Numerical Method: Euler Method (MTH 102) N i+1 = N i λhn i where, h = time step Δt Consider two different elements with λ = 0.1 and 2.2 Let us compare true analytical solutions with the numerical solutions for h = Δt = 1 for these two elements.

λ = 0.1 /day, N 0 = 10 6, h = Δt = 1, solution for 25 days There is some error but the numerical solution behaves like the true solution

λ = 2.2 /day, N 0 = 10 6, h = Δt = 1, solution for 25 days The error can grow to make the solution unacceptable! Numerical analysis could have told me this saving much time of programming and computation!

λ = 0.1 /day, N 0 = 10 6, varying h, solution for 25 days Numerical analysis could have told me this saving much time of programming and computation!

Take away message: Learning Numerical Analysis is as important as the Numerical Method for you to be able to apply the method for a given problem!! This is true irrespective of whether you are writing the program or using an existing program or package or software!

Errors and Error Analysis

Accuracy, Precision what are they? Accuracy: how closely a computed or measured value agrees with the True value opposite sense: inaccurate Precision: How closely individual computed or measured values agree with each other Opposite sense: imprecise

Define Error: True Value (a) = Approximate Value a + Error (ε) Absolute Error: ε = a a Relative Error: e = ε a = a a a 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.

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

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

Condition Number of the Problem (C p ): C p = Relative Error in y Relative Error in x = y y x x xf x f x = xf x x x f x Also: C p = As Δx 0, y y x = Τ x f x f x f x x = x Τ x f x f x+ x f x x C p = xf f x x C p < 1: problem is well-conditioned, error is attenuated C p > 1: problem is ill-conditioned, error is amplified C p = 1: neutral, error is translated

Examples of Forward Error Analysis and C p : Problem 1: y = e x ; y = xe x ; C p = x. The problem is well-conditioned for 0 x < 1; neutral at x = 1 and illconditioned for x > 1. Problem 2: Solve the following system of equations: x + αy = 1; αx + y = 0 Solving: x = 1 1 α 2 = x α ; x α = 2α 1 α 2 2 2α α 1 α C p = 2 2 2α 2 = 1 1 α 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 = {x 0, x 1,.. x n }. If error is introduced in the x i s, what is the error in y? X = X X = f X = f X + x i n i=1 y = y y = f X f X x 0 x 0 x 1 x 1 = x n x n f ቤ x i An upper bound of y = σn i=1 X x 0 x 1 x n + HOT f σ n i=1 x i ቚ x i x i f x i ቚ X X

Bacward Error Analysis: Computation using numerical algorithm Computation using mathematical problem Error in the Output 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. 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 b q m = mantissa; 1/b m 1 b = base; 2 for binary, 10 for decimal, 16 for hexadecimal q Q (set of rationals) If a machine (computer) rounds a number off to t decimal places: a = m 10 q ; a = m 10 q m m 0.5 10 t Machine round-off unit(u) is the upper bound of the relative error in one round-off operation a a 0.5 10 t 10 q a m 10 q 0.5 10 1 t = u Condition Number of Algorithm (C a ): change necessary in the input data in order to explain the error in the final result expressed in terms of u.

Consider one floating point operation fl(x op y). op can be any of +, -,, /. By definition of u: fl x op y x op y x op y u Let s consider the op as : fl(x y) = x y(1 + δ) x y(1 + u) where δ u Example: A machine with t = 2, u = 0.5 10 1-2 = 0.05 x = 0.30, 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: fl x 1 x 2 x 3 x n = x 1 x 2 1 + δ 1 x 3 1 + δ 2 x n 1 + δ n 1 δ i u for i = 1, 2, n 1 Relative error in the final computed value: e = fl x 1 x 2 x 3 x n x 1 x 2 x 3 x n x 1 x 2 x 3 x n = 1 + δ 1 1 + δ 2 1 + δ n 1 1 1 + u n 1 1 The quantity 1 + u n 1 1 may be approximated as 1.06(n-1)u for (n-1)u < 0.1

Example: Using a machine with 4-decimal place precision, t = 4, u = 0.5 10 1-4 = 0.5 10-3 Compute y = 1 + sin x 1 for x = 1 fl x = π = 0.1745 10 1 180 fl sin x = 0.1745 10 1 fl 1 + sin x = 0.1017 10 1 fl 1 + sin x = 0.1008 10 1 fl 1 + sin x 1 = 0.8000 10 2 True value of y using infinite precision is 0.8688 10-2 This is equivalent to performing the same computation in a machine with infinite precision with a starting x = 0.1606 10-1 Required relative change in x is (0.1745-0.1606)/0.1745 = 0.7966 10-1 Condition number of the algorithm is C a = 0.7966 10-1 /0.5 10-3 160 sin x If the algorithm is changed to y =, the same machine with 4-1+sin x+1 decimal place precision computes y = 0.8690 10-2 with C a = 0.4

Total Relative Error in the output: Recall: C p = Relative Error in the output Relative Error in the input Relative Error in the Output = C p Relative Error in the Input Relative Error in the Input has two components: User specified relative error in the input data = r (say) Error introduced due to truncation and round-off errors in the algorithm. Equivalent relative error in the input due to this is computed by backward error analysis as C a u Total relative error in the Input data = (r + C a u) Therefore, Relative Error in the Output = C p (r + C a u)