22
Computational Methods CMSC/AMSC/MAPL 460 Quadrature: Integration Ramani Duraiswami, Dept. of Computer Science

Lecture15 Integrations

Embed Size (px)

DESCRIPTION

`12312

Citation preview

Page 1: Lecture15 Integrations

Computational MethodsCMSC/AMSC/MAPL 460

Quadrature: Integration

Ramani Duraiswami, Dept. of Computer Science

Page 2: Lecture15 Integrations

0

2

4

6

8

10

12

3 5 7 9 11 13 15

Numerical IntegrationNumerical IntegrationIdea is to do integral in small parts, like the way you first learned integration - a summation

Numerical methods just try to make it faster and more accurate

Page 3: Lecture15 Integrations

Basic Numerical IntegrationBasic Numerical Integration• Weighted sum of function values

)x(fc)x(fc)x(fc

)x(fcdx)x(f

nn1100

i

n

0ii

b

a

+++=

≈ ∑∫=

LL

x0 x1 xnxn-1x

f(x)

Page 4: Lecture15 Integrations

Numerical IntegrationNumerical Integration• Characterized by where the function is

evaluated• Newton-Cotes Closed Formulae -- Use both end

points– Trapezoidal Rule : Linear– Simpson’s 1/3-Rule : Quadratic– Simpson’s 3/8-Rule : Cubic– Boole’s Rule : Fourth-order

• Newton-Cotes Open Formulae -- Use only interior points– midpoint rule

Page 5: Lecture15 Integrations

Trapezoid RuleTrapezoid Rule• Straight-line approximation

[ ])x(f)x(f2h

)x(fc)x(fc)x(fcdx)x(f

10

1100i

1

0ii

b

a

+=

+=≈ ∑∫=

x0 x1x

f(x)

L(x)

Page 6: Lecture15 Integrations

Example:Trapezoid RuleExample:Trapezoid RuleEvaluate the integral• Exact solution (integration by parts)`

• Trapezoidal Rule

926477.5216)1x2(e41

e41e

2xdxxe

1

0

x2

4

0

x2x24

0

x2

=−=

⎥⎦⎤

⎢⎣⎡ −=∫

dxxe4

0

x2∫

[ ]

%12.357926.5216

66.23847926.5216

66.23847)e40(2)4(f)0(f2

04dxxeI 84

0

x2

−=−

=

=+=+−

≈= ∫ε

4

Page 7: Lecture15 Integrations

SimpsonSimpson’’s 1/3s 1/3--RuleRuleApproximate the function by a parabola

[ ])x(f)x(f4)x(f3h

)x(fc)x(fc)x(fc)x(fcdx)x(f

210

221100i

2

0ii

b

a

++=

++=≈ ∑∫=

x0 x1x

f(x)

x2h h

L(x)

Page 8: Lecture15 Integrations

SimpsonSimpson’’s 3/8s 3/8--RuleRuleApproximate by a cubic polynomial

[ ])x(f)x(f3)x(f3)x(f8h3

)f(xc)f(xc)f(xc)f(xc)x(fcdx)x(f

3210

33221100i

3

0ii

b

a

+++=

+++=≈ ∑∫=

x0 x1x

f(x)

x2h h

L(x)

x3h

Page 9: Lecture15 Integrations

Example: SimpsonExample: Simpson’’s Ruless RulesEvaluate the integral• Simpson’s 1/3-Rule

• Simpson’s 3/8-Rule

dxxe4

0

x2∫[ ]

4 2

0

4 8

(0) 4 (2) (4)3

2 0 4(2 ) 4 8240.41135216.926 8240.411 57.96%

5216.926

x hI xe dx f f f

e e

ε

= ≈ + +

⎡ ⎤= + + =⎣ ⎦

−= = −

[ ]

4 2

0

3 4 8(0) 3 ( ) 3 ( ) (4)8 3 3

3(4/3) 0 3(19.18922) 3(552.33933) 11923.832 6819.2098

5216.926 6819.209 30.71%5216.926

x hI xe dx f f f f

ε

⎡ ⎤= ≈ + + +⎢ ⎥⎣ ⎦

= + + + =

−= = −

Page 10: Lecture15 Integrations

Midpoint RuleMidpoint RuleNewton-Cotes Open Formula

)(f24

)ab()2

ba(f)ab(

)x(f)ab(dx)x(f3

m

b

a

η′′−+

+−=

−≈∫

a b x

f(x)

xm

Page 11: Lecture15 Integrations

TwoTwo--point Newtonpoint Newton--Cotes Open Cotes Open FormulaFormula

Approximate by a straight line

[ ] )(f108

)ab()x(f)x(f2

abdx)x(f3

21

b

aη′′−

++−

≈∫

x0 x1x

f(x)

x2h h x3h

Page 12: Lecture15 Integrations

ThreeThree--point Newtonpoint Newton--Cotes Open Cotes Open FormulaFormula

Approximate by a parabola

[ ]

)(f23040

)ab(7

)x(f2)x(f)x(f23

abdx)x(f5

321

b

a

η′′′′−+

+−−

≈∫

x0 x1x

f(x)

x2h h x3h h x4

Page 13: Lecture15 Integrations

• F_1*( x^3/3-5h*x^2/2+6*h^2*x)/(2h^2)• F_1*((4h)^3/3-5h*(4h)^2/2+6h^2*4*h))/(2h^2)• F_1*(4h)(8/3-5+3)• F_1*(4h/3)(8+9-15)• (b-a)/3*F_1*2

Page 14: Lecture15 Integrations

Better Numerical IntegrationBetter Numerical Integration

• Composite integration – Composite Trapezoidal Rule– Composite Simpson’s Rule

• Richardson Extrapolation• Romberg integration

Page 15: Lecture15 Integrations

Apply trapezoid rule to multiple segments over Apply trapezoid rule to multiple segments over integration limitsintegration limits

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

Two segments

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

Four segments

0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

Many segments0

1

2

3

4

5

6

7

3 5 7 9 11 13 15

Three segments

Page 16: Lecture15 Integrations

Composite Trapezoid RuleComposite Trapezoid Rule

[ ] [ ] [ ]

[ ])x(f)x(f2)2f(x)f(x2)f(x2h

)f(x)f(x2h)f(x)f(x

2h)f(x)f(x

2h

f(x)dxf(x)dxf(x)dxf(x)dx

n1ni10

n1n2110

x

x

x

x

x

x

b

a

n

1n

2

1

1

0

++++++=

++++++=

+++=

∫∫∫∫−

LL

L

LL

x0 x1x

f(x)

x2h h x3h h x4

nabh −

=

Page 17: Lecture15 Integrations

Composite Trapezoid RuleComposite Trapezoid RuleEvaluate the integral dxxeI

4

0

x2∫=[ ]

[ ]

[]

[

][

]%66.2 95.5355

)4(f)75.3(f2)5.3(f2

)5.0(f2)25.0(f2)0(f2hI25.0h,16n

%50.10 76.5764)4(f)5.3(f2 )3(f2)5.2(f2)2(f2)5.1(f2

)1(f2)5.0(f2)0(f2hI5.0h,8n

%71.39 79.7288)4(f)3(f2

)2(f2)1(f2)0(f2hI1h,4n

%75.132 23.12142)4(f)2(f2)0(f2hI2h,2n

%12.357 66.23847)4(f)0(f2hI4h,1n

−==+++

+++=⇒==

−==++++++

++=⇒==

−==++

++=⇒==

−==++=⇒==

−==+=⇒==

ε

ε

ε

ε

ε

L

Page 18: Lecture15 Integrations

Composite Trapezoid Rule with Unequal Composite Trapezoid Rule with Unequal SegmentsSegments

Evaluate the integral• h1 = 2, h2 = 1, h3 = 0.5, h4 = 0.5

dxxeI4

0

x2∫=

[ ] [ ]

[ ] [ ]

[ ] [ ] [ ]

[ ] %45.14 58.5971 45.3 2

0.5

5.33e 2

0.5322120

22

)4()5.3(2

)5.3()3(2

)3()2(2

)2()0(2

)()()()(

87

76644

43

21

4

5.3

5.3

3

3

2

2

0

−=⇒=++

+++++=

++++

+++=

+++= ∫∫∫∫

εee

eeee

ffhffh

ffhffh

dxxfdxxfdxxfdxxfI

Page 19: Lecture15 Integrations

Composite SimpsonComposite Simpson’’s Rules Rule

x0 x2x

f(x)

x4h h xn-2h xn

nabh −

=

…...

Piecewise Quadratic approximations

hx3x1 xn-1

Page 20: Lecture15 Integrations

[ ] [ ]

[ ]

[

])x(f)x(f4)x(f2)4f(x)x(f2)f(x4

)2f(x)f(x4)2f(x)f(x4)f(x3h

)f(x)4f(x)f(x3h

)f(x)f(x4)f(x3h)f(x)f(x4)f(x

3h

f(x)dxf(x)dxf(x)dxf(x)dx

n1n2n

12ii21-2i

43210

n1n2n

432210

x

x

x

x

x

x

b

a

n

2n

4

2

2

0

+++

++++

+++++=

++++

+++++=

+++=

−−

+

−−

∫∫∫∫−

L

L

L

L

Composite SimpsonComposite Simpson’’s Rules RuleMultiple applications of Simpson’s rule

Page 21: Lecture15 Integrations

Composite SimpsonComposite Simpson’’s Rules RuleEvaluate the integral• n = 2, h = 2

• n = 4, h = 1

dxxeI4

0

x2∫=

[ ]

[ ]%70.8 975.5670

e4)e3(4)e2(2)e(4031

)4(f)3(f4)2(f2)1(f4)0(f3hI

8642

−=⇒=

++++=

++++=

ε

[ ]

[ ] %96.57 411.8240e4)e2(4032

)4(f)2(f4)0(f3hI

84 −=⇒=++=

++=

ε

Page 22: Lecture15 Integrations

Composite SimpsonComposite Simpson’’s Rule with s Rule with Unequal SegmentsUnequal Segments

Evaluate the integral• h1 = 1.5, h2 = 0.5

dxxeI4

0

x2∫=

[ ]

[ ]

[ ] [ ]%76.3 23.5413

4)5.3(4335.03)5.1(40

35.1

)4(2)5.3(4)3(3

)3(2)5.1(4)0(3

)()(

87663

2

1

4

3

3

0

−=⇒=

+++++=

+++

++=

+= ∫∫

ε

eeeee

fffh

fffh

dxxfdxxfI