1.08k likes | 1.28k Views
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.
E N D
Applied Numerical Methods with MATLAB Chapter 4 Roundoff and Truncation Errors
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.
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.
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?”
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.
Fig. 3.2 Inaccurate and Imprecise Accurate and Imprecise Inaccurate and Precise Accurate and Precise
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
Significant Figures Zeros are sometimes used to locate the decimal point not significant figures. 0.00001753 4 0.0001753 4 0.001753 4
Error Definitions True Value = Approximation + Error Et = True value – Approximation (+/-) True error
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
Approximate Error We used the approximate error as a convergence criteria when we did the final Fibonacci problem in our first assignment
Convergence Criteria • Use absolute value. • Computations are repeated until stopping criterion is satisfied. Pre-specified % tolerance based on the knowledge of your solution
Significant Figures For n significant figures, a convenient convergence criteria is: Scarborough, 1966
Example 4.1 Maclaurin Series Expansion Use the Maclaurin series expansion to find e0.5 to 3 significant figures
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
Round-off Errors • Numbers such as p, e, or cannot be expressed by a fixed number of significant figures.
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.
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.
Summary • Precision vs Accuracy • Significant Figures • True vs. Approximate Error • Convergence Criteria • Round-off Errors due to chopping or rounding
Applied Numerical Methods with MATLAB Chapter 4B Roundoff and Truncation Errors
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
Taylor Series Derivation If you evaluate this function at f(0) you get….
Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0
Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0
Taylor Series Derivation Now lets differentiate the function to give….. Evaluate at x=0
Taylor Series Derivation Substitute the a values into the power series
Special case of the Taylor Series called the Maclaurin Series We are expanding the Taylor Series around 0
Taylor Series Derivation • More generally • Which allows for a shift in a • What happens if x=a?
General form of the Taylor Series It is expanded around a
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
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.
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
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!
The first order approximation just uses the first and second term (the zeroth and first derivative terms)
The second order approximation just uses the first, second and third terms (the zeroth ,first and second derivative terms)