You are on page 1of 25

Taylor Series

Chapter 1 Lecture 2

Taylor Series

Taylor series states that any smooth function can be approximated


as a polynomial. The Taylor series then provides a mean to predict a
function value at one point in terms of the function value and its
derivatives at another point.

Taylor Series
f (x)

f ( xi 1 )
f ( xi )

h
xi

xi 1

The Taylor series expansion of the function f(x) at xi+1 is given by

f ( xi 1 ) f ( xi h)
f " ( xi ) 2 f " ' ( xi ) 3
f ( n ) ( xi ) n
f ( xi ) f ' ( xi )h
h
h ...
h Rn
2!
3!
n!

Taylor Series
Rn
where h xi 1 xi and
terms from n+1 to infinity:

Rn

k n 1

is a remainder term to account for all

f ( k ) ( xi ) k f ( n 1) ( ) n 1
h
h
k!
(n 1)!

where is a value of x that lies between


Usually R is expressed as

xi and xi 1.

where

Rn O (h n 1 )

O(h n 1 )

means the truncation error is of the order of h n 1.

Taylor Series

The zero-order Taylor series approx. is

f ( xi 1 ) f ( xi )

The first-order Taylor series approx. is

f ( xi 1 ) f ( xi ) f ' ( xi )h
The second-order Taylor series approx. is
and so on.

f ( xi 1 ) f ( xi ) f ' ( xi )h

f " ( xi ) 2
h
2!

In general, the nth-order Taylor series approximates the function with


an nth-order polynomial.

Taylor Series
Substitute xi 1 xi h and thus h x xi we get

f " ( xi )
f ( n ) ( xi )
2
f ( x) f ( xi ) f ' ( xi )( x xi )
( x xi ) ...
( x xi ) n Rn
2!
n!
This series is called Taylor series expansion of f(x)
around the point xi.

f ( x)
f ( xi )

xi
h

Maclaurin Series

For the special case where


becomes

xi 0

the Taylor series

f " ( 0) 2
f ( n ) ( 0) n
f ( x ) f ( 0) f ' ( 0) x
x ...
x ...
2!
n!
This series is called Maclaurin series expansion of f(x).

Example 1

Use zero through fourth-order Taylor series expansions


to approximate the function

f ( x) 0.1x 4 0.15 x 3 0.5 x 2 0.25 x 1.2


at xi 1 1 on the basis of the values at xi 0 .

Solution
The step size

h xi 1 xi 1 0 1

We have

f ( x) 0.1x 4 0.15 x 3 0.5 x 2 0.25 x 1.2

f (0) 1.2

f ' ( x) 0.4 x 3 0.45 x 2 1.0 x 0.25

f ' (0) 0.25

f " ( x) 1.2 x 2 0.9 x 1.0

f " (0) 1.0

( 3)

(4)

( x) 2.4 x 0.9

f ( 3) (0) 0.9

( x) 2.4

f ( 4 ) (0) 2.4

Solution
The true value of f(x) at

xi 1 1

is

f (1) 0.1 0.15 0.5 0.25 1.2 0.2

The zero-order Taylor series approx. is


The true error is

f (1) f (0) 1.2

Et | 0.2 1.2 | 1.0

The first-order approx. is


The true error is

f (1) f (0) f ' (0)h 0.95

Et | 0.2 0.95 | 0.75

Solution
The second-order approx. is

f (1) f (0) f ' (0)h


The true error is

f " (0) 2
h 0.45
2!

Et | 0.2 0.45 | 0.25

The third-order approx. is

f (1) f (0) f ' (0)h


The true error is

f " ( 0) 2 f " ' ( 0) 3


h
h 0.3
2!
3!

Et | 0.2 0.3 | 0.1

Solution

The fourth-order approx. is


f " ( 0) 2 f " ' ( 0) 3 f ( 4 ) ( 0) 4
f (1) f (0) f ' (0)h
h
h
h 0 .2
2!
3!
4!
The true error is

Et | 0.2 0.2 | 0

Thus, the 4th-order Taylor series approx. of f(1) is equal to


the true value. We observed that the truncation error is
decreased by the addition of terms.

Example 2

Use Taylor series expansions with n=0 to 5 to approx.

f ( x) cos x

at

xi 1 3

on the basis of the value at xi 4 .

Solution

h xi 1 xi 3 4 12
The step size

xi 1 3
The true value at
is f ( 3 ) cos( 3 ) 0.5

The zero-order Taylor series approx. is

f ( xi 1 ) f ( xi )

f ( 3 ) f ( 4 ) cos( 4 ) 0.707106781

The true percent relative error is

0.5 0.707106781
100% 41.4%
0.5

Solution
The first-order approx. is

f ( xi 1 ) f ( xi ) f ' ( xi )h

f ( 3 ) f ( 4 ) f ' ( 4 )( 12
) cos( 4 ) sin( 4 )( 12
) 0.521986659

The true percent relative error is

0.5 0.521986659
100% 4.40%
0.5

Solution
The second-order approx. is

f " ( xi ) 2
h
2!
cos( 4 ) 2

f ( 3 ) cos( 4 ) sin( 4 )( 12 )
( 12 ) 0.497754491
2
f ( xi 1 ) f ( xi ) f ' ( xi )h

The true percent relative error is

0.5 0.497754491
100% 0.449%
0.5

Solution
The third-order approx. is

f " ( xi ) 2 f " ' ( xi ) 3


h
h
2!
3!
cos( 4 ) 2 sin( 4 ) 3

f ( 3 ) cos( 4 ) sin( 4 )( 12 )
( 12 )
( 12 )
2!
3!
0.499869147
f ( xi 1 ) f ( xi ) f ' ( xi )h

The true percent relative error is

0.5 0.499869147
t
100% 0.0262%
0.5

Solution
The fifth-order approx. is

cos( 4 ) 2 sin( 4 ) 3
f ( ) cos( ) sin( )( )
( 12 )
( 12 )
2!
3!
cos( 4 ) 4 sin( 4 ) 5

( 12 )
( 12 ) 0.500000304
4!
5!

12

The true percent relative error is


0.5 0.500000304
t
100% 0.000060838%
0.5
Thus, the inclusion of additional terms results in an improved
estimate.

Example 3

A chemical solution is tested in a temperature chamber.


Microwave signals are transmitted towards the solution
and the reaction is reported with the following function
0 t 0.5

t 0.5

f (t )

t 3e t

(a) Find the sixth-order Maclaurin series for the reaction


that happened between t=0 and 0.5 seconds
(b) Calculate the true value of k from the function
definition.

Example 3

(c) Starting with the simplest version of the Maclaurin


series obtained in part (a), add terms one at a time to
estimate k by considering the intersection point t=0.5
between the two steps of the function. After each new
term is added, compute the true and approximate
percent relative errors. Add terms until the absolute
value of the approximate error estimate falls below a pre
specified error criterion s 10%.

Solution

(a) Here

f (t ) t 3et

f ( 0) 0

f ' (t ) (3t 2 t 3 )et

f ' ( 0) 0 t

f " (t ) (6t 6t 2 t 3 )et

f " ( 0) 0

f ( 3) (t ) (6 18t 9t 2 t 3 )e t

f (3) (0) 6

f ( 4 ) (t ) (24 36t 12t 2 t 3 )e t

f ( 4 ) (0) 24

f ( 5) (t ) (60 60t 15t 2 t 3 )et

f (5) (0) 60

f ( 6) (t ) (120 90t 18t 2 t 3 )et

f ( 6) (0) 120

The Maclaurin series expansion of f(t) is

f (t ) t 3 t 4 12 t 5 16 t 6

Solution

(b) The true value of k from3 the


0.5 function definition is

k f (0.5) (0.5) e

0.206090158

(c) The pre specified error estimate is s 10%.


First estimate:

f (t ) t 3

k f (0.5) (0.5) 3 0.125


The true percent relative error is

0.206090158 0.125
100% 39.35%
0.206090158

Solution

Second estimate:

f (t ) t 3 t 4
k f (0.5) (0.5) 3 (0.5) 4 0.1875

The true percent relative error is

0.206090158 0.1875
100% 9.0204%
0.206090158

The approx. percent relative error is

0.1875 0.125
100% 33.33% s 10%
0.1875

Solution

Third estimate:

f (t ) t 3 t 4 12 t 5
k f (0.5) (0.5)3 (0.5) 4 12 (0.5)5 0.203125

The true percent relative error is

0.206090158 0.203125
100% 1.4388%
0.206090158

The approx. percent relative error is

0.203125 0.1875
100% 7.6923% s 10%
0.203125

Solution

Thus, after three terms are included, the approximation


error falls below s 10% and the approx. value of k is
0.203125.

You might also like