Presentation is loading. Please wait.

Presentation is loading. Please wait.

Errors and Error Analysis Lecture 2

Similar presentations


Presentation on theme: "Errors and Error Analysis Lecture 2"โ€” Presentation transcript:

1 Errors and Error Analysis Lecture 2

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.

3 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.

4 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

5 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

6 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

7 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!) โˆ†๐‘ฆ=๐‘“ ๐‘ฅ โˆ’๐‘“ ๐‘ฅ โ‰ˆโˆ†๐‘ฅ ๐‘“ โ€ฒ ๐‘ฅ

8 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 = = 4.99 (x + y)min = = 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 +โ€ฆ

9 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

10 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 ๐›ผ 2 1โˆ’ ๐›ผ 2 well-conditioned for โ”‚ฮฑโ”‚<< 1 and ill-conditioned for ฮฑ โ‰ˆ 1.

11 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 ๐‘› โˆ† ๐‘ฅ ๐‘– ๐œ•๐‘“ ๐œ• ๐‘ฅ ๐‘– ๐‘‹

12 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

13 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

14 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.153| = 0.02 โ‰ค u (= 0.05) For this operation: ฮด = -0.01; | ฮด | = โ‰ค u (= 0.05)

15 Multiple Floating Point Operations:
๐‘“๐‘™ ๐‘ฅ 1 ร— ๐‘ฅ 2 ร— ๐‘ฅ 3 ร—โ€ฆร— ๐‘ฅ ๐‘› = ๐‘ฅ 1 ร— ๐‘ฅ ๐›ฟ 1 ร— ๐‘ฅ ๐›ฟ 2 ร—โ€ฆ ๐‘ฅ ๐‘› 1+ ๐›ฟ ๐‘›โˆ’1 ๐›ฟ ๐‘– โ‰ค๐‘ข ๐‘“๐‘œ๐‘Ÿ ๐‘–=1, 2, โ€ฆ ๐‘›โˆ’1 Relative error in the final computed value: ๐‘’= ๐‘“๐‘™ ๐‘ฅ 1 ร— ๐‘ฅ 2 ร— ๐‘ฅ 3 ร—โ€ฆร— ๐‘ฅ ๐‘› โˆ’ ๐‘ฅ 1 ร— ๐‘ฅ 2 ร— ๐‘ฅ 3 ร—โ€ฆร— ๐‘ฅ ๐‘› ๐‘ฅ 1 ร— ๐‘ฅ 2 ร— ๐‘ฅ 3 ร—โ€ฆร— ๐‘ฅ ๐‘› = 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!)

16 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 ร—10-2 Solve the remaining problem to find the condition number of the algorithm


Download ppt "Errors and Error Analysis Lecture 2"

Similar presentations


Ads by Google