Taylor Series: Applications and Examples
Learn about Taylor series and their applications in approximating functions using polynomial expressions. Explore examples and illustrations to understand the concept better.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
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 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: approximation exact 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: (i) 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 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 approximation exact
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 +?2(??) 2+ +???? ? ??+1 = ? ?? +? (??) Taylor series ?+ ?? 1! 2! ?! ? ??+1 = ? ?? +? ?? (??+1 ??) +?2(??) (??+1 ??)2+ +???? (??+1 ??)?+?? 1! 2! ?! First-order approximation forward finite difference ? ??+1 = ? ?? +? ?? (??+1 ??) +?2(?) ? ?? ? ??+? ? ?? (??+1 ??)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 ) ? ? ??+? ?? ? ?? ??= ( 1)?+1??+1?? Taylor series ?+1 (? + 1)! ? ?? 1 = ? ?? ? ?? +?2?? 2+ + ( 1)????? ?+ ?? 1! 2! ?!
Sec:4.1 THE TAYLOR SERIES ??= ( 1)?+1??+1?? Taylor series ?+1 (? + 1)! ? ?? 1 = ? ?? ? ?? +?2?? 2+ + ( 1)????? ?+ ?? 1! 2! ?! First-order approximation backward finite difference ? ?? 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 backward finite difference forward finite difference ? ?? =??(?) ? ??+? ? ?? ??+? ?? ? ?? = ??(?) ? ?? ? ?? ? ?? ?? ? ? ? ?! ?! Centered finite difference ? ??+? ? ?? ? ?? ? ?? = ?(??) Notice that the truncation error is of the order of 2in 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 * backward difference forward difference centered difference h 0.1 0.01 0.001 0.0001 0.00001 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 centered diff error forward diff error back 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]; 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 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] 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 ??(?) forward finite difference ? ??+? ?? ??+? + ? ?? ?? ? ?? = ?(?) ??+? ??+? ?? ? ?? ? ?? backward finite difference ? ?? ?? ?? ? + ? ?? ? ?? ? ?? = ?(?) ??+? ??+? ?? ? ?? ? ?? Centered finite difference ? ??+? ?? ?? + ? ?? ? ?? ??+? ??+? ? ?? = ?(??) ?? ? ?? ? ??