Numerical Integration Gerald Recktenwald Portland State University Mechanical Engineering Department
[email protected]
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
a
b
L
NMM: Numerical Integration
page 2
Figure 11.3
f (x )
a
NMM: Numerical Integration
b
page 3
Figure 11.4
Composite Rule: N panels f (x )
1 a
2
...
N b
Basic Rule: m nodes
1
2 ...
NMM: Numerical Integration
m
page 4
Figure 11.5
f(x) f2 f1
P1(x) h = x2 –x1 x1
NMM: Numerical Integration
x2
page 5
Figure 11.6
fn–1
fn–2
fn
f3
f2 f1 h x1 a
NMM: Numerical Integration
h x2
h x3
xn–2
h xn–1
xn b
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
NMM: Numerical Integration
1.5
2
2.5
3
3.5
4
4.5
5
page 7
Figure 11.8
P2(x) f(x)
f3
f2
f1 h x1
NMM: Numerical Integration
h x2
x3
page 8
Figure 11.9
f5
fn–2
f3
f1 h x1
fn–3
fn h
x3
h x5
NMM: Numerical Integration
h
xn–3 xn–2 xn
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
NMM: Numerical Integration
1.5
2
2.5
3
3.5
4
4.5
5
page 10
Figure 11.11
Three point closed rule
h = b 2– a
f3
f2
h=b–a 4
Three point open rule
f3
f2
f1
f1 h x1 a
h x2
NMM: Numerical Integration
h x3 b
a
h x1
h x2
h x3
b
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
-1
0.3608
0.4679
-0.5
NMM: Numerical Integration
0.4679
0
0.3608
0.5
0.1713
1
page 12
Figure 11.13
f(x)
f(z)
H 2 xi
x*1
H 2 x*2
xm,i
x*3
NMM: Numerical Integration
1 2 x*4 xi+1
–1
z1
1 2 z2
0
z3
z4
1
page 13
Figure 11.14
0
10
trapezoid simpson GL 4 node
-5
Truncation error
10
-10
10
-15
10
0
10
NMM: Numerical Integration
1
2
10 10 Number of function evaluations
10
3
page 14
Figure 11.15
H for level 1 level 1 a
d
c
e
left
b
right
level 2 a
d
c left
e
b
a
d
c
e
b
right
level 3 a
d
c
e
b
a
d
c
e
b
level 4 a
NMM: Numerical Integration
b
a
b
page 15
Figure 11.16
100
y = humps(x)
80 60 40 20 0
Space between f(x) evaluations
-20
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
0
0.2
0.4
0.6
0.8
1 x
1.2
1.4
1.6
1.8
2
0.07 0.06 0.05 0.04 0.03 0.02 0.01 0
NMM: Numerical Integration
page 16
Figure 11.17
0
10
quad quad8 -2
tol
10
-4
10
-6
10 -10 10 10
-8
10
-6
10
-4
10 Absolute error
-2
10
10
0
5
quad quad8 4
flops
10
10
3
2
10 -10 10
-8
10
NMM: Numerical Integration
-6
10
-4
10 Absolute error
-2
10
10
0
page 17