150 likes | 165 Views
Learn about symbolic summation, Taylor series, Taylor command, and more with examples and comparisons. See how Taylor series can be used for function approximation and analysis. Understand the importance of increasing the number of terms for improved accuracy.
E N D
Math Review with Matlab: Calculus Taylor’s Series S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn
Series Operations • Symbolic Summation • Taylor Series • Taylor Command • Taylor Series Example • Approximation and Comparison Example
Symbolic Summation • Find the sum of the following series s1 and s2 if they converges Diverges! • Example 1: » s1=symsum(1/x^2,1,inf) s1 = 1/6*pi^2 Converges • Example 2 » num = 4*x*x-x-3 » den = x^3+2*x » s2=symsum(num/den,1,inf) s2 = inf
Summation Examples » s3=symsum(1/(x-1.5)^2,1,inf) s3 = 4+1/2*pi^2 » eval(s3) ans = 8.9348 • Example 3: » s4=symsum((1/x)*(-1)^(x+1),1,inf) s4 = log(2) » eval(s4) ans = 0.6931 • Example 4:
Finite Summation Example • Example 5: » syms x N; » s5=symsum((x+3)*(x+1),1,N) s5 = 7/6*N-11/6+3/2*(N+1)^2+1/3*(N+1)^3 » s5=simple(s5) s5 = 1/6*N*(31+15*N+2*N^2)
Taylor Series • Taylor Series approximation is defined as: • MacLaurin Series is the Taylor series approximation with a=0:
Taylor Command • taylor(f) is the fifth order MacLaurin polynomial approximation to f • taylor(f,n) is the (n -1)-st order MacLaurin polynomial • taylor(f,n,a) is the Taylor polynomial approximation about point a with order (n -1).
Taylor Series Example • Given the function: 1) Find the first 6 Taylor Series Terms (a=0) 2) Find the first 4 terms about the point a=2 » sym x; » f=log(1+x) % Matlab's Natural Log f = log(1+x)
Taylor Series Terms • Find the first 6 Taylor Series Terms (a=0) » taylor(f) %Default is 5th order ans = x-1/2*x^2+1/3*x^3-1/4*x^4+1/5*x^5 • Find the first 4 terms about the point a=2 • Note that this is 3rd order » taylor(f,4,2) ans = log(3)+1/3*x-2/3-1/18*(x-2)^2+1/81*(x-2)^3
Taylor Series Approximation and Comparison Example • Given the function: 1) Plot f(x) from -2p to 2p 2) Find the first 8Taylor Series Terms (a=0) 3) Plot the approximation and compare against the original function f(x)
Plot f(x) • The easiest way to generate a graph is to use ezplot • ezplot leaves the axes unlabeled » syms x » f=1/(5+4*cos(x)); » ezplot(f,-2*pi,2*pi); » grid on » xlabel('x');ylabel('f(x)')
Taylor Approximation • To find the first 8 terms of the Taylor series approximation: » ft_8=taylor(f,8) ft_8 = 1/9+2/81*x^2+5/1458*x^4+49/131220*x^6
Taylor approximation Original f(x) Comparison • Plot approximation: » hold on » ezplot(ft_8) » axis([-2*pi 2*pi 0 5]) • Approximation is only good for small x
Summary • The symbolic toolbox can be used to analyze definite and indefinite series summations • Taylor series can be used to approximate functions • MacLaurin series is a special case of the Taylor series approximated around x=0 • Increase the number of terms to increase approximation accuracy