1 / 101

Applied Numerical Methods with MATLAB

Applied Numerical Methods with MATLAB. Chapter 4 Roundoff and Truncation Errors. Round-Off and Truncation Errors Chapter 4 – Part A. For many engineering problems, we cannot obtain analytical solutions.

asheets
Download Presentation

Applied Numerical Methods with MATLAB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Applied Numerical Methods with MATLAB Chapter 4 Roundoff and Truncation Errors

  2. Round-Off and Truncation ErrorsChapter 4 – Part A • For many engineering problems, we cannot obtain analytical solutions. • Numerical methods yield approximate results, results that are close to the exact analytical solution. We cannot exactly compute the errors associated with numerical methods.

  3. Why Not? • Only rarely given data are exact, since they originate from measurements. Therefore there is probably error in the input information. • Algorithm itself usually introduces errors as well, e.g., unavoidable round-offs, etc … • The output information will then contain error from both of these sources.

  4. Quantify the Error • How confident we are in our approximate result? • The question is “how much error is present in our calculation and is it tolerable?”

  5. Accuracy. How close is a computed or measured value to the true value • Precision (or reproducibility). How close is a computed or measured value to previously computed or measured values. • Inaccuracy(or bias). A systematic deviation from the actual value. • Imprecision(or uncertainty). Magnitude of scatter.

  6. Fig. 3.2 Inaccurate and Imprecise Accurate and Imprecise Inaccurate and Precise Accurate and Precise

  7. Errors are introduced whenever we take measurements

  8. Significant Figures • Number of significant figures indicates precision. Significant digits of a number are those that can be used with confidence, e.g.,the number of certain digits plus one estimated digit. 53,800 How many significant figures? 5.38 x 1043 5.380 x 1044 5.3800 x 1045

  9. Significant Figures Zeros are sometimes used to locate the decimal point not significant figures. 0.00001753 4 0.0001753 4 0.001753 4

  10. Error Definitions True Value = Approximation + Error Et = True value – Approximation (+/-) True error

  11. True Error

  12. Approximate Error • For numerical methods, the true value will be known only when we deal with functions that can be solved analytically (simple systems). In real world applications, we usually do not know the answer a priori. • For iterative processes we can compare each approximation as we do the numerical calculations

  13. Approximate Error We used the approximate error as a convergence criteria when we did the final Fibonacci problem in our first assignment

  14. Fractional Approximate Error

  15. Convergence Criteria • Use absolute value. • Computations are repeated until stopping criterion is satisfied. Pre-specified % tolerance based on the knowledge of your solution

  16. Significant Figures For n significant figures, a convenient convergence criteria is: Scarborough, 1966

  17. Example 4.1 Maclaurin Series Expansion Use the Maclaurin series expansion to find e0.5 to 3 significant figures

  18. Error Estimates for exp(x) Calculation Terms Approximation %True Error %Approx Error 1 1.0000 39.3469 NaN 2 1.5000 9.0204 33.3333 3 1.6250 1.4388 7.6923 4 1.6458 0.1752 1.2658 5 1.6484 0.0172 0.1580 6 1.6487 0.0014 0.0158 e0.5 =1.6487 true value

  19. Round-off Errors • Numbers such as p, e, or cannot be expressed by a fixed number of significant figures.

  20. Chopping Example: p=3.14159265358 to be stored on a base-10 system carrying 7 significant digits. p=3.141592 chopping error et=0.00000065 If rounded p=3.141593 et=0.00000035 • Some machines use chopping, becauserounding adds to the computational overhead. Since number of significant figures is large enough, resulting chopping error is negligible.

  21. Matlab • Uses double precision floating point numbers (15 to 17 significant decimal digits) • This reduces the importance of chopping and round-off error • In general we don’t need to worry about this problem – but we do need to be aware of it.

  22. Summary • Precision vs Accuracy • Significant Figures • True vs. Approximate Error • Convergence Criteria • Round-off Errors due to chopping or rounding

  23. Applied Numerical Methods with MATLAB Chapter 4B Roundoff and Truncation Errors

  24. Taylor Series Derivation • Taylor’s Theorem states that any smooth function can be approximated as a polynomial • Please refer to the derivation of the Taylor Series in the Handouts section of the Canvas website

  25. Taylor Series Derivation If you evaluate this function at f(0) you get….

  26. Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0

  27. Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0

  28. Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0

  29. Taylor Series Derivation

  30. Taylor Series Derivation Substitute the a values into the power series

  31. Special case of the Taylor Series called the Maclaurin Series We are expanding the Taylor Series around 0

  32. Taylor Series Derivation • More generally • Which allows for a shift in a • What happens if x=a?

  33. General form of the Taylor Series It is expanded around a

  34. This allows us to find the value of f(x), if we know the value of f(a) and it’s derivatives In our book, the author lets the difference between x and a equal an increment called h

  35. Non-elementary functions such as trigonometric, exponential, and others are expressed in an approximate fashion using Taylor series when their values, derivatives, and integrals are computed. • Any smooth function can be approximated as a polynomial. Taylor series provides a means to predict the value of a function at one point in terms of the function value and its derivatives at another point.

  36. Figure 4.1

  37. Example 4.5 Consider the polynomial…. Approximate the function value with xi=0 and h=1. That is, predict the value at xi+1=1 Use 0 through 4th order approximations

  38. Example 4.5 But this isn’t what we were asked to do! • The most obvious thing to do is just substitute into the given equation %% Example 4.5 We’re supposed to use the Taylor Series!

  39. The zeroth order approximation just uses the first term

  40. %% Example 4.5 - Error Estimates

  41. Figure 4.1

  42. The first order approximation just uses the first and second term (the zeroth and first derivative terms)

  43. %% Example 4.5 - Error Estimates

  44. Figure 4.1

  45. The second order approximation just uses the first, second and third terms (the zeroth ,first and second derivative terms)

  46. %% Example 4.5

More Related