Page 181 - Numerical methods for chemical engineering
P. 181
Multidimensional integrals 167
Multidimensional integrals
The techniques introduced above are extended easily to multidimensional integrals. For
example, consider the double integral
' b ' u(x)
I D = f (x, y)dydx (4.76)
a l(x)
Let us define the function of x alone,
' u(x)
F(x) = f (x, y)dy (4.77)
l(x)
- b
such that I D = F(x)dx. Applying the methods of 1-D integration,
a
' b N
x
F(x)dx ≈ w F(x k ) (4.78)
k
a k=0
We approximate each F(x k ) using support points y kj ∈ [l(x k ), u(x k )],
u(x k )
' M k
y
F(x k ) = f (x k , y)dy ≈ w f (x k , y kj ) (4.79)
kj
l(x k ) j=0
such that
b u(x) N
' ' M k
. /
I D = f (x, y)dydx ≈ w x w y f (x k , y kj ) (4.80)
k kj
a l(x) k=0 j=0
dblquad applies this approach to integration domains that are rectangles in two dimen-
sions. For nonrectangular domains, we must compute the integral over a rectangular region
encompassing the domain of integration, and then set the integrand to zero outside of the
integration domain,
' b ' u(x) ' b ' u max
f (x, y)dydx = f (x, y) (x, y)dydx
a l(x) a l min
u max = max x∈ [a, b] u(x) l min = min x∈ [a, b] l(x)
(4.81)
1, if l(x) ≤ y ≤ u(x)
(x, y) =
0, otherwise
In three dimensions, triple integrals are evaluated using triplequad. To integrate f (x, y) =
2
2
2
2
x + 2y − 2xy over the unit circle, x + y ≤ 1,
'
2
2
I D = [x + 2y − 2xy]dxdy (4.82)
2
2
x +y ≤1
we write a routine that returns f (x, y) for (x, y) within the circle and a value of zero for
(x, y) outside of it. dblquad expects the function to accept a vector of x arguments and a
scalar y argument. Here, the function is
function f = calc integrand 2D(x,y);
f = zeros(size(x));