15
Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan- Dearborn Math Review with Matlab: Taylor’s Series

Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

Embed Size (px)

Citation preview

Page 1: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

Calculus

S. Awad, Ph.D.

M. Corless, M.S.E.E.

D. Cinpinski

E.C.E. Department

University of Michigan-Dearborn

Math Review with Matlab:

Taylor’s Series

Page 2: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

2

Calculus: Taylor Series

Series Operations

Symbolic Summation

Taylor Series

Taylor Command

Taylor Series Example

Approximation and Comparison Example

Page 3: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

3

Calculus: Taylor Series

Symbolic Summation

» s1=symsum(1/x^2,1,inf)s1 =1/6*pi^2

» num = 4*x*x-x-3» den = x^3+2*x» s2=symsum(num/den,1,inf)s2 =inf Diverges!

1

2

11

x xS

1

3

2

2

342

x xx

xxS

Example 1:

Example 2

Converges

Find the sum of the following series s1 and s2 if they converges

Page 4: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

4

Calculus: Taylor Series

Summation Examples» s3=symsum(1/(x-1.5)^2,1,inf)s3 =4+1/2*pi^2

» eval(s3)ans = 8.9348

12

23

13

x xS

Example 3:

» s4=symsum((1/x)*(-1)^(x+1),1,inf)s4 =log(2) » eval(s4)ans = 0.6931

1

111

4x

x

xS

Example 4:

Page 5: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

5

Calculus: Taylor Series

Finite Summation Example

» 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)

311526

1315 2

1

NNNxxSN

x

Example 5:

Page 6: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

6

Calculus: Taylor Series

Taylor Series

MacLaurin Series is the Taylor series approximation with a=0:

0 !

)0(

n

nn

n

fxft

0 !

)()(

n

nn

t n

afaxxf

Taylor Series approximation is defined as:

Page 7: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

7

Calculus: Taylor Series

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).

Page 8: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

8

Calculus: Taylor Series

Taylor Series Example Given the function: xxf 1ln

» sym x;» f=log(1+x) % Matlab's Natural Log f =log(1+x)

1) Find the first 6 Taylor Series Terms (a=0)

2) Find the first 4 terms about the point a=2

Page 9: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

9

Calculus: Taylor Series

Taylor Series Terms Find the first 6 Taylor Series Terms (a=0)

» taylor(f) %Default is 5th orderans =x-1/2*x^2+1/3*x^3-1/4*x^4+1/5*x^5

» taylor(f,4,2) ans = log(3)+1/3*x-2/3-1/18*(x-2)^2+1/81*(x-2)^3

Find the first 4 terms about the point a=2 Note that this is 3rd order

Page 10: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

10

Calculus: Taylor Series

Taylor Series Approximation and Comparison Example

xxfcos45

1

Given the function:

1) Plot f(x) from -2 to 2

2) Find the first 8 Taylor Series Terms (a=0)

3) Plot the approximation and compare against the original function f(x)

Page 11: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

11

Calculus: Taylor Series

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)')

Page 12: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

12

Calculus: Taylor Series

Plot of f(x)

Page 13: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

13

Calculus: Taylor Series

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

131220

49

1458

5

81

2

9

1 642 xxxft

Page 14: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

14

Calculus: Taylor Series

Approximation is only good for small x

Comparison

» hold on» ezplot(ft_8)» axis([-2*pi 2*pi 0 5])

Plot approximation:

Taylor approximation

Original f(x)

Page 15: Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series

U of M-Dearborn ECE DepartmentMath Review with Matlab

15

Calculus: Taylor Series

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