Anda di halaman 1dari 18

Numerical Integration

Gerald Recktenwald
Portland State University
Mechanical Engineering Department
gerry@me.pdx.edu

These slides are a supplement to the book Numerical Methods with


Matlab: Implementations and Applications, by Gerald W. Recktenwald,
c 2002, Prentice-Hall, Upper Saddle River, NJ. These slides are  c
2002 Gerald W. Recktenwald. The PDF version of these slides may
be downloaded or stored or printed only for noncommercial, educational
use. The repackaging or sale of these slides in any form, without written
consent of the author, is prohibited.

The latest version of this PDF file, along with other supplemental material
for the book, can be found at www.prenhall.com/recktenwald.

Version 0.01 March 9, 2002


Primary Topics

• Basic concepts
• Newton Cotes Rules
 Trapezoid rule
 Simpson’s rule
• Gaussian Quadrature
• Adaptive Quadrature
• Improper Integrals

NMM: Numerical Integration page 1


Figure 11.2

NMM: Numerical Integration page 2


Figure 11.3

f (x )

a b

NMM: Numerical Integration page 3


Figure 11.4

Composite Rule: N panels


f (x )

1 2 ... N

a b

Basic Rule: m nodes

1 2 ... m

NMM: Numerical Integration page 4


Figure 11.5

f(x)

f2

f1 P1(x)
h = x2 –x1

x1 x2

NMM: Numerical Integration page 5


Figure 11.6

fn–1
fn–2
f3 fn
f2

f1

h h h h

x1 x2 x3 xn–2 xn–1 xn
a b

NMM: Numerical Integration page 6


Figure 11.7

0.4
3 panels error = -0.208654
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.4
4 panels error = -0.124097
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.4
5 panels error = -0.081554
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

NMM: Numerical Integration page 7


Figure 11.8

P2(x)
f(x) f2 f3

f1

h h

x1 x2 x3

NMM: Numerical Integration page 8


Figure 11.9

f5 fn–3
fn–2
f3 fn
f1

h h h h

x1 x3 x5 xn–3 xn–2 xn

NMM: Numerical Integration page 9


Figure 11.10

0.4
3 panels error = -0.007070
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.4
4 panels error = -0.002368
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.4
5 panels error = -0.000997
0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

NMM: Numerical Integration page 10


Figure 11.11

Three point closed rule h = b 2– a Three point open rule h=b–a


4

f2 f3 f3
f2
f1
f1

h h h h h h

x1 x2 x3 a x1 x2 x3 b
a b

NMM: Numerical Integration page 11


Figure 11.12

Order 2
1.0000 1.0000

Order 3
0.5556 0.8889 0.5556

Order 4
0.3479 0.6521 0.6521 0.3479

Order 5
0.2369 0.4786 0.5689 0.4786 0.2369

Order 6
0.1713 0.3608 0.4679 0.4679 0.3608 0.1713

-1 -0.5 0 0.5 1

NMM: Numerical Integration page 12


Figure 11.13

f(x) f(z)

H H 1 1
2 2 2 2

x*1 x*2 x*3 x*4 z1 z2 z3 z4


xi xm,i xi+1 –1 0 1

NMM: Numerical Integration page 13


Figure 11.14

0
10
trapezoid
simpson
GL 4 node

-5
10
Truncation error

-10
10

-15
10 0 1 2 3
10 10 10 10
Number of function evaluations

NMM: Numerical Integration page 14


Figure 11.15

H for level 1
level 1
a d c e b

left right

level 2
a d c e b a d c e b

left right

level 3
a d c e b a d c e b

level 4
a b a b

NMM: Numerical Integration page 15


Figure 11.16

100

80
y = humps(x)

60

40

20

-20
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

0.07
Space between f(x) evaluations

0.06

0.05

0.04

0.03

0.02

0.01

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
x

NMM: Numerical Integration page 16


Figure 11.17

0
10
quad
quad8
-2
10
tol

-4
10

-6
10 -10 -8 -6 -4 -2 0
10 10 10 10 10 10
Absolute error
5
10
quad
quad8
4
10
flops

3
10

2
10 -10 -8 -6 -4 -2 0
10 10 10 10 10 10
Absolute error

NMM: Numerical Integration page 17

Anda mungkin juga menyukai