Presentation is loading. Please wait.

Presentation is loading. Please wait.

ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University.

Similar presentations


Presentation on theme: "ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University."— Presentation transcript:

1 ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University

2 ES 240: Scientific and Engineering Computation. Chapter 4 Murphy's Laws of Computing 1. 1.When computing, whatever happens, behave as though you meant it to happen. 2. 2.For every action, there is an equal and opposite malfunction. 3. 3.To err is human... to blame your computer for your mistakes is even more than human--it's downright natural. 4. 4.He who laughs last probably made a backup. 5. 5.If at first you don't succeed, blame your computer. 6. 6.The number one cause of computer problems is computer solutions. 7. 7.A computer program will always do what you tell it to do, but rarely what you want to do.

3 ES 240: Scientific and Engineering Computation. Chapter 4 Accuracy and 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.

4 ES 240: Scientific and Engineering Computation. Chapter 4 Error Definitions  True error: – E t = True Value - Approximation  Absolute error: –|Et|–|Et|  True fractional relative error: –  Relative error –

5 ES 240: Scientific and Engineering Computation. Chapter 4 Error Approximation  The approximate percent relative error –  For iterative processes, the error can be approximated as the difference in values between successive iterations.

6 ES 240: Scientific and Engineering Computation. Chapter 4 Using Error Estimates  Stopping Criterion –The sign of the error is not the problem –We just want the error to be less than a specific value –The computation is repeated until |  a |<  s  Correct to at least n significant figures – set

7 ES 240: Scientific and Engineering Computation. Chapter 4 Error Estimates - Example  Write an m-file that –approximates cos(x) using 1-10 terms –plots the relative error versus the number of terms  Determine the stopping criterion that will ensure that the cosine approximation is correct to at least 5 significant figures  Write an m-file that will –Approximate cos(x) correctly up to 10 significant figures. –Display the approximation until it stops –Be creative –Display the number of terms it took

8 ES 240: Scientific and Engineering Computation. Chapter 4 Roundoff Errors  Roundoff errors arise because digital computers cannot represent some quantities exactly.  There are two major facets of roundoff errors involved in numerical calculations: –Digital computers can only represent numbers up to a certain size and precision, so they round-off. –Some numerical manipulations are easily affected by the roundoff errors.

9 ES 240: Scientific and Engineering Computation. Chapter 4 Roundoff Errors Example  Let’s try 4.8

10 ES 240: Scientific and Engineering Computation. Chapter 4 The Taylor Theorem and Series  The Taylor theorem states that any smooth function can be approximated as a polynomial.  The Taylor series provides a means to express this idea mathematically.

11 ES 240: Scientific and Engineering Computation. Chapter 4 The Taylor Series Step Size

12 ES 240: Scientific and Engineering Computation. Chapter 4 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.

13 ES 240: Scientific and Engineering Computation. Chapter 4 Taylor Series - Example  In Matlab: –Use Taylor Series for n = 0-5 to Evaluate f(x) = sin x, at x i+1 = π on the basis of f(x) and its derivatives at π/2. –Display the truncation error as n increases –Vary h and observe the difference

14 ES 240: Scientific and Engineering Computation. Chapter 4 Numerical Differentiation  The first order Taylor series can be used to calculate approximations to derivatives: –Given: –Then:  This is termed a “forward” difference because it utilizes data at i and i+1 to estimate the derivative.

15 ES 240: Scientific and Engineering Computation. Chapter 4 Differentiation (cont)  There are also backward difference and centered difference approximations, depending on the points used:  Forward:  Backward:  Centered:

16 ES 240: Scientific and Engineering Computation. Chapter 4Example x = 0.5; h = 0.5

17 ES 240: Scientific and Engineering Computation. Chapter 4 Total Numerical Error  The total numerical error is the summation of the truncation and roundoff errors.  The truncation error generally increases as the step size increases, while the roundoff error decreases as the step size increases - this leads to a point of diminishing returns for step size.

18 ES 240: Scientific and Engineering Computation. Chapter 4 Other Errors  Blunders - errors caused by malfunctions of the computer or human imperfection.  Model errors - errors resulting from incomplete mathematical models.  Data uncertainty - errors resulting from the accuracy and/or precision of the data.

19 ES 240: Scientific and Engineering Computation. Chapter 4 Taylor Series - Lab  4.12

20 ES 240: Scientific and Engineering Computation. Chapter 4HW  4.11, 15, 17,


Download ppt "ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University."

Similar presentations


Ads by Google