Numerical Integration Techniques
Numerical Integration Techniques
Improper Integrals
Joe Mahaffy,
hmahaffy@[Link]
Department of Mathematics
Dynamical Systems Group
Computational Sciences Research Center
San Diego State University
San Diego, CA 92182-7720
[Link]
Spring 2010
Outline
1 Multiple Integrals
CSR in n-D
Non-Rectangular Domains
2 Improper Integrals
Calculus Treasures
Taylor Expansions... Surprise!
We write
ZZ Z b ·Z d ¸
I= f (x, y ) dx dy = f (x, y ) dy dx,
R a c
This looks somewhat painful, but do not despair!!! [First, a peek at the error...]
(b − a)(d − c) 4 ∂ 4 f 4
· ¸
4∂ f
E =− hx 4 (νx , µx ) + hy 4 (νy , µy )
180 ∂x ∂y
Consider the tensor product of the x- and y -stencils for CSR with
2 sub-intervals:
1
hx hy
1 4 2 4 1 ⊗ 2 =
3 3
4
Consider the tensor product of the x- and y -stencils for CSR with
2 sub-intervals:
1 1 4 2 4 1
4 4 16 8 16 4
hx hy hx hy
1 4 2 4 1 ⊗ 2 = 2 8 4 8 2
3 3 9
4 4 16 8 16 4
1 1 4 2 4 1
Consider the tensor product of the x- and y -stencils for CSR with
2 sub-intervals:
1 1 4 2 4 1
4 4 16 8 16 4
hx hy hx hy
1 4 2 4 1 ⊗ 2 = 2 8 4 8 2
3 3 9
4 4 16 8 16 4
1 1 4 2 4 1
x4 y4
9
Z Z
f (x, y ) dx dy ≈
hx h·y x0 y0 ¸
1 f (x0 , y0 ) + 4f (x1 , y0 ) + 2f (x2 , y0 ) + 4f (x3 , y0 ) + f (x4 , y0 ) +
· ¸
4 f (x0 , y1 ) + 4f (x1 , y1 ) + 2f (x2 , y1 ) + 4f (x3 , y1 ) + f (x4 , y1 ) +
· ¸
2 f (x0 , y2 ) + 4f (x1 , y2 ) + 2f (x2 , y2 ) + 4f (x3 , y2 ) + f (x4 , y2 ) +
· ¸
4 f (x0 , y3 ) + 4f (x1 , y3 ) + 2f (x2 , y3 ) + 4f (x3 , y3 ) + f (x4 , y3 ) +
· ¸
1 f (x0 , y4 ) + 4f (x1 , y4 ) + 2f (x2 , y4 ) + 4f (x3 , y4 ) + f (x4 , y4 )
x4 − x 0 y4 − y 0
hx = , hy = .
4 4
Joe Mahaffy, hmahaffy@[Link] Multiple Integrals; Improper Integrals — (9/25)
Multiple Integrals CSR in n-D
Improper Integrals Non-Rectangular Domains
There’s nothing unique about the usage of CSR. The same idea can be
used to build higher dimensional Gaussian Quadrature schemes. If we
have the stencils for the one-dimensional (Composite) Gaussian
Quadrature schemes in the x-, y - and z-directions (GQx , GQy , GQz ):
There’s nothing unique about the usage of CSR. The same idea can be
used to build higher dimensional Gaussian Quadrature schemes. If we
have the stencils for the one-dimensional (Composite) Gaussian
Quadrature schemes in the x-, y - and z-directions (GQx , GQy , GQz ):
If you’re really twisted you could use different schemes in the different
coordinate directions, i.e.
a b
and get
Z b Z d(x)
f (x, y ) dy dx ≈
a c(x)
½ · ¸
hx d(x0 )−c(x0 ) c(x0 )+d(x0 )
6 f (x 0 , c(x0 )) + 4f (x0 , 2 ) + f (x0 , d(x0 )) +
3
· ¸
4(d(x1 )−c(x1 )) c(x1 )+d(x1 )
6 f (x1 , c(x1 )) + 4f (x1 , 2 ) + f (x1 , d(x1 )) +
· ¸¾
d(x2 )−c(x2 ) c(x2 )+d(x2 )
6 f (x 2 , c(x2 )) + 4f (x2 , 2 ) + f (x2 , d(x2 )) ,
a+b
where x0 = a, x1 = , x2 = b.
2
Joe Mahaffy, hmahaffy@[Link] Multiple Integrals; Improper Integrals — (13/25)
Multiple Integrals CSR in n-D
Improper Integrals Non-Rectangular Domains
“Improper” integrals:
“Improper” integrals:
The integral
Z b
dx
a (x − a)p
converges if and only if p ∈ (−∞, 1), and
(b − a)1−p
Z b
dx
p
= .
a (x − a) 1−p
The integral
Z b
dx
a (x − a)p
converges if and only if p ∈ (−∞, 1), and
(b − a)1−p
Z b
dx
p
= .
a (x − a) 1−p
If f (x) can be written on the form
g (x)
f (x) = , p ∈ (−∞, 1), g ∈ C [a, b]
(x − a)p
then the improper integral
Z b
f (x) dx, exists.
a
If we let
b d
g (k) (a)
Z X
f (x) dx ≈ (b − a)k+1−p ,
a k!(k + 1 − p)
k=0
b b b
g (x) − Pd (x) Rd (x) g (d+1) (ξ(x))(x − a)d+1
Z Z Z
dx = dx = dx
a (x − a)p a (x − a)p a (k + 1)!(x − a)p
b
1
Z
≤ max |g (d+1) (x)| (x − a)d+1−p dx
(k + 1)! x∈[a,b] a
g(d+1) (ξ)
= (b − a)d+2−p .
(k + 1)! (d + 2 − p)
If we let
b d
g (k) (a)
Z X
f (x) dx ≈ (b − a)k+1−p ,
a k!(k + 1 − p)
k=0
b b b
g (x) − Pd (x) Rd (x) g (d+1) (ξ(x))(x − a)d+1
Z Z Z
dx = dx = dx
a (x − a)p a (x − a)p a (k + 1)!(x − a)p
b
1
Z
≤ max |g (d+1) (x)| (x − a)d+1−p dx
(k + 1)! x∈[a,b] a
g(d+1) (ξ)
= (b − a)d+2−p .
(k + 1)! (d + 2 − p)
g (x) − Pd (x)
x ∈ (a, b]
G (x) = (x − a)p
0 x = a.
g (x) − Pd (x)
x ∈ (a, b]
G (x) = (x − a)p
0 x = a.
g (x) − Pd (x)
x ∈ (a, b]
G (x) = (x − a)p
0 x = a.
Pd g (k) (a)
Add the CSR-approximation to k=0 k!(k+1−p) (b − a)k+1−p .
Joe Mahaffy, hmahaffy@[Link] Multiple Integrals; Improper Integrals — (20/25)
Multiple Integrals Calculus Treasures
Improper Integrals Taylor Expansions... Surprise!
Example#1 I/III
We want to compute
1
ex
Z
dx.
0 x 1/2
The fourth order Taylor polynomial is
x2 x3 x4
P4 (x) = 1 + x + + + ,
2 6 24
Example#1 I/III
We want to compute
1
ex
Z
dx.
0 x 1/2
The fourth order Taylor polynomial is
x2 x3 x4
P4 (x) = 1 + x + + + ,
2 6 24
so
1 1
P4 (x) x 3/2 x 5/2 x 7/2
Z Z
dx = x −1/2 + x 1/2 + + + dx
0 x 1/2 0 2 6 24
2 2 2 2 2
= + + + + ≈ 2.923544974
1 3 2 · 5 6 · 7 24 · 9
Example#1 II/III
R1
Next, we apply CSR with h = 1/4 to 0
G (x) dx, where
x
e − P4 (x) x ∈ (0, 1]
G (x) = x 1/2
0 x = 0.
Example#1 II/III
R1
Next, we apply CSR with h = 1/4 to 0
G (x) dx, where
x
e − P4 (x) x ∈ (0, 1]
G (x) = x 1/2
0 x = 0.
1 ·
1
Z
G (x) dx ≈ 0 + 4 · 0.0000170 + 2 · 0.00413 + 4 · 0.0026026
0 4·3
¸
+0.0099485 = 0.0017691.
Example#1 II/III
R1
Next, we apply CSR with h = 1/4 to 0
G (x) dx, where
x
e − P4 (x) x ∈ (0, 1]
G (x) = x 1/2
0 x = 0.
1 ·
1
Z
G (x) dx ≈ 0 + 4 · 0.0000170 + 2 · 0.00413 + 4 · 0.0026026
0 4·3
¸
+0.0099485 = 0.0017691.
Hence,
Result
1
ex
Z
dx ≈ 2.923544974 + 0.0017691 = 2.9253141
0 x1/2
Example#1 III/III
Since |G (4) (x)| < 1 on (0, 1], the error from CSR is bounded by
1 1
· 4 = 0.0000217.
180 4
Example#1 III/III
Since |G (4) (x)| < 1 on (0, 1], the error from CSR is bounded by
1 1
· 4 = 0.0000217.
180 4
The error bound for the Taylor-only approximation is bounded by
1
= 0.00151515
5! · 5.5
Example#1 III/III
Since |G (4) (x)| < 1 on (0, 1], the error from CSR is bounded by
1 1
· 4 = 0.0000217.
180 4
The error bound for the Taylor-only approximation is bounded by
1
= 0.00151515
5! · 5.5
R
If, instead of adding the CSR-approximation of G (x) dx, we used
P5 (x), the error bound for that Taylor-only approximation would be
1
= 0.00021044.
6! · 6.5
Example#1 III/III
Since |G (4) (x)| < 1 on (0, 1], the error from CSR is bounded by
1 1
· 4 = 0.0000217.
180 4
The error bound for the Taylor-only approximation is bounded by
1
= 0.00151515
5! · 5.5
R
If, instead of adding the CSR-approximation of G (x) dx, we used
P5 (x), the error bound for that Taylor-only approximation would be
1
= 0.00021044.
6! · 6.5
Example#2 I/II
Example#2 I/II
Example#2 I/II
Example#2 I/II
Example#2 II/II
We define
sin(t) − P6 (t) t ∈ (0, 1]
G (t) = t 1/2
0 t = 0,
R1
and apply CSR with h = 1/32 to 0 G (t) dt to get
Result
∞ µ ¶
1 1
Z
sin dx
1 x3/2 x