Top Banner
Integration Integration COS 323 COS 323
17

Integration

Feb 08, 2016

Download

Documents

orsin

Integration. COS 323. Numerical Integration Problems. Basic 1D numerical integration: Given ability to evaluate f ( x ) for any x , find Goal: best accuracy with fewest samples Other problems (future lectures): Improper integration Multi-dimensional integration - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Integration

IntegrationIntegration

COS 323COS 323

Page 2: Integration

Numerical Integration ProblemsNumerical Integration Problems

• Basic 1D numerical integration:Basic 1D numerical integration:– GivenGiven ability to evaluate ability to evaluate ff ((xx)) for any for any xx, , findfind – Goal:Goal: best accuracy with fewest samples best accuracy with fewest samples

• Other problems (future lectures):Other problems (future lectures):– Improper integration Improper integration – Multi-dimensional integrationMulti-dimensional integration– Ordinary differential equationsOrdinary differential equations– Partial differential equationsPartial differential equations

b

a

dxxf )(

Page 3: Integration

Trapezoidal RuleTrapezoidal Rule

• Approximate function by trapezoidApproximate function by trapezoid

aa bb

f(a)f(a)

f(b)f(b)

Page 4: Integration

Trapezoidal RuleTrapezoidal Rule

aa bb

f(a)f(a)

f(b)f(b)

2)()()()( bfafabdxxf

b

a

Page 5: Integration

Extended Trapezoidal RuleExtended Trapezoidal Rule

aa bb

f(a)f(a)

f(b)f(b)

2)()()()( bfafabdxxf

b

a

)()()()()( 21

1121 bfxfxfafhdxxf n

b

a

Divide into segments of width Divide into segments of width hh::

aa bb

Page 6: Integration

Trapezoidal Rule Error AnalysisTrapezoidal Rule Error Analysis

• How accurate is this approximation?How accurate is this approximation?

• Start with Taylor series for Start with Taylor series for ff ((xx)) around around aa )()()()()()( 2

21 afaxafaxafxf

E

)()(2

)()( bfafabdxxfb

a

Page 7: Integration

Trapezoidal Rule Error AnalysisTrapezoidal Rule Error Analysis

• Expand LHS:Expand LHS:

• Expand RHSExpand RHS

)()()()()()()( 3612

21 afabafabafabdxxf

b

a

E

E

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

)()()()(2

)(

3412

21

21

21

afabafabafab

afabbfafab

Page 8: Integration

Trapezoidal Rule Error AnalysisTrapezoidal Rule Error Analysis

• So,So,

• In general, error for a In general, error for a singlesingle segment segment proportional to proportional to hh33

• Error for subdividing entire aError for subdividing entire ab interval b interval proportional to proportional to hh22

– ““Cubic local accuracy, quadratic global Cubic local accuracy, quadratic global accuracy”accuracy”

)()( 3121 afabE

Page 9: Integration

Determining Step SizeDetermining Step Size

• Change in integral when reducing step Change in integral when reducing step sizesizeis a reasonable guess for accuracyis a reasonable guess for accuracy

• For trapezoidal rule, easy to go from h For trapezoidal rule, easy to go from h h/2h/2without wasting previous sampleswithout wasting previous samples

aa bb

Page 10: Integration

• Approximate integral byApproximate integral byparabola throughparabola throughthree pointsthree points

• Better accuracy for same # of Better accuracy for same # of evaluationsevaluations

Simpson’s RuleSimpson’s Rule

aa bb

f(a)f(a)

f(b)f(b)

)()()(4)(3

)( 5hObfhafafhdxxfb

a

Page 11: Integration

Richardson ExtrapolationRichardson Extrapolation

• Better way of getting higher accuracy for aBetter way of getting higher accuracy for agiven # of samplesgiven # of samples

• Suppose we’ve evaluated integral for step Suppose we’ve evaluated integral for step sizesizeh and step size h/2:h and step size h/2:

• ThenThen

4

22

22/

42

hhh

h

FF

hhFF

)( 431

2/34 hOFFF hh

Page 12: Integration

Richardson ExtrapolationRichardson Extrapolation

• This treats the approximation as a This treats the approximation as a function of h and “extrapolates” the function of h and “extrapolates” the result to h=0result to h=0

• Can repeat:Can repeat:

)()()()( 8642

8/

4/

2/

hOhOhOhO

F

F

F

F

h

h

h

h ––1/31/3

4/34/3 ––1/151/15

16/1516/15 ––1/631/63

64/6364/63

Page 13: Integration

Open MethodsOpen Methods

• Trapezoidal rule won’t work if function Trapezoidal rule won’t work if function undefined at one of the points where undefined at one of the points where evaluatingevaluating– Most often: function infinite at one endpointMost often: function infinite at one endpoint

• Open methods only evaluate function on Open methods only evaluate function on the the openopen interval (i.e., not at endpoints) interval (i.e., not at endpoints)

1

02x

dx

Page 14: Integration

Midpoint RuleMidpoint Rule

• Approximate function by rectangle Approximate function by rectangle evaluated at midpointevaluated at midpoint

aa bb

)( 2baf

Page 15: Integration

Extended Midpoint RuleExtended Midpoint Rule

)()()( 2ba

b

a

fabdxxf

)()()()( 223

2hhh

b

a

bfafafhdxxf

Divide into segments of width Divide into segments of width hh::

aa bb

aa bb

Page 16: Integration

Midpoint Rule Error AnalysisMidpoint Rule Error Analysis

• Following similar analysis to trapezoidal Following similar analysis to trapezoidal rule,rule,find that local accuracy is cubic,find that local accuracy is cubic,quadratic global accuracyquadratic global accuracy

• Formula suitable for adaptive method,Formula suitable for adaptive method,Richardson extrapolation,Richardson extrapolation,but can’t halve intervals withoutbut can’t halve intervals withoutwasting sampleswasting samples

Page 17: Integration

DiscontinuitiesDiscontinuities

• All the above error analyses assumed nice All the above error analyses assumed nice (continuous, differentiable) functions(continuous, differentiable) functions

• In the presence of a discontinuity, all methodsIn the presence of a discontinuity, all methodsrevert to accuracy proportional to hrevert to accuracy proportional to h

• Locally-adaptive methods: do not subdivideLocally-adaptive methods: do not subdivideall intervals equally, focus on those with large all intervals equally, focus on those with large errorerror(estimated from change with a single (estimated from change with a single subdivision)subdivision)