You are on page 1of 9

D.

Keffer, ChE 505 ,University of Tennessee, September, 1999


i
Numerical Techniques for the Evaluation of
Multi-Dimensional Integral Equations
David Keffer
Department of Chemical Engineering
University of Tennessee, Knoxville
September 1999
Table of Contents
1. Numerical Derivation of the trapezoidal rule for the 2-D case with constant integration limits 1
2. Numerical Derivation of the trapezoidal rule for the 3-D case with constant integration limits 3
3. Numerical Derivation of the trapezoidal rule for the 2-D case with variable integration limits 5
4. Numerical Derivation of the Simpsons 1/3 rule for the 2-D case with constant integration limits 7
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
1
1. Numerical Derivation of the trapezoidal rule for the 2-D case with constant integration limits
In Section 4.6 of Numerical Recipes in Fortran 77, second edition, you can find a brief discussion of
when to use different types of numerical methods for evaluating multidimensional integrals.
For the purposes of this course, I am going to show you how to extend the one-dimensional integral
evaluation to n-dimensional integral evaluation. This techniques relies upon you have rather simple boundaries to
the integral.
For integrals in one dimension, we could start with something simple like the trapezoidal rule.
1
]
1

+ +

n
2 i
i
b
a
) x ( f 2 ) b ( f ) a ( f
2
h
dx ) x ( f (1.1)
Now if we have a 2-D integral we write this as:


xf
xo
xf
xo
yf
yo
D 2
dx ) x ( g dx dy ) y , x ( f I (1.2)
where
1
1
]
1

+ +

y
n
2 i
i f o
y
yf
yo
) y , x ( f 2 ) y , x ( f ) y , x ( f
2
h
dy ) y , x ( f ) x ( g (1.3)
Substituting the discretized approximation for g(x) in equation (1.3) into equation (1.2) we have



1
1
]
1

+ +

xf
xo
n
2 i
i f o
y
xf
xo
yf
yo
dx ) y , x ( f 2 ) y , x ( f ) y , x ( f
2
h
dx dy ) y , x ( f
y
(1.4)
Well, we can repeat the application of the trapezoidal rule:

'

1
]
1

+ + +
1
]
1

+ + +
1
]
1

+ +

x
y
y
y
n
2 j
n
2 i
i j f j o j
y
n
2 i
i f f f o f
y
n
2 i
i o f o o o
y
x
D 2
) y , x ( f 2 ) y , x ( f ) y , x ( f
2
h
2
) y , x ( f 2 ) y , x ( f ) y , x ( f
2
h
) y , x ( f 2 ) y , x ( f ) y , x ( f
2
h
2
h
I (1.5)
Now we can simplify this as much as possible,
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
2
[ ] [ ]

'

+ + + +
+ + + +



y
x
y x
n
2 i
n
2 j
f j o j i f i o
n
2 i
n
2 j
i j f f o f f o o o
y x
D 2
) y , x ( f ) y , x ( f 2 ) y , x ( f ) y , x ( f 2
) y , x ( f 4 ) y , x ( f ) y , x ( f ) y , x ( f ) y , x ( f
4
h h
I (1.6)
If we add up the number of function evaluations, we can see that we have
y x
n n function evaluations. If
n n n
y x
, then we have
2
n function evaluations for a 2-D integral. If we need to evaluate an m-dimensional
integral, then we will have
m
n function evaluations.
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
3
2. Numerical Derivation of the trapezoidal rule for the 3-D case with constant integration limits
Now if we have a 3-D integral we write this as:


xf
xo
xf
xo
yf
yo
zf
zo
D 3
dx ) x ( h dx dy dz ) z , y , x ( f I (2.1)
where


yf
yo
yf
yo
zf
zo
dy ) y , x ( g dy dz ) z , y , x ( f ) x ( h (2.2)
where

zf
zo
dz ) z , y , x ( f ) y , x ( g (2.3)
Using the trapezoidal rule approximation:
1
]
1

+ +

z
n
2 i
i f o
z
zf
zo
) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f
2
h
dz ) z , y , x ( f ) y , x ( g (2.4)
Substituting the discretized approximation for g(x,y) from equation (2.4) into equation (2.2) we have



1
]
1

+ +

yf
yo
n
2 i
i f o
z
yf
yo
zf
zo
dy ) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f
2
h
dy dz ) z , y , x ( f ) x ( h
z
(2.5)
Well, we can repeat the application of the trapezoidal rule:

'

1
]
1

+ + +
1
]
1

+ + +
1
]
1

+ +

y
z
z
z
n
2 j
n
2 i
i j f j o j
z
n
2 i
i f f f o f
z
n
2 i
i o f o o o
z
y
) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f
2
h
2
) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f
2
h
) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f
2
h
2
h
) x ( h (2.6)
Now we can simplify this as much as possible,
[ ] [ ]

'

+ + + +
+ + + +



z
y
y z
n
2 i
n
2 j
f j o j i f i o
n
2 j
n
2 i
i j f f o f f o o o
z y
) z , y , x ( f ) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f 2
) z , y , x ( f 4 ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
4
h h
) x ( h (2.7)
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
4
Now we can apply the trapezoidal rule one more time:
[ ] [ ]
[ ] [ ]
[ ] [ ]
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
]
1

'

+ + + +
+ + + +
+

'

+ + + +
+ + + +
+

'

+ + + +
+ + + +







nx
2 k
n
2 i
n
2 j
f j k o j k i f k i o k
n
2 j
n
2 i
i j k f f k o f k f o k o o k
n
2 i
n
2 j
f j f o j f i f f i o f
n
2 j
n
2 i
i j f f f f o f f f o f o o f
n
2 i
n
2 j
f j o o j o i f o i o o
n
2 j
n
2 i
i j o f f o o f o f o o o o o
3
z y x
D 3
z
y
y
z
z y
y
z
z y
y z
) z , y , x ( f ) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f 2
) z , y , x ( f 4 ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
2
) z , y , x ( f ) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f 2
) z , y , x ( f 4 ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
) z , y , x ( f ) z , y , x ( f 2 ) z , y , x ( f ) z , y , x ( f 2
) z , y , x ( f 4 ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
2
h h h
I
(2.8)
which if we really are bored ten minutes to five on a Wednesday evening, we can rearrange as:
[ ]
[ ]
[ ]
[ ] [ ]
[ ]
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
]
1

'

+ +
+ + +
+

'

+ + + +
+ + + +
+ + +
+

'

+ + + +
+ + +

nx
2 k
n
1 j
n
2 i
i j k
nx
2 k
n
1 j
f j k o j k
nx
2 k
n
2 i
i f k i o k
n
1 j
n
2 i
i j f i j o
nx
2 k
f f k o f k f o k o o k
n
2 j
f j f o j f f j o o j o
n
2 i
i f f i o f i f o i o o
f f f o f f f o f o o f
f f o o f o f o o o o o
3
z y x
D 3
y z
y
z
y
z
y
z
) z , y , x ( f 8
) z , y , x ( f ) z , y , x ( f
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
4
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
2
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
) z , y , x ( f ) z , y , x ( f ) z , y , x ( f ) z , y , x ( f
2
h h h
I
(2.9)
This is the explicit form of the trapezoidal rule applied in 3-dimensions, when the limits of integration are
constant.
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
5
3. Numerical Derivation of the trapezoidal rule for the 2-D case with variable integration limits
Now if we have a 2-D integral with variable limits of integration, we write this as:


xf
xo
xf
xo
) x ( yf
) x ( yo
D 2
dx ) x ( g dx dy ) y , x ( f I (3.1)
where
1
]
1

+ +

) x ( n
2 i
i f o
y
) x ( yf
) x ( yo
y
)) x ( y , x ( f 2 )) x ( y , x ( f )) x ( y , x ( f
2
h
dy ) y , x ( f ) x ( g (3.2)
The number of y-intervals, ) x ( n
y
, is now a function of x because the size of the y-range of integration is a
function of x. Substituting the discretized approximation for g(x) in equation (3.2) into equation (3.1) we have



1
]
1

+ +

xf
xo
) x ( n
2 i
i f o
y
xf
xo
yf
yo
dx )) x ( y , x ( f 2 )) x ( y , x ( f )) x ( y , x ( f
2
h
dx dy ) y , x ( f
y
(3.3)
Well, we can repeat the application of the trapezoidal rule:

'

1
]
1

+ + +
1
]
1

+ + +
1
]
1

+ +

x
j y
f y
o y
n
2 j
) x ( n
2 i
j i j j f j j o j
y
) x ( n
2 i
f i f f f f f o f
y
) x ( n
2 i
o i o o f o o o o
y
x
D 2
)) x ( y , x ( f 2 )) x ( y , x ( f )) x ( y , x ( f
2
h
2
)) x ( y , x ( f 2 )) x ( y , x ( f )) x ( y , x ( f
2
h
)) x ( y , x ( f 2 )) x ( y , x ( f )) x ( y , x ( f
2
h
2
h
I (3.4)
Now we can simplify this as much as possible,

'

+
1
]
1

+ + + +
+ + +





x j y
x x f y o y
n
2 j
) x ( n
2 i
j i j
n
2 j
j f j
n
2 j
j o j
) x ( n
2 i
f i f
) x ( n
2 i
o i o
f f f f o f o f o o o o
y x
D 2
)) x ( y , x ( f 4
)) x ( y , x ( f )) x ( y , x ( f )) x ( y , x ( f )) x ( y , x ( f 2
)) x ( y , x ( f )) x ( y , x ( f )) x ( y , x ( f )) x ( y , x ( f
4
h h
I (3.5)
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
6
Lets do an example. Lets integrate cxy ) y , x ( f over the range 1 x 0 and y x 0 . Lets do it
analytically first:
8
c
8
cx
dx
2
cx
dx
2
cxy
dx cxydy dx dy ) y , x ( f I
1
0
4 1
0
3 1
0
x
0
2 1
0
x
0
xf
xo
yf
yo
D 2

1
]
1



(3.6)
Now lets do it analytically with 1 . 0 h y x 2 c
i x yo(x) yf(x) ny(x) f(x,yo) f(x,yf) sum(f(x,yj
)
integral(x)
0 0 0 0 0 0 0 0 0
1 0.1 0 0.1 1 0 0.2 0 0.01
2 0.2 0 0.2 2 0 0.4 0.02 0.022
3 0.3 0 0.3 3 0 0.6 0.12 0.042
4 0.4 0 0.4 4 0 0.8 0.36 0.076
5 0.5 0 0.5 5 0 1 0.8 0.13
6 0.6 0 0.6 6 0 1.2 1.5 0.21
7 0.7 0 0.7 7 0 1.4 2.52 0.322
8 0.8 0 0.8 8 0 1.6 3.92 0.472
9 0.9 0 0.9 9 0 1.8 5.76 0.666
10 1 0 1 10 0 2 8.1 0.91
total 0.2405
The numerical solution is 2405 . 0 I
D 2
compared to the exact solution, 25 . 0 I
D 2

D. Keffer, ChE 505 ,University of Tennessee, September, 1999
7
4. Numerical Derivation of the Simpsons 1/3 rule for the 2-D case with constant integration limits
Now if we have a 2-D integral we write this as:


xf
xo
xf
xo
yf
yo
D 2
dx ) x ( g dx dy ) y , x ( f I (4.1)
where

,
_

+ + +

2 n
7 , 5 , 3 i
i
1 n
6 , 4 , 2 i
i f o
y
yf
yo
y y
) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
dy ) y , x ( f ) x ( g (4.2)
Substituting the discretized approximation for g(x) in equation (4.2) into equation (4.1) we have

,
_

+ + +

xf
xo
2 n
7 , 5 , 3 i
i
1 n
6 , 4 , 2 i
i f o
y
xf
xo
yf
yo
dx ) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
dx dy ) y , x ( f
y y
(4.3)
Well, we can repeat the application of the trapezoidal rule:

'

,
_

+ + + +

,
_

+ + + +

,
_

+ + + +

,
_

+ + +

2 n
7 , 5 , 3 j
2 n
7 , 5 , 3 i
i j
1 n
6 , 4 , 2 i
i j f j o j
y
1 n
6 , 4 , 2 j
2 n
7 , 5 , 3 i
i j
1 n
6 , 4 , 2 i
i j f j o j
y
2 n
7 , 5 , 3 i
i f
1 n
6 , 4 , 2 i
i f f f o f
y
2 n
7 , 5 , 3 i
i o
1 n
6 , 4 , 2 i
i o f o o o
y
x
D 2
x
y y
x
y y
y y
y y
) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
2
) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
4
) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
) y , x ( f 2 ) y , x ( f 4 ) y , x ( f ) y , x ( f
3
h
3
h
I (4.4)
Now we can simplify this as much as possible,
D. Keffer, ChE 505 ,University of Tennessee, September, 1999
8
[ ] [ ]
[ ] [ ]

'

+ +

,
_

+ +

,
_

+ + + +

,
_

+ + + +
+ + +

1 n
6 , 4 , 2 j
1 n
6 , 4 , 2 i
i j
2 n
7 , 5 , 3 j
2 n
7 , 5 , 3 i
i j
2 n
7 , 5 , 3 j
1 n
6 , 4 , 2 i
i j
1 n
6 , 4 , 2 j
2 n
7 , 5 , 3 i
i j
1 n
6 , 4 , 2 j
f j o j
1 n
6 , 4 , 2 i
i f i o
2 n
7 , 5 , 3 j
f j o j
2 n
7 , 5 , 3 i
i f i o
f f o f f o o o
y x
D 2
x
y
x
y
x
y
x
y
x
y
x y
) y , x ( f 16 ) y , x ( f 4
) y , x ( f ) y , x ( f 8
) y , x ( f ) y , x ( f ) y , x ( f ) y , x ( f 4
) y , x ( f ) y , x ( f ) y , x ( f ) y , x ( f 2
) y , x ( f ) y , x ( f ) y , x ( f ) y , x ( f
9
h h
I (4.5)

You might also like