Professional Documents
Culture Documents
Scientific Computing
An Introductory Survey
Second Edition
by Michael T. Heath
Chapter 8
Numerical Integration
and Differentiation
2
Numerical Quadrature
Main issues:
3
Quadrature Rules
4
Quadrature Rules, continued
5
Method of Undetermined Coefficients
6
Example: Undetermined Coefficients
w1 · a + w2 · (a + b)/2 + w3 · b =
Z b
x dx = (x2/2)|ba = (b2 − a2)/2,
a
w1 · a2 + w2 · ((a + b)/2)2 + w3 · b2 =
Z b
x2 dx = (x3/3)|ba = (b3 − a3)/3
a
7
Example Continued
In matrix form,
b−a
1 1 1
w1
8
Method of Undetermined Coefficients
9
Accuracy of Quadrature Rules
11
Stability of Quadrature Rules
12
Newton-Cotes Quadrature
Examples:
• Midpoint rule:
a+b
M (f ) = (b − a)f
2
• Trapezoid rule:
b−a
T (f ) = (f (a) + f (b))
2
• Simpson’s rule:
b−a a+b
S(f ) = f (a) + 4f + f (b)
6 2
13
Example: Newton-Cotes Quadrature
Approximate integral
Z 1
I(f ) = exp(−x2) dx ≈ 0.746824
0
M (f ) = (1 − 0) exp(−1/4) ≈ 0.778801
≈ 0.747180
1.0.........................................................................................................
.. ......... .................................
.. ......... ...........................
.. ...... . .........
..... .... .... .... .... .... .... .... ................................ .................................... .... .... .... .... .... .... .... .... .... .... .... .... .... ..
.........
..
.. ......... ............................... ..
..
.. ......... ..................... ..
.. ......... ..................... ..
.. .. . .
......... ..................... ..
.. . .. .
.............................. ..
.. ..............................
.. . . . ................. . ...
. .
.. ................
.. ..
.. ..
.. ..
.. ..
.. ..
.. ..
.. ..
.....................................................................................................................................................................................................................................
|
0.0 0.5 1.0
14
Error Estimation
0 f 00(m)
f (x) = f (m) + f (m)(x − m) + (x − m)2
2
f 000(m) 3 f (4)(m)
+ (x − m) + (x − m)4 + · · ·
6 24
f (4)(m)
+ (b − a)5 + · · ·
1920
= M (f ) + E(f ) + F (f ) + · · · ,
where E(f ) and F (f ) represent first two terms
in error expansion for midpoint rule
15
Error Estimation, continued
I(f ) = T (f ) − 2E(f ) − 4F (f ) − · · ·
16
Error Estimation, continued
T (f ) − M (f ) = 3E(f ) + 5F (f ) + · · · ,
so
T (f ) − M (f )
E(f ) ≈
3
17
Example: Error Estimation
M (f ) = (1 − 0)(1/2)2 = 1/4,
1−0 2
T (f ) = (0 + 12) = 1/2,
2
E(f ) ≈ (T (f ) − M (f ))/3 = (1/4)/3 = 1/12
Also,
18
Accuracy of Newton-Cotes Quadrature
...
.... . ...............................................................
...... ...
............ .... .
.. .....
...................
....... ..........
........ .........
...... . .
...................................................................................................... ..... ............ ......
.........
.. ... .. .. ..
.. ..................... .. .. ..
........ .. .. ..
.
................................................|.................................................
. ................................................|.................................................
.
.
a m b a m b
20
Drawbacks of Newton-Cotes Rules
21
Clenshaw-Curtis Quadrature
24
Example Continued
26
Change of Interval
28
Gaussian Quadrature
29
Progressive Gaussian Quadrature
(200|Gn − K2n+1|)1.5
30
Progressive Gaussian Quadrature, cont.
1 1
=h 2
f (a) + f (x1) + · · · + f (xk−1) + f (b)
2
33
Composite Quadrature Rules, cont.
35
Adaptive Quadrature, continued
|....|...|....|....|...|....|...|....|...|....|...|....|...|....|...|....|..||||||||||||||||
.|....|....|...|....|...|....|...|....|...|....|...|....|...|....|...|..||||||||||||||||
..|...|....|...|....|....|...|....|...|....|...|....|...|....|...|....|...|....|...|....|...|....|....|...|....|...|....|...|....|...|....|...|
36
Adaptive Quadrature, continued
37
Adaptive Quadrature, continued
38
Integrating Tabular Data
40
Double Integrals
41
Multiple Integrals
√
Error in estimate goes to zero as 1/ n, so to
gain one additional decimal digit of accuracy
requires n to increase by factor of 100
42
Multiple Integrals, continued
43
Integral Equations
44
Integral Equations, continued
• Truncated SVD
• Regularization
• Constrained optimization
45
Numerical Differentiation
46
Numerical Differentiation, continued
47
Finite Difference Approximations
0 f 00(x) 2 f 000(x) 3
f (x+h) = f (x)+f (x)h+ h + h +· · · ,
2 6
and
0 f 00(x) 2 f 000(x) 3
f (x−h) = f (x)−f (x)h+ h − h +· · ·
2 6
49
Finite Difference Approximations, cont.
f (4)(x) 2
− h + ···,
12
f (x + h) − 2f (x) + f (x − h)
≈ ,
h2
which is also second-order accurate
50
Automatic Differentiation
51
Richardson Extrapolation
52
Richardson Extrapolation, continued
Suppose that
53
Richardson Extrapolation, continued
Then we have
55
Example: Richardson Extrapolation
56
Example Continued
57
Example: Romberg Integration
58
Example Continued
59
Romberg Integration
60