cis541 07 integration

138
 Numerical Integration Roger Crawfis

Upload: beverly-paman

Post on 01-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 1/138

 Numerical Integration

Roger Crawfis

Page 2: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 2/138

March 24, 2015 OSU/CSE 541 2

Quadrature

• We talk in terms of Quadrature Rules –  1. The process of making something square. 2. 

 Mathematics The process of constructing a squareequal in area to a given surface. 3.  Astronomy A

configuration in which the position of one celestial

 od! is "#$ from another celestial od!% as measured

from a third. –  The American &eritage' (ictionar!) *ourth +dition. ,###

Page 3: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 3/138

March 24, 2015 OSU/CSE 541 3

Outline

• (efinite -ntegrals

• ower and /pper 0ums

 –  Reimann -ntegration or Reimann 0ums• /niforml!1spaced samples

 –  Trape2oid Rules

 –  Romerg -ntegration

 –  0impson3s Rules –  Adaptive 0impson3s 0cheme

•  4on1uniforml! spaced samples –  5aussian Quadrature *ormulas

Page 4: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 4/138

March 24, 2015 OSU/CSE 541 4

What does an integral represent6

7asic definition of an integral)

 Motivation

∫    =b

adx x f  area89 ∫ ∫    =

c

b

adxdy x f  volume89

∑∫ =

∞→∆=

n

b

a   n x x f dx x f 

:

89lim89

sum of height × width

  f 9 x8

∆ x

n

ab x

  −=∆where

Page 5: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 5/138

March 24, 2015 OSU/CSE 541 5

• +valuate the integral% without doing the

calculation anal!ticall!.

•  4ecessar! when either)

 –  -ntegrand is too complicated to integrate anal!ticall!

 –  -ntegrand is not precisel! defined ! an equation% i.e.%we are given a set of data 9 xi , yi8% i ; :% ,% <% =%n

 Motivation

∫ =  b

adx x f  I  89

dxe x

 x x>.#

,

# >.#:

8:cos9,

∫  + ++

Page 6: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 6/138

March 24, 2015 OSU/CSE 541 6

• -ntegration is a summing process. Thus virtuall!all numerical appro?imations can e represented

 !

in which wi are the weights%  xi are the sampling

 points% and E t  is the truncation error • @alid for an! function that is continuous on the

closed and ounded interval of integration.

b

ai

n

i

i  E  x f wdx x f  I    +== ∫    ∑=

8989:

 eimann Integral !heorem

Page 7: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 7/138

March 24, 2015 OSU/CSE 541 7

• The most common numerical integration formula

is ased on equall! spaced data points.

• (ivide  x" , xnB into n intervals 9n≥:8

∫ n x

 xdx x f 

#

89

 #artitioning the Integral 

: ,

#

# : :

9 8 9 8 9 8 9 8n

n

n

 x x x x

 x x x x

 f x dx f x f x f x

= + + +∫ ∫ ∫ ∫  L

Page 8: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 8/138

March 24, 2015 OSU/CSE 541 8

$%%er &ums

• Assume that f'x()" ever!where*

• -f within each interval% we could determine

the ma?imum value of the function% then we

have)

• where

( )#

:

:

#

9 8n x n

i i i

i x

 f x M x x−

+=

≤ −∑∫ 

{ }:sup 9 8 )i i i M f x x x x += ≤ ≤ &u%remum + least

u%%er bound 

Page 9: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 9/138

March 24, 2015 OSU/CSE 541 9

$%%er &ums

• 5raphicall!)

 x" x x- x. x/

Page 10: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 10/138

March 24, 2015 OSU/CSE 541 10

 0ower &ums

• ikewise% still assuming that f'x()"

ever!where*

• -f within each interval% we could determine

the minimum value of the function% then we

have)

• where

( )#

:

:#

9 8n x n

i i ii x

 f x m x x−

+=

≥ −

∑∫ 

{ }:inf 9 8 )i i im f x x x x += ≤ ≤ Infimum + greatest

lower bound 

Page 11: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 11/138

March 24, 2015 OSU/CSE 541 11

 0ower &ums

• 5raphicall!

 x" x x- x. x/

Page 12: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 12/138

March 24, 2015 OSU/CSE 541 12

 1iner #artitions

• We now have a ound on the integral of thefunction for some partition 9 x" ,**,xn8)

• As n→∞% one would assume that the sum of theupper ounds and the sum of the lower oundsapproach each other.

• This is the case for most functions% and we callthese Riemann1integrale functions.

( ) ( )#

: :

: :

# #

9 8n x

n n

i i i i i i

i i x

m x x f x M x x− −+ +

= =

− ≤ ≤ −∑ ∑∫ 

Page 13: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 13/138

March 24, 2015 OSU/CSE 541 13

 2ounding the Integral 

• 5raphicall!

 x" x x- x. x/

Page 14: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 14/138

March 24, 2015 OSU/CSE 541 14

 2ounding the Integral 

• &alving each interval 'much like 0ab()

 x" x/ x3 x4 x5 

Page 15: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 15/138

March 24, 2015 OSU/CSE 541 15

 2ounding the Integral 

• ne more time)

 x" x3 x5 x x4

Page 16: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 16/138

March 24, 2015 OSU/CSE 541 16

 Monotonic 1unctions

•  4ote that if a function is monotonicall!

increasing 9or decreasing8% then the lower

sum corresponds to the left partition values%and the upper sum corresponds to the right

 partition values.

 x" x/ x3 x4 x5 

Page 17: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 17/138

March 24, 2015 OSU/CSE 541 17

 0ab and Integration

• Thinking ack to la:% what were the limits

or the integration6

• -s the sin function monotonic on this

interval6

• 0hould the Reiman sum e an upper or

lower sum6

Page 18: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 18/138

March 24, 2015 OSU/CSE 541 18

 #olynomial A%%roximation

• Rather than search for the ma?imum or minimum%

we replace f'x( with a known and simple function.

• Within each interval we appro?imate f 9 x8 ! an mth order pol!nomial.

m

mm  xa xa xaa x %   ++++= ...89 ,

,:#

Page 19: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 19/138

March 24, 2015 OSU/CSE 541 19

• The m3s 9order of the pol!nomials8 ma! e the

same or different.

• (ifferent choices for m3s lead to different

formulas)

: : ,

:

# #

: ,# # #

9 8 9 8 9 8 ... 9 8n m m m n

nm n mn

 x x x x

m m m x x x x

 f x dx % x dx % x dx % x dx+ + +

+ −= + + +∫ ∫ ∫ ∫  

89<DEs0impsonFcuic<

89:D<s0impsonFquadratic,

89Trape2oidlinear :

+rror *ormulaGol!nomial

H

H

,

hO

hO

hO

m

 Newton+6otes 1ormulas

Page 20: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 20/138

March 24, 2015 OSU/CSE 541 20

• 0implest wa! to appro?imate the area under a

curve – using first order polynomial 9a straight

line8• /sing 4ewton3s form of the interpolating

 pol!nomial)

•  4ow% solve for the integral)

( ) ( )∫ ∫    ≈=  b

a

b

adx x %dx x f  I  :

( ) ( )  ( ) ( )

( )a xab

a f b f a f  x %   −

−−

+=:

!ra%e7oid ule

Page 21: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 21/138

March 24, 2015 OSU/CSE 541 21

!ra%e7oid ule

( )  ( ) ( )

( )∫   

−−

+≈b

adxa x

ab

a f b f a f  I 

( )( ) ( )[ ]b f a f 

ab I    +

−≈

a b

  f 9a8  f 9b8

heightaveragewidth ×≈ I 

!ra%e7oid ule

Page 22: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 22/138

March 24, 2015 OSU/CSE 541 22

!ra%e7oid ule

• -mprovement6

 x" x x- x. x/

Page 23: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 23/138

March 24, 2015 OSU/CSE 541 23

• The integration error is)

• Where h 8 b + a and ξ  is an unknown point where

a I ξ  I b 9intermediate value theorem8

• Jou get e?act integration if the function% f, is

linear 9 f ′′  ; #8

( ) ( ) ,<

:,

89

:,

:h f 

abh f  E t    ξ ξ    ′′−

−=′′−=89

<

hO

!ra%e7oid ule Error 

Page 24: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 24/138

March 24, 2015 OSU/CSE 541 24

,

89   xe x f    −=-ntegrate from a ; # to b ; ,

( ) ( ) ( )[ ] [ ]

#:E<.:89: 

8#98,9,

8#,9,

 

#H

,

#

,

=+×=

+−=+−≈

=

−∫ 

ee

 f  f b f a f ab

dxe I    x

/se trape2oidal rule)

 Exam%le

Page 25: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 25/138

March 24, 2015 OSU/CSE 541 25

+stimate error)   ( ) <

:,

:h f  E t    ξ ′′−=

Where h 8 b + a and a I ξ  I b

(on3t know ξ  1 use average value,

8H,989,   x

e x x f    −

+−=′′

,>KH.#8,9

,8#9

=′′−=′′

 f 

 f 

( ) ( )[ ]>E.#

,

,#

:,

,<

=′′+′′

−=≈  f  f 

 E  E  at 

,#,   =−=h

 Exam%le

Page 26: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 26/138

March 24, 2015 OSU/CSE 541 26

Lore intervals% etter result error ∼ O9h-8B

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

n ; ,

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

n ; <

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

n ; H

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

n ; E

Page 27: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 27/138

March 24, 2015 OSU/CSE 541 27

• -f we do multiple intervals% we can avoid duplicate

function evaluations and operations)

• /se nM: equall! spaced points.• +ach interval has)

• 7reak up the limits of integration and e?pand.

n

abh

  −=

( ) ( ) ( )∫ ∫ ∫    −+

++ +++=   b

hb

ha

ha

ha

adx x f dx x f dx x f  I  ...,

6om%osite !ra%e7oid ule

Page 28: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 28/138

March 24, 2015 OSU/CSE 541 28

• 0ustituting the trape2oid rule for each integral.

• Results in the Composite Trape2oid *ormula)

( ) ( ) ( )

( )( ) ( )[ ]

  ( )( ) ( )[ ]

( )( ) ( )[ ]

,

,,

, ,

....,

...a h a h b

a a h b h

a h a a h a h f a f a h f a h f a h

b b h f b h f b

 I f x dx f x dx f x dx+ +

+ −

+ − + − −= + + + + + +

− ++ + − +

= + + +∫ ∫ ∫ 

( ) ( ) ( )

+++=   ∑−

=

b f iha f a f h

 I n

i

:

:

,,

6om%osite !ra%e7oid ule

Page 29: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 29/138

March 24, 2015 OSU/CSE 541 29

( ) ( ) ( )

( )

( ) ( ) ( )

n

b f iha f a f 

ab

b f iha f a f h

 I 

n

i

n

i

,

,

,,

:

:

:

:

+++−=

+++=

∑−

=

=

width

Average height

6om%osite !ra%e7oid ule

• Think of this as the width times the average

height*

Page 30: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 30/138

March 24, 2015 OSU/CSE 541 30

• The error can e estimated as)

• Where% is the average second derivative.

• -f n is douled% h → hD, and E a →  E aDH•  4ote% that the error is dependent upon the

width of the area eing integrated.

( ) ( ) f n

ab

 f 

hab

 E a   ′′−

=′′−

= ,

<,

:,:,

 f  ′′

89,

hO

 Error 

Page 31: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 31/138

March 24, 2015 OSU/CSE 541 31

0

5

10

15

20

25

30

35

40

0 0.2 0.4 0.6 0.8 1 1.2

 Exam%le

• -ntegrate)

• from

a;#.,to

b;#.E

( ) >H<, ,##E:#N<#:H#,#<.#   x x x x x x f    +−+−+=

Page 32: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 32/138

March 24, 2015 OSU/CSE 541 32

( )

  ( ) ( )

( )

,K.::

,

E:.<,,.<H,.#E.#

,

=

+−=

+−=

b f a f 

ab I 

 Exam%le

• A single application of the Trape2oid rule.

• +rror)( ) ( )<

:,

:ab f  E t    −′′−=   ξ 

Page 33: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 33/138

March 24, 2015 OSU/CSE 541 33

 Exam%le

• We don3t know ξ  so appro?imate with

average f ′′ 

( ) <, H###"N,#H<E#,E#  x x x x f    +−+−=′′

( ) H<, :###<,H#,:"#,E#,#  x x x x x f    +−+−=′

( )

K.:<:,.#E.#

8,.#98E.#9 

,.#E.#

 

E.#

,.#

−=−

′−′=

−′′=′′   ∫ 

 f  f 

dx f  x f 

Page 34: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 34/138

March 24, 2015 OSU/CSE 541 34

( ) ( )

( ) ( )

<,

,

<

:, :,

::<:.K #.E #., ,.<N

:,

b a h b a

 E f f n

− −′′ ′′= =

= − − − =

 Exam%le

• The error can thus e estimated as)

Page 35: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 35/138

March 24, 2015 OSU/CSE 541 35

0

5

10

15

20

25

30

35

40

0 0.2 0.4 0.6 0.8 1 1.2

True value of integral is :,.E,. Trape2oid

rule is ::.,K 1 within appro? error 1 E t  is :,O

Page 36: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 36/138

Page 37: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 37/138

March 24, 2015 OSU/CSE 541 37

0

5

10

15

20

25

30

35

40

0 0.2 0.4 0.6 0.8 1 1.2

 E t  is now ,O

Page 38: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 38/138

March 24, 2015 OSU/CSE 541 38

( )  ( ) ( ) ( ) ( ) ( ) ( )[ ]   ( )

( )

NK.:, :,

,,.<H,,.<>:K.<#:E.,,"<.:<<H.N,<:.<K.# 

8K89,9

E.#N.#K.#>.#H.#<.#,,.#,.#E.#

=

++++++=

++++++−=   f  f  f  f  f  f  f 

 I 

$sing &ix Intervals

• /se intervals 9#.,%#.<8%9#.<%#%H8% etc.

 – 9n ; K% h ; #.:8

True value of integral is :,.E,

Page 39: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 39/138

March 24, 2015 OSU/CSE 541 39

0

5

10

15

20

25

30

35

40

0 0.2 0.4 0.6 0.8 1 1.2

 E t  is now #.>O

Page 40: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 40/138

March 24, 2015 OSU/CSE 541 40

 Multi+dimensional Integration

• Consider a two1dimensional case.

( ): : :

## # #

:

# #

# #

# #

% %

%

%

%

n

ii

n

i

i

n n

i 9

i 9

n n

i 9

i 9

i f x y dxdy A f y dy

n

i A f y dy

n

i 9 A A f n n

i 9 A A f 

n n

=

=

= =

= =

 ≈     

 =      

 ≈      

 =      

∑∫∫ ∫ ∑   ∫ 

∑ ∑

∑∑

Page 41: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 41/138

March 24, 2015 OSU/CSE 541 41

 Multi+dimensional Integration

• *or the Trape2oid Rule% this leads to

weights in the following pattern): , , , , , :

, H H H H H ,

, H H H H H ,

, H H H H H ,

, H H H H H ,

, H H H H H ,

: , , , , , :

{ } { }

[ ]   { }

[ ]

[ ] [ ]

,

: #% #%

, :% % , :% ::

, P:% : :% % :H

H :% % , :% % ,

i9

i n 9 n

i n 9 n A

i n 9 nn

i n 9 n

∈ ∈ ∈ − ∈ −=   ∈ − ∈ −

  ∈ − ∈ −

K K 

:

,

,

,

,

,

:

: , , , , , :

Page 42: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 42/138

March 24, 2015 OSU/CSE 541 42

 Multi+dimensional Integration

• -f we use the weights from the Trape2oid

rule% the error is still O9h,8.

• &owever% there are now n, function

evaluations.

 – +quall!1spaced samples on a square region.

Page 43: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 43/138

March 24, 2015 OSU/CSE 541 43

 Multi+dimensional Integration

• -n general% given k  dimensions% we have N8 nk  function evaluations)

• -f the dimension is high% this leads to a

significant amount of additional work ingoing from h→ hD,. – Rememer this for Lonte1Carlo -ntegration.

( ) ( ) ( ),,

, , k  k k O h O n O n O N  −−−      = = =            

Page 44: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 44/138

March 24, 2015 OSU/CSE 541 44

 educing the Error 

• To improve the estimate of the integral% we

can either)

 – Add more intervals

 – /se a higher order pol!nomial

 – /se Richardson +?trapolation to e?amine the

limit as h→#.• Called Romerg -ntegration

Page 45: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 45/138

March 24, 2015 OSU/CSE 541 45

 Adding More Intervals

• -f we have an estimate for one value of h%

do we need to recompute ever!thing for a

value of hD,6

( ) ( ) ( ):

:

,,

n

h

i

h I f a f a ih f b

=

= + + + ∑

Page 46: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 46/138

March 24, 2015 OSU/CSE 541 46

 Adding More Intervals

• This is called the Recursive Trapezoid

Rule in the ook.

• We have n→  ,n and h→ hD,.

( )

, :

:,

: :

: #

:

#

9 8 , 9 8H ,

9 8 , , 9 8H ,

,, H ,

n

h

i

n n

i i

nh

i

h h I f a f a i f b

h h f a f a ih f a ih f b

 I  h h f a ih

=

− −

= =

=

 = + + +    

 = + + + + + +      = + + +    

∑ ∑

Page 47: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 47/138

March 24, 2015 OSU/CSE 541 47

• 5iven two numerical estimates otained

using different h3s% compute higher1order

estimate• 0tarting with a step si2e h,% the e?act value is

• 0uppose we reduce step si2e to h-

8989 ::

nhOh A A   +=

8989 ,,

nhOh A A   +=

 ecall ichardson Extra%olation

Page 48: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 48/138

March 24, 2015 OSU/CSE 541 48

• Lultipl!ing the ,nd eqn ! 9h,Dh-8n and

sutracting from the :st eqn)

• The new error term is generall! O9h,n:,8 or

O9h,n:-8.

:

8989

,

:

:,

,

:

−  

 

 

 

 

−    

  

=n

n

h

h

h Ah Ah

h

 A

 ichardson Extra%olation

Page 49: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 49/138

March 24, 2015 OSU/CSE 541 49

• The true integral value can e written

• This is true for an! iteration

 ichardson Extra%olation

( ) ( )h E h I  I    +=

( ) ( ) ( ) ( ),,::   h E h I h E h I  I    +=+=

Page 50: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 50/138

March 24, 2015 OSU/CSE 541 50

 ichardson Extra%olation

• *or e?ample) /sing 9n ; ,8

• where c is a constant

• Therefore)( )

( ) ,

,

,

:

,

:

h

h

h E 

h E ≈

 f ch E    ′′≈

,

error ; O9h-

8B

order of error in

tra%e7oidal rule

Page 51: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 51/138

March 24, 2015 OSU/CSE 541 51

• This leads to)

• *or integration% we have)

( ) ( ) ,

,

,

:,:

h

hh E h E    ≈

( ) ( ) ( ) ( ),,,

,

,

:,:   h E h I 

hhh E h I    +≈+

 ichardson Extra%olation

Page 52: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 52/138

March 24, 2015 OSU/CSE 541 52

 ichardson Extra%olation

• 0olving for E 9h-8)

• And plugging ack into the estimatedintegral.

( )  ( ) ( )

,

,

,

:

,:,

:h

h

h I h I h E 

−≈

( ) ( ),,   h E h I  I    +=

Page 53: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 53/138

March 24, 2015 OSU/CSE 541 53

• eads to)

• etting h- ; h, D,

 ichardson Extra%olation

( ) ( )   ( ) ( )[ ]:,,,:

, :D

:

h I h I hhh I  I    −−+≈

( ) ( ) ( )[ ]

( ) ( ):,

:,,,

<

:

<

H

:,

:

h I h I  I 

h I h I h I  I 

−≈

−−+≈

Page 54: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 54/138

March 24, 2015 OSU/CSE 541 54

• We comined two O9h-8 estimates to get an

O9h.8 estimate.

• Can also comine two O9h.8 estimates to

get an O9h; 8 estimate.

( ) ( )l m   h I h I  I  :>

:

:>

:K

−≈

 omberg Integration

Page 55: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 55/138

March 24, 2015 OSU/CSE 541 55

 omberg Integration

• 5reater weight is placed on the more

accurate estimate.

• Weighting coefficients sum to unit!

 – i.e% 9:K1:8D:>;:

• Can continue% ! comining two O9h; 8

estimates to get an O9h<8 estimate.

( ) ( )l m   h I h I  I K<

:

K<

KH−≈

Page 56: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 56/138

March 24, 2015 OSU/CSE 541 56

• 5eneral pattern is called Romerg -ntegration

 –  9 ) level of sudivision% 9M: has more intervals.

 – k  ) level of integration% k ; : is original trape2oid

estimate O9h-8B% k ; , is improved O9h.8B% etc.

( )% :%

% : % % :%

H :

H : H :

 9 k 9 k 

 9 k 9 k 9 k 9 k k k 

 I I 

 I I I I −

+ −

≈ = + −− −

 omberg Integration

Page 57: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 57/138

March 24, 2015 OSU/CSE 541 57

 omberg Integration

• *or e?ample% 9 ; :% k ; : leads to

( ):%# #%# :

:%: :

H H :

< < , <

 I I  h

 I I I h

−    = ≈ − ÷  

Page 58: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 58/138

March 24, 2015 OSU/CSE 541 58

• Consider the function)

• -ntegrate from a ; # to b ; #.E

• /sing the trape2oidal rule !ields the

following results)

>H<, H##"##KN>,##,>,.#89  x x x x x x f    +−+−+=

 Exam%le

Page 59: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 59/138

March 24, 2015 OSU/CSE 541 59

intervals -ntegral

  : #.E #.:N,E

  , #.H :.#KEE

  H #., :.HEHE

h

 Exam%le

• Trape2oid Rules)

 Exact integral is *;."3///.

<KNHKKN.:8:N,E.#9<

:8#KEE.:9

<

H=−= I 

9 9;:% k ;:8

 k 

 9

k  ; # k  ; :

 9 ; #

 9 ; :

 9 ; ,

Page 60: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 60/138

March 24, 2015 OSU/CSE 541 60

, Hsegments 9 8 9 8

  : #.E #.:N,E

, #.H :.#KEE :.<KNHKKN

  H #., :.HEHE

h O h O h

 k 

 9

K,<HKKKN.:8#KEE.:9<

:8HEHE.:9

<

H=−= I  9 9;,% k ;:8

k  ; :k  ; #

 Exact integral is *;."3///.

 Exam%le

Page 61: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 61/138

March 24, 2015 OSU/CSE 541 61

 Exam%le

, H

segments 9 8 9 8  : #.E #.:N,E

  , #.H :.#KEE :.<KNHKKN

  H #., :.HEHE :.K,<HKKKN

h O h O h

 k 

 9

9 9;,% k ;,8

k  ; ,k  ; :

 Exact integral is *;."3///.

KH#><<<H.:8<KNHKKN.:9:>

:8K,<HKKKN.:9

:>

:K=−= I 

Page 62: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 62/138

March 24, 2015 OSU/CSE 541 62

, H Ksegments 9 8 9 8 9 8

  : #.E #.:N,E

  , #.H :.#KEE :.<KNHKKN

  H #., :.

h O h O h O h

HEHE :.K,<HKKKN :.KH#><<<H

 k 

 9

k  ; <k  ; ,k  ; :

 Exam%le

Page 63: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 63/138

March 24, 2015 OSU/CSE 541 63

, H K Esegments 9 8 9 8 9 8 9 8

: #.E #.:N,E

  , #.H :.#KEE :.<KNHKKN

  H

h O h O h O h O h

  #., :.HEHE :.K,<HKKKN :.KH#><<<H

  E #.: 66 66 66 66

668KH#><<<H.:9K<

:9668

K<

KH=−= I  9 9;<% k ;<8

 k 

 9

k  ; <

 Exam%le

• 7etter and etter results can e otained !

continuing this

Page 64: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 64/138

March 24, 2015 OSU/CSE 541 64

 omberg Integration

• -s this that  significant6

• Consider the cost of computing the

Trape2oid Rule for :### data points. – Refinement would lead to ,### data points.

• -mplies an additional :##< operations using theRecursive Trape2oid Rule.

•  4ot to mention the :### 9e?pensive8 function evals.

 – Romerg -ntegration cost)• Three additional operations – no function evals

Page 65: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 65/138

March 24, 2015 OSU/CSE 541 65

 =igher+Order #olynomials

• Recall)

89<DEs0impsonFcuic<89:D<s0impsonFquadratic,

89Trape2oidlinear :

+rror *ormulaGol!nomial

H

H

,

hOhO

hO

m

: : ,

:

# #

: ,

# # #

9 8 9 8 9 8 ... 9 8n m m m n

n

m n mn

 x x x x

m m m x x x x

 f x dx % x dx % x dx % x dx+ + +

+ −

= + + +

∫ ∫ ∫ ∫  

Page 66: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 66/138

March 24, 2015 OSU/CSE 541 66

• -f we use a ,nd order pol!nomial 9need <

 points or , intervals8)

 – agrange form.

( ) ( )

( ) ( )  ( )

  ( ) ( )

( ) ( )  ( )

( ) ( )

( ) ( )  ( ) dx x f 

 x x x x

 x x x x

 x f  x x x x

 x x x x x f 

 x x x x

 x x x x I 

 x

 x

−−

−−+

−−

−−+

−−

−−= ∫ 

,

:,#,

:#

:

,:#:

,##

,#:#

,:,

#

   

     +=

,,#

: x x x

&im%son>s ?/ ule

Page 67: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 67/138

March 24, 2015 OSU/CSE 541 67

&im%son>s ?/ ule

• Requiring equall!1spaced intervals)

( ) ( )

( )   ( )  ( ) ( )

( ) ( )   ( )

( ) ( )

( ) ( )  ( )

,

#

# # # ## :

# #

,

, ,

,

,

 x

 x

 x x h x x h x x x x h I f x f xh h h h

 x x x x h f x dx

h h

  − − − − − − −= + − − −

− − −+  

∫ 

Page 68: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 68/138

March 24, 2015 OSU/CSE 541 68

• -ntegrate and simplif!)

0

2

4

6

8

10

12

3 5 7 9 11 13 15

( ) ( ) ( )[ ],:# H

<

 x f  x f  x f h

 I    ++≈,

abh

  −=

&im%son>s ?/ ule

Quadratic

 #olynomial 

Page 69: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 69/138

March 24, 2015 OSU/CSE 541 69

• -f we use a 8 x" and b 8 x-% and

 x, 8 9b:a8D,

&im%son>s ?/ ule

( )  ( ) ( ) ( )

K

H ,:#   x f  x f  x f ab I 

  ++−≈

widthaverage height

Page 70: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 70/138

March 24, 2015 OSU/CSE 541 70

• +rror for 0impson3s :D< rule

⇒-ntegrates a cuic e?actl!)  ( ) ( ) #H =ξ  f 

( )

( )

  ( )   ( )

( )ξ ξ H

>

H>

,EE#"#  f 

ab

 f 

h

 E t −

−=−=

,

abh

  −=

89>

hO

&im%son>s ?/ ule

Page 71: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 71/138

March 24, 2015 OSU/CSE 541 71

6om%osite &im%son>s ?/ ule

• As with Trape2oidal rule% can use multiple

applications of 0impson3s :D< rule.

•  4eed even numer of intervals

 – An odd numer of points are required.

Page 72: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 72/138

March 24, 2015 OSU/CSE 541 72

6om%osite &im%son>s ?/ ule

• +?ample) " points% H intervals

-5

0

5

10

15

20

25

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5

Page 73: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 73/138

March 24, 2015 OSU/CSE 541 73

• As in composite trape2oid% reak integral up

into nD, su1integrals)

• 0ustitute 0impson3s :D< rule for each

integral and collect terms.

6om%osite &im%son>s ?/ ule

( ) ( ) ( )∫ ∫ ∫    −+++=

  n

n

 x

 x

 x

 x

 x

 xdx x f dx x f dx x f  I 

,

H

,

,

#

...

( )

( ) ( )   ( )   ( ): ,

#

:%<%> ,%H%K

H ,

<

n n

i 9 n

i 9

 f x f x f x f x

 I b an

− −

= =

+ + += −

∑ ∑

n:: data points% an odd numer 

Page 74: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 74/138

March 24, 2015 OSU/CSE 541 74

• dd coefficients receive a weight of H% even

receive a weight of ,.

• (oesn3t seem ver! fair% does it6

coefficients on

numerator : H :

: H :

:H :

i ; # 

i ; n 

6om%osite &im%son>s ?/ ule

Page 75: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 75/138

March 24, 2015 OSU/CSE 541 75

• The error can e estimated !)

• -f n is douled% h → hD, and E a →  E aD:K

( ) 8H9H

8H9>

:E#:E#

 f hab

 f nh

 E a−

==

8H9 f 

is the average Hth derivative

89 HhO

 Error Estimate

Page 76: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 76/138

March 24, 2015 OSU/CSE 541 76

• -ntegrate from a ; # to b ; ,.

• /se 0impson3s :D< rule)

( ) ( )

( ) ( )

,,

# : ,#

# : H

:  H 9 8

<

:  # H 9:8 ,<

:  9 H 8 #.E,""H

<

 x I e dx h f x f x f x

 f f f 

e e e

− −

= ≈ + +

= + +

= + + =

∫ 

,

89   xe x f    −=

, :,

 # :,

,:#   ===+====−=   b xba xa xabh

 Exam%le

Page 77: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 77/138

March 24, 2015 OSU/CSE 541 77

• +rror estimate)

• Where h 8 b + a and a I ξ  I b

• (on3t know ξ   –  use average value

( ) ( )ξ H>

"# f 

h E t    −=

( )

( )

( )  ( )

( )  ( )

( )H H H

> > # : ,H: :

"# "# <t a

 f x f x f x E E f  + + ≈ = − = −

 Exam%le

Page 78: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 78/138

March 24, 2015 OSU/CSE 541 78

• et3s look at the pol!nomial again)

 – *rom a ; # to b ; #.E

>H<, H##"##KN>,##,>,.#89  x x x x x x f    +−+−+=

E.# H.#,

 # H.#,

,:#   ===+

====−

=   b xba

 xa xab

h

( ) ( )[ ]

( ) ( )[ ]

<KNHKKKN.: 

E.#8H.#9H#<

8H.#9 

89H

<

: 89 ,:#

,

#

=

++=

++≈=

∫  f  f  f 

 x f  x f  x f hdx x f  I 

 Exact integral is *;."3///.

 Another Exam%le

Page 79: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 79/138

March 24, 2015 OSU/CSE 541 79

• Actual +rror) 9using the known e?act value8

• +stimate error) 9if the e?act value is not

availale8

• Where a I ξ  I b*

( ) ( )ξ H>

"# f 

h E t    −=

,N<#KKKK.#<KNHKKKN.:1:.KH#><<<H   == E  :KO

 Error 

Page 80: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 80/138

March 24, 2015 OSU/CSE 541 80

• Compute the fourth1derivative

• Latches actual error prett! well.

 Error 

 x x  f     HE###,:K##898H9+−=

( ) ( )   ( ) ( )   ,N<#KKKN.#H.#"#

H.#

"#

H.#   H>

:

H>

=−=−=≈   f   x  f   E  E  at 

middle %oint 

Page 81: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 81/138

March 24, 2015 OSU/CSE 541 81

• -f we use H segments instead of :)

 –  x  ; #.# #., #.H #.K #.EB#.,

b ah

n

−= =

,<,.#8E.#9 HKH.<8K.#9

H>K.,8H.#9 ,EE.:8,.#9 ,.#8#9

==

===

 f  f 

 f  f  f 

( )

( ) ( )   ( )   ( )

( )

K,<HKKN.: 

:,

,<,.#8H>K.,9,8HKH.<,EE.:9H,.#E.# 

8H89<9

8E.#98K.#9H8H.#9,8,.#9H8#9#E.# 

<

,H:

>%<%:

,

K%H%,

#

=

++++=

++++−=

+++−=

∑ ∑−

=

=

 f  f  f  f  f 

n

 x f  x f  x f  x f 

ab I 

n

n

i

n

 9

 9i

 Exact integral is *;."3///.

 Exam%le 6ontinued 

Page 82: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 82/138

March 24, 2015 OSU/CSE 541 82

• Actual +rror) 9using the known e?act value8

• +stimate error) 9if the e?act value is not

availale8

#:N#KKKN.#K,<HKKN.:1:.KH#><<<H   == E  :O

( ) ( )   ( ) ( ) ##E>.#H.#

"#

,.#

"#

,.# H>

,

H>

−=−=−=≈   f  x f  E  E  at 

middle %oint 

 Error 

Page 83: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 83/138

March 24, 2015 OSU/CSE 541 83

 Error 

• Actual is twice the estimated% wh!6

• Recall)

 x x  f     HE###,:K##898H9 +−=

[ ] { }9 H8 9 H8

#%#.E

9 H8

ma? 9 8 9#8 ,:K##

9#.H8 ,H##

 x  f x f  

  f  

= = −

=

Page 84: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 84/138

March 24, 2015 OSU/CSE 541 84

 Error 

• Rather than estimate% we can ound the

asolute value of the error)

• *ive times the actual% ut provides a safer

error metric.

( ) ( )   ( ) ( )> >

H H#., #.,# #.#NKE

"# "#a E f f ξ = − ≤ =

Page 85: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 85/138

March 24, 2015 OSU/CSE 541 85

&im%on>s ?/ ule

• 0impson3s :D< rule uses a ,nd order pol!nomial

 –  need < points or , intervals

 –  This implies we need an even numer of intervals.• What if !ou don3t have an even numer of

intervals6 Two choices)

:. /se 0impson3s :D< on all the segments e?cept the last

9or first8 one% and use trape2oidal rule on the one left. –  Gitfall 1 larger error on the segment using trape2oid

,. /se 0impson3s <DE rule.

Page 86: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 86/138

March 24, 2015 OSU/CSE 541 86

• 0impson3s <DE rule uses a third order pol!nomial

 –  need < intervals 9H data points8

<

<

,

,:#< 8989   xa xa xaa x % x f    +++=≈

( ) ( )∫ ∫    ≈=

<

#

<

#<

 x

 x

 x

 x dx x %dx x f  I 

&im%son>s /?< ule

Page 87: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 87/138

March 24, 2015 OSU/CSE 541 87

&im%son>s /?< ule

• (etermine a3s with agrange pol!nomial

• *or evenl! spaced points

<

ab

h

  −

=

( ) ( ) ( ) ( )[ ]<,:# <<E

<  x f  x f  x x f h I    +++=

Page 88: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 88/138

March 24, 2015 OSU/CSE 541 88

• 0ame order as :D< Rule.

 – Lore function evaluations.

 – -nterval width% h% is smaller.

• -ntegrates a cuic e?actl!)

⇒   ( ) ( ) #H =ξ  f 

( ) ( )H><

E#t  E h f    ξ = − 89 HhO

 Error 

Page 89: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 89/138

March 24, 2015 OSU/CSE 541 89

6om%arison

• 0impson3s :D< rule and 0impson3s <DE rule have thesame order of error  –  O9h.8

 –  trape2oidal rule has an error of O9h-8

• 0impson3s :D< rule requires even number ofsegments.

• 0impson3s <DE rule requires multiples of threesegments.

• 7oth 0impson3s methods require evenly spaced data points

Page 90: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 90/138

March 24, 2015 OSU/CSE 541 90

• n ; :# points ⇒ " intervals

 –  *irst K intervals 1 0impson3s :D<

 –  ast < intervals 1 0impson3s <DE

0impson3s :D<

0impson3s <DE

 Mixing !echni@ues

Page 91: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 91/138

March 24, 2015 OSU/CSE 541 91

• We can e?amine even higher1order

 pol!nomials.

 –  0impson3s :D< 1 ,nd order agrange 9< pts8 –  0impson3s <DE 1 <rd order agrange 9H pts8

• /suall! do not go higher.

• /se multiple segments. –  7ut onl! where needed.

 Newton+6otes 1ormulas

Page 92: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 92/138

March 24, 2015 OSU/CSE 541 92

 Ada%tive &im%son>s &cheme

• Recall 0impson3s :D< Rule)

• Where initiall!% we have a; x" and b; x-.

• 0udividing the integral into two)

( ) ( ) ( )[ ],:# H

<

 x f  x f  x f h

 I    ++≈

( ) ( ) ( ) ( ) ( ): , <H , HK

h I f a f x f x f x f b≈ + + + +

Page 93: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 93/138

March 24, 2015 OSU/CSE 541 93

 Ada%tive &im%son>s &cheme

• We want to keep sudividing% until we

reach a desired error tolerance% ε.

• Lathematicall!)

( ) ( ) ( ) ( )

( ) ( ) ( ) ( ) ( ) ( )

:

: , <

H<

H , HK

b

a

b

a

h f x dx f a f x f b

h f x dx f a f x f x f x f b

ε 

ε 

− + + ≤

− + + + + ≤

∫ 

∫ 

Page 94: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 94/138

March 24, 2015 OSU/CSE 541 94

 Ada%tive &im%son>s &cheme

• This will e satisfied if)

• The left and the right are within one1half of theerror.

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

: ,

, <

,

H %K ,

H %K ,

,

c

a

b

c

h f x dx f a f x f x and 

h f x dx f x f x f b where

a bc x

ε 

ε 

− + + ≤

− + + ≤

+= =

∫ 

∫ 

Page 95: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 95/138

March 24, 2015 OSU/CSE 541 95

 Ada%tive &im%son>s &cheme

• ka!% now we have two separate intervals

to integrate.

• What if one can e solved accuratel! withan h;:#1<% ut the other requires man!%

man! more intervals% h;:#1K6

Page 96: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 96/138

March 24, 2015 OSU/CSE 541 96

 Ada%tive &im%son>s &cheme

• Adaptive 0impson3s method provides a

divide and conquer scheme until the

appropriate error is satisfied ever!where.• @er! popular method in practice.

• Grolem)

 – We do not know the e?act value% and hence donot know the error.

Page 97: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 97/138

March 24, 2015 OSU/CSE 541 97

 Ada%tive &im%son>s &cheme

• &ow do we know whether to continue to

sudivide or terminate6

( ) ( ) ( )

( ) ( ) ( )

( )   ( )>

H

% % %

% H %

K ,:

%"# ,

b

a

 I f x dx & a b E a b where

b a a b& a b f a f f b and  

b a E a b f 

≡ = +

− +  = + +  

  −  = −    

 

∫ 

Page 98: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 98/138

March 24, 2015 OSU/CSE 541 98

 Ada%tive &im%son>s &cheme

• The first iteration can then e defined as)

• 0usequent sudivision can e defined as)

( )

( ) ( )

,

% %& & a c & c b= +

( ) ( )

( ) ( )   ( ) ( )

: :

: :

%

% % %

 I & E where

& & a b E E a b

= +

= =

Page 99: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 99/138

March 24, 2015 OSU/CSE 541 99

 Ada%tive &im%son>s &cheme

•  4ow% since

• We can solve for E 9,8 in terms of E 9:8.

( ) ( ) ( )

( ) ( )

> >

, H H

>H :

H

: D , : D ,

"# , "# ,

: : :

, "# , :K

h h E f f 

h f E 

 = − −    

 = − =    

( ) ( ) ( ),

% % E E a c E c b= +

Page 100: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 100/138

March 24, 2015 OSU/CSE 541 100

 Ada%tive &im%son>s &cheme

• *inall!% using the identit!)

• We have)

• Glugging into our definition)

( ) ( ) ( ) ( ): : , , I & E & E = + = +

( ) ( ) ( ) ( ) ( ), : : , ,:>& & E E E  − = − =

( ) ( ) ( ) ( ) ( )( ), , , , ::

:> I & E & & & = + = + −

Page 101: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 101/138

March 24, 2015 OSU/CSE 541 101

 Ada%tive &im%son>s &cheme

• ur error criteria is thus)

• 0implif!ing leads to the termination

formula)

( ) ( ) ( )

( )

, , ::

:> I & & &    ε − = − ≤

( ) ( )

( ), :

:>& &    ε − ≤

Page 102: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 102/138

March 24, 2015 OSU/CSE 541 102

 Ada%tive &im%son>s &cheme

• What happens graphicall!)

Page 103: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 103/138

March 24, 2015 OSU/CSE 541 103

:, :>&   subd v&  i ideε − ≥ →

Page 104: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 104/138

March 24, 2015 OSU/CSE 541 104

Page 105: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 105/138

March 24, 2015 OSU/CSE 541 105

:, :>

,

 subdivide& &   ε 

− ≥ →

Page 106: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 106/138

March 24, 2015 OSU/CSE 541 106

( ), :,

:

:>

&  I  & & = + −

:, :>H

&    o&    d neε 

− ≤ →

Page 107: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 107/138

March 24, 2015 OSU/CSE 541 107

:, :>H

 subdivide& &   ε 

− ≥ →

Page 108: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 108/138

March 24, 2015 OSU/CSE 541 108

( ), :,

:

:>

&  I  & & = + −

Page 109: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 109/138

March 24, 2015 OSU/CSE 541 109

( ), :,

:

:>&  I  & & = + −

Page 110: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 110/138

March 24, 2015 OSU/CSE 541 110

 I8I left  : I right 

 I right 

 8I left 

 : I right 

Page 111: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 111/138

March 24, 2015 OSU/CSE 541 111

Page 112: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 112/138

March 24, 2015 OSU/CSE 541 112

Page 113: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 113/138

March 24, 2015 OSU/CSE 541 113

 Ada%tive &im%son>s &cheme

• We graduall! capture the difficult spots.

Page 114: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 114/138

March 24, 2015 OSU/CSE 541 114

 Ada%tive &im%son>s 6ode

• 0imple Recursive Grogramstatic const int m_nMaximum_Divisions = 1000;Real IntegrationSimpson( const Real (*f) (Real x) const Real start const Real en! const Real

error_tolerance int "level )

#level $= 1;Real % = (en! & start);Real mi!point = (start $ en!) ' 0;Real f_start = f(start);Real f_en! = f(en!);Real f_mi! = f(mi!point );oneevel = %*( f_start $ +0*f_mi! $ f_en!) ' ,0;Real leftMi!point = (start$ mi!point ) ' 0;Real rig%tMi!point = (en!$ mi!point ) ' 0Real f_mi!eft = f(leftMi!point );Real f_mi!Rig%t = f(rig%tMi!point );t-oevel = %*(f_start $ +0* f_mi!eft $ 0* f_mi! $ +0* f_mi!Rig%t $ f_en!) ' 10;if( level .= m_nMax_Divisions ) '' /erminate t%e process converging too slo-

return t-oevel;

Page 115: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 115/138

March 24, 2015 OSU/CSE 541 115

 Ada%tive &im%son>s 6ode

if( asf( t-oevel & oneevel) 120*error_tolerance) '' Desire! solution reac%e!return t-oevel $ (t-oevel3oneevel) ' 120;

''

'' 4t%er-ise split t%e interval in t-o an! recursivel5 evaluate eac% %alf''leftIntegral = IntegrationSimpson( f start mi!point error_tolerance'0 level );rig%tIntegral = IntegrationSimpson( f mi!point en! error_tolerance'0 level );return leftIntegral $ rig%tIntegral;

d

Page 116: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 116/138

March 24, 2015 OSU/CSE 541 116

• -dea is that if we evaluate the function at certain

 points% and sum with certain weights% we will get a

more accurate integral

• +valuation points and weights are pre1computed

and taulated

• 7asic form)

∫    ∑− =

≈=:

: :

8989n

i

ii  x f cdx x f  I 

 ci ) weighting factors

  xi ) sampling points selected optimall!

uassian Quadrature

 NewBB

Q d

Page 117: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 117/138

March 24, 2015 OSU/CSE 541 117

•  4ote that the interval is etween –: and :

• *or other intervals% a change of variales is used to

transfer the prolem so that it utili2es the interval1:% :B

• This is a linear transform% such that for t ∈a%B)

• We have for x∈1:%:B)

∫ b

adt t  f  89

,

89 ab xabt 

  ++−=

ab

abt  x

−−−

=,

uassian Quadrature

Q d

Page 118: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 118/138

March 24, 2015 OSU/CSE 541 118

• As t 8 a ⇒  x ; 1:

• As t 8 b ⇒  x ; :

dxab

dt ,

89   −=

  

  

    ++−=

,

8989

  ab xab f t  f 

dxab xab

 f ab

dt t  f b

a   ∫ ∫    −   

  

     ++−−

=:

: ,

89

,

8989

uassian Quadrature

Q d

Page 119: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 119/138

March 24, 2015 OSU/CSE 541 119

• 7asic form of 5aussian quadrature)

• *or n;,% we have)

• This leads to H unknowns) c% c-% x% and x-

 – two unknown weights 9c% c-8 

 – two unknown sampling points 9 x% x-8 

∫    ∑−

=

≈=:

:

:

8989n

i

ii  x f cdx x f  I 

( ) ( ),,::   x f c x f c I    +≈

uassian Quadrature

i Q d

Page 120: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 120/138

March 24, 2015 OSU/CSE 541 120

uassian Quadrature

• What we need now% are four known values

for the equation.

• -f we had these% we could then attempt tosolve for the four unknowns.

• et3s make it work for pol!nomials

i Q d

Page 121: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 121/138

March 24, 2015 OSU/CSE 541 121

• -n particular% let3s look at these simple pol!nomials) –  Constant

•  f'x(8

 –  inear •  f'x(8x

 –  Quadratic

•  f'x(8x-

 –  Cuic•  f'x(8x/

uassian Quadrature

i Q d

Page 122: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 122/138

March 24, 2015 OSU/CSE 541 122

uassian Quadrature

• Recalling the formula)

 –  Constant

•  f'x(8

 –  inear 

•  f'x(8x

 –  Quadratic

•  f'x(8x-

 –  Cuic

•  f'x(8x/

( ) ( )

( ) ( )

( ) ( )

( ) ( ) <

,,

<

::,,::

:

:

<

,

,,

,

::,,::

:

:

,

,,::,,::

:

:

,:,,::

:

:

 #<

,

 #

 ,:

 xc xc x f c x f cdx x

 xc xc x f c x f cdx x

 xc xc x f c x f c xdx

cc x f c x f cdx

+=+==

+=+==

+=+==

+=+==

∫ 

∫ 

∫ ∫ 

( ) ( ),,::  x f c x f c I    +≈

i Q d

Page 123: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 123/138

March 24, 2015 OSU/CSE 541 123

• We can now solve for our unknowns) –  Note, this is not an easy %roblem and will not be

covered in this class*

>NN.#<:

>NN.#<

:

:

,

:

,:

==

−=−=

==

 x

 x

cc

uassian Quadrature

i Q d t

Page 124: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 124/138

March 24, 2015 OSU/CSE 541 124

uassian Quadrature

• This !ields the two point Gauss!egendre 

formula

   

  + 

  

  −≈

<:

<:  f  f  I 

i Q d t

Page 125: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 125/138

March 24, 2015 OSU/CSE 541 125

uassian Quadrature

• This is exact for all pol!nomials up to and

including degree < 9cuics8.

( )

( )

( )

: : : : :< , < ,

: : : : :

< < , ,

:

<

:

<

: : : : : :: :

< < < < < <

< ,

ax bx cx d dx a x dx b x dx c xdx d dx

a b c d

ax bx cx d  

− − − − −

+ + + = + + +

    − − −  = + + + + + + +               

=

∫ ∫ ∫ ∫ ∫  

+ + +

i Q d t

Page 126: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 126/138

March 24, 2015 OSU/CSE 541 126

 x

  f 9 x8

1: :

  f 9#.>NN8  f 91#.>NN8

1#.>NN #.>NN

∫ − +−≈:

:8>NN.#98>NN.#989   f  f dx x f 

uassian Quadrature

E l

Page 127: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 127/138

March 24, 2015 OSU/CSE 541 127

 Exam%le

>H<, H##"##KN>,##,>,.#89  x x x x x x f    +−+−+=

dxab xab

 f ab

dt t  f b

a   ∫ ∫    −   

  

     ++−−

=:

: ,

89

,

8989

( )dt t  f 

dt t 

 f dx x f  I 

∫ 

∫ ∫ 

+=

   

     ++−−==

:

:

:

:

E.#

#

H.#H.#H.#

,

#E.#8#E.#9

,

8#E.#989

• -ntegrate f'x( from a ; # to b ; #.E

• Transform from #% #.EB to 1:% :B

E l

Page 128: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 128/138

March 24, 2015 OSU/CSE 541 128

• 0olving

• And sustituting for the ,1point formula)

 Exact integral is 1."#$%333#

( )

dt t t t 

t t 

dt t  f  I 

∫ 

∫ 

−+−−−+−−−+=

+=

:

: >H<

,

:

:

8H.#H.#9H##8H.#H.#9"##8H.#H.#9KN>

8H.#H.#9,##8H.#H.#9,>,.#H.#

H.#H.#H.#

<D:±=t 

E,,>NNNE.:<#>E<N,<.:>:KNH#>>.#   =+≈ I 

( )dt t  f  I  ∫ −= :

:H.#

 Exam%le

=i h d i Q d t

Page 129: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 129/138

March 24, 2015 OSU/CSE 541 129

• Recall the asic form)

• et3s look at n;<.

• We now have K unknowns) c,% c-% c/% x,% x-% and x/

 –  three unknown weights 9c,% c- % c/8

 –  three unknown sampling points 9 x,% x- % x/8 

∫    ∑−

=

≈=:

:

:

8989n

i

ii  x f cdx x f  I 

( ) ( ) ( )<<,,::   x f c x f c x f c I    ++≈

 =igher+order aussian Quadrature

/se K equations 1 constant% linear% quadratic% cuic%

Page 130: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 130/138

March 24, 2015 OSU/CSE 541 130

/se K equations constant% linear% quadratic% cuic%

Hth order and >th order to find those unknowns

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( ) >

<<

>

,,

>

::<<,,::

:

:

>

H<<

H,,

H::<<,,::

:

:

H

<

<<

<

,,

<

::<<,,::

:

:

<

,

<<

,

,,

,

::<<,,::

:

:

,

<<,,::<<,,::

:

:

<,:<<,,::

:

:

 #

 >,

 #

<,

 #

 ,:

 xc xc xc x f c x f c x f cdx x

 xc xc xc x f c x f c x f cdx x

 xc xc xc x f c x f c x f cdx x

 xc xc xc x f c x f c x f cdx x

 xc xc xc x f c x f c x f c xdx

ccc x f c x f c x f cdx

++=++==

++=++==

++=++==

++=++==

++=++==

++=++==

∫ ∫ 

∫ 

∫ 

∫ ∫ 

=i h d i Q d t

Page 131: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 131/138

March 24, 2015 OSU/CSE 541 131

• Can solve these equations 9or have some one

smarter than us% like 5uass solve them8.

• Groduces the three point 5auss1egendre formula

 –  +?act for pol!nomials up to and including degree >

9ecause using >th degree pol!nomial8

NNH>"KK".#>D< # NNH>"KK".#>D<

"D> "DE "D>

,,:

<,:

===−=−=

===

 x x x

ccc

( ) ( ) ( )<<,,::   x f c x f c x f c I    ++≈

 =igher+order aussian Quadrature

=i h d i Q d t

Page 132: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 132/138

March 24, 2015 OSU/CSE 541 132

∫ − ++−≈:

:8NN>.#9

"

>8#.#9

"

E8NN>.#9

"

>89  f  f  f dx x f 

1: :

 x

  f 9#.NN>8  f 91#.NN>8

1#.NN> #.NN>

  f 9#8

 =igher+order aussian Quadrature

Exam%le

Page 133: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 133/138

March 24, 2015 OSU/CSE 541 133

>H<, H##"##KN>,##,>,.#89  x x x x x x f    +−+−+=

-ntegrate from a ; # to b ; #.E

Transform from #% #.EB to 1:% :B

( )

dt 

t t t 

t t 

dx x f  I 

∫ 

∫ 

−  

−+−−−+

−−−+=

=

:

: >H<

,

E.#

#

8H.#H.#9H##8H.#H.#9"##8H.#H.#9KN>

8H.#H.#9,##8H.#H.#9,>,.#

 Exam%le

replace 1#.H with M#.H

Exam%le

Page 134: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 134/138

March 24, 2015 OSU/CSE 541 134

( )    

  

 ++   

  

 −≈ >

<

"

>#"

E

>

<

"

> f  f  f  I 

KH#><<<H.: 

HE>"EN>"".#EN<,HHHHH.#,E:<#:,"#.#

=++≈ I 

0ustitute into the transform equation and get

 Exact integral is 1."#$%333#

 Exam%le

• /sing the <1point 5auss1egendre formula)

aussian Quadrature

Page 135: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 135/138

March 24, 2015 OSU/CSE 541 135

Can develop higher order 5auss1egendre forms

using

( ) ( ) ( )nn  x f c x f c x f c I    +++≈ ...,,::

@alues for c3s and x3s are taulated

/se the same transformation to map interval onto1:% :B

aussian Quadrature

( ) ( ) ( )xfcxfcxfcdxxfI +++≈= ∫ ...89 ,,::

:

Page 136: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 136/138

March 24, 2015 OSU/CSE 541 136

:N:<,H>.#

<K#NK:K.#

HKN":<".#

HKN":<".#

<K#NK:K.#

:N:<,H>.#

 

>##.,<K",KEE

#>#.HNEK,EKN

E"#.>KEEEEEE

#>#.HNEK,EKN

>##.,<K",KEE

 >:#.<HNE>HEH

H"#.K>,:H>:>

H"#.K>,:H>:>

>:#.<HNE>HEH

 

>K#.>>>>>>>>

E"#.EEEEEEEE

>K#.>>>>>>>>

 

#.:

#.:

 

"<,HK">:H#

KK:,#"<EK#

,<EK:":EK#

,<EK:":EK#KK:,#"<EK#

"<,HK">:H#

"#K:N"EH>"#

><EHK"<:#:#

###########><EHK"<:#:#

"#K:N"EH>"#

EK::<K<::K#

<<""E:#H<K#<<""E:#H<K#

EK::<K<::K#

NNH>"KKK",############

NNH>"KKK",#

>NN<>#,K",#

>NN<>#,K",#

*

*

*

**

*

 

*

*

**

*

 *

**

*

 **

*

 

*

*

−−

−−−

, < H > Kn

ci

 xi

( ) ( ) ( )nn   x f c x f c x f cdx x f  I    +++∫ − ...89 ,,:::

aussian Quadrature

Page 137: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 137/138

March 24, 2015 OSU/CSE 541 137

aussian Quadrature

• Requires function evaluations at non1uniforml! spaced points within theintegration interval – not appropriate for cases where the function is

unknown

 – not suited for dealing with taulated data that

appear in man! engineering prolems• -f the function is known% its efficienc! can

 e a decided advantage

aussian Quadrature

Page 138: CIS541 07 Integration

8/9/2019 CIS541 07 Integration

http://slidepdf.com/reader/full/cis541-07-integration 138/138

aussian Quadrature

• Grolems)

 – -f we add more data points% like douling the

numer of sample points.