Sec:4.1 THE TAYLOR SERIES.

Slides:



Advertisements
Similar presentations
Truncation Errors and Taylor Series
Advertisements

Section 11.6 – Taylor’s Formula with Remainder
Roundoff and truncation errors
Numerical Methods Lecture 14 Differentiation-Continuous Functions
Computational Modeling for Engineering MECN 6040
Example: Obtain the Maclaurin’s expansion for
Part 5 Chapter 19 Numerical Differentiation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Numerical Computation
High Accuracy Differentiation Formulas
CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari
Part 3 Truncation Errors Second Term 05/06.
Taylor Series (11/12/08) Given a nice smooth function f (x): What is the best constant function to approximate it near 0? Best linear function to approximate.
Chapter 1 Introduction The solutions of engineering problems can be obtained using analytical methods or numerical methods. Analytical differentiation.
Part 3 Truncation Errors.
Chapter 7 Differentiation and Integration
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 5 Approximations, Errors and The Taylor Series.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 23 Numerical Differentiation.
8/15/ Differentiation-Continuous Functions Major: All Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati.
Derivatives and Differential Equations
Interpolation. Interpolation is important concept in numerical analysis. Quite often functions may not be available explicitly but only the values of.
Numerical Methods on Partial Differential Equation Md. Mashiur Rahman Department of Physics University of Chittagong Laplace Equation.
Infinite Series Copyright © Cengage Learning. All rights reserved.
ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University.
Taylor’s Polynomials & LaGrange Error Review
Consider the following: Now, use the reciprocal function and tangent line to get an approximation. Lecture 31 – Approximating Functions
Now that you’ve found a polynomial to approximate your function, how good is your polynomial? Find the 6 th degree Maclaurin polynomial for For what values.
MECN 3500 Lecture 4 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
9.7 and 9.10 Taylor Polynomials and Taylor Series.
Taylor’s Theorem: Error Analysis for Series. Taylor series are used to estimate the value of functions (at least theoretically - now days we can usually.
10/27/ Differentiation-Continuous Functions Computer Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati.
Finite Difference Methods Definitions. Finite Difference Methods Approximate derivatives ** difference between exact derivative and its approximation.
MECN 3500 Inter - Bayamon Lecture Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Engineering Analysis – Computational Fluid Dynamics –
The Convergence Problem Recall that the nth Taylor polynomial for a function f about x = x o has the property that its value and the values of its first.
Sect. 9-B LAGRANGE error or Remainder
Remainder Theorem. The n-th Talor polynomial The polynomial is called the n-th Taylor polynomial for f about c.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Truncation Errors and the Taylor Series Chapter 4.
9.3 Taylor’s Theorem: Error Analysis yes no.
Taylor series are used to estimate the value of functions (at least theoretically - now days we can usually use the calculator or computer to calculate.
NUMERICAL DIFFERENTIATION or DIFFERENCE APPROXIMATION Used to evaluate derivatives of a function using the functional values at grid points. They are.
Copyright © Cengage Learning. All rights reserved Applications of Taylor Polynomials.
Convergence of Taylor Series Objective: To find where a Taylor Series converges to the original function; approximate trig, exponential and logarithmic.
1 Numerical Differentiation. 2  First order derivatives  High order derivatives  Examples.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 21 Numerical Differentiation.
High Accuracy Differentiation Formulas
Copyright © Cengage Learning. All rights reserved.
Applied Numerical Methods
Differentiation-Continuous Functions
The Taylor Polynomial Remainder (aka: the Lagrange Error Bound)
Taylor series in numerical computations (review)
Numerical Differentiation
Interpolation.
The LaGrange Error Estimate
Roundoff and Truncation Errors
Chapter 23.
Taylor Polynomials & Approximation (9.7)
Calculus BC AP/Dual, Revised © : Lagrange's Error Bound
Remainder of a Taylor Polynomial
Section 11.3 Power Series.
Sec:4.3 Total Numerical Error.
Find the Taylor series for f (x) centered at a = 8. {image} .
Taylor Series and Maclaurin Series
Numerical Differentiation Chapter 23
11.1 – Polynomial Approximations of Functions
Section 11.6 – Taylor’s Formula with Remainder
Numerical Analysis Lecture 2.
9.7 Taylor Polynomials & Approximations
Roundoff and Truncation Errors
9.2 Taylor Series.
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

Sec:4.1 THE TAYLOR SERIES

Sec:4.1 THE TAYLOR SERIES Taylor’s theorem states that any smooth function can be approximated as a polynomial. Taylor series ( center is a ) If the function f and its first n + 1 derivatives are continuous on an interval containing a and x,   there exists a point ξ between a and x such that the reminder   Maclaurin series ( center is 0 )     ξ between 0 and x

Sec:4.1 THE TAYLOR SERIES Example: Taylor series ( center is a )   Example: Let f (x) = cos x and a = 0. Determine (a) the second order approximation for f about a; and (b) Use (a) to approximate cos(0.01) f(x) = cos x, f'(x) = −sin x, f’’(x) = −cos x, f’’’(x) = sin x, f’’’’(x) = cos x, f(0) = 1, f'(0) = 0, f’’(0) = −1, f’’’(0) = 0, f’’’’(0) = 1, 𝑓 𝑥 =𝑐𝑜𝑠𝑥 syms x taylor(cos(x),x,0,'order',3) 1 - x^2/2 p 𝒙 =𝟏− 𝟏 𝟐 𝒙 𝟐     ezplot('cos(x)',[-pi,pi]); hold on ezplot('1-x.^2/2',[-pi,pi]); hold off grid on  

Sec:4.1 THE TAYLOR SERIES Example: Let f (x) = cos x and a = 0. Determine (a) the second order approximation for f about a; and (b) Use (a) to approximate cos(0.01)         How accurate this approximation:         exact approximation   Hence the approximation 0.99995 matches at least the first five digits of the exact      

Sec:4.1 THE TAYLOR SERIES Example: Let f (x) = cos x and a = 0. Determine (a) the second order approximation for f about a; and   (b) Use (a) to approximate cos(0.01)     This example illustrates the two objectives of numerical analysis: Find an approximation to the solution of a given problem. (ii) Determine a bound for the accuracy of the approximation

Sec:4.1 THE TAYLOR SERIES Example: Why: we want to approximate a function by a polynomial.   Example: Let f (x) = cos x and a = 0. Determine (a) the third order approximation for f about a; and (b) Use (a) to approximate     integrate both sides       exact approximation            

Sec:4.1 THE TAYLOR SERIES Taylor’s theorem states that any smooth function can be approximated as a polynomial. Taylor series ( center is a )   there exists a point ξ between a and x such that   Another expression for the Reminder  

Sec:4.1 THE TAYLOR SERIES Taylor series ( center is a )                 It is often convenient to simplify the Taylor series by defining a step size h = xi+1 − xi and expressing above as Taylor series ( center is a )    

Sec:4.1 THE TAYLOR SERIES 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 𝑓 𝑥 𝑖+1 =𝑓 𝑥 𝑖 + 𝑓′( 𝑥 𝑖 ) 1! ℎ+ 𝑓 2 ( 𝑥 𝑖 ) 2! ℎ 2 +…+ 𝑓 𝑛 𝑥 𝑖 𝑛! ℎ 𝑛 + 𝑹 𝒏 Taylor series 𝑓 𝑥 𝑖+1 =𝑓 𝑥 𝑖 + 𝑓 ′ 𝑥 𝑖 1! ( 𝑥 𝑖+1 − 𝑥 𝑖 )+ 𝑓 2 ( 𝑥 𝑖 ) 2! ( 𝑥 𝑖+1 − 𝑥 𝑖 ) 2 +…+ 𝑓 𝑛 𝑥 𝑖 𝑛! ( 𝑥 𝑖+1 − 𝑥 𝑖 ) 𝑛 + 𝑹 𝒏 First-order approximation forward finite difference 𝑓 𝑥 𝑖+1 =𝑓 𝑥 𝑖 + 𝑓 ′ 𝑥 𝑖 1! ( 𝑥 𝑖+1 − 𝑥 𝑖 )+ 𝑓 2 (𝜉) 2! ( 𝑥 𝑖+1 − 𝑥 𝑖 ) 2 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 Move the first term to left side and divid by h 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 − 𝒇 ′ 𝒙 𝒊 = 𝒇 𝟐 (𝝃) 𝟐! 𝒉 Truncation error Approximation to the derivative

Sec:4.1 THE TAYLOR SERIES forward finite difference 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 − 𝒇 ′ 𝒙 𝒊 = 𝒇 𝟐 (𝝃) 𝟐! 𝒉 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 SIMILAR TO PROBLEM 4.5/p105: 𝒙 𝒊 =2 𝒙 𝒊+𝟏 =2.2 Use forward difference approximations to estimate the first derivative of the function 𝒇 (𝒙) = 𝟐𝟓 𝒙 𝟑 − 𝟔 𝒙 𝟐 + 𝟕𝒙 Evaluate the derivative at x = 2 using a step size of h = 0.2, 0.1, 0.001. Compare your results with the true value of the derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion. 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 h = 0.2 𝒇 ′ 𝟐 ≈ 𝒇 𝟐.𝟐 −𝒇 𝟐 𝟎.𝟐 = 𝟐𝟓𝟐.𝟓𝟔−𝟏𝟗𝟎 𝟎.𝟐 =𝟑𝟏𝟐.𝟖 h = 0.1 𝒇 ′ 𝟐 ≈ 𝒇 𝟐.𝟏 −𝒇 𝟐 𝟎.𝟏 =𝟐𝟗𝟕.𝟔𝟓 h = 0.001 𝒇 ′ 𝟐 ≈ 𝒇 𝟐.𝟎𝟎𝟏 −𝒇 𝟐 𝟎.𝟎𝟎𝟏 =𝟐𝟖𝟑.𝟏𝟒𝟒𝟎𝟐𝟓 𝒇 ′ 𝟐 =𝟐𝟖𝟑

Sec:4.1 THE TAYLOR SERIES first finite divided difference 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 − 𝒇 ′ 𝒙 𝒊 = 𝒇 𝟐 (𝝃) 𝟐! 𝒉 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 SIMILAR TO PROBLEM 4.5/p105: 𝒙 𝒊 =2 𝒙 𝒊+𝟏 =2.2 Use forward difference approximations to estimate the first derivative of the function 𝒇 (𝒙) = 𝟐𝟓 𝒙 𝟑 − 𝟔 𝒙 𝟐 + 𝟕𝒙 Evaluate the derivative at x = 2 using a step size of h = 0.2, 0.1, 0.001. Compare your results with the true value of the derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion. h = 0.001 𝒇 ′ 𝟐 ≈ 𝒇 𝟐.𝟎𝟎𝟏 −𝒇 𝟐 𝟎.𝟎𝟎𝟏 =𝟐𝟖𝟑.𝟏𝟒𝟒𝟎𝟐𝟓 𝒇 ′ 𝟐 =𝟐𝟖𝟑 Error = 0.𝟏𝟒𝟒𝟎𝟐𝟓 𝒇 𝟐 (𝝃) 𝟐! 𝒉 𝒇 (𝟐) (𝒙) =𝟏𝟓𝟎𝒙−𝟏𝟐 𝒇 𝟐 (𝝃) 𝟐! 𝒉= 75ξ−6 ∗(0.001) ≤ 75∗2.001−6 ∗(0.001) ≤0.14407

Sec:4.1 THE TAYLOR SERIES 𝒂 𝒙 𝒙 𝒊+𝟏 𝒙 𝒊−𝟏 𝒙 𝒊 Taylor series ( center is a )     𝒙 𝒂 𝒙 𝒊−𝟏 𝒙 𝒊+𝟏 𝒙 𝒊 Taylor series 𝑹 𝒏 = (−1) 𝑛+1 𝑓 𝑛+1 𝑥 𝑖 (𝑛+1)! ℎ 𝑛+1 𝑓 𝑥 𝑖−1 =𝑓 𝑥 𝑖 − 𝑓 ′ 𝑥 𝑖 1! ℎ+ 𝑓 2 𝑥 𝑖 2! ℎ 2 +…+ (−1) 𝑛 𝑓 𝑛 𝑥 𝑖 𝑛! ℎ 𝑛 + 𝑹 𝒏

Sec:4.1 THE TAYLOR SERIES 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊 −𝒇 𝒙 𝒊−𝟏 𝒙 𝒊 − 𝒙 𝒊−𝟏 𝑹 𝒏 = (−1) 𝑛+1 𝑓 𝑛+1 𝑥 𝑖 (𝑛+1)! ℎ 𝑛+1 𝑓 𝑥 𝑖−1 =𝑓 𝑥 𝑖 − 𝑓 ′ 𝑥 𝑖 1! ℎ+ 𝑓 2 𝑥 𝑖 2! ℎ 2 +…+ (−1) 𝑛 𝑓 𝑛 𝑥 𝑖 𝑛! ℎ 𝑛 + 𝑹 𝒏 First-order approximation backward finite difference 𝑓 𝑥 𝑖−1 =𝑓 𝑥 𝑖 − 𝑓 ′ 𝑥 𝑖 1! ( 𝑥 𝑖 − 𝑥 𝑖−1 )+ 𝑓 2 (𝜉) 2! ℎ 2 𝒇 ′ 𝒙 𝒊 ≈ 𝒇 𝒙 𝒊 −𝒇 𝒙 𝒊−𝟏 𝒙 𝒊 − 𝒙 𝒊−𝟏 Move the first term to left side and divid by h 𝒇 𝒙 𝒊 −𝒇 𝒙 𝒊−𝟏 𝒙 𝒊 − 𝒙 𝒊−𝟏 − 𝒇 ′ 𝒙 𝒊 =− 𝒇 𝟐 (𝝃) 𝟐! 𝒉 Truncation error Approximation to the derivative

Sec:4.1 THE TAYLOR SERIES forward finite difference backward finite difference 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊 𝒙 𝒊+𝟏 − 𝒙 𝒊 − 𝒇 ′ 𝒙 𝒊 = 𝒇 𝟐 (𝝃) 𝟐! 𝒉 𝒇 𝒙 𝒊 −𝒇 𝒙 𝒊−𝟏 𝒙 𝒊 − 𝒙 𝒊−𝟏 − 𝒇 ′ 𝒙 𝒊 =− 𝒇 𝟐 (𝝃) 𝟐! 𝒉 Centered finite difference 𝒇 𝒙 𝒊+𝟏 −𝒇 𝒙 𝒊−𝟏 𝟐𝒉 − 𝒇 ′ 𝒙 𝒊 =𝑶( 𝒉 𝟐 ) Notice that the truncation error is of the order of ℎ 2 in contrast to the forward and backward approximations that were of the order of h. Consequently, the Taylor series analysis yields the practical information that the centered difference is a more accurate representation of the derivative

Sec:4.1 THE TAYLOR SERIES SIMILAR TO PROBLEM 4.5/p105: Use forward and backward difference approximations of O(h) and a centered difference approximation of O(h2)to estimate the first derivative of the function 𝒇 (𝒙) = 𝟐𝟓 𝒙 𝟑 − 𝟔 𝒙 𝟐 + 𝟕𝒙 Evaluate the derivative at x = 2 using a step size of h = 0.1, 0.01, 0.001, 0.0001, 0.00001 Compare your results with the true value of the derivative. 1.0e+02 * 2.688500000000002 2.976500000000002 2.832500000000002 2.815625000000011 2.844424999999916 2.830024999999964 2.828560250000010 2.831440249999560 2.830000249999785 2.829856002497877 2.830144002504653 2.830000002501265 2.829985600016016 2.830014400046821 2.830000000031419 h backward difference forward difference centered difference 0.1 0.01 0.001 0.0001 0.00001 back diff error forward diff error centered diff error 0.1 0.01 0.001 0.0001 0.00001 -14.149999999999807 14.65000000000014 0.250000000000171 -1.437499999998863 1.442499999991583 0.002499999996360 -0.143974999999045 0.144024999955946 0.000024999978450 -0.014399750212306 0.014400250465314 0.000000250126504 -0.001439998398382 0.001440004682081 0.000000003141849 Error Table

Sec:4.1 THE TAYLOR SERIES format short fun = @(x) 25*x^3 - 6*x^2+7*x; dfun = @(x) 75*x^2 - 12*x + 7; x=2; exact = dfun(2); h_vec=[0.1 0.01 0.001 0.0001 0.00001]; for i=1:5 h = h_vec(i); [bd,fd,cd] = num_diff(fun,x,h); bd_vec(i) = bd; fd_vec(i) = fd; cd_vec(i) = cd; end format long res1 = [ bd_vec' fd_vec' cd_vec'] res2 = [h_vec' bd_vec' fd_vec' cd_vec'] err = [bd_vec' fd_vec' cd_vec']-exact; err_res = [h_vec' err] function [bd,fd,cd] = num_diff(f,x,h) xi = x; xip1 = xi+h; xim1 = xi-h; bd = (f(xi) - f(xim1))/h; fd = (f(xip1) - f(xi) )/h; cd = (f(xip1) - f(xim1))/(2*h); end fun = @(x) 25*x^3 - 6*x^2+7*x; dfun = @(x) 75*x^2 - 12*x + 7; h=0.2; x=2; [bd,fd,cd] = num_diff(fun,x,h) dfun(2)

Sec:4.1 THE TAYLOR SERIES 𝒇 𝟐 (𝒙) Second Derivative Approximation 𝒇 𝟐 (𝒙) Second Derivative Approximation forward finite difference 𝒙 𝒊−𝟏 𝒙 𝒊 𝒙 𝒊+𝟏 𝒙 𝒊+𝟐 𝒙 𝒊−𝟐 𝒇 𝒙 𝒊+𝟐 −𝟐𝒇 𝒙 𝒊+𝟏 +𝒇 𝒙 𝒊 𝒉 𝟐 − 𝒇 ′′ 𝒙 𝒊 =𝑶(𝒉) backward finite difference 𝒙 𝒊−𝟏 𝒙 𝒊 𝒙 𝒊+𝟏 𝒙 𝒊+𝟐 𝒙 𝒊−𝟐 𝒇 𝒙 𝒊 −𝟐𝒇 𝒙 𝒊−𝟏 +𝒇 𝒙 𝒊−𝟐 𝒉 𝟐 − 𝒇 ′′ 𝒙 𝒊 =𝑶(𝒉) Centered finite difference 𝒙 𝒊−𝟏 𝒙 𝒊 𝒙 𝒊+𝟏 𝒙 𝒊+𝟐 𝒙 𝒊−𝟐 𝒇 𝒙 𝒊+𝟏 −𝟐𝒇 𝒙 𝒊 +𝒇 𝒙 𝒊−𝟏 𝒉 𝟐 − 𝒇 ′′ 𝒙 𝒊 =𝑶( 𝒉 𝟐 )