Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using...

28
Second Term 05/06 1 Part 3 Truncation Errors
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    222
  • download

    0

Transcript of Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using...

Page 1: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 1

Part 3

Truncation Errors

Page 2: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 2

Key Concepts• Taylor's Series

• Using Taylor's series to approximate functions

• The Remainder of Taylor's Series

• Using the Remainder to estimate truncation errors

Page 3: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 3

Truncation Errors

Truncation Errors are those that result from using an approximation in place of an exact mathematical procedure.

ii

ii

tt

tvtv

t

v

dt

dv

1

1 )()(

...)!1(!

...!3!2

1132

n

x

n

xxxxe

nnx

Approximation of accelaration

MacLaurin series of ex

Approximation Truncation Errors

Exact mathematical formulation

Page 4: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 4

A more general form of approximation is in terms of Taylor Series.

Page 5: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 5

Taylor's Theorem: If the function f and its first n+1 derivatives are continuous on an interval containing a and x, then the value of the function at x is given by

nn

n

Raxn

af

axaf

axaf

axafafxf

)(!

)(

...)(!3

)()(

!2

)("))((')()(

)(

3)3(

2

x

a

nn

n dttfn

txR )(

!

)( )1(

where the remainder Rn is defined as

(the integral form)

Taylor's Theorem

Page 6: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 6

1)1(

)()!1(

)(

nn

n axn

fR

The remainder Rn can also be expressed as

Derivative or Lagrange Form of the remainder

for some ξ between a and x

(the Lagrange form)

The Lagrange form of the remainder makes analysis of truncation errors easier.

Page 7: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 7

Any smooth function can be approximated as a polynomial. Taylor series provides a mean to predict a function value at one point x in terms of the function and its derivatives at another point a.

Taylor Series

nn

iii

n

iii

iii

iiiii

Rxxn

xfxx

xf

xxxf

xxxfxfxf

)(!

)(...)(

!3

)(

)(!2

)("))((')()(

1

)(3

1

)3(

2111

Note:

This is the same expression except that a and x are replaced by xi and xi+1 respectively.

Page 8: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 8

If we let h = xi+1 - xi, we can rewrite the Taylor series and the remainder as

Taylor Series

nni

n

iiiii

Rhn

xf

hxf

hxf

hxfxfxf

!

)(...

!3

)(

!2

)(")(')()(

)(

3)3(

21

1)1(

)!1(

)(

n

n

n hn

fR

h is called the step size.

Page 9: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 9

Taylor Series ApproximationIf we take away the remainder, the Taylor series becomes the Taylor series approximation.

nii

in

iii

iii

iiiii

xxn

xfxx

xf

xxxf

xxxfxfxf

)(!

)(...)(

!3

)(

)(!2

)("))((')()(

1

)(3

1

)3(

2111

The remainder Rn accounts for all the terms not included in the approximation starting from term n+1.

n can be as small as zero.

The larger n is (more terms used), the better the approximation and thus the smaller the error.

Page 10: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 10

Zero-order approximation: use only the first term

)()( 1 ii xfxf

First-order approximation: use only the first two terms

))((')()( 11 iiiii xxxfxfxf

Second-order approximation: use only the first three terms

2111 )(

!2

)("))((')()( ii

iiiiii xx

xfxxxfxfxf

Some Terminologies

Page 11: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 11

Taylor Series Approximation Example:More terms used implies better approximation

f(x) = 0.1x4 - 0.15x3 - 0.5x2 - 0.25x + 1.2

Page 12: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 12

Taylor Series Approximation Example:Smaller step size implies smaller error

f(x) = 0.1x4 - 0.15x3 - 0.5x2 - 0.25x + 1.2

Reduced step size

Errors

Page 13: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 13

The Remainder of the Taylor Series Expansion

1)1(

)!1(

)(

n

n

n hn

fR

Relationship between h and Rn

Smaller h implies smaller Rn, but if we reduce/magify h by a factor of k, how much smaller/larger Rn would be?

That is,

if h' = kh, what is Rn' in terms of Rn?

Page 14: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 14

Example: Relationship between h and R1

Use the first order Taylor series to approximate the function f(x) = x4 at x+h where x=1.

h True value

(x+h)4

1st Order Approx

f(x) + f'(x)h = x4+4x3h

= 1+4h

Error = R1=

True value –

1st order Approx.

1 16 5 11

0.5 5.0625 3 2.0625

0.25 2.441406 2 0.441406

0.125 1.601807 1.5 0.101807

0.0625 1.274429 1.25 0.024429

0.03125 1.130982 1.125 0.005982

0.015625 1.063980 1.0625 0.001480

Page 15: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 15

Pictorial View of h vs. R1

)log2(log 211 hRhR

1log.log Rvsh

A slop of 2 shown in the log-log plot of the remainder indicates that the truncation error is propotional to h2

)(62

12

12)(")(

!2

)("

22222

1

24

21

hOhhR

xxfxxf

hf

R

Theoritical result

Do they agree?

Page 16: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 16

The Remainder of the Taylor Series Expansion

)()!1(

)( 11)1(

nnn

n hOhn

fR

Summary

To reduce truncation errors, we can reduce h or/and increase n.

If we reduce h, the error will get smaller quicker (with less n).

This relationship has no implication on the magnitude of the errors because the constant term can be huge! It only give us an estimation on how much the truncation error would reduce when we reduce h or increase n.

Page 17: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 17

Example

...!

...!3!2

132

n

xxxxe

nx

If we want to approximate e0.01 with an error less than 10-12, at least how many terms are needed?

This is the Maclaurin series expansion for ex

Note: Maclaurin series expansion is a special case of the Taylor series expansion with xi = 0 and h = x.

Page 18: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 18

1101.0

1 )01.0()!1(

1.1)01.0(

)!1()01.0(

)!1(

nnn

n nn

e

n

eR

xnx exfexfx )()(,01.00,01.0With )1(

To find the smallest n such that Rn < 10-12, we can find the smallest n that satisfies

121 10)01.0()!1(

1.1

n

n

Note:1.1100 is about 13781 > e

With the help of a computer:

n=0 Rn=1.100000e-02

n=1 Rn=5.500000e-05

n=2 Rn=1.833333e-07

n=3 Rn=4.583333e-10

n=4 Rn=9.166667e-13So we need at least 5 terms

Page 19: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 19

115.0

1 )5.0()!1(

7.1)5.0(

)!1()5.0(

)!1(

nnn

n nn

e

n

eR

xnx exfexfx )()(,5.00,5.0With )1(

Note:1.72 is 2.89 > e

With the help of a computer:

n=0 Rn=8.500000e-01

n=1 Rn=2.125000e-01

n=2 Rn=3.541667e-02

n=3 Rn=4.427083e-03

n=4 Rn=4.427083e-04

So we need at least 12 terms

n=5 Rn=3.689236e-05

n=6 Rn=2.635169e-06

n=7 Rn=1.646980e-07

n=8 Rn=9.149891e-09

n=9 Rn=4.574946e-10

n=10 Rn=2.079521e-11

n=11 Rn=8.664670e-13

Same problem with larger step size

Page 20: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 20

Other methods for estimating truncation errors of a series

1. By Geometry Series

2. By Integration

3. Alternating Convergent Series Theorem

nn R

nnn

S

n ttttttttS ...... 3213210

Note: Some Taylor series expansions may exhibit certain characteristics which would allow us to use different methods to approximate the truncation errors.

Page 21: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 21

Estimation of Truncation ErrorsBy Geometry Series

k

tkkkt

tktkt

tttR

n

n

nnn

nnnn

1

...)1(

...

...

1

321

12

11

321

k

tkR n

n

1

If |tj+1| ≤ k|tj| where 0 ≤ k < 1 for all j ≤ n, then

Page 22: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 22

Estimation of Truncation Errors by Geometry Series

11.0

66

11

11

1

21

2

2

221

jt

t

jj

j

t

t

j

j

j

j

j

j

k

tkR n

n

1

jj

j

jt

jS2

2642 ......321

What is |R6| for the following series expansion?

66

66

10311.01

11.0

1

103,11.0

k

tkR

tk

n

Solution:

Page 23: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 23

Estimation of Truncation ErrorsBy Integration

nn dxxfR )(

If we can find a function f(x) s.t. |tj| ≤ f(j) j ≥ n

and f(x) is a decreasing function x ≥ n, then

11321 )(...

njnjjnnnn jfttttR

Page 24: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 24

Estimation of Truncation Errors by Integration

11

1133

jjj

13

1

)1(where

jttS jj

j

Estimate |Rn| for the following series expansion.

23 2

11

ndx

xR

nn

Solution:

We can pick f(x) = x-3 because it would provide a tight bound for |tj|. That is

So

Page 25: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 25

Alternating Convergent Series Theorem (Leibnitz Theorem)

If an infinite series satisfies the conditions– It is strictly alternating.– Each term is smaller in magnitude than that

term before it.– The terms approach to 0 as a limit.

Then the series has a finite sum (i.e., convergent) and moreover if we stop adding the terms after the nth term, the error thus produced is between 0 and the 1st non-zero neglected term not taken.

Page 26: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 26

Alternating Convergent Series Theorem

16666.06

109.02log

693.02log

7833333340.05

1

4

1

3

1

2

112log

e

e

e

SR

S

Example:

77

8642

1076.2!10

11073.2)1cos(

5403023059.0)1cos(

5403025793.0!8

1

!6

1

!4

1

!2

11)1cos(

S

S

Eerror estimated using the althernating convergent series theoremAnother example:

Actual error

Actual error

Page 27: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 27

More ExamplesIf the sine series is to be used to compute sin(1) with an error less than 0.5x10-14, how many terms are needed?

...!9

1

!7

1

!5

1

!3

11)1sin(

9753

This series satisfies the conditions of the Alternating Convergent Series Theorem.

14102

1

!

1 n

Solving

for odd n, we get n = 17 (Need 8 terms)

Solution:

Page 28: Second Term 05/061 Part 3 Truncation Errors. Second Term 05/062 Key Concepts Taylor's Series Using Taylor's series to approximate functions The Remainder.

Second Term 05/06 28

More Examples

How many terms should be taken in order to compute π4/90 with an error of at most 0.5x10-8?

...4

1

3

1

2

11

90 444

4

406102

1

3

1 83

nn

Solution (by integration):

3

44

1

4

3

1

3 n

xdxxk

nn

nk