Computing Integrals over Polynomially Defined Regions and Their

Computing Integrals over Polynomially
Defined Regions and Their Boundaries in 2
and 3 Dimensions
Michael J. Wester
Department of Mathematics and Statistics
Center for High Performance Computing
University of New Mexico
Albuquerque NM 87131-1141 USA
Yuzita Yaacob
Department of Industrial Computing
National University of Malaysia
43100 Malaysia
Stanly Steinberg
Department of Mathematics and Statistics
Cancer Research and Treatment Center
University of New Mexico
Albuquerque NM 87131-1141 USA
June 2, 2011
Key Words: area integral, line integral, volume integral, surface integral,
iterated integrals, cylindrical algebraic decomposition
Short title: Two and Three Dimensional Integrals
1
Contents
1 Introduction
4
2 Integrals
5
3 Regions and Volumes
7
4 Two Dimensional Examples
11
4.1 Simple Examples . . . . . . . . . . . . . . . . . . . . . . . . . 12
5 Boxes and Planar Integrals
5.1 Examples . . . . . . . . . .
5.2 Boundaries of Boxes . . . .
5.3 Boundaries of Regions . . .
5.4 Integrals Over Boundaries of
5.5 Examples Continued . . . .
5.6 Green’s Theorem . . . . . .
. . . . . .
. . . . . .
. . . . . .
Boxes and
. . . . . .
. . . . . .
. . . . .
. . . . .
. . . . .
Regions
. . . . .
. . . . .
6 Advanced Two-Dimensional Examples
6.1 A Hexagon . . . . . . . . . . . . . . . . .
6.2 The Intersection of Two Circles . . . . .
6.3 A Self Intersecting Curve . . . . . . . . .
6.4 The Intersection of Two Ellipses . . . . .
6.5 Examples with Symbolic Parameters . .
6.5.1 A Circle with Parametric Radius
6.5.2 The Witch of Agnesi . . . . . . .
7 Three-Dimensional Integration
7.1 3D Cylinders . . . . . . . . . . . .
7.2 The Boundary of a Cylinder . . . .
7.3 The Divergence Theorem . . . . . .
7.4 General Curves and Surfaces in 3D
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14
14
15
17
19
20
21
.
.
.
.
.
.
.
22
22
24
25
26
27
27
28
.
.
.
.
28
29
30
31
31
8 Summary
32
A Parameterization of Boundary Curves
36
2
List of Figures
1
2
3
4
5
6
7
8
9
10
11
An Annulus . . . . . . . . . . . . . . . . . . . . . . . . . . .
A Diamond . . . . . . . . . . . . . . . . . . . . . . . . . . .
An Unbounded Region . . . . . . . . . . . . . . . . . . . . .
A Generalized Box (Cylinder). . . . . . . . . . . . . . . . . .
The Boxes for a Circle and Square and Their Complements.
Tangents and Normals for a Box. . . . . . . . . . . . . . . .
A Hexagon. . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Intersection of Two Circles. . . . . . . . . . . . . . . . .
A self Intersecting Curve. . . . . . . . . . . . . . . . . . . . .
The Intersection of Two Ellipses. . . . . . . . . . . . . . . .
The Intersection of a Circular Cylinder and a Sphere. . . .
Abstract
We use the cylindrical algebraic decomposition algorithms implemented in Mathematica to produce procedures to analytically compute integrals over polynomially defined regions and their boundaries
in two and three dimensions. Using these results, we can implement
the Divergence Theorem in three dimensions or the Green’s theorems
in two dimensions. These theorems are of central importance in the applications of multidimensional integration. They also provide a strong
correctness test for the implementation of our results in a computer
algebra system. The resulting software can solve many of the two
and some of the three dimensional integration problems in vector calculus textbooks. The three dimensional results are being extended.
The results in this paper are being included in an automated student
assistant for vector calculus.
3
.
.
.
.
.
.
.
.
.
.
.
7
8
9
11
12
16
22
24
25
27
29
1
Introduction
The evaluation of integrals over planar regions and curves in two dimensions
is a problem addressed in most (probably all) introductory one-year calculus
textbooks. More advanced texts will also discuss integrals over volumes,
surfaces and curves in three dimensions [5]. These topics are central to
the application of vectors in science and engineering. If the geometry or
the function being integrated is complicated, then the method of choice for
evaluation is numerical. Here, we focus on developing procedures for the
analytic evaluation of such integrals when the ingredients in the integral
are sufficiently simple. In two dimensions, we focus on planar regions and
curves that are the boundaries of such regions. In three dimensions, we
only consider simple volumes and the surfaces that are boundaries of these
regions. We assume that the planar regions and volumes can be described
using polynomial inequalities.
An important contribution is the extension of the integration tools in
Mathematica to boundary curves and surfaces, allowing the use of Green’s
and the Divergence Theorems, a central part of integration theory in vector
calculus.
The basic tool in our work is the cylindrical algebraic decomposition
(CAD) algorithm that can decompose complicated regions into a union of
simple regions [1, 2]. This algorithm requires the region to be described
by polynomial inequalities. Historically, the CAD algorithm was used to
solve quantifier elimination problems [3, 4]. For applications of quantifier
elimination algorithms to engineering problems, see [8, 10]. For newer types
of CAD algorithms, see [6].
Our ultimate goal is to include the material in this paper into a program
that helps students learn vector calculus [13, 14]. This program uses Mathematica, so we have implemented our ideas in this system. Mathematica
can already evaluate area and volume integrals using procedures based on
[11, 12]. However, for the student assistant, we need to know some of the
intermediate results, so these tools are not exactly what we need. More importantly, these tools cannot find integrals over the boundaries of regions.
Consequently, we will return to the ideas presented in [9, 11] to build our
vector calculus tools.
4
2
Integrals
If R is a region and C is a curve in a two dimensional plane, then mathematicians write the integrals that we will study as
Z
ZZ
Z
Z
ds
f=
f (x, y) dx dy ,
g = g(ξ)
dξ .
(2.1)
dξ
R
R
C
where x and y are real variables, f is a real valued function defined on the
region, g is a real valued function of a real variable, s is an arc length variable
on the curve and ξ is a parameter. Also, if Ω is a volume and S is a surface
in three dimensional space, then we will study integrals of the form
Z
ZZZ
Z
ZZ
f=
f (x, y, z) dx dy dz ,
h=
h(ξ, η) J(x, y, z; ξ, η) dξ dη .
Ω
Ω
S
(2.2)
where x, y and z are real variables, f is a real valued function defined in the
volume, h is a real valued function of two real variables, J is a surface area
element, and ξ and η are parameters. We will focus on curves that are the
boundary of a region, C = ∂R, and surfaces that are boundaries of volumes,
S = ∂Ω.
Integrals over planar regions will be reduced to a sum of iterated integrals, while integrals over curves will be reduced to a sum of integrals over
intervals. In three dimensions, integrals over volumes will be reduced to a
sum of triple integrated integrals, integrals over surfaces to a sum of double
iterated integrals. Many computer algebra systems can evaluate the resulting
integrals if this is mathematically possible. We write the integrals as sums
of simpler integrals by writing the region or volume as a union of simple regions or volumes where integrals over each part can be written as an iterated
integral or an integral over an interval.
To accomplish our goals, we use some basic facts about integrals. The first
is that integrals over lower dimensional sets are zero. For volume integrals,
adding or removing surfaces, curves or points from the volume doesn’t change
the value of the integral. For integrals over regions in the plane or surfaces in
three dimensions, adding or removing curves and points does not affect the
value of the integrals. Finally, for curves, adding or removing points doesn’t
change the value.
For applications that involve Green’s or the Divergence Theorems, it is
customary to assume the regions are non-trivial and contain their boundary.
5
More formally, we assume that the region satisfies
clo int R = R ,
where clo means the closure and int means the interior of the set. It is also
important that the boundary consists of a finite number of smooth pieces.
Another crucial fact is that if R is the union of essentially disjoint sets,
that is, if K is a positive integer and
R = ∪K
k=1 Sk ,
(2.3)
where
int Sj ∧ int Sk = ∅ ,
1 ≤ j, k ≤ K ,
and ∅ is the empty set, then
Z
f=
R
K Z
X
k=1
f.
Sk
The situation for boundary integrals is more complex because boundaries
are oriented. If Sj and Sk have a portion of their boundaries in common, then
the orientation of these parts must be opposing, and thus they are not part of
the boundary of R and so can be eliminated from the boundary calculation.
With this understanding,
∂R = ∪K
k=1 ∂Sk .
This operation is also commonly written as a sum rather than a union to
indicate that the parts with opposite orientation cancel. This simplification
gives
∂R = ∪Jj=1 Cj ,
where J is a positive integer, Cj is an oriented curve and the Cj are essentially
disjoint. Then
Z
J Z
X
g=
g.
∂R
j=1
Cj
For some important boundary integrals, the simplification is not required,
but it does reduce the amount of computation needed to find the integral.
6
y
3
2
1
x
-3
-2
1
-1
2
3
-1
-2
-3
Figure 1: An Annulus
3
Regions and Volumes
We will assume that the regions and volumes can be described by a finite
number of polynomials. This well cover many problems from vector calculus,
but not regions that are described by logarithms, exponentials, trigonometric,
or more general functions. More precisely, we will assume that our sets are
semi-algebraic, that is, a region R is defined by
R = {(x, y) : F (x, y) is true } ,
where F (x, y) is a finite logical formula that involves only real polynomials
in the real variables x and y. We will assume that a volume Ω is defined by
Ω = {(x, y, z) : F (x, y, z) is true } ,
where F (x, y, z) is a finite logical formula that involves only real polynomials
in the real variables x, y and z. The logical formulas can use any of ≤, ≥,
<, > and = to connect two polynomials and not (¬), and (∧), and or (∨) in
the construction of the logical formulas. For example,
x2 + y 2 ≥ 1 ∧ x2 + y 2 ≤ 2
defines the annulus shown in Figure 1. A basic theorem in logic says that
we can write any formula as the ∨ of a finite number of terms that are an ∧
of a finite number of terms, that is, the set is a union of intersections of sets
where each set is given by a polynomial equality or inequality.
7
Figure 2: A Diamond
The powerful cylindrical algebraic decomposition (CAD) algorithm [3, 4]
decomposes general semi-algebraic sets into unions of simpler sets that are
called cylinders in the computational algebraic geometry literature. However,
we are not interested in general semi-algebraic sets, but only sets that are
the closure of their interior. Mathematica provides two CAD functions:
CylindricalDecomposition,
which we abbreviate CD;
GenericCylindricalDecomposition, which we abbreviate GCD.
Neither of these do exactly what we want, as the following two examples
illustrate.
Consider the region D defined by the formula
D(x, y) = x + y ≥ −1 ∧ x − y ≥ −1 ∧ x − y ≤ 1 ∧ x + y ≤ 1 ,
(3.1)
which describes a closed set that is the diamond in Figure 2. The integral of
a function f over this region is
Z 0 Z x+1
Z 1 Z −x+1
f (x, y) dy dx +
f (x, y) dy dx .
(3.2)
−1
0
−x−1
x−1
If we apply CD to the formula (3.1) for D, we get
(x = −1 ∧ y = 0) ∨ (−1 < x ≤ 0 ∧ −x − 1 ≤ y ≤ x + 1)
∨ (0 < x < 1 ∧ x − 1 ≤ y ≤ 1 − x) ∨ (x = 1 ∧ y = 0) ,
(3.3)
which lists two of the corner points as separate cylinders. We can eliminate
the terms containing = as planar integrals over points are zero. Note that
8
Figure 3: An Unbounded Region
the vertical line segment that is part of x = 0 is listed as part of one of the
triangles, but not the other.
If we apply the rules ≥→> and ≤→< to the formula (3.1) for D and
then apply CD to the result, we get
(−1 < x ≤ 0 ∧ −x − 1 < y < x + 1) ∨ (0 < x < 1 ∧ x − 1 < y < 1 − x) ,
which is what we got by eliminating the equalities from (3.3). Alternatively,
if we apply GCD and then take the the first part of the answer, we get
(−1 < x < 0 ∧ −x − 1 < y < x + 1) ∨ (0 < x < 1 ∧ x − 1 < y < 1 − x) .
This is a subset of the interior of D with the property that its closure is again
D. Any of these results can easily translated into the integrals in (3.2), but
we prefer this last form because of its symmetry, that is, no part of x = 0 is
included in the answer.
Cylinders for unbounded regions have a different algebraic form than
those for bounded regions. Integrals over such regions are called improper.
Consider the closed unbounded region
xy ≤ 1 ∧ x ≥ 0 ∧ y ≥ 0
shown in Figure 3. From CD, we get
1
(x = 0 ∧ y ≥ 0) ∨ x > 0 ∧ 0 ≤ y ≤
,
x
9
(3.4)
while from the other two methods we get
x> 0∧0 <y <
1
,
x
which is easy to translate into the integral
Z ∞Z 1
x
f (x, y) dy dx .
0
0
It is common to use
0 ≤ x ∧ 0 ≤ y ≤ 1/x ,
to denote the region given in (3.4).
For programming, writing the cylinders in open form is the best for us.
All such cylinders can be written in the form
a < x < b ∧ l(x) < y < u(x) ,
(3.5)
where a and b are extended real numbers and l and u are smooth functions
with values in the extended real numbers. One important example is the full
plane:
−∞ < x < +∞ ∧ −∞ < y < +∞ .
Implementation Note: As far as we know, it doesn’t make a significant
difference which method is used to find the CAD. For translating the cylinders
to integrals, we put them into open form. Even so there are many special
cases where CD and GCD do not put cylinders exactly in the form in (3.5).
Examples are the half-plane, which has a CAD of 0 ≤ x, and the full plane
given above, which has the CAD that is the word True. There are many
special cases like these that must be individually programmed. The examples
of the exterior of a circle and the exterior of a square, given below, will
illustrate these complexities.
Implementation Note: Because we want to use our work here as part of
a student assistant, we will allow the students to use general semi-algebraic
formulas. For the students, we built a function OurForm that first applies
the Mathematica command LogicalExpand to put formulas in a standard
form as a union of intersections of sets with all negations (¬) removed. Any
intersection containing an = will be deleted as these describe sets of measure
zero. We put the cylinders into closed form to display to the students. All
inequalities are written with one of the terms zero. However, P ≥ 0 is the
same as −P ≤ 0, so we only need to use one of ≤ or ≥ in our formulas.
10
y
u (x)
l (x)
x
a
b
Figure 4: A Generalized Box (Cylinder).
4
Two Dimensional Examples
Since we are considering two variables, the cylinders will be generalized boxes
(and are thus called a box and denoted by B) that have two straight sides
and a curved top and bottom as illustrated in Figure 4. The formulas for the
interior of such boxes can be written in the form
B(x, y) = a < x < b ∧ l(x) < y < u(x) ,
(4.1)
where a and b are either real constants or a = −∞ or b = +∞, and l(x) and
u(x) are continuous real valued functions on the interval (a, b) or l(x) = −∞
or u(x) = +∞. Importantly, a < b and l(x) < u(x). In summary, if we
assume that R is a semi-algebraic set in the plane satisfying clo int R = R,
then we decompose R into a union of essentially disjoint boxes:
R = ∪K
k=1 Bk ,
where K > 0 is an integer.
11
(4.2)
y
y
1.0
1.0
0.5
0.5
C1
C1
x
-1.0
0.5
-0.5
x
1.0
-1.0
0.5
-0.5
-0.5
-0.5
-1.0
-1.0
disk
1.0
square
y
y
3
3
C3
2
2
C3
1
1
C1
C4
C1
C4
x
-3
-2
1
-1
-1
2
x
3
-3
-2
1
-1
2
3
-1
C2
C2
-2
-2
-3
-3
exterior of a disk
exterior of a square
Figure 5: The Boxes for a Circle and Square and Their Complements.
For our examples, we do not assume that they are given as open or closed
regions. In working with an example, we convert it to a closed representation
for presentation and open representation for computation.
4.1
Simple Examples
Simple examples of regions are given by a disk, a square and their complements (see Figure 5). The disk and square are both generalized boxes, while
their complements are the union of four boxes. The closed disk is given by
the formula
F (x, y) = x2 + y 2 ≤ 1 ,
while the closed square is given by the formula
F (x, y) = x ≥ −1 ∧ x ≤ 1 ∧ y ≥ −1 ∧ y ≤ 1 .
These two regions are boxes: for the disk, the closed box is given by
√
√
B(x, y) = −1 ≤ x ≤ 1 ∧ − 1 − x2 ≤ y ≤ 1 − x2 ,
12
(4.3)
while for the square, the closed box is
B(x, y) = −1 ≤ x ≤ 1 ∧ −1 ≤ y ≤ 1 .
(4.4)
The exterior of the closed disk is an open set given by formula
¬ x2 + y 2 ≤ 1 = x2 + y 2 > 1 .
It’s closure is given by
F (x, y) = x2 + y 2 ≥ 1 .
The complement of the square is more interesting. It is an open set described
by the formula
¬(x ≥ −1 ∧ x ≤ 1 ∧ y ≥ −1 ∧ y ≤ 1) ,
which can be expanded to
x < −1 ∨ x > 1 ∨ y < −1 ∨ y > 1 .
The formula for the closure of this region is:
F (x, y) = x ≤ −1 ∨ x ≥ 1 ∨ y ≤ −1 ∨ y ≥ 1 .
The closed boxes for the complement of the disk are
B1 (x, y)
B2 (x, y)
B3 (x, y)
B4 (x, y)
= −∞ < x ≤ −1
=
−1 ≤ x ≤ 1
=
−1 ≤ x ≤ 1
=
1≤x<∞
∧
∧
∧
∧
−∞ < y < ∞√,
−∞ < y ≤ − 1 − x2 ,
√
1 − x2 ≤ y < ∞ ,
−∞ < y < ∞ ,
(4.5)
while the closed boxes for the complement of the square are
B1 (x, y)
B2 (x, y)
B3 (x, y)
B4 (x, y)
= −∞ < x ≤ −1
=
−1 ≤ x ≤ 1
=
−1 ≤ x ≤ 1
=
1≤x<∞
13
∧
∧
∧
∧
−∞ < y < ∞ ,
−∞ < y ≤ −1 ,
1 ≤ y < ∞,
−∞ < y < ∞ .
(4.6)
5
Boxes and Planar Integrals
Our modified CAD algorithm writes regions as the essentially disjoint union
of the closures of open boxes (4.2). We use this to explicitly give the integral
of a function over a region as a sum of iterated integrals over boxes. We also
write integrals over the boundary of a region as sums of integrals over an
interval, so that we can apply Green’s theorem to such integrals.
The interior of a box B has a formula of the form (4.1)
B(x, y) = a < x < b ∧ l(x) < y < u(x) .
The integral of a function f = f (x, y) over the box is given by
Z
5.1
f=
B
Z bZ
a
u(x)
f (x, y) dy dx .
l(x)
Examples
As stated earlier, the circle and square shown in Figure 5 are already boxes
described by the formulas (4.3) and (4.4). Typically, simple integrals over a
circle are best done in polar coordinates, but our methods work directly on
the Cartesian representation. The integrals of f over these regions are given
by
Z 1 Z √1−x2
Z 1Z 1
f (x, y) dy dx and
f (x, y) dy dx.
√
−1
− 1−x2
−1
−1
The exteriors of the circle and square are the disjoint union of four boxes
as given by (4.5) and (4.6). The integral of f over these exteriors are
Z
−1
−∞
Z
Z
∞
f (x, y) dy dx +
−∞
1 Z ∞
−1
√
Z
1
−1
f (x, y) dy dx +
1−x2
Z
−∞
Z ∞Z ∞
1
14
√
− 1−x2
−∞
f (x, y) dy dx
f (x, y) dy dx ,
and
Z
−1
−∞
Z
Z
f (x, y) dy dx +
−∞
1 Z ∞
−1
5.2
∞
Z
f (x, y) dy dx +
1
1
Z
−1
f (x, y) dy dx
−1 −∞
Z ∞Z ∞
1
f (x, y) dy dx .
−∞
Boundaries of Boxes
In general, if a curve is parameterized by ξ, 0 ≤ ξ ≤ 1, then a tangent vector
to the curve in the direction of increasing ξ is given by
T~ (ξ) = (x′ (ξ), y ′ (ξ)) .
The rate of change of the arc length with respect to ξ is given by
q
ds
~
= kT (ξ)k = (x′ (ξ))2 + (y ′(ξ))2 .
dξ
The unit tangent is given by
′
′
~t(ξ) = (x (ξ), y (ξ)) .
ds/dξ
The boundary of the box described in (4.1) is oriented in a counterclockwise direction as shown in Figure 6 and is generically given by the four
curves:
C1 = (x, l(x)),
a ≤ x ≤ b,
oriented →
C2 = (b, y),
l(b) ≤ y ≤ u(b), oriented ↑
(5.1)
C3 = (x, u(x)),
a ≤ x ≤ b,
oriented ←
C4 = (a, y),
l(a) ≤ y ≤ u(a), oriented ↓
It may be the case that l(a) = u(a) and/or l(b) = u(b), which would eliminate
C2 and/or C4 . Also, if any of a = −∞, b = +∞, l(x) ≡ −∞ or u(x) ≡ +∞
holds, then the curve involving the infinite variable doesn’t exist. Thus the
boundary of a box is a list of up to four segments that compose it.
It is convenient to parameterize the horizontal boundary curves using x
and the vertical ones using y. However, this parameterization traces out
the curves C3 and C4 in the wrong direction. This is not a problem if the
15
y
N3
u(x)
T3
T2
N4
N2
T4
l (x)
N1
T1
x
a
b
Figure 6: Tangents and Normals for a Box.
16
tangents and normals are chosen in the correct direction (see Appendix A).
The tangents to the boundary curves in (5.1) are chosen in the direction of
the orientation of the curve, while the normal vectors point in the direction
~ = T~ × ~k, where ~k is the unit normal
outward from the region, that is, by N
to the x-y plane. If prime indicates differentiation with respect to x or y,
then the tangents, normal vectors, and the differentials of arc length for the
curves (5.1) are given by (see Figure 6):
p
~ 1 = (l′ (x), −1) , ds = 1 + l′ (x)2 ,
T~1 = (1, l′ (x)) ,
N
dx
ds
~ 2 = (1, 0) ,
T~2 = (0, 1) ,
N
= 1,
dy
p
(5.2)
ds
′
′
~
~
T3 = (−1, −u (x)) , N3 = (−u (x), 1) , dx = 1 + u′ (x)2 ,
ds
~ 4 = (−1, 0) ,
T~4 = (0, −1) ,
N
= 1,
dy
Implementation Note: The boundary is represented by two lists, each
containing two curves. The lists are the horizontal segments that are parameterized by x
~ 1 } and {a ≤ x ≤ b, y = u(x), T~3 , N
~ 3 }, (5.3)
{a ≤ x ≤ b, y = l(x), T~1 , N
and the vertical segments that are parameterized by y
~ 2 } and {x = a, l(a) ≤ y ≤ u(a), T~4 , N
~ 4} .
{x = b, l(b) ≤ y ≤ u(b), T~2 , N
(5.4)
5.3
Boundaries of Regions
As regions are unions of boxes, a critical issue is the simplification of the
union of the boundaries of the boxes that make up the region. We begin by
finding the boundaries of our previous examples.
The boundary for the disk shown in Figure 5 has only two parts (not four
parts) because l(−1) = u(−1) and l(1) = u(1). Using the format (5.3), the
boundary is
√
x
√ x
,
,
−1
},
{ −1 ≤ x ≤ 1 , y = − 1 − x2 ,
1, √1−x
2
1−x2 √
x
√ x
,1
}.
{ −1 ≤ x ≤ 1 , y = 1 − x2 ,
−1, √1−x
,
2
1−x2
The boundary for the square has four parts and is given by
{ −1 ≤ x ≤ 1,
y = −1,
{1, 0}, {0, −1}
{
x = 1,
−1 ≤ y ≤ 1, {0, 1},
{1, 0}
{ −1 ≤ x ≤ 1,
y = 1,
{−1, 0}, {0, 1}
{
x = −1,
−1 ≤ y ≤ 1, {0, −1}, {−1, 0}
17
},
},
},
},
(5.5)
using the formats (5.3) and (5.4).
The boundaries of the boxes that make up the exterior of the box (4.6)
are given by the horizontal line segments
{ −1 ≤ x ≤ 1, y = −1, {−1, 0}, {0, 1} } ,
{ −1 ≤ x ≤ 1, y = 1,
{1, 0}, {0, −1} } ,
and the vertical line segments
{ x = −1,
{ x = 1,
{ x = −1,
{ x = −1,
{ x = 1,
{ x = 1,
−∞ < y ≤ −1, {0, −1}, {−1, 0} } ,
−∞ < y ≤ −1, {0, 1},
{1, 0} } ,
−∞ < y < ∞, {0, 1},
{1, 0} } ,
1 ≤ y < ∞,
{0, −1}, {−1, 0} } ,
1 ≤ y < ∞,
{0, 1},
{1, 0} } ,
−∞ < y < ∞, {0, −1}, {−1, 0} } .
The vertical segments can be simplified. The first
up of
{ x = −1, −∞ < y ≤ −1, {0, 1},
{ x = −1, −1 ≤ y ≤ 1, {0, 1},
{ x = −1,
1 ≤ y < ∞,
{0, 1},
vertical segment is made
{1, 0} } ,
{1, 0} } ,
{1, 0} } .
The first segment of this and the first vertical segment are
{ x = −1, −∞ < y ≤ −1, {0, 1},
{1, 0} } ,
{ x = −1, −∞ < y ≤ −1, {0, −1}, {−1, 0} } .
These cancel because the first two entries are the same, but the tangents
(and consequently the normals) are in opposite directions. Repeating this
three more times gives the boundary of the exterior of the square as found
above (5.5).
The general simplification rule is that if two vertical segments have opposite orientations, that is, their tangent vectors are in opposite directions,
then they cancel and are removed from the boundary. The difficulty is to
understand how to break up segments to give a complete cancellation. The
CAD algorithm does not produce horizontal segments that need simplification. The CAD for the L-shaped region that is the union of three “stacked”
boxes,
x ≥0∧x≤1∧y ≥0∧y ≤1 ∨
x ≥1∧x≤2∧y ≥0∧y ≤1 ∨
x ≥ 0∧x ≤ 1∧ y ≥ 1∧y ≤ 2,
18
is analyzed in one of our Mathematica notebooks to illustrate this point.
Also, note that the boundary of the exterior of the square has an orientation opposite that of the square. This must be the case because the union
of the square and it’s exterior is the full plane that has empty boundary.
Consequently the boundary of the interior and exterior must cancel. The
results for the exterior of the circle are similar.
Implementation Note: In Mathematica, we represent the segments of the
boundary by two lists, (5.4) gives the vertical segments while (5.3) gives the
horizontal segments. The inclusion of the tangent vectors make it easy to
check if two segments have opposite orientation. We have implemented simplification rules for vertical segments in one of our Mathematica notebooks.
5.4
Integrals Over Boundaries of Boxes and Regions
For the horizontal segments of the box shown in Figure 6, the arc length
integral, the second formula in (2.1) with ξ = x, g(ξ) replaced by f (x, y(x)),
and using (5.2), becomes
Z b
Z b
p
p
′
2
f (x, l(x)) 1 + l (x) dx and
f (x, u(x)) 1 + u′ (x)2 dx .
a
a
For the vertical segments, with ξ = y, the formula becomes
Z u(a)
Z u(b)
f (a, y) dy and
f (b, y) dy .
l(a)
l(b)
if the curve is parameterized by y. If f ≡ 1, then this integral gives the
length of the curve C. To find the length of a boundary, the union of the
boundaries of the boxes given by the CAD of the region must be simplified
and the above rules applied to the remaining segments.
In important applications, the curve integrals involve the inner product
of a vector field with the unit tangent or normal to the curve. In these
problems, the quantity being integrated will contain one of
~t(ξ) ds = (x′ (ξ), y ′(ξ)) = T~ (ξ) ,
dξ
~n(ξ)
ds
~ (ξ) .
= (y ′(ξ), −x′ (ξ)) = N
dξ
~ (x, y) is a force field, then the work done in moving an
For example, if V
object of unit mass along a curve C is
Z
Z 1
Z 1
~ · ~t ds =
~ · T~ dξ =
~ (x(ξ), y(ξ)) · T~ (ξ) dξ .
W =
V
V
V
C
0
0
19
~ is a velocity field for moving particles, then the flux through
Similarly, if V
the curve is
Z
Z 1
Z 1
~
~
~
~ (x(ξ), y(ξ)) · N
~ (ξ) dξ .
F =
V · ~n ds =
V · N dξ =
V
C
0
0
For the box (4.1), the work and flux integrals are given by
W =
4
X
Wi ,
i=1
F =
4
X
Fi ,
i=1
where
W1 =
W2 =
W3
W4
Z
b
~ (x, l(x)) · (1, l (x)) dx
V
′
Za u(b)
F1 =
~ (b, y) · (0, 1) dy
V
F2 =
Z
b
~ (x, l(x)) · (l′ (x), −1) dx ,
V
Za u(b)
~ (b, y) · (1, 0) dy ,
V
Zl(b)
Zl(b)
b
b
′
~
~ (x, u(x)) · (−u′ (x), 1) dx ,
=
V (x, u(x)) · (−1, −u (x)) dx F3 =
V
Za u(a)
Za u(a)
~ (a, y) · (0, −1) dy
~ (a, y) · (−1, 0) dy .
=
V
F4 =
V
l(a)
l(a)
(5.6)
For regions that are unions of boxes, it is not necessary to simplify the
union of the boundary segments, because these formulas are linear in the tangent or normal vectors, which causes integrals over two curves with opposite
orientation to cancel.
5.5
Examples Continued
~ = (x, y)/2, then the work integrals are
For the square (4.4), if we choose V
Z 1
Z 1
(x, −1)
x
W1 =
· (1, 0) dx =
dx = 0
2
Z−11 2
Z−11
y
(1, y)
· (0, 1) dy
=
dy = 0
W2 =
2
2
−1
−1
Z 1
Z 1
x
(x, 1)
· (−1, 0) dx =
− dx = 0
W3 =
Z−11 2
Z−11 2
(−1, y)
y
W4 =
· (0, −1) dy =
− dy = 0 .
2
2
−1
−1
20
~ is conservative, so the work moving an
Thus W = 0. The vector field V
object around a closed path in a conservative vector field should be zero.
The flux integrals are
Z 1
Z 1
(x, −1)
1
F1 =
· (0, −1) dx =
dx = 1
2
2
−1
−1
Z 1
Z 1
(1, y)
1
F2 =
· (1, 0) dy
=
dy = 1
Z−11 2
Z−11 2
1
(x, 1)
· (0, 1) dx
=
dx = 1
F3 =
Z−11 2
Z−11 2
1
(−1, y)
· (−1, 0) dy =
dy = 1 .
F4 =
2
−1 2
−1
Consequently F = 4. This is the area of the square which is not an accident
as we will see in the next section. There are more details in the Mathematica
notebooks.
5.6
Green’s Theorem
For any region R, if V = (V1 , V2 ), then Green’s theorem implies
Z Z ∂V2 ∂V1
∂V1 ∂V2
W =
dx dy , F =
dx dy .
−
+
∂x
∂y
∂x
∂y
R
R
In three dimensions, these are known as Stokes’ theorem and the divergence
~ so that
theorem. If we choose V
∂V1 ∂V2
−
+
= 1,
∂y
∂x
then the work integral gives the area of the region R. A convenient choice is
~ = (−y, x)/2. Similarly, if we choose V
~ so that
V
∂V1 ∂V2
+
= 1,
∂x
∂y
~ = (x, y)/2.
then F gives the area of the region R. A convenient choice is V
This explains the answer to the last example in the previous section. These
observations are the basis for the construction of a device called the planimeter that gives the area of a complex region by tracing its boundary.
Implementation Note: We use the results of Green’s theorem to test our
algorithms for evaluating integrals. This is especially helpful for checking the
boundary simplification rules.
21
y
y
1.0
1.0
0.5
0.5
C1
x
0.5
1.0
1.5
2.0
2.5
C3
C2
x
3.0
0.5
1.0
1.5
2.0
2.5
3.0
-0.5
-0.5
-1.0
-1.0
Figure 7: A Hexagon.
6
Advanced Two-Dimensional Examples
In this section, we demonstrate the power of our algorithm with some more
complex examples. The first example uses a hexagon discussed in [14]. Here
we provide most details about what the Mathematica notebook computes.
For the other examples, we only present the most interesting parts of what
was computed.
6.1
A Hexagon
The hexagon in Figure 7 can be defined using six linear inequalities:
R = {(x, y) : y ≥ −x ∧ y ≤ x ∧ y ≥ −1 ∧ y ≤ 1 ∧ y ≥ x − 3 ∧ y ≤ 3 − x} .
Because the hexagon is the union of two triangles and a rectangle,
√ it’s area
is easily seen to be 4 and the length of the boundary is 2 + 4 2. Use the
CAD algorithm to find its area and the length of its boundary. Also, find
the centroid which by symmetry must be (x, y) = (3/2, 0). Find the flux and
work boundary integrals and then use them to check the results of Green’s
theorem for computing areas.
The boxes in the CAD for the hexagon are shown in Figure 7 and are
given by
B1 = {(x, y) : 0 ≤ x ≤ 1 ∧ −x ≤ y ≤ x} ,
B2 = {(x, y) : 1 ≤ x ≤ 2 ∧ −1 ≤ y ≤ 1} ,
B3 = {(x, y) : 2 ≤ x ≤ 3 ∧ x − 3 ≤ y ≤ 3 − x} .
22
The integral of the function f over the hexagon is given by
Z 1Z x
Z 2Z 1
Z 3 Z 3−x
I(f ) =
f (x, y) dy dx +
f (x, y) dy dx +
f (x, y) dy dx .
0
1
−x
2
−1
x−3
The area and the x and y moments of the region are given by
I(x)
3
I(y)
= , My =
= 0.
A
2
A
The list of the boundary segments for all of the boxes contains the entries
A = I(1) = 4 ,
{x = 1 ,
{x = 1 ,
{x = 2 ,
{x = 2 ,
Mx =
−1 ≤ y
−1 ≤ y
−1 ≤ y
−1 ≤ y
≤ 1,
{0, 1} ,
{1, 0}},
≤ 1 , {0, −1} , {−1, 0}},
≤ 1,
{0, 1} ,
{1, 0}},
≤ 1 , {0, −1} , {−1, 0}}.
These need to be removed from the list as they are pairwise the same segments
with tangent vectors pointing in opposite directions. After simplification, the
boundary becomes:
{0 ≤ x ≤ 1 ,
{0 ≤ x ≤ 1 ,
{1 ≤ x ≤ 2 ,
{1 ≤ x ≤ 2 ,
{2 ≤ x ≤ 3 ,
{2 ≤ x ≤ 3 ,
y
y
y
y
y
y
= −x ,
{1, −1} , {−1, −1}},
= x,
{−1, −1} ,
{−1, 1}},
= −1 ,
{1, 0} ,
{0, −1}},
= 1,
{−1, 0} ,
{0, 1}},
= x − 3,
{1, 1} ,
{1, −1}},
=3−x
{−1, 1}
{1, 1}},
Consequently, the boundary integrals will have six terms. The arc length
integral is
Z 1√
Z 2
Z 3√
L=2
2g(x) dx + 2
2g(x) dx .
g(x) dx + 2
0
1
2
√
If g(x) ≡ 1, then this gives the length of the boundary as 2 + 4 2.
The work integral is
Z 1
Z 1
W =
(V1 (x, −x) − V2 (x, −x)) dx +
(−V1 (x, x) − V2 (x, x)) dx
0
0
Z 2
Z 2
+
V1 (x, −1) dx +
−V1 (x, 1) dx
1
1
Z 3
Z 3
+
(V1 (x, x − 3) + V2 (x, x − 3)) dx +
(−V1 (x, 3 − x) + V2 (x, 3 − x)) dx .
2
2
23
y
1.0
0.5
C1
C2
x
0.2
0.4
0.6
0.8
1.0
-0.5
-1.0
Figure 8: The Intersection of Two Circles.
To apply Green’s Theorem, choose V1 (x, y) = −y/2 and V2 (x, y) = x/2 to
get W = 4, the area of the hexagon. The flux integral is
Z 1
Z 1
F =
(−V1 (x, −x) − V2 (x, −x)) dx +
(−V1 (x, x) + V2 (x, x)) dx
0
0
Z 2
Z 2
+
−V2 (x, −1) dx +
V2 (x, 1) dx
1
1
Z 3
Z 3
+
(V1 (x, x − 3) − V2 (x, x − 3)) dx +
(V1 (x, 3 − x) + V2 (x, 3 − x)) dx .
2
2
As with the work integral, choosing V1 (x, y) = x/2 and V2 (x, y) = y/2 gives
F = 4, the area of the hexagon.
6.2
The Intersection of Two Circles
The boxes for the intersection of two circles,
R = (x, y) : x2 + y 2 ≤ 1 ∧ (x − 1)2 + y 2 ≤ 1 ,
are plotted in Figure 8. The problem is to find the area and length of the
boundary of the intersection. Confirm the area results using both forms of
Green’s Theorem. The boxes in the CAD of the intersection are
√
√
1
B1 = (x, y) : 0 ≤ x ≤ ∧ − 2 x − x2 ≤ y ≤ 2 x − x2 ,
2
√
√
1
2
2
B2 = (x, y) : ≤ x ≤ 1 ∧ − 1 − x ≤ y ≤ 1 − x .
2
24
y
y
2
2
1
1
x
-3
-2
1
-1
2
x
3
-3
-2
1
-1
-1
-1
-2
-2
2
3
p(x, y) ≤ 0
p(x, y) = 0
Figure 9: A self Intersecting Curve.
The boundary is given by
0 ≤ x ≤ 21 ,
0 ≤ x ≤ 12 ,
1
≤ x ≤ 1,
2
1
≤ x ≤ 1,
2
y
y
y
y
o
n
√
x−1
2
√
= − 2x − x ,
1, 2x−x2
o
n
√
x−1
= 2x − x2 ,
−1, √2x−x
2
o
n
√
x
2
=− 1−x ,
1, √1−x2
o
n
√
x
2
√
= 1−x ,
−1, 1−x2
The area is given by
Z 1 Z √2x−x2
Z
2
A=
dy dx +
√
0
− 2x−x2
1
1
2
Z
√
1−x2
√
− 1−x2
,
,
,
,
n
√
2π
3
dy dx =
−
.
3
2
and the length of the boundary is given by
Z 1r
Z 1r
2
(x − 1)2
4π
x2
dx
+
2
dx =
.
1+
1
+
L=2
2
2
1
2x − x
1−x
3
0
2
Applying both versions of Green’s theorem reproduces the area.
6.3
A Self Intersecting Curve
The curve given by
p(x, y) = y 2 − x2 (x + 3) = 0
25
oo
√ x−1 , −1
n2x−x2
oo
√ x−1 , 1
n 2x−x2 oo
√ x
, −1
n1−x2
oo
√ x
,1
1−x2
is plotted in Figure 9 with title p(x, y) = 0. Part of the curve bounds a
region with finite area. The problem is to find the area and the length of the
boundary of this region. The point (−2, 0) is in the region and p(−2, 0) =
−4 < 0 so we need to look at the region p(x, y) ≤ 0 (see Figure 9). To remove
the infinite part of the region with x > 0, we choose
R = (x, y) : y 2 − x2 (x + 3) ≤ 0 ∧ x ≤ 0 .
The CAD of this region has only one box:
√
√
−3 ≤ x ≤ 0 ∧ − x3 + 3 x2 ≤ y ≤ x3 + 3 x2 .
The area is given by
A=
Z
0
−3
Z
√
24 3
,
dy dx =
√
5
− x3 +3x2
√
x3 +3x2
while the length is given by
s
Z 0
(3x2 + 6x)2
1+
L=2
dx ≈ 10.7351 .
4 (x3 + 3x2 )
−3
The integral for the length could not be evaluated analytically so was computed numerically. The work and flux integrals can be evaluated analytically.
6.4
The Intersection of Two Ellipses
Find the area and length of the boundary for the region
x 2
y 2
2
2
R = (x, y) :
+y ≤1∧x +
≤1 ,
2
2
which is shown in Figure 10. The CAD for this region has three boxes. The
area is given by
A=
Z
− √2
Z
1
5
−1
+
√2
5
Z
Z
√
2 1−x2
√
−2 1−x2
√
2 1−x2
√
−2 1−x2
dy dx +
Z
√2
5
− √2
5
Z
√
−
4−x2
2
√
−1
dy dx = 2π + 4 sin
26
4−x2
2
dy dx
1
√
5
−1
− 4 sin
2
√
5
≈ 3.70918 .
y
2
1
x
-2
1
-1
2
-1
-2
Figure 10: The Intersection of Two Ellipses.
and the length is given by
Z − √2 r
5
L=2
−1
Z
1
r
4x2
dx + 2
1+
1 − x2
Z
√2
5
− √2
5
s
1+
x2
dx
4 (4 − x2 )
4x2
dx
1 − x2
3
−1
= 8E cot 2 |
+ 4(E(−3) − E(tan−1 2 | − 3)) ≈ 7.22281 .
4
+2
√2
5
1+
Here, E(x) is the complete elliptic integral and E(x|y) is the elliptic integral
of the second kind.
6.5
Examples with Symbolic Parameters
Our Mathematica program can also solve some problems with parameters. It
turns out that the Mathematica CAD program produces results that are very
useful in at least simple situations. We are still working on a good method
for finding the boundary of parametric regions. We show two examples with
parameters: a circle and the Witch of Agnesi.
6.5.1
A Circle with Parametric Radius
A circle of radius a > 0 is given by
R = (x, y) : x2 + y 2 ≤ a2 .
27
Find the area of this circle. The CAD for this region, using the variables
a, x, y, is a single box
√
√
a > 0 ∧ −a ≤ x ≤ a ∧ − a2 − x2 ≤ y ≤ a2 − x2 .
If we eliminate the first term, then this is in the correct form for our boxes.
The area is given by
Z a Z √a2 −x2
dy dx .
√
−a
− a2 −x2
Mathematica can easily evaluate this integral to get π a2 .
6.5.2
The Witch of Agnesi
The Witch of Agnesi is a curve given by
8 a3
, −∞ < x < ∞ .
x2 + 4 a2
Find the area between this curve and the x-axis. The region is given by
R = (x, y) : y ≥ 0 ∧ y (x2 + 4 a2 ) ≤ 8 a3 ∧ a > 0 .
y=
The CAD for this region, using the variables a, x, y, is the infinite box
8a3
.
4a2 + x2
If we remove the first term and note that x missing, then we get a box in
standard form:
8a3
−∞ < x < ∞ ∧ 0 ≤ y ≤ 2
.
4a + x2
This is easily converted into an area integral that Mathematica can evaluate,
yielding 4 πa2 .
a>0∧0≤y ≤
7
Three-Dimensional Integration
In this section, we will discuss integrals over generic three-dimensional cylinders, but not regions, because we have not implemented how to convert
cylinders with a non-standard descriptions to a uniform description and we
have not worked out all of the needed boundary simplification rules. For
volumes, the ideas for planar cylinders apply to three dimensional cylinders
with only straightforward changes. Computing the boundary of a cylinder is
more complex.
28
2
1
0
-1
-2
2
1
0
-1
-2
-2
-1
0
1
2
Figure 11: The Intersection of a Circular Cylinder and a Sphere.
7.1
3D Cylinders
A 3D cylinder has the form
a ≤ x ≤ b ∧ c(x) ≤ y ≤ d(x) ∧ g(x, y) ≤ z ≤ h(x, y) ,
(7.1)
where a and b are real constants, c and d are real valued functions of a single
real variable, and g and h are real valued function of two variables. The
integral of f = f (x, y, z) over the cylinder (7.1) is
Z b Z d(x) Z h(x,y)
f (x, y, z) dz dy dx .
a
c(x)
g(x,y)
As in two dimensions, this can now be used with the CAD algorithm to
reduce integrals over three dimensional regions to iterated integrals.
A simple example is given by a circular cylinder cut out of a sphere,
x2 + y 2 + z 2 ≤ 4 ∧ x2 + y 2 ≤ 1 ,
shown in Figure 11. The integral of f over the region is given by
Z √
Z Z √
1
1−x2
−1
√
− 1−x2
4−x2 −y 2
−
√
4−x2 −y 2
29
f (x, y, z) dz dy dx .
(7.2)
Mathematica
√ can be used to compute that the volume of the region is
8
4π 3 − 3 .
7.2
The Boundary of a Cylinder
The boundary of the cylinder (7.1) is given by
{x, y} , a ≤ x ≤ b , c(x) ≤ y ≤ d(x) ,
{x, y} , a ≤ x ≤ b , c(x) ≤ y ≤ d(x) ,
{x, z} , a ≤ x ≤ b ,
{x, z} , a ≤ x ≤ b ,
{y, z} ,
{y, z} ,
x = b,
x = a,
z = g(x, y) ,
z = h(x, y) ,
~1
+N
~2
−N
~3
g(x, c(x)) ≤ z ≤ h(x, c(x)) , +N
~4
g(x, d(x)) ≤ z ≤ h(x, d(x)) , −N
y = c(x) ,
y = d(x) ,
c(x) ≤ y ≤ d(x) ,
c(x) ≤ y ≤ d(x) ,
g(x, y) ≤ z ≤ h(x, y) ,
g(x, y) ≤ z ≤ h(x, y) ,
~5
+N
~6
−N
where
~ 1 = g (1,0) (x, y), g (0,1) (x, y), −1 , N
~ 2 = h(1,0) (x, y), h(0,1) (x, y), −1 ,
N
~ 3 = {c′ (x), −1, 0} ,
~ 4 = {d′ (x), −1, 0} ,
N
N
~ 5 = {1, 0, 0} .
~ 6 = {1, 0, 0} .
N
N
and the superscripts indicate derivatives. Each piece of the boundary contains 5 entries. The first entry is the two variables used to parameterize the
piece. The next 3 entries give the equation for the piece and the limits on
the variables. The final entry is an outward normal to the piece.
The surface integral of the normal component of V~ is
R b R d(x)
~ 1 (x, y) · V
~ (x, y, g(x, y)) dy dx
N
a c(x)
R b R d(x)
~ 2 (x, y) · V~ (x, y, h(x, y)) dy dx
− a c(x) N
R b R h(x,c(x))
~ 3 (x) · V
~ (x, c(x), z) dz dx
+ a g(x,c(x)) N
R b R h(x,d(x))
~ 4 (x) · V
~ (x, d(x), z) dz dx
− a g(x,d(x)) N
R d(b) R h(b,y)
~5 · V
~ (b, y, z) dz dy
+ c(b) g(b,y) N
R d(a) R h(a,y)
~ 6 · V~ (a, y, z) dz dy
− c(a) g(a,y) N
The integral of the normal component of a vector field over the boundary of
the circular cylinder intersected with a sphere (7.2) is too lengthy to print
30
here, but the formula is given in a notebook. We can compute the area of
~ ·V
~ with the square root of N
~ ·N
~ in the previthe surface by replacing N
ous formulas. The surface area of the intersection of the
√ circular cylinder
intersected with the sphere shown in Figure 11 is 4 (4 − 3)π.
7.3
The Divergence Theorem
The divergence theorem is
Z
Ω
~ · V~ =
∇
Z
∂Ω
~,
V~ · N
~ = (∂/∂x , ∂/∂y , ∂/∂z) is the
where Ω is simply connected 3D region, ∇
~
divergence operator, V~ is a vector field, ∂Ω is the boundary of Ω, and N
~
is the outward normal to the surface. If we choose V = (x/3, y/3, z/3),
~ ·V
~ = 1 and consequently the surface integral gives the volume of the
then ∇
region. This fact was used to to check our surface integration formulas.
7.4
General Curves and Surfaces in 3D
In 3D, algebraic surfaces are be given by P (x, y, z) = 0, while algebraic
curves are given by P (x, y, z) = 0 ∧ Q(x, y, z) = 0. However simple this
seems, there are several problems. First, the objects can be degenerate.
For example, if P (x, y, z) = x2 + y 2 + z 2 + 1, then the surface will be the
empty set. If P can be factorized, then the zero set can be the union of two
or more simpler curves. Another problem is that such curves and surfaces
have two possible orientations and we do not see a nice way to specify their
orientation. If the curve or surface is given parametrically, which is the case
in many applications, then an orientation is induced by the parameterization.
If a curve C is oriented and starts at a point P1 and ends at the point P2 and
f is a smooth function, then the Potential Theorem (Fundamental Theorem
of Calculus) can be applied:
Z
~ = f (P2 ) − f (P1 ) .
∇f
C
~ the right-hand rule
In the case of an oriented surface S with normal N,
~
~ is a smooth vector
orients the boundary ∂S with a tangent vector T . If V
31
field, then one can apply Stokes’ Theorem,
Z
Z
~
~
~
~ · T~ ,
∇×V ·N =
V
S
∂S
to evaluate integrals. Some examples are given in a notebook.
8
Summary
We have shown that combining the Mathematica cylindrical algebraic decomposition (CAD) routines with some computer algebra tools that we developed
that put the CADs into a standard form allows us to break up complex two
dimensional regions into cylinders and then reduce integrals over the regions
to sums of iterated integrals. If the iterated integrals are not too complicated, they can be evaluated analytically by most computer algebra systems.
In the two dimensional case, we can also find the length of the boundary
curve of the region and two types of boundary integrals. We can also use the
two dimensional versions of the Divergence and Stokes’ Theorems to evaluate
integrals and check our codes.
Our 3D results only apply to regions that are cylinders. We can find
the volume and the area of the surface area of the cylinder. In 3D, there
is only one integration theorem for volumes and their boundaries: the divergence theorem. We use the divergence theorem to check our surface and
volume integral formulas. Extending these results to more general regions is
in progress.
Importantly, the computation of the length of a curve and the area of a
surface rely on a “boundary simplification” algorithm. We have implemented
a general simplification heuristic in two dimensions and a partial heuristic in
three dimensions. It is an important problem to convert these heuristics to
algorithms that are proven correct.
It is also important that we do not use the full power of the CAD algorithm. Because integrals over “small” sets are zero, we can restrict our
attention to regions that are closures of their interiors. A CAD restricted to
such sets should be much faster and produce more appropriate answers than
the general CAD. We have also included some simple examples where the
description of the integration region contains a parameter. Here, the CAD
is applied simultaneously to the integration variables and the parameter.
32
We have implemented some ideas for general curves and surfaces—surfaces
that are not boundaries of regions—in 3D. Extending these results and implementing Stokes’ Theorem is also in progress. The algebraic methods developed here can be used as a basis for numerically estimating the volume of
a region in a multi-dimensional space [7]. It should also be possible to extend
our results to regions defined by simple transcendental functions.
33
References
[1] D. S. Arnon, G. E. Collins, and S. McCallum. Cylindrical algebraic
decomposition I: The basic algorithm. SIAM Journal on Computing,
13(4):865–877, 1984.
[2] C. W. Brown. Simple CAD construction and its applications. J. Symbolic Comput., 31:521–547, 2001.
[3] B. F. Caviness and J. R. Johnson, editors. Quantifier Elimination and
Cylindrical Algebraic Decomposition, Texts and Monographs in Symbolic
Computation, New York, 1998. Springer-Verlag.
[4] G.E. Collins and H.Hong. Partial cylindrical algebraic decomposition for
quantifier elimination. Journal of Symbolic Computation, 12(3):299–328,
Sep 1991.
[5] H. F. Davis and A. D. Snider. Introduction to Vector Analysis. William
C Brown Pub., 1995.
[6] Andreas Dolzmann and Volker Weispfenning. Local quantifier elimination. In ISSAC ’00: Proceedings of the 2000 international symposium
on Symbolic and algebraic computation, pages 86–94, New York, NY,
USA, 2000. ACM.
[7] D. Henrion, J. B. Lasserre, and C. Savorgnan. Approximate volume
and integration for basic semialgebraic sets. SIAM Rev., 51(4):722–743,
2009.
[8] Hoon Hong, Richard Liska, and Stanly Steinberg. Testing stability by
quantifier elimination. J. Symb. Comput., 24(2):161–187, 1997.
[9] S. McCallum. Solving polynomial strict inequalities using cylindrical
algebraic decomposition. Comput. J., 36:432–438, 1993.
[10] Hiroyuki Sawada and Xiu-Tian Yan. Application of Gröbner bases and
quantifier elimination for insightful engineering design. Math. Comput.
Simul., 67(1-2):135–148, 2004.
[11] Adam Strzeboński. Solving systems of strict polynomial inequalities. J.
Symb. Comput., 29(3):471–480, 2000.
34
[12] Adam Strzeboński. Applications of algorithms for solving equations and
inequalities in mathematica. In A. Seidl A. Dolzmann and T. Sturm,
editors, Proceedings of the A3L 2005, pages 243–248, Passau, Germany,
2005. Conference in Honor of the 60th Birthday of Volker Weispfenning.
[13] Yuzita Yaacob. Interactive Learning—Mathematica Enhanced Vector calculus (ILMEV). PhD thesis, International Islamic University
Malaysia, Gombak, Selangor Darul Ehsan, Malaysia, 2007.
[14] Yuzita Yaacob, Michael Wester, and Stanly Steinberg. ILMEV: An
automated learning assistant for vector calculus. submitted, 2009.
35
A
Parameterization of Boundary Curves
Here we justify the formulas used in (5.6) by using a standard parameterization that moves points in a counter clockwise direction on the boundary
curve:
C1
C2
C3
C4
:
:
:
:
x1 (ξ)
x2 (ξ)
x3 (ξ)
x4 (ξ)
=
=
=
=
a + (b − a)ξ ,
b,
b + (a − b)ξ ,
a,
y1 (ξ)
y2 (ξ)
y3 (ξ)
y4 (ξ)
=
=
=
=
l(a + (b − a)ξ) ,
l(b) + (u(b) − l(b))ξ ,
u(b + (a − b)ξ) ,
u(a) + (l(a) − u(a))ξ .
where a and b are finite and 0 ≤ ξ ≤ 1. If a or b are infinite, then a special
parameterization is needed. The work and flux integrals are given by
Z 1
Z 1
~
~
~ (x(ξ), y(ξ))·N(x(ξ),
~
W =
V (x(ξ), y(ξ))·T (x(ξ), y(ξ)) dξ , F =
V
y(ξ)) dξ .
0
0
For curves 1 and 3, we make a change of variables from ξ to x, while for curves
2 and 4, we change from ξ to y. The work and flux integrals transform in the
same manner, so for simplicity we will only transform the work integrals.
For the first curve, ξ = (x−a)/(b−a), dξ = dx/(b−a), x(0) = a, x(1) = b
and
T~1 = (x′ (ξ), y ′(ξ)) = (b − a, l′ (x)(b − a)) = (b − a)(1, l′ (x)) .
Consequently,
W =
Z
a
b
~ (x, l(x)) · (1, l′ (x)) dx .
V
For the third curve, ξ = (x − b)/(a − b), dξ = dx/(a − b), x(0) = b, x(1) = a
and
T~3 = (x′ (ξ), y ′(ξ)) = (a − b, u′ (x)(a − b)) = (a − b)(1, u′ (x)) .
Consequently,
Z a
Z b
′
~ (x, u(x)) · (−1, −u′ (x)) dx .
W =
V~ (x, u(x)) · (1, u (x)) dx =
V
b
a
For the second curve, ξ = (y − l(b))/(u(b) − l(b)), dξ = dy/((u(b) − l(b)),
y(0) = l(b), y(1) = u(b), and
T~2 = (x′ (ξ), y ′(ξ)) = (0, u(b) − l(b)) = (u(b) − l(b))(0, 1) .
36
Consequently,
W =
Z
u(b)
l(b)
V~ (b, y) · (0, 1) dy .
For the fourth curve, ξ = (y − u(a))/(l(a) − u(a)), dξ = dy/((l(a) − u(a)),
y(0) = u(a), y(1) = l(a), and
T~4 = (x′ (ξ), y ′(ξ)) = (0, l(a) − u(a)) = (l(a) − u(a))(0, 1) .
Consequently,
W =
Z
l(a)
u(a)
V~ (a, y) · (0, 1) dy =
37
Z
u(a)
l(a)
~ (a, y) · (0, −1) dy .
V