MECN 3500 Lecture 4 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus
Lecture 4 MECN 3500 Inter - Bayamon 2 Tentative Lectures Schedule TopicLecture Mathematical Modeling and Engineering Problem Solving 1 Introduction to Matlab 2 Numerical Error 3 Root Finding 3 System of Linear Equations Least Square Curve Fitting Polynomial Interpolation Numerical Integration Ordinary Differential Equations
Lecture 4 MECN 3500 Inter - Bayamon Taylor Theorem Truncation Errors and the Taylor Series 3
Lecture 4 MECN 3500 Inter - Bayamon To understand the use of Taylor Series in the study of numerical methods. 4 Course Objectives
Lecture 4 MECN 3500 Inter - Bayamon Truncation Errors: use approximation in place of an exact mathematical procedure. Truncation Errors: use approximation in place of an exact mathematical procedure. Numerical Methods express functions in an approximate fashion: The Taylor Series. Numerical Methods express functions in an approximate fashion: The Taylor Series. What is a Taylor Series? What is a Taylor Series? Some examples of Taylor series which you must have seen 5 Introduction
Lecture 4 MECN 3500 Inter - Bayamon The general form of the Taylor series is given by The general form of the Taylor series is given by provided that all derivatives of f(x) are continuous and exist in the interval [x,x+h] What does this mean in plain English? 6 General Taylor Series As Archimedes would have said, “Give me the value of the function at a single point, and the value of all (first, second, and so on) its derivatives at that single point, and I can give you the value of the function at any other point” ( fine print excluded )
Lecture 4 MECN 3500 Inter - Bayamon 7
Lecture 4 MECN 3500 Inter - Bayamon Example: Find the value of f(6) given that f(4)=125, f’(4)=74, f’’(4)=30, f’’’(4)=6 and all other higher order derivatives of f(x) at x=4 are zero. Example: Find the value of f(6) given that f(4)=125, f’(4)=74, f’’(4)=30, f’’’(4)=6 and all other higher order derivatives of f(x) at x=4 are zero. Solution: x=4, x+h=6 h=6-x=2 Solution: x=4, x+h=6 h=6-x=2 Since the higher order derivatives are zero, Since the higher order derivatives are zero, 8 General Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon The Taylor Series (x i+1 -x i )= hstep size (define first) (x i+1 -x i )= hstep size (define first) Reminder term, R n, accounts for all terms from (n+1) to infinity. Reminder term, R n, accounts for all terms from (n+1) to infinity. 9
Lecture 4 MECN 3500 Inter - Bayamon The Taylor Series Zero-order approximation Zero-order approximation First-order approximation First-order approximation Second-order approximation Second-order approximation 10
Lecture 4 MECN 3500 Inter - Bayamon 11
Lecture 4 MECN 3500 Inter - Bayamon Example 4.1: Taylor Series Approximation of a polynomial Use zero- through fourth- order Taylor Series approximation to approximate the function: Example 4.1: Taylor Series Approximation of a polynomial Use zero- through fourth- order Taylor Series approximation to approximate the function: From x i =0 with h=1. That is, predict the function’s value at x i+1 =1 From x i =0 with h=1. That is, predict the function’s value at x i+1 =1 f(0)=1.2 f(0)=1.2 f(1)=0.2 - True value f(1)=0.2 - True value 12 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Zero-order approximation Zero-order approximation First-order approximation First-order approximation 13 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Second-order approximation Second-order approximation 14 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Third-order approximation Third-order approximation 15 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Fourth-order approximation Fourth-order approximation 16 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon 17 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon If we truncate the series after the first derivative term If we truncate the series after the first derivative term 18 Taylor Series to Estimate Truncation Errors First-order approximation Truncation Error
Lecture 4 MECN 3500 Inter - Bayamon Forward Difference Approximation Forward Difference Approximation 19 Numerical Differentiation
Lecture 4 MECN 3500 Inter - Bayamon Backward Difference Approximation Backward Difference Approximation 20 Numerical Differentiation
Lecture 4 MECN 3500 Inter - Bayamon Centered Difference Approximation Centered Difference Approximation 21 Numerical Differentiation
Lecture 4 MECN 3500 Inter - Bayamon 22
Lecture 4 MECN 3500 Inter - Bayamon Example 4.4: To find the forward, backward and centered difference approximation for f(x) at x=0.5 using step size of h=0.5, repeat using h=0.25. The true value is Example 4.4: To find the forward, backward and centered difference approximation for f(x) at x=0.5 using step size of h=0.5, repeat using h=0.25. The true value is h=0.5 h=0.5 x i-1 =0 - f(x i-1 )=1.2 x i-1 =0 - f(x i-1 )=1.2 x i =0.5 - f(x i )=0.925 x i =0.5 - f(x i )=0.925 X i+1 =1 - f(x i+1 )=0.2 X i+1 =1 - f(x i+1 )= The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Forward Difference Approximation Forward Difference Approximation Backward Difference Approximation Backward Difference Approximation 24 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Centered Difference Approximation Centered Difference Approximation 25 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon h=0.25 h=0.25 x i-1 = f(x i-1 )= x i-1 = f(x i-1 )= x i =0.5 - f(x i )=0.925 x i =0.5 - f(x i )=0.925 X i+1 = f(x i+1 )= X i+1 = f(x i+1 )= Forward Difference Approximation Forward Difference Approximation 26 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Backward Difference Approximation Backward Difference Approximation Centered Difference Approximation Centered Difference Approximation 27 The Taylor Series
Lecture 4 MECN 3500 Inter - Bayamon Homework3 Omar E. Meza Castillo Ph.D. 28