





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Lecture Notes # — Numerical Differentiation and Integration — Composite Numerical Integration; Romberg Integration Adaptive Quadrature / Gaussian Quadrature
Peter Blomgren, 〈[email protected]〉
Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research Center San Diego State University San Diego, CA 92182- http://terminus.sdsu.edu/
Peter Blomgren, 〈[email protected] Fall 2009〉 Composite-Romberg-Adaptive-Gaussian — (1/45)
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Outline
1 Composite Quadrature Divide and Conquer; Example — Simpson’s Rule Generalization Collecting the Error... Summary, Algorithm, Homework #7 (version #1) 2 Romberg Quadrature Applying Richardson’s Extrapolation Romberg Quadrature — Code Outline 3 Adaptive Quadrature Introduction Building the Adaptive CSR Scheme Example... Putting it Together... 4 Gaussian Quadrature Ideas... 2-point Gaussian Quadrature Higher-Order Gaussian Quadrature — Legendre Polynomials Examples: Gaussian Quadrature in Action; HW#
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
Divide and Conquer with Simpson’s Rule II/III
The exact solution: ∫ (^4)
0
ex^ dx = e^4 − e^0 = 53. 59815
Divide-and-Conquer: Simpson’s Rule with h = 1/ 2 ∫ (^1)
0
1
2
3
ex^ dx ≈
(e^0 + 4e^1 /^2 + e^1 ) +
(e^1 + 4e^3 /^2 + e^2 )
(e^2 + 4e^5 /^2 + e^3 ) +
(e^3 + 4e^7 /^2 + e^4 ) = 53. 61622
The error has been reduced to − 0. 01807 (0.034%).
h abs-error err/h err/h^2 err/h^3 err/h^4 2 3.17143 1.585715 0.792857 0.396429 0. 1 0.26570 0.265700 0.265700 0.265700 0. 1/2 0.01807 0.036140 0.072280 0.144560 0.
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
Divide and Conquer with Simpson’s Rule III/III
Extending the table... h abs-error err/h err/h^2 err/h^3 err/h^4 err/h^5 2 3.171433 1.585716 0.792858 0.396429 0.198215 0. 1 0.265696 0.265696 0.265696 0.265696 0.265696 0. 1/2 0.018071 0.036142 0.072283 0.144566 0.289132 0. 1/4 0.001155 0.004618 0.018473 0.073892 0.295566 1. 1/8 0.000073 0.000580 0.004644 0.037152 0.297215 2.
Clearly, the err/h^4 column seems to converge (to a non-zero constant) as h ց 0. The columns to the left seem to converge to zero, and the err/h^5 column seems to grow. This is numerical evidence that the composite Simpson’s rule has a convergence rate of O
h^4
. But, isn’t Simpson’s rule 5th order???
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
Generalized Composite Simpson’s Rule II/II
∫ (^) b
a
f (x)dx =
h 3
f (x 0 ) − f (xn) +
∑^ n/^2
j=
4 f (x 2 j− 1 ) + 2f (x 2 j )
h^5 90
∑^ n/^2
j=
f (4)(ξj ).
The error term is:
E (f ) = −
h^5 90
∑^ n/^2
j=
f (4)(ξj ), ξj ∈ [x 2 j− 2 , x 2 j ]
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
The Error for Composite Simpson’s Rule I/II
If f ∈ C 4 [a, b], the Extreme Value Theorem implies that f (4) assumes its max and min in [a, b]. Now, since min x∈[a,b]
f (4)(x) ≤ f (4)(ξj ) ≤ max x∈[a,b]
f (4)(x),
[ (^) n 2
min x∈[a,b]
f (4)(x) ≤
∑^ n/^2
j=
f (4)(ξj ) ≤
[ (^) n 2
max x∈[a,b]
f (4)(x),
min x∈[a,b] f (4)(x) ≤
n
] (^) ∑n/ 2
j=
f (4)(ξj ) ≤ max x∈[a,b] f (4)(x),
By the Intermediate Value Theorem ∃μ ∈ (a, b) so that
f (4)(μ) =
n
∑^ n/^2
j=
f (4)(ξj ) ⇔
n 2 f (4)(μ) =
∑^ n/^2
j=
f (4)(ξj )
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
Composite Simpson’s Rule — Summary
Theorem (Composite Simpson’s Rule) Let f ∈ C 4 [a, b], n be even, h = (b − a)/n, and xj = a + jh, j = 0, 1 ,... , n. There exists μ ∈ (a, b) for which the Composite Simpson’s Rule for n subintervals can be written with its error term as ∫ (^) b
a
f (x) dx =
h 3
f (a) − f (b) +
∑^ n/^2
j=
[4f (x 2 j− 1 ) + 2f (x 2 j )]
(b − a) 180
h^4 f (4)(μ).
Note: x 0 = a, and xn = b.
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Divide and Conquer; Example — Simpson’s Rule GeneralizationCollecting the Error... Summary, Algorithm, Homework #7 (version #1)
Composite Simpson’s Rule — Algorithm
Algorithm (Composite Simpson’s Rule) Given the end points a and b and an even positive integer n: [1] h = (b − a)/n [2] ENDPTS = f(a)+f(b) ODDPTS = 0 EVENPTS = 0 [3] FOR i = 1,... , n − 1 — (interior points) x = a + i ∗ h if i is even: EVENPTS += f(x) if i is odd: ODDPTS += f(x) END [4] INTAPPROX = h(ENDPTS+2EVENPTS+4*ODDPTS)/
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Applying Richardson’s ExtrapolationRomberg Quadrature — Code Outline
Romberg Integration The Return of Richardson’s Extrapolation
Romberg Integration is the combination of the Composite Trapezoidal Rule (CTR)
∫ (^) b
a
f (x)dx =
h 2
f (a) + f (b) + 2
n∑− 1
j=
f (xj )
(^) − (b^ −^ a) 12 h^2 f ′′(μ)
and Richardson Extrapolation. Here, we know that the error term for regular Trapezoidal Rule is O(h^3 ). By the same argument as for Composite Simpson’s Rule, this gets reduced to O(h^2 ) for the composite version.
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Applying Richardson’s ExtrapolationRomberg Quadrature — Code Outline
Romberg Integration Step-1: CTR Refinement
Let Rk, 1 denote the Composite Trapezoidal Rule with 2k−^1 sub-intervals, and hk = (b − a)/ 2 k−^1. We get:
R 1 , 1 = h 21 [f (a) + f (b)] R 2 , 1 = h 22 [f (a) + 2f (a + h 2 ) + f (b)] = (b− 4 a)[f (a) + f (b) + 2f (a + h 2 )] = 12 [R 1 , 1 + h 1 f (a + h 2 )] .. .
Rk, 1 =
Rk− 1 , 1 + hk− 1
(^2) ∑k−^2
i=
f (a + (2i − 1)hk )
Update formula, using previous value + new points
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Applying Richardson’s ExtrapolationRomberg Quadrature — Code Outline
Extrapolate using Richardson
We know that the error term is O(h^2 ), so in order to eliminate this term we combine to consecutive entries Rk− 1 , 1 and Rk, 1 to form a higher order approximation Rk, 2 of the integral.
Rk, 2 = Rk, 1 +
Rk, 1 − Rk− 1 , 1 22 − 1 Rk, 1 — O `h^2 ´^ Rk, 2 0 0 1.5707963267949 2. 1.8961188979370 2. 1.9742316019455 2. 1.9935703437723 2. 1.9983933609701 2. 1.9995983886400 2.
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Applying Richardson’s ExtrapolationRomberg Quadrature — Code Outline
Extrapolate, again...
It turns out (Taylor expand to check) that the complete error term for the Trapezoidal rule only has even powers of h: ∫ (^) b
a
f (x) = Rk, 1 −
i=
E 2 i h^2 k i.
Hence the Rk, 2 approximations have error terms that are of size O(h^4 ). To get O(h^6 ) approximations, we compute
Rk, 3 = Rk, 2 +
Rk, 2 − Rk− 1 , 2 42 − 1
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Applying Richardson’s ExtrapolationRomberg Quadrature — Code Outline
Homework? No, enough already — Here’s the code outline!
Code (Romberg Quadrature) % Romberg Integration for sin(x) over [0,pi] a = 0; b = pi; % The Endpoints R = zeros(7,7); R(1,1) = (b − a)/ 2 ∗ (sin(a) + sin(b)); for k = 2 : 7 h = (b − a)/ 2 (k−1); R(k,1)= 1 / 2 ∗ (R(k − 1 , 1) + 2 ∗ h ∗ P(sin(a + (2 ∗ (1 : (2(k−2))) − 1) ∗ h))); end for j = 2 : 7 for k = j : 7 R(k,j) = R(k, j − 1) + (R(k, j − 1) − R(k − 1 , j − 1))/(4(j−1)−1); end end disp(R)
Composite Quadrature Romberg QuadratureAdaptive Quadrature Gaussian Quadrature
Introduction Building the Adaptive CSR SchemeExample... Putting it Together...
More Advanced Numerical Integration Ideas