Yutaka Abe (auth.), Thomas Lee (eds.) - Mathematical Computation with Maple V_ Ideas and Applications_ Proceedings of the Maple Summer Workshop and Symposium, University of Michigan, Ann Arbor, June 2.pdf
Yutaka Abe (auth.), Thomas Lee (eds.) - Mathematical Computation with Maple V_ Ideas and Applications_ Proceedings of the Maple Summer Workshop and Symposium, University of Michigan, Ann Arbor, June 2.pdf
with Maple V:
Ideas and Applications
Mathematicai Computation
with Maple V:
Ideas and Applications
Thomas Lee
Editor
9 8 7 6 5 432 1
Contents
Preface . . . . . . . . . . . . . . . . . . . . . vii
I. Maple V in Education 1
Developments in both computer hardware and Perhaps the greatest impact has been felt by the
software over the decades have fundamentally education community. Today, it is nearly
changed the way people solve problems. impossible to find a college or university that has
Technical professionals have greatly benefited not introduced mathematical computation in
from new tools and techniques that have allowed some form, into the curriculum. Students now
them to be more efficient, accurate, and creative have regular access to the amount of
in their work. computational power that were available to a very
exclusive set of researchers five years ago. This
Maple V and the new generation of mathematical has produced tremendous pedagogical
computation systems have the potential of challenges and opportunities.
having the same kind of revolutionary impact as
high-level general purpose programming Comparisons to the calculator revolution of the
languages (e.g. FORTRAN, BASIC, C), 70's are inescapable. Calculators have
application software (e.g. spreadsheets, extended the average person's ability to solve
Computer Aided Design - CAD), and even common problems more efficiently, and
calculators have had. Maple V has amplified our arguably, in better ways. Today, one needs at
mathematical abilities: we can solve more least a calculator to deal with standard problems
problems more accurately, and more often. In in life - budgets, mortgages, gas mileage, etc.
specific disciplines, this amplification has taken For business people or professionals, the
excitingly different forms. spreadsheet is quickly becoming the minimum
level of electronic assistance for solving modern
For mathematicians, computer algebra systems problems. Many look towards the next decade
has spawned entire new research and with great anticipation as what is now considered
application directions. In addition, Maple V has advanced mathematical and computing
allowed mathematicians to approach existing techniques (like Maple V) begin influencing the
problems in ways that were not conceivable 20 work of businessmen, social scientists, and
years ago. others who have traditionally not exploited the
tremendous potential of this particular dimension
For scientists and engineers, Maple V of the Information Revolution.
represents a bridge between theory and
practice. Techniques that were traditionally
considered too complex for application are now The Maple Summer Workshop and
beginning to be used by a wide range of Symposium - MSWS '93
scientists and engineers in both academia and
industry. Indeed the concept of "scientific The primary goal of MSWS '93 is to bring
computation" has evolved from a relatively interested people together and to generate
narrow field encompassing primarily numerical ideas and strategies to promote the effective
methods to a much broader field that includes, use of Maple V and other modern computation
numerical methods, algebraic and analytical techniques. This year, the conference was held
methods, and graphics. on June 28-30 at the University of Michigan in
vii
Ann Arbor. This volume summarizes the paper
sessions of the conference. The paper
presentations were part of a varied conference
program designed to encourage interaction
among users from a wide variety of disciplines.
T. Lee
Waterloo, canada
viii
I
MAPLE V IN EDUCATION
INTRODUCTORY QUANTUM MECHANICS USING
MAPLE V
YutakaAbe
Quantum Instrumentation Laboratory, Hokkaido University, Sapporo, Japan
Abstract 1. INTRODUCTION
3
electron wave function under a general wave function by matching
certain general potential function, the wave function and its derivative
you may suddenly encounter severe at the discontinuities of the given
difficulty if you stick to some potential function. The transfer
analytical solution. Numerical matrix method is one commonly
methods can treat a much wider used method.
variety of interesting problems Let us consider the Schrodinger
than can be handled by analytical equation for the potential function
methods. in Fig. 1. The Schrodinger equation
The motivation of this paper for regions I, II, III are:
is to explore new methods of
instruction balanced between
analytical and numerical approaches. d 2¢ 2
--+a x=O (x<O and x>a)
The author selected Maple V for dx 2
symbolic (analytical) and numerical (2.1.a),
calculations [2] because of its
excellent interface with users, d 2¢ 2
- - f J x=O (O<x<a), V>E
distinguished power for mathematical dx 2
(2.1.b),
operations, and suitability for
students exploring creative pro-
d 2¢ 2 V<E
gramming with small computers. In --+Il x=O (O<x <a),
dx 2
the following sections, we treat (2.1.c)
several elementary quantum mech-
where
anical problems with this approach.
a 2 =2mE;1)2, fJ 2 =2m (V -E)/fl 2
11 2 =2m(E-V)/fJ2
2. ONE-DIMENSIONAL FINITE
(2.2) .
POTENTIAL BARRIER PROBLEMS
We take the wave functions in each
region as:
The problems of one-dimensional
finite potential barriers and
wells are treated universally in ¢I =exp(ia x )+r exp(-iax), x<O
introductory quantum mechanics
textbooks. There are a number of (2.3.a)
ways to attack these problems. In
¢II =A exI( -fJx)+B exp(f3 x), O<x<a
the simple type of potential, the
overall wave function is constructed (2.3.b)
out of pieces having the form of a
4
dl:=diff(fl(x), x):
tPII=AexJX-fJx)+Bexp(fJx), O<x<a d2:=diff(f2(x), x):
d3:=diff(f3(x), x):
(2.3. c) .
f1(O)=f2(O)i
f2(a)=f3(a)i
evalf(subs(x=O,dl»=evalf(subs(x=O,
v d2) ) i
II III evalf(subs(x=a,d2»=evalf(subs(x=a,
d3»i
• el:= 1 + R = A + B:
e2:= I*alpha - R*I*alpha = -A*beta + B*beta:
e3:= A*u + B*v = T*s:
5
v 1 alpha (1 alpha - beta)
{A 2 --------------------------
%1
u beta v 1 alpha
T - 4
s %1
2 2 2 2
- v alpha - beta v + alpha u + beta u
R -----------------------------------------}
%1
2 2 2
%1 .- - v alpha + beta v - 2 1 alpha u beta + alpha u
2
- beta u - 2 v 1 alpha beta
4i af3u v
T
s {(a 2 -13 2 )(u-v )+2i af3( u +v)}
(Calculation of TT*)
• Tl:=2*I*alpha*beta*exp(-I*alpha*a)/«alpha A 2 -
beta A 2)*sinh(beta*a) + 2*I*alpha*beta*cosh(beta*a»;
6
I alpha beta exp(- I alpha a)
Tl .- 2
2 2
(alpha - beta) sinh(beta a) + 2 I alpha beta cosh(beta a)
• T2:=-2*I*alpha*beta*exp(-I*alpha*a)/«alpha A2 -
beta A2)*sinh(beta*a) - 2*I*alpha*beta*cosh(beta*a»;
• evalc(Tl*T2):
simplify(");
2 2 2
4 beta alpha (2 cos (alpha a) - 2 cos (alpha a) sin (alpha a) I - 1)1
4 2 4 2 2 2
(alpha cosh (beta a) - alpha + 2 alpha beta cosh (beta a)
2 2 4 2 4
+ 2 beta alpha + beta cosh (beta a) - beta )
• m:=9.01*lOA(-31):
hbar:=1.0546*lOA(-34):
v:=O.5*1.602*lOA(-19):
en:= ep*1.602*lOA(-19):
alfa:=sqrt( 2* m* en)/hbar:
beta:=sqrt(2* m*(v-en»/hbar:
a:=lO*lOA(-lO):
tl:=4* beta A2* alfa A2:
t2:=«alfa A2 + beta A2»A2* (sinh(beta* a»A2 + 4* beta A2* alfa A2:
d:=tl/t2:
7
p:=simplify(d) ;
10 10 /
p := 4. ep ( - .1684315858*10 + .3368631715*10 ep) /
/
9 1/2 2
_ .842157929*10 cosh(3.602515719 (1. - 2. ep) ) + .842157929*10 9
10 11 2
_ .6737263430*10 ep + .1347452686*10 ep)
- 3
- 1
•8
8
- 5
tJl
0
~
-6
8
problem in the form of the segmented into n discrete flat
potential is more general than the barriers each of width wand height
square barrier? By the WKB method Vi, where
[3] you might obtain rigorous
solutions. Anyone can understand 1
intuitively that the approximate
Vi ="2 {V[l - (i - l)w] + V[l + iw]),
50
1/Ji =Ai exp( ai x)+ Bi ex]:( -ai x)
(2.8) .
40
0 and
1 2 4
9
Ain exI(ikl)+Bin exp(ikl)=Al exp(all)+ Bl exp( -all) (2 .12b) .
(2 .12a) I
• with (linalg):
10
exp (a 1 (l + w)) exp (- a1 (l + w))
m2 .-
a1 exp(a1 (1 + w)) - a1 exp(- a1 (1 + w))
• m3:=inverse(m2);
1 1
%2 + %1
[1/2 ---------------------------------
exp (a 1 (l + w)) exp (- a 1 (1 + w))
%2 - %1
1/2 ------------------------------------]
exp(a1 (1 + w)) a1 exp(- a1 (1 + w))
a1 (%2 - %1)
[1/2 ---------------------------------
exp(a1 (1 + w)) exp(- a1 (1 + w))
%2 + %1
1/2 ---------------------------------]
exp(a1 (1 + w)) exp(- a1 (1 + w))
11
If we denote the product of the k It is rather easily verified that
matrix as Eq. (2.16) is reduced to Eq. (2.4)
when the potential is a square flat
barrier, and this offers a good
exercise to the student.
Returning to the one-dimensional
(2.15) , square potential problem again, let
us study the situation where the
then the transmission coefficient incident electron energy is much
TT* is given by larger than the potential energy.
Since R has already been obtained
in the preceding paragraph, we
apply that formula for E > V. The
wave function in the barrier region
with this condition, is given by
(2.16) .
Calculation of RR*
2 2
(alpha - gamma) sin (gamma a)
R .- -------------------------------------------------------------
2 2
(alpha + gamma sin (gamma a) + '2 I alpha gamma cos (gamma a)
2 2
(alpha - gamma) sin (gamma a)
RC .- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 2
(alpha + gamma sin (gamma a) - 2 I alpha gamma cos (gamma a)
12
• simplify(expand(R*RC»;
4 4 2 2 2
(- alpha + alpha cos (gamma a) + 2 alpha gamma
2 2 2 4 4 2
I
- 2 alpha gamma cos (gamma a) - gamma + gamma cos (gamma a)) I
I
4 4 2 2 2
(- alpha + alpha cos (gamma a) - 2 alpha gamma
2 2 244 2
- 2 alpha gamma cos (gamma a) - gamma + gamma cos (gamma a) )
• factor(n) i
2
(- 1 + cos (gamma a)) (cos(gamma a) + 1) (alpha - gamma) (alpha +
gamma) 2
I 2 2 2 2
I ((cos(gamma a) alpha - cos (gamma a) gamma - alpha - gamma )
I
2 2 2 2
(cos (gamma a) alpha - cos (gamma a) gamma + alpha + gamma ) )
13
From the above calculations, RR* is 20
ep
expressed as
RR *
(2.17 )
14
the physical meaning involved in
Feynman's path integral, we Since the Eq. (3.1b) is linear, the
successfully introduce this superposition
approach using Maple V in the
class of senior undergraduate N
students. 'l/J(x/)=¢i p Lan¢ipn(x,t)
n=l
meaning.
where f(p) is the weighting
Here, we illustrate some of the function for the different momenta
visualized instruction for this p. Let us consider the case where
kind of problem. f(p) is given by a Gaussian
In order to describe a particle distribution function:
at a local position in quantum
mechanics, it is necessary to
construct a wave packet. A free
electron wave function with
momentum p is
(3.3) .
(3 .4a),
(3 .1b) .
15
It is eas ily realized from Fig 5a
where
and 5b that the wavepacket behaves
as a probability density in a
1l
axO=2a diffusion process. Actually if we
p put ~ =it/h in the time-dependent
(3.4 .b) . Schroedinger equation, we have
(al (bl
16
It is noteworthy that the
Schroedinger wave equation takes
very different mathematical form
from a classical wave equation . It
(3.6) .
is said that the concept of the
imaginary time domain was first
By performing the actual
suggested by E. Fermi. Various
computational procedures, the
textbooks of mathematical physics
students will realize the precision
present complete solutions for
and the limitation of the finite
diffusion equation, most of which
difference method as well as the
are concerned with the problem of
the dynamical behavior of the
thermal conduction in an infinite
wavepacket, namely the transmission
or finite medium.
and the reflection of the
The diffusion processes is
wavepacket (Fig. 7).
considered to be random walk
processes, and therefore the Monte
1 . 0 ,--------------------------,
Carlo method is naturally
introduced in this phenomena. In (a)
Fig.6 , numerical results of Monte
Carlo simulations on the ground
state wave function of simple
harmonic oscillator are shown.
It is rather easy to extend the
above discussion into the problem
of wavepacket propagation through a o -1. 0 1.0
simple potential barrier or well,
Normalized x
and this offers a very good
exercise for the students to learn
1.0
about a scattering phenomenon of
Q)
the wavepacket. '0 n=1000
::l
The most simple computational ....
~
..-1
(b)
equation:
~
0
-1.0 1.0
Normalized x
17
problems are enough for the
a}
students to grasp the basic
ideas involved in quantum
mechanics. The most important
point for the success of the
program is to illustrate to the
students that there exist
various approaches to the same
problem, rather than just to
show a collection of numerical
b} examples.
1) It is not necessary to
provide all the topics which are
usually described in the
standard textbooks. A few basic
18
References
Yutaka Abe
[1] There are published a number of
Professor Abe received a BS
packages. Among these packages one
degree in electrical engineer-
of the typical numerical
ing from Hokkaido University
calculations is:
(Japan) in 1954. He joined
W. H. Press et aI, "Numerical
Electrotechnical Laboratories
Recipes-The Art of scientific
in 1956 and worked on basic
Computing", (Cambridge Press,
physics of semiconductor
Cambridge 1986) .
devices. In 1966, he received
a doctoral degree in applied
[2] B. W. Char t al,"Maple V
physics from Hokkaido Univer-
Language Reference
sity and, in 1967 joined their
Manual", (Springer-Verlag, 1991).
department of applied physics.
He was appointed a full Professor
[3]E. Merzbacher, "Quantum
of Engineering at Hokkaido
Mechanics", Chapt. 7, (John Wiley &
University in 1973. His
Sons, New York 1961).
personal fax number is
011-757-1162 and his email
[4] T. M. Kaltos and A. R. Lee, "A
address is
new approach to one-dimensional
[email protected]
scattering", Am.J. Physics, 59
(1990) 48-52.
19
COMBINATORIAL OBJECTS AND THEIR GENERATING
FUNCTIONS: A MAPLE CLASS ROOM ENVIRONMENT
John.8. Devitt
Department of Combinatorics and Optimization, University of Waterloo
(on leave from the University of Saskatchewan), Waterloo ON, Canada
20
122, 222] + Objects(nops = 4) > alias( v=countsubstring ):
> genfunc(pat,[t,x,y],[nops,v[O],v[1]]);
This set is infinite / 2 \
> cardinality(S); I t y x I
infinity 1/«1 - t x) 11 - -------------------1
\ (1 - t y) (1 - t xlI
so only some of the sequences can be displayed.
They are chosen to be of minimum weight accord-
(1 - t y»
ing to a user definable weight function. By default, We still need to keep track of blocks. To do so
at least 30 are displayed and the default weight we introduce an indeterminant into the pattern to
function is nops( ). record every occurrence of every block.
> pat2 := [ [phi + u.[O,Star(O)]] ,
The displayed sequences can be extracted as a > Star(u.phi,1,Star(1),phi.u,O,Star(O»,
> [phi+u.[1,Star(1)]]];
set or a list from the above collection by use of the
pat2 := [[phi + u [0, 0 ]],
•
select( ) command.
> displayed_sequences(S);
[phi, 0, 1, 2, 00, 10, 20, 01, 11, 21,
•
[u phi, 1, 1 , u phi, 0, 0 ] ,
••
02, 12, 22, 000, 100, 200, 010,
[phi + u [1, 1 ]]]
•
110, 210, 020, 120, 220, 001, 101,
Here, phi = ¢ denotes the null string. The se-
201, 011, iii, 211, 021, 121, 221,
quences produced by this pattern and displaying
002, 102, 202, 012, 112, 212, 022, at least the first 50 are
122, 222] > S := genseq(pat2,nops, 50 );
2
For example, those having at least one occurrence S := [phi, u 1, u 0, u 00, u 10,
of the sequence 01 are found by the command 2 2 3
> select( countsubstring[O,1]>O, S ); u 01, u ii, u 000, u 100, u 010,
[01, 010, 001, 101, 201, 011, 012]
2 2 3 2
The genfunc( ) command works with either the u 110, u 001, u 101, u 011,
result produced by a call to genseq( ), sets of se- 333
quences or regular expressions. Lists are used u iii, u 1101, u 1001, u 1011,
denote sequence concatenation as in 2 2 2
> T := genseq([A,A]); u 1000, u 1100, u 1110, u 0000,
T :=
4 4 3
[00, 10, 20, 01, ii, 21, 02, 12, 22] u 1111, u 1010, u 0101, u 0100,
The sequences produced in this manner form a 3 2 2 3
monoid with coefficients chosen from a ring as in u 0110, u 0001, u 0011, u 0010,
> genseq(T + u.Seq(O,O) + 3.Seq(»; 2 2 2
[3 phi, (u + 1) 00, 10, 20, 01, ii, 21, u 0111, u 00001, u 00011,
02, 12, 22] 3 4 2
u 00110, u 00101, u 00111,
Example 2.2 Find the average number of blocks
in the set of all 0-1 sequences of length n. 3 3 3
u 11101, u 11001, u 10001,
Solution: A block is a maximal string of D's or 3 3 3
a maximal string of 1'So The set of all such strings u 11011, u 10011, u 10111,
is generated by the pattern 3 2 2
> alphabet (0,1); u 00100, u 11110, u 11000,
{O, 1}
2 5 2
> pat := [Star(O), u 10000, u 10101, u 11100,
> Star( 1,Star(1),O,Star(O»,
> Star(1)]; 3
pat : =
•
[0 , [1,
•
1 , 0,
•••
0] , 1 ]
u 00010, u 00000, u 11111,
4 4 4
The generating function based on this pattern with u 10100, u 10110, u 10010,
respect to length, number of D's and number of 1's 4 2 3
IS u 11010, u 01111, u 01110,
21
3 3 4 > diff(c1,u)/2-n;
u 01100, u 01000, u 01101, n n
(u + 1) u (u + 1)
445 (2 -------- - 2 ----------
u 01011, u 01001, u 01010] u + 1 2
(u + 1)
+ Objects(nops = 6)
n
The corresponding generating function with re- u (u + 1) n / n
spect to length of the sequence is + 2 ------------) / 2
2 /
> genfunc(S,x,nops); (u + 1)
2 2
1 + 2 u x + (2 u + 2 u ) x > subs(u=l,x=l,");
n n
2 3 3 1/2 2 + 1/2 2 n
+ (2 u + 4 u + 2 u ) x
n
3 2 4 4 2
+ (6 u + 6 u + 2 u + 2 u ) x
We can also obtain this as
2 3 4 5 5
+ (8 u + 12 u + 8 u + 2 u + 2 u) x > diff(f,u);
x (1 - x + u x) x
6 - ----------- + ---------------
+ O(x ) ux+x-l 2
(u x + x - 1)
In closed form this is > g := subs(u=l,");
> f := genfunc(S,x,nops,closedform); x x
/ u x \2 g := - ------- + ----------
11 + -----1 2 x - 1 2
\ 1 - x/ (2 x - 1)
f := ------------
2 2 > convert(g,Series,x);
u x infinity
1 - --------
2 \ n1 n1 n1
(1 - x) ) (1/2 2 n1 + 1/2 2 ) x
/
which simplifies to
> f := normal(f): n1 = 1
n1 =0
These can be added, or multiplied as in
22
> evals( s1 + s2); 3
infinity + 4 (k + 1) )
\ / n1 [ -2] [-3] \ n1 (k - 1) 2
) 1(-1) [ ]+[ ]Ix - 1/16 (-1) (11 + 10 k + 2 k )
/ \ [ n1] [n1] /
This enables us to solve the following sorts of
n1 = 0
problems.
> expand(n);
/infinity \ Example 2.3 Find the coefficient of xn in f de-
I I
I \ n1 [ -2] n11 fined by
I ) (-1) [ ] x I > f := (x+1)/( 2*x'2-3*x+1 );
I / [ n1 ] I x + 1
I I f := --------------
\ n1 = 0 / 2
2x -3x+1
/infinity \
I I
I \ [ -3] n11 Solution: This rational function is equivalent
+ I ) [ ] x I
I / [ n1 ] I to
I I >s := convert(f,parfrac,x);
\ n1 =0 / 3 2
s := - ------- + -----
or 2x-1 x-1
> evals( s1*s2 ); which is a sum of two terms, each of which can
infinity
be expanded using the binomial series. The corre-
\ sponding series representation based on formulas
) Sum(
/ for the nth coefficient are
n1 = 0
> t := map(convert,s,Series,x);
/infinity \
n1_1 [ -2 ] [ -3 ] I I
(-1) [ ] [ ] ,
I \ n1 n11
[ n1_1 ] [n1_2] t := I ) 3 2 x I
I / I
n1 I I
n1_1 + n1_2 = n1) x \ n1 = 0 /
/infinity \
and we can extract coefficients as in I I
> getcoeff(n,x,k); I \ n11
n1_1 [ -2 ] [ -3 ] + I ) - 2 x I
Sum«-i) [ ] [ ], I / I
[ n1_1 ] [n1_2] I I
\ n1 = 0 /
The required coefficient is just
simplify them > map( getcoeff,n,x,n);
> simplify(n); n
3 2 - 2
\ (2 n1_1 + n1_2)
) (-1)
/ The next example illustrates how the environ-
ment can be used to experiment with a given prob-
[ 2 + nC2 ]
lem.
(1 + n1_1) [ ]
[ nC2 ] Example 2.4 Find the generating function with
or find the value of them respect to length for the sequences over the alpha-
> value(n); bet {O, I} in which no substring of the form 0110
(2 k) 2 occurs.
1/16 (-1) (15 + 14 k + 2 k
>S := genseq(Star(n»;
23
S := [phi, 0, 1, 01, 11, 00, 10, 010, The right answer is produced by looking at over
110, 000, 100, 011, 111, 001, 101,
300 sequences as in
>S := genseq(S,nops,300):
0100, 1100, 0000, 1000, 0110, 1110, > select(lot(hassubstring[O,l,l,O]),S):
> genfunc( convert(II,set) , x , nops);
0010, 1010, 0101, 1101, 0001, 1001, 3 6 4 5 8
8 x + 52 x + 15 x + 28 x + 181 x
0111, 1111, 0011, 1011]
2 7
+ Objects(nops = 5) + 4 x + 97 x + 1 + 2 x
The displayed sequences that do not have 0110 are The commands genfunc( ) and genseq( ) interact
> select(lot(hassubstring[O,l,l,O]),S); in such a way that all coefficients that are dis-
[phi, 0, 1, 01, 11, 00, 10, 010, 110, played are correct. In this case all sequences up to
000, 100, 011, 111, 001, 101, 0100, length 8 have been considered.
> closedform(II);
1100, 0000, 1000, 1110, 0010, 1010, closedform:
You may vant to compare this estimate
0101, 1101, 0001, 1001, 0111, 1111, vith the next order of approximation!
3
0011, 1011] 1 + x
We can guess at the generating function by using 3 4
these sample coefficients. 1 + x - 2 x - x
> genfunc ( convert (II, set) , x , nops ); This is easily verified by using a regular expression
3 2 4
8 x + 4 x + 15 x + 1 + 2 x to explicitly construct the same set of sequences.
> closedform(II);
closedform:
You may vant to compare this estimate
vith the next order of approximation!
1
3 Overview
- 2 x + 1
The primary purpose of these tools is to pro-
This is the generating function for all 0-1 sequences
vide support for interactive experimentation on se-
so it is clearly not correct. The "guess" at the
quence enumeration problems. A number of tech-
closed form for the generating function is wrong.
nical issues had to be confronted. In particular,
However, we try again with a larger sample of co-
efficients. 1. Any sequence is a concatenation of alphabet
> S := genseq(S,nops,100): symbols. These symbols must remain distinct
> select(Iot(hassubstring[O,l,l,O]),S):
> genfunc ( convert (II, set) , x , nops ); and recognizable if we are to effectively ma-
3 2 4 5 6
8 x + 4 x + 15 x + 28 x + 52 x + 1
nipulate them.
This guess is still wrong for it has fractional coef- 4. In order to manipulate and extract coeffi-
ficients as in cients a representation that retained informa-
> taylor(II ,x,10); tion about the computation of the nth coeffi-
2 3 4 5 cient was necessary.
1 + 2 x + 4 x + 8 x + 15 x + 28 x
24
> alphabet(O,1,2,10):
{O, 1, 2, 10} B := 1*
> Seq(1,O): > S := genseq([A,B],nops,15):
10 S : = [phi, 0, 1, 00, 11, 01, 000, 111,
25
5 6 show the general patterns that the theory predicts.
x + O(x )
This inability to consider fairly large examples has
Maple's usual commands can be used as weight traditionally been a stumbling block for students
functions as well as user defined commands. in this course.
The select command has been greatly enhanced The author thanks both the Symbolic Compu-
to facilitate a wide variety of selections based on tation Group and the Combinatorics Department
weight. For example, the user may specify a selec- at the University of Waterloo for the opportunity
tion of the form to explore this use of algebraic computing in a new
> select(nops=2 .. 4,5 ); environment.
[00, ii, 01, 000, iii, 011, 001, 0111,
26
EXPERIENCES WITH MAPLE IN ENGINEERING
EDUCATION AT THE UNIVERSITY OF WATERLOO
Mustafa Fofana, Ian LeGrow, Stephen Carr
Engineering Education Research Centre, University of Waterloo, Waterloo ON, Canada
27
In this paper, we first describe the • Introduce Maple (approximately 1/2-1
organization of courses which have hours);
incorporated Maple, including several
examples from courses in differential equations • Continued tutorial sessions-ranging from
(in which members of the EERC, (Austin and unstructured question-and-answer periods to
Pofana [1993]) had effectively participated in structured, course-related examples
enhancing the teaching of differential (approximately 10 one hour sessions);
equations). A summary of some of the
problems encountered and recommendations • Unstructured lab time (accessible 24 hours
for future ventures will be categorized. per day).
28
> simplify(");
> de3:=x"2*diff(y(x),x$2)+5*x*
diff( Y(X),x)+4*y( x)=x"2+ 16*(\n( x»"2:
a
5x (Txy(x) ) + 4y(x) '"
# (Q2). Define differen[ial equation x~+161n(x)"
> ue2:=diff(y(x).x$2)-4*diff(y(x).x) +
3*y(x)=5 *ws(x); # General solution
a 2
de2 : = (~y(x) ) - 4 (~y(x)
a > ygs3:=dsolve(de3,y(x»;
ax- aX
+ 3y(x) =5cos (x)
ygs3 :=y(x) "'~ (x 4 +
16x-
64In(x)2 x 2-1281n(x) x L +
# General solution 96x~+16Cl+16C21n(x) )
> ygs2:=dsolve(de2.y(x));
> expand(");
ygs2 :=y(x) ",-';:cos (xl-
1 -
sin(x) +Cle"'+C2e x y(x) = '1"'7x~+
i6
~
41n (xl - -
8In (x) + 6 + C 1 + C2 In (x)
XL XC
# Checking the general solution
29
> simplify ("); a2 1 2 28 122
(
dx2 - ""S" x - 7S" x - "T25" +
> simplify(");
a 2 a
de4: = (~y(x)) + 4 (-:r:-:Y(x))
ax 2 oX
- 5 Y (x) = x 2 + 4 x x 2 +4x =x 2 +4 x
icl =1 "'da"X3 Y ( x)
3
:=y(O) deS: = ( ) -
a
2
2 ((Jx2Y(x) ) - 5 (TxY(X) )
a
> ic2:=D(y)(O)=o; + 6y(x) = e 'x
ic2 :=D(y) (0) =0
# Define three initial conditions
> ic2:=D(y)(O)=O;
1 28
yps4 :=y(x) =-_x 2 -..,.,.-rx-
5 ~5
122 + 11 x + 107 -5x i c2 : = D (y) (0) = 0
"TIS be 750 e
> ic3:=D(D(y»(O) = 1;
# Checking the particular solution
ic3 :=D(2) (y) (0) =1
> subs(y(x)=rhs(yps4),de4);
30
# Particular solution
3. Problems Encountered
> yps5 :=usolve( {de5,ic I ,ic2.ic3} ,y(x»;
Incorporation of Maple software into the
engineering curriculum has met with mixed
success. A summary of the main difficulties
follows:
31
4. Recommendations • Differentiation/lntegration of rational
functions,
These recommendations are based on
comments by instructors (professors), students' • Expansion of partial fractions.
critiques, and personal experiences. These are:
These were all concepts the students were
(i) It is important not to oversaturate students familiar with prior to the course. The majority
with information. This happened when the of the controls students said that Maple
students were introduced to a new computer software did not teach them control theory; it
system at the same time as Maple software. simply allowed them to quickly confirm ideas
For the ODEs course the students were about the theory learned in class or from the
introduced to Unix and Maple in one session. text. The successful application of Maple
Many of the students became confused with software to a course depends strongly on the
the Unix operating system. This confusion course curriculwn. Those courses in which the
was exacerbated by introducing Maple, leaving material is based on mathematics learned prior
many students frustrated. For future classes, a to the course are most successful.
tutorial dedicated exclusively to teaching the
operating system, its basic commands, and the (iii) Communication between the instructors of
use of a text editor is recommended. For the the courses and the T.A.s (teaching assistants)
controls course only 27% of the students had regarding tutorial content is essential. This
used Unix previously; most students were ensures that the T.A.s use the same
familiar with DOS. Newer DOS machines are terminology as the instructors and present
sufficiently powerful to operate Maple for Maple examples that illustrate lecture material.
Microsoft Windows, putting Maple in a Many students in some of the courses felt the
familiar computing environment. Following examples they were shown in the Maple
the operating system tutorial, a subsequent sessions were not close enough to the
tutorial would then be used to teach Maple. instructors' blackboard examples. Coordinating
The controls course had a two hour session the Maple tutorials to lectures makes the use of
which the professor deemed too short. Maple more relevant to the course and
increases student participation in the tutorials.
(ii) Students' appreciation and desire to use
Maple was higher in courses where they were (iv) Students must receive motivation from the
already comfortable with the mathematical course instructor to use Maple. If Maple is
theory. In the ODEs course, where Maple was introduced as an option and the instructor does
being used to help teach the theory, students not require its use for any assignments or
who were having difficulty with the material projects then students are not encouraged to
found Maple to be an additional burden. In surmount the initial learning curve. Motivation
contrast, the students in the controls course should consist of classroom encouragement
found Maple extremely useful for and discussion of the use of Maple to solve
(Lee and Heppler [1990)): sample problems. Some assigrunent problems
should also be tailored to being solved using
• Laplace and inverse Laplace transforms, Maple. This can be done by using parameters
in equations instead of nwnerical coefficients,
• Plotting, encouraging students to experiment with and
plot different solutions.
• Factoring polynomials,
32
(v) Students expressed frustration over trying Biographies
to find the commands to complete desired
operations. The Maple software help facility Mr. Stephen Carr is a doctoral student
contains detailed descriptions of every in the Department of Systems Design
command along with examples. However, Engineering, Mr. Ian LeGrow is a fourth year
fmding the desired command is an arduous Mechanical Engineering undergraduate student
task. To overcome this difficulty, a listing of and Dr. Mustapha S. Fofana is a research
the most common commands for a given associate in the Department of Civil
course should be prepared for the students Engineering, University of Waterloo. Mr.
along with common tricks and tips. Carr's research interests include modelling and
simulation of engineering systems using graph
theory, with applications to design based on
reliability and quality criteria. Mr. LeGrow
References studies flexible robot anns and control of
nonlinear systems. Dr. Fofana's research
Austin, H., and Fofana, M. S., " Maple as a interests are delay dynamical systems and their
Tool for Enhancing the Teaching of Ordinary applications to machine-tool chatter; the use of
Differential Equations to Second Year Civil Maple, Mathcad and Mathematica for
Engineering Students," Proceedings of the enhancing the teaching of mathematics,
Sixth Instructional Show & Tell for Ontario mechanics and dynamic stability. All of the
Universities and Colleges- Sharing Innovations three authors work for the Engineering
for Teaching and Learning, University of Education Research Centre (EERC) on a part
Guelph, Guelph, 1993. time basis. The authors may be reached at
Lee, T., and Heppler, G. R, "Algebra Systems Engineering Education Research Centre
for Enhancing the Learning Environment for University of Waterloo, Waterloo,
Control Systems," Proceedings of the ASEE Ontario N2L 3G1,
Annual Conference, Education Research and
Markets Division, Toronto, Ontario, Canada [email protected]
1990.
[email protected]
Heppler, G. R, Course Critique of Systems
Design (SD) 352 - Linear Control Systems, [email protected]
Internal Report, 1989.
33
ON INTEGRATING COMPUTERS INTO THE PHYSICS
CURRICULUM
Ronald L. Greene
Department of Physics, University of New Orleans, New Orleans LA, USA
34
Because of this, CACS are quite appropriate for a is sufficiently powerful both to save
tool that is meant to aid students' understanding of tedious, time-consuming calculations in
physics, rather than programming. The emphasis junior level classical mechanics and to
shifts to analysis of the solution, such as verifying allow instructors and students to take
limiting cases and studying dependence upon the advantage of interactive computing to
parameters of the problem. probe more deeply into the physics of a
given problem.
So much of what we have traditionally taught
in our core physics courses deals with analytical 2) Avoid trying to teach the typical physics
solutions. The symbolic abilities of CACS will major how to write programs with the
allow us to incorporate their use into our courses language included in the system. More
with minimal required changes in the way the advanced students may want to get into
courses are now taught, which is necessary for programming, or instructors may want to
acceptance by the majority of current physics introduce programming in specialized
faculty. However, their numerical and graphical courses, but time spent programming in
abilities, and their interactivity will allow us to go core undergraduate physics courses is for
beyond the bounds of conventional lecturing and the most part time taken away from
the idealistic, analytically solvable problems to learning physics.
which we now limit ourselves.
3) Emphasize the importance of checking
CACS are very large and powerful programs. solutions. All CACS still have bugs in
Many hours of experience are required to become them, some of which are serious. This is
proficient with them. Fortunately, only a small not a reason to avoid their use, since both
subset of the predefined functions need be learned students and teachers also make errors.
by the student (teacher) to usefully apply a given However, there seems to be a tendency
CACS to learning (teaching) the material in for students to accept results that come
undergraduate physics courses. No programming from a computer as correct, without the
is required, although it can be used to extend the need to check them. Results can be
power of the system. To illustrate, I will shortly checked using the CACS (since typically
present some aspects of using Maple V in the a different portion of the program code is
junior level classical mechanics course at the used for checking a solution than for
University of New Orleans. I will list the subset obtaining the solution), and/or by hand
of functions used and give examples taken from (since it is often easier to verify a
the course. First, however, it is important to solution by plugging it into the equation
discuss briefly a general approach toward using than to solve the equation in the first
these programs in physics courses. place). Beyond mathematical checking,
however, students should be taught to
examine their answers for physical
Philosophy of Use plausibility, and to verify limiting cases.
35
on paper or in their heads, let them do conducted in the usual manner, covering
so. The simplified form can be re- introductory material on vectors and kinematics,
entered into the CACS if desired. and reviewing Newton's equations of motion
through in-class and homework problems. I then
5) In so far as possible, the basics of the proceeded to introduce the students to Maple and
CACS should be taught using physics had them use it to solve many of the same
that is already familiar to the students, problems that they had already done by hand.
for obvious reasons. For example, early
in the first semester of the typical Like most CACS, Maple V has a large
classical mechanics sequence is a unit number of predefined functions (2500 in the latest
reviewing Newtonian physics of a release). Fortunately, very few are needed to use
particle. Most of the CACS functions the program productively in a classical mechanics
that will be used in the complete classical course. For their basic Maple text and reference,
mechanics course can be introduced here students were required to purchase First Leaves:
and used to solve and analyze the kinds A Tutorial Introduction to Maple V by Char et
of problems that students have already al. 17 I spent two class periods introducing Maple
seen in their introductory course. V, discussing entering expressions, editing, basic
operations, and most of the functions that would
Probably the matter that will generate the be used in the course. This corresponds to most
most controversy with regard to using a CACS in of Chapter 1 and a third of Chapter 2 in the Maple
physics courses is the question of how much
mathematics students should be required to do by
hand. The same type of question was debated
years ago with regard to students' use of Table I. Basic Maple Functions
calculators. (Apparently this kind of debate goes
back much further. A Mathematics professor diff -- ordinary and partial differentiation
friend of mine tells me that there was an outcry int -- indefinite and definite integration
against students' use of chalk and slate in learning solve -- solution of algebraic equations
mathematics because of the deleterious effect it dsolve -- solution of differential equations
would have on their ability to do arithmetic in subs -- substituting expressions into
their heads.) Obviously, each teacher will decide equations
for him/herself how much they will allow their eval -- forcing evaluation of an expression
students to rely on the computer for solving evalc -- separating an expression into real
equations. My personal expectation is that within and imaginary parts
ten years virtually all solutions at the evalf -- numeric evaluation of expressions
undergraduate level will be done by computer, and assign -- assign values to variables of a
we instructors will be grading students on their solution set
understanding of physics as reflected in their simplify -- generic simplification of
ability to obtain the proper equations to solve, and expressions
their analysis of the results, rather than their limit -- verifying limiting cases
mathematical manipulations. series -- small parameter expansions
unapply -- creating functions from
expressions
Maple V in Classical Mechanics plot -- plotting results
36
functions, there are a number of more specialized and massless pulley which is supported by a
functions for manipulating expressions (expand, massless rope whose ends are tied to Ml and M2.
factor, combine, normal, convert, collect) or The problem is to use Newton's 2nd law to find
extracting parts of solutions (rhs, lhs, coeff, the tension in the rope.
numer, denom). Students used some of these
more specialized functions after they became
comfortable with the basic Maple operations and
functions.
37
many of these problems, and the likelihood of simplify(eval(subs(sol, {eqx,eqy} »); ,
error in getting the solution diminishes the value
of the exercise of examining limiting cases. which results in
Maple not only removes the tedium and reduces
the chance of error, but it can aid in the {O = O} .
examination of the analysis of the solutions.
If we assign the appropriate values to vx(t) and
Example 2 vy(t), we can verify the initial conditions:
For the second example let us consider the
assign(sol);
motion of a projectile subject to a drag force
limit(vx(t),t=O);
proportional to the velocity. The problem is to
limit(vy(t),t=O);
calculate the position and velocity as a function of
time, and to examine the effect of drag on the
As always, it is important to verify limiting
trajectory. Assume x and yare the horizontal and
cases for which we know the answers. One
vertical axes with positive directions being to the
obvious limiting case to check is that of no air
right and upward, respectively. For this problem,
resistance. This case can be obtained with
Newton's 2nd law can be used to obtain an
equation of motion which is a first order
limit(vx(t),b=O);
differential equation for v(t), rather than the more
limit(vy(t),b=O); ,
usual second order equation for r(t):
~ dv which yield the expected results.
-mgy-bv=m dt .
With some rearrangement this vector equation can Another useful limit to verify is the long-time
be broken into the following x and y equations: limit. Physics tells us that as t~oo, vX<t~, and
v/t)~-mg/b, the so-called terminal velocity. We
dv (t) were not able to verify this limit with Maple
m x +bv (t) =0
dt x
because I did not know how to specify that blm is
and positive. Release 2 has solved this problem.
dv (t)
m Y +bv (t) +mg=O . In order to graphically compare velocity and
dt Y
position as functions of time for different drag
The initial values of velocity are taken to be coefficients, it is convenient to create functions of
vx(O)=vo x and v/O)=voy ' b and t out of the expresssions which are the
values of the Maple variables vx(t) and vy(t).
To solve these equations with Maple, we first This can be done with the 'unapply' function:
use the 'diff function to enter the equations,
VX : = unapply(vx(t),b,t);
eqx : = m*diff(vx(t),t) + b*vx(t) = 0; VY : = unapply(vy(t),b,t); .
eqy := m*diff(vy(t),t)+b*vy(t)+m*g=O; ,
[Capital letters have been used to avoid confusion
and solve them with the 'dsolve' function. (At with the Maple variables vx(t) and vy(t).] Given
this point in the course I introduced the concept of the velocity components as functions of time, we
scaling equations to show students how to reduce can then find the position components by
the number of parameters. However, I will not integrating in the usual way. Assuming that the
use scaling in this paper.) The solutions are found origin of the coordinate system is chosen at the
with the statement initial position of the projectile, we define
(The equations are uncoupled, and thus can be Once we specify the parameters of the
solved separately if desired.) They can be problem, the definitions for VX(b,t), VY(b,t),
checked with X(b,t) and Y(b,t) will allow us to plot the x- and
38
y-components of position and velocity as functions plotting facility to plot Y(b,t) vS. X(b,t) over time,
of time or drag coefficient. For example, suppose for several values of b. For example, the Maple
we look at the special case of dropping a rock sequence
vertically from the edge of a cliff. We make the
assignments (in SI units) vOx: = 10; vOy: = 10;
plot( ([limit(X(b,t),b=O),
m:=I; g:=9.8; vOx:=O; vOy:=O; . limit(Y(b,t),b=0),t=0 .. 2],
[X(.l,t), Y(.I ,t),t=O .. 2],
Maple will automatically incorporate these values [XCI ,t), Y(I,t),t=O .. 2]});
for the parameters into our definitions for the
position and velocity functions, allowing us to plot
the results with little effort. (For some reason I - -- -
...... : : .-.-.-. ....
do not yet understand, the values for vx(t) and ,;
~., ' ,, ' "-
vy(t) do not incorporate the new values of the I' "
, " "
' ,
/
parameters. ) ./
We can directly compare the y-component of
" \
\
,
\
39
W. This is easily done by first defining the total
d 2 x(t) +2y dx(t) +(Il~(t)-Fosin«(Il t)= energy to be a function of W and t:
dt 2 dt m
where wo2=k/m and -y=b/(2m). If we take En := unapply(evalc(K+U),w,t);
conditions such that the initial position and
velocity are zero, the following lines enter the The purpose of the 'evalc' function in this
equation into Maple, solve it, check the solution definition is to force Maple to separate the real
(including initial conditions), and assign the values and imaginary parts of the K + U sum so that that
for the position and velocity to the variables x(t) the total energy is recognized as real. Note that
and v: it is only after the assignment of Wo and -y that
Maple can unambiguously perform the evalc. (If
Dforce : = F*sin(w*t); the result contained a small imaginary part to due
eq : = diff(x(t),t,t) + 2*gam*diff(x(t) ,t) rounding of floating point numbers, we would also
+ wO A2*x(t) - Dforce/m = 0; have to extract the real part to perform the plot.)
sol : = dsolve({eq,x(O)=O,D(x)(O)=O},x(t));
simplify(eval(subs(sol,eq))); If we now plot the total energy as a function
assign(sol); of time for w= .5, .9, and 1 rad/s (The last value
limit(x(t),t=O); corresponds to resonance.),
v : = diff(x(t),t);
limit(v,t=O); plot({En(.5,t), En(.9,t), E(l,t)},
t=0 .. 10/gam,numpoints=200);
(The class of the solution --- underdamped,
overdamped, or critically damped --- depends on
the value of Wo 2 - y. I had not found a way to
specify the signs or relative magnitudes of II / . . .- ._._._._0_'_'_'-,-,-,-"
,/"
parameters or combinations of parameters in
Maple at the time that I did this in class. With
the advent of Release 2, the underdamped case
can be specified by including statements
assume(gam> 0);
additionally(gam A2-wO A2 < 0); .)
40
in Fig. 4 by the fact that energy absorption at is fairly easy to reproduce the steady-state-only
w= 1 radls is much larger than the other two case with Maple, should we desire. However, the
values plotted, can be illustrated more clearly by Pss function is a good approximation to it.
examining the power absorbed by the oscillator
from the driving force, averaged over one period.
It is instructive to compare the power absorbed for '.1 n
different values of damping, so we will unassign II
)' and define the average power absorbed as a !!
II
function of)'. We treat two cases with different I I
gam: = 'gam';
' .1
T := 2*Pi/w;
int(Dforce*v, t = to .. to +T)/T;
AvgPower : = unapply(simplify("),tO,gam,w);
PO := (gam,w) -> Real(AvgPower(O,gam,w»;
Pss:= (gam,w)->
Real(AvgPower(lO/gam,gam,w,t»; . Figure 6. Average near-steady-state power
absorption of the oscillator in Example 3 as a
If now the average power is plotted as a function function of driving f~equency. Three different
of w, the effect of a driving force whose values of damping are shown.
frequency is at or near resonance can be clearly
seen. Finally, we show in Fig. 6 a comparison of
near-steady-state power absorption for three
plot( {PO(l/lO, w),Pss(1 llO,w)}, w=O . .4); different values of )'. The plot is that obtained
from
'.1
II
plot( {Pss(1I10, w),Pss(1I4, w),
II Pss(1I2,w)},w=0 . .4);
II
II
I I The most obvious features, of course, are the
I I
I.' I I strong power absorption near resonance (w = Wo = 1
rad/s), and the large increase in resonant
absorption as damping is decreased.
' .1
Additional Comments
Much of what we teach in our upper division
physics courses is driven by the difficulty in
Figure 5. Average power absorption of the obtaining results mathematically. The absence of
oscillator in Example 3 as a function of the analytical solutions can cause us to spend little
driving frequency. The two curves represent the time with a given problem, or to ignore it entirely.
average over periods starting at t=O and t= 10/)' Even when analytic solutions exist they may be so
(near-steady-state). tedious to work with that we similarly avoid the
problem. The driven harmonic oscillator provides
us an example of this latter type of problem. The
The result is shown in Fig. 5, for the case ),=.1, mathematics required to study the energy of the
which corresponds to weak damping. Most oscillator and power absorption in the general case
mechanics texts show an average power absorbed is simple, but extremely tedious. Its very detail
vs. driving frequency at steady state, but not at tends to obscure the physics. This has caused us
earlier times when transients are still present. It
41
to omit interesting parts of the physics in our class Romer, and Bruce R. Thomas, "The
discussions. However, as seen in the previous undergraduate physics major," Am. J. Phys.
section, a CACS analysis allows us to look (for 59, 106-111 (1991).
example) just as easily at energy of the oscillator 11. Richard E. Crandall, "Symbolic Software
and average power absorption when the transients Supports New Adventures in Physics,"
are still present as when it has reached steady Computers in Physics 5, 576-579 (1991).
state. A similar argument can be made for using 12. Patrick Tam, "Physics and MathematicaTll " ,
the numerical abilities of a CACS to study the Computers in Physics 5, 342-348 and 438-442
physics of problems which have no analytical (1991).
solutions. These software packages open new 13. Cyrus Taylor, "Mathematica in the
territory for us to explore in our classes without Classroom," Computers in Physics 5, 16-21
the necessity of spending hours filling blackboards (1991).
with additional derivations or looking only at 14. David M. Cook, Russell Dubisch, Glenn
limited approximations. In addition, using a Sowell, Patrick Tam, and Denis Donnelly, "A
CACS at the level that I advocate for our Comparison of Several Symbol-Manipulating
undergraduate courses is sufficiently easy that we Programs: Part I," Computers in Physics 6,
can assign such explorations to students with the 411-420 (1992).
confidence that they can learn interesting physics 15. David M. Cook, Russell Dubisch, Glenn
from the exercise. Sowell, Patrick Tam, and Denis Donnelly, "A
Comparison of Several Symbol-Manipulating
Programs: Part II," Computers in Physics 6,
References 530-540 (1992).
16. Bruce W. Char, Keith o. Geddes, Gaston H.
1. Denis Donnelly, "CIP's First Annual Gonnet, Benton L. Leong, Michael B.
Software Contest: The Winners, " Computers Monagan, Stephen M. Watt, First Leaves: A
in Physics 4, 540-548 (1990). Tutorial Introduction to Maple V (Springer-
2. Denis Donnelly, ''eIP Announces Winners of Verlag, New York, NY, 1992).
Second Annual Software Contest, " Computers
in Physics 5, 636-642 (1991).
3. Denis Donnelly, "CIP's Third Annual Ronald L. Greene is a University of New Orleans
Software Contest: The Winners," Computers Research Professor in the Department of Physics.
in Physics 6, 686-691 (1992). He has been actively involved in theoretical and
4. Steven E. Koonin, Computational Physics computational studies in plasma spectroscopy and
(Benjamin Cummings, Menlo Park, CA, semiconductor physics at various times in his
1986). career. Most recently his research interests have
5. Harvey Gould and Jan Tobochnik, An been in the area of neural networks and associative
Introduction to Computer Simulation Methods: memory. He is leading the effort at the UNO
Applications to Physical Systems, Parts 1 and Department of Physics to incorporate computer
2 (Addison-Wesley, Reading, MA, 1988). algebra and calculus into the undergraduate
physics curriculum.
6. Marvin L. De Jong, Introduction to
Computational Physics (Addison-Wesley,
Reading, MA, 1991).
7. Denis Donnelly, MathCAD® for Introductory
Physics (Addison-Wesley, Reading, MA,
1992).
8. Charles Misner and Patrick Cooney,
Spreadsheet Physics (Addison-Wesley,
Reading, MA, 1991).
9. Jack M. Wilson, "Computer Software Has
Begun to Change Physics Education, "
Computers in Physics 5, 580-581 (1991).
10. Neal B. Abraham, James B. Gerhart, Russell
K. Hobbie, Lillian C. McDermott, Robert H.
42
USING MAPLE AND THE CALCULUS REFORM
MATERIAL IN THE CALCULUS SEQUENCE
David C. Royster
Department of Mathematics, University of North Carolina, Charlotte NC, USA
43
terfaces. At the Tulane Conference workshop Donald independently. Since the arrival of the CMS coin-
Small and John Hosack [SH86] looked at the possi- cided with this era of change in calculus teaching, we
bility of using a Computer Mathematics System in the have embraced it as a means to bring about change
Calculus sequence. They raised a number of questions both in the curriculum and, especially, in the way that
and these questions have been discussed extensively we teach and the way that the student learns mathe-
in [SH86, Dev90, Harv90, Ral90, Zorn90], and in matics.
many of the articles in [Kar92]. How should the
computer be used in the Calculus sequence? When This multiple-representation approach to Calcu-
should it be used in the Calculus sequence? Should it lus is well-suited for the use of Maple. Maple very
be used in the Calculus sequence? In [HLLL92] the easily allows us to use each of these representations in
authors mention that computer mathematics systems studying functions, limits, derivatives, integrals, and
"were not initially designed or perceived as pedagogi- other topics in the reformed Calculus curriculum.
cal tools but rather as professional tools." Like most Maple allows the students to tackle more realistic,
of the technologies introduced, their influence spilled more complex, and more interesting problems.
into the academic arena. At this point we had to
admit their existence, though we did not know how to Questions remain about the appropriate use of
use them wisely or too well. Maple.
• When should Maple, or any computer mathe-
Here, following the suggestion of Dick Shum- matics system, be introduced to the students in
way, we call such a system a Computer Mathematics the Calculus sequence?
System(CMS) rather than a Computer Algebra Sys- • How much symbolic manipulation is appropriate
tem because it does so much more than algebra. for the first semester of Calculus?
Among computer mathematics systems, in addition to • How much symbolic manipulation is appropriate
Maple, are programs such as Axiom, Derive, for the second semester?
Macsyma, and Mathematica. These are mentioned • Is Maple inappropriate for the Calculus se-
because they are commercially available for a variety quence?
of platforms l . Their latest incarnations allow the stu- • What does the research say about the use of com-
dent to do symbolic manipulation at a basic level of puter mathematics systems with respect to under-
algebra, but more import<ultly, at higher levels. standing of the concepts from Calculus?
They handle graphical output much better and have • Can the use of Maple, in conjunction with the
the ability to give high precision numerical output. Calculus Reform material, help students under-
They have been classified as super-calculators, but st.'U1d the concepts more easily?
should be considered as much more.
These questions are addressed to the Calculus
Several NSF funded projects-Calculus Con- course. We are not certain how to begin to answer
sortium at Harvard, St. Olaf Calculus Project, Oregon these types of questions about the learning processes
State Calculus Project, Purdue Calculus Project, of students at lower levels. There are many things
Calculus in Context Project(Five Colleges, MA), that we do not know about the process of learning al-
Project CALC(Duke University)--have decided to use gebra and its role in the learning· of Mathematics.
multiple representations for each of the concepts in We are only beginning to make progress at the Mid-
presenting the Calculus. This development of the dle School level and the High School level in learning
Calculus refonn material paralleled the development how students construct their own mathematical sys-
of the computer mathematics systems and their use in tems. The universities are not dealing with students
the Calculus classroom. The concerns raised by the at this cognitive level, but are dealing with students
use of the CMS in the classrooms were being ad- who have constructed their algebra and their mathe-
dressed in the reform material, though of course not matical systems. Newer research by Rachlin in the
Hawaii Algebra Project and by Heid, Sheets, and
Matras [HSM90] is giving us a better understanding
1 with the exception of Derive available only on DOS
based machines, but such a wide variety of DOS based
of the process that students use to construct their
machines. mathematics and their algebra. We are coming to
44
the realization that their algebra may not be our al- shoulders of the giants upon which our stu-
gebra. dents will stand to see further and perhaps
to go where no one has gone before.
• Is there some way in which the computer
mathematics systems can direct the students'
learning and the construction of the students' The State of the Computer Mathematics
mathematics?
System
• Is it possible that having students use a computer
mathematics system will retard their natural Does a computer mathematics system make a differ-
learning of the pattern recognition that is in- ence in a student's learning mathematics? Not a
herent in the learning of algebra? great deal of research has been published to date. A
• Are the algebraic abilities and the pattern rec- number of 1990-1992 dissertations address the area
ognition gained in learning these abilities neces- of the use of technology in the collegiate mathematics
sary in later mathematics? setting. Of those, a small number deal with Calculus
• Will these abilities not be present at a later date and computer mathematics systems [HLLL92,
when they are required to underst<,md deeper Heid88, Palm91, Jud90). In these experiments the
mathematical concepts? computer mathematics system was used in different
ways. The researchers were not always able to offer
We can spend many hours, days, and weeks ar- the computer mathematics system to the student in a
guing about the appropriateness of using technology same format. Nonetheless, the fmdings of these
in the classroom, let me quote a former engineer who studies indicate that the students in the groups using
responded to a post to the GRAPH-TI LISTSER V on the computer mathematics system learn the concepts
the Internet: better than the control groups and do as well, or bet-
ter, than the control on standard paper-and-pencil
After a career of 20 years in Research, De- tests. Charlene Beckmann [Beck90) studied the im-
velopment, Testing and Evaluation in the pact of a graphical interface with the students in dif-
Department of Defense, I find it appalling ferent calculus courses (N=163). She found that de-
that technology would not be allowed in en- veloping the calculus concepts through the use of a
gineering courses. graphical representation system (specifically com-
puter graphics) positively affected student under-
In my experience an engineer who is not
standing and interest without necessariIy negatively
fully aware of technology and how to use it
influencing skill acquisition.
is not a viable candidate for a job. When I
hired an entry level engineer, he was ex-
These results are in line with similar studies on
pected to be proficient in the available tech-
the connection between the use of the scientific and
nology. Time and dollars do not permit the
graphing calculator in learning mathematics and the
use of long division and reliance on paper
numerical abilities of students at all levels. For those
and pencil memory. They require the use of
students who took a class and learned their mathe-
the best technology available.
matics using the calculator, the calculator had a neu-
In all those years, I never met a real-world tral impact or a slightly positive impact on their
engineering problem that was solvable using ability to perform, unaided by the calculator, on
only paper and pencil. The ability to use st<'mdard paper-and-pencil tests.
technology is required and demanded.
Our students are required to work and live The State of the Calculus Reform Mate-
in a world of technology, not one populated rial
by old Greeks drawing figures in the sand. Does the Calculus Reform material make a difference
Newton wrote, "If I have seen further it is by in how students learn calculus and what they learn?
standing on the shoulders of giants." The
Again, there is anecdotal evidence that it does have a
small black, blue or gray boxes that are to- positive impact on those students who complete the
day's technology are the epaulets on the
45
course, regardless of the technology chosen for the The Situation at UNC Charlotte
course, cf. [Hart92]. There have not been, to date,
any large studies published on these effects. Studies How has Maple changed the way in which I teach?
are underway in the Purdue Project, Project CALC, Dramatically! How have the Calculus Reform mate-
and at UNC Charlotte. Other studies are in progress. rials changed the way in which I teach? Also, dra-
matically! In fact, the two fit together quite well.
Part of the difficulty in this area of study is to de-
termine a good baseline for the mathematical knowl- All of the Calculus Reform materials assume
edge of the college student. In addition we do no that the student has access to some sort of technology.
know how college students learn mathematics? Du- Some are very specific, such as the Uhl-Porta project
binsky [Dub92] outlines four possible ways in which at the University of Illinois, closely tied to
students learn mathematics: Mathematica. Project CALC has been closely
aligned with MathCAD and Derive; the Oregon State
• Spontaneously: Students learn mathematics in- Project, HP calculators; the Purdue Project, ISE1L
dividually and spont.'Uleously. and Maple. Most of the projects are- rather independ-
• Inductively: Students learn inductively by doing ent of the technology, letting the teacher choose
many examples, extracting common features, and something appropriate.
organizing this information in their minds.
• Constructively: Students learn by making men- We have used both the Oregon State [DP92] ma-
tal constructions to deal with mathematical phe- terial and the Harvard [HHG92] material here. We
nomena. have used TI-S1 calculators and MapleV on Sun !PC
• Pragmatically: Students learn mathematics as a workstations networked using the afs ftle system.
response to problems in other fields. The TI-S1 calculators have a very short learning
curve, are programmable, and draw reasonable
Many researchers in Mathematics Education graphs for planar objects. Students quickly learn to
follow the constructivist theory of Piaget: mathemat- use them and use them in many classes. Maple takes
ics is not something that you have, but it is some- longer for them to learn and, at first, I fmd a number
thing that you do. This theory fits well with much of of students resistant to using and learning Maple.
what we know about the mathematical knowledge One reason that they give is that when they go on to
and mathematics learning of elementary students. later courses in Engineering they feel certain that
they will be able to use a calculator, but they fear that
Taking the constructivist viewpoint, we must they will not be able to use Maple. The longer they
believe that students construct their mathematics and, use it and the more interesting the problems to which
then, we need to learn how they construct it and what it is applied, the more they like it. After two semes-
they construct. Students may actually understand ters many feel comfortable enough to continue using
more mathematics than we think, but are unable to it in their later courses.
communicate their understanding within the confmes
of algebraic symbols. What "mathematics" have our Using the Calculus Reform materials that are
students constructed who are entering our universi- oriented toward teaching the concepts of Calculus, I
ties? Does the constructivist theory hold with our spend class time teaching more concepts and fewer
Calculus students? Are they constructivists or prag- algorithms. Maple makes it possible to change the
matists? How have we been teaching our Calculus type and complexity of problems that I ask the stu-
courses? dent to solve. The problems have more realistic data
and often do not have an analytical solution, or not a
Answers to these questions and others will affect nice one. Relieving the students from the manipula-
the way in which we teach and assess our Calculus tions should enable them to spend more time plan-
courses. They will also affect the way in which we ning a method of solution and interpreting the results.
try to determine the effectiveness of the Calculus
Reform material, as well as the effectiveness of com- Consider the following syllabus for the first year
puter mathematics systems. Calculus course and compare it to the standard sylla-
46
bus. Note that Maple meshes well with the refonn the derivative, but the focus and the questions are
syllabus. This syllabus is based on using the Hughes- different.
Hallett, Gleason, et.al. text. Each semester is a 14
week semester and the Calculus class meets 4 days At this point we start the integral. We do not
per week, for a total of 56 class meetings. spend a lot of time on the techniques of integration as
algorithms to be learned. Instead, we study inte-
In the first two and a half weeks we cover A Li- gration by parts as the reverse process to the product
brary of Functions. In this chapter the students get a rule of differentiation, and integration by substitution
brief review of functions and are introduced to func- as the reverse process to the chain rule. Maple and
tions as they can be represented graphically and nu- the student package are used here to help the stu-
merically. The exponential and logarithmic functions dents experiment. After working with it for a while, I
are introduced here, as defined numerically by the have found the students will eventually learn to use
computer-calculator. The students spend time be- Maple to experiment with different choices in these
coming familiar with the graphical and numerical techniques. Their experimentation though has a pur-
representations for functions. Maple is used here to pose. They are trying to fmd rules for integration by
give a wider variety of functions and graphs. Also, parts and substitution that they can then memorize.
the students are introduced to Maple procedures, They still want to classify all anti differentiation
reinforcing the concept of function. In addition, the problems so that they can then memorize the appro-
concepts of accuracy and roots are introduced. Roots priate rule.
are discovered approximately by zooming-in
graphically, using fsol ve ( ... ), or using the Following this we talk about the different nu-
bisection method. We are only using the tool at this merical approximations of the integral: Midpoint
point, not explaining completely how the tool works. Rule, Trapezoid Rule, and Simpson's Rule. With the
technology these subjects really come alive for the
The next two weeks cover an intuitive introduc- students and they begin to enjoy the subject. Some
tion to the derivative-geometric and numerical. prefer to approximate all integrals after that if they
This introduces the idea of local linearity. Using don't have access to Maple. This is something we
Maple the student will look at the symmetric differ- need to work on.
ence quotient and different possible defmitions of the
derivative. Maple makes it a reasonable task to Next we look at applications of the definite in-
graph these different "derivative defmitions" and tegral-standard fare, but done really from the stand-
compare them to the derivative of a function. point of setting up the Riemann sum. Having worked
with Riemann sums for most of the course, the stu-
The next 2 weeks are then an intuitive intro- dents don't seem to dislike this as much as in tradi-
duction to the integral using Riemann sums and lim- tional classes.
its. Maple and the student package are helpful
here. The students can use Riemann sums to com- At this point we introduce differential equations.
pute the necessary integrals. More time is spent on We use slope fields, Euler's method and Separation of
the concepts associated with integration. The tech- Variables to handle most of the equations we
niques are done later. This is called resequencing of encounter. The ODE. In package is extremely useful
skills by Heid and Judson [Heid88, Jud90). for MapleV, Release J. The package is used by the
students at their stage of development for drawing
The next 2 and a half weeks deal with the tech- slope fields and using the firsteuler procedure to
niques of differentiation, the power rule, the product approximate a solution curve. 2 We ask questions
rule, the chain rule, transcendental functions and about solutions that are not dependent upon fmding
implicit differentiation. This is followed by about 2 an analytic solution. Once again the graphical and
weeks on the applications of the derivative. Note that the numerical solutions are readily available to the
there is no need to use the derivative for graphing as
we used to do. We do spend time on graphing and 2 MapleV Release 2 has the tools of this package
incorporated into its DETools library.
47
student, and quite possibly more underst.mdable than #
F := x -> SymDiffQuot(A,x,.OOl);
the algebraic solution.
Once again the students make a table of values for
An Example this function and plot both this result and the original
function on the same axes. The students then see that
At the time we first discuss integration, we discuss they have pretty well recovered the original function.
the Fundament.'ll Theorem of Calculus. Note that
none of the symbolic techniques of computing de- This is not a new idea. Here we have used the
rivatives or anti derivatives have been discussed at this numerical and the graphical representations made
time. The students do know what an antiderivative possible by Maple to emphasize the relationship be-
is, but not having studied the symbolic represent.'ltion tween the integral as the area under the curve and the
of the derivative to any extent yet in the course. As derivative as the slope of the tangent line. Do the
such, they do not have a large repertoire of de- students understand the Fundamental Theorem of
rivatives and antiderivatives. Calculus better? Anecdotally, I can say that most
students do see the FTC differently. They do not per-
The class and I work through the following in ceive it as merely a means to an end. Most of the
our Maple lab in order to deal with the concepts in students do tend to believe that every continuous
the Fundamental Theorem of Calculus. We st.'lrt with function has an antiderivative on a closed interval.
a function, usually something that does not have a Now, if they cannot fmd a formula for the antideri-
closed form antiderivative in terms of elementary vative they will use Maple or a programmable,
functions: graphing calculator to plot the antiderivative over the
> f := x -> sin(x A 2): given interval.
We then define, what we call, the "area function"
based on this function: Conclusion
> A := x -> evalf(int(f(t),t=O .. x)): There is still a lot to be learned about the interplay
between the student and the computer mathematics
We could use the student package and defme the
system. We do not know enough about how it affects
area function via the midpoint Riemann sum:
the learning of mathematics. What we do know is
> B := x -> middlesum(f(t),t=o .. x,250); not enough to draw sharp conclusions about the ap-
The students can then plot this function or get a table propriate usage of a CMS in a Calculus course. We
of values: do know something from the research [Hart92]:
> plot(A(x), x=O .. 5); • Students using the calculus reform material
> for u from 0 by .1 to 2 do showed greater facility with graphical and nu-
> print(u, A(u)) od; merical representations.
The purpose is to get the students to see this "area • Individual students have a definite preference for
function" as a function. Since this is a function, we one particular representation, but different fac-
then a symmetric difference quotient to compute the tors determine the preference.
derivative of this function. • Students' use of computer mathematics systems is
closely tied to their management of the represen-
SymDiffQuot := proc(f,pt,h)
#Syrnrnetric Difference Quotient tations.
#Inputs • When a device (CMS or even a formula) is used
#f = function for difference quotient to perform a computation in a routine manner,
#pt = point at which difference the students look at this result less critically.
# quotient is computed
#h = tolerance • Students' confidence in the graphical information
local sdq; from the computer mathematics system is closely
sdq := (f(pt+h)-f(pt-h))/(2*h); tied to having a priori information.
RETURN(evalf(sdq)); • Student attitudes towards calculus improved
end;
# when using the Calculus Reform material.
48
• Student attitudes toward mathematics improved [Hart92] Dianne Hart. Building concept im-
when using a eMS, regardless of the particular ages-supercalculators and students' use
calculus curriculum. of multiple representations in calculus.
Ph.D. thesis, Oregon State University,
1992. Thomas P. Dick, advisor.
There is much that a computer mathematics system
can offer a calculus student. However, if this is not
[Harv90] John Harvey. changes in pedagogy and
done in conjunction with a curriculum which takes testing when using technologies in col-
advantage of the different strengths of the computer, lege-level mathematics courses. In
we will not be having as much of an effect on the Franklin Demana, Bert K. Waits, and
student. The computer mathematics system can offer John Harvey, editors, Proceeding of the
a lot to the calculus class, but we must never look on Conference on Technology in Collegiate
it as a panacea for all of our ills. Mathematics, pages 40-54, Reading,
MA, 1990. Addison Wesley
References
[Beck90] Charlene E. Beckmann. Effect of com- [Heid88] M. Kathleen Heid. Resequencing skills
puter graphic use on student understand- and concepts in applied calculus using
ing of calculus concepts. In Franklin the computer as a tool. Journal for
Demana, Bert K. Waits, and John Research in Mathematics Education,
Harvey, editors, Proceeding of the Con- 19(1):3-25, 1988.
ference on Technology in Collegiate
Mathematics, pages 104-107, Reading, [HHG92] Deborah Hughes-Hallett, Andrew Glea-
MA, 1990. Addison Wesley son, et. al. Calculus, John Wiley, New
York, NY, preliminary edition, 1992.
[Dev90] J.S. Devitt, Adapting the Maple com-
puter algebra system to the mathematics [HLLL92] Joel Hillel, Lesley Lee, Colette LaBorde,
curriculum. In Franklin Demana, Bert and Liora Linchevski. Basic functions
K. Waits, and John Harvey, editors, Pro- through the lens of computer algebra
ceeding of the Conference on Technology systems. Journal of Mathematical Be-
in Collegiate Mathematics, pages 12-27, havior, 11:119-158, 1992.
Reading, MA, 1990. Addison Wesley
[HSM90] M. Kathleen Heid, Charlene Sheets, and
[Doug86] Ronald G. Douglas, editor. Toward a Mary Ann Matras. Computer-enhanced
Lean and Lively Calculus, Washington algebra: New roles and challenges for
DC, 1986. The Mathematical Associa- teachers and students. In Th()mas J.
tion of America. MAA Notes 6. Cooney and Christian R. Hirsch, editors,
Teaching and Learning Mathematics in
[DP92] Thomas P. Dick and Charles Patton. the 1990s: 1990 Yearbook, Chapter 23,
Calculus, Volume I. Wadsworth Pub- pages 194-204. National Council of
lishing Co., preliminary edition, 1992. Teachers of Mathematics, Reston, VA,
1990.
[Dub92] Ed Dubinsky. A learning theory ap-
proach to calculus. In Zaven A. Karian, [Jud90] Phoebe T. Judson. Elementary business
editor, Symbolic Computation in Under- calculus with computer algebra. Journal
graduate Mathematics Education, pages of Mathematical Behavior, 9(2):153-
43-55, Washington, DC, 1992. The 157,1990.
Mathematical Association of America.
49
[Kar92] Zaven Z. Karian, editor. Symbolic Com-
putation in Undergraduate Mathematics
Education, Washington DC, 1992. The
Mathematical Association of America.
MAA Notes 24.
50
INTERACTIVE MATHEMATICS TEXTS: IDEAS FOR
DEVELOPERS
Carol Scheftic
Department of Mathematics, Carnegie-Mellon University, Pittsburgh PA, USA
Abstract Introduction
If you're going to try and reinvent the gear, Interactive texts are a new medium, one in
it may be easier if you don't have to which IMT authors, math teachers, and
reinvent the wheel first. If you're going to students alike have little experience. It will
try and develop interactive mathematics take time, experimentation, and practice
texts (IMTs) using Maple, it may be easier before IMTs will come into their own. Early
if you have experience as a mathematician, films started out being little more than
teacher of mathematics, computer recorded stage plays, yet the film industry
programmer, instructional designer, today is significantly larger and more
developer of computer-based instructional influential than is the theater. It makes
materials, and textbook author, in addition sense that our first attempts at IMTs will
to being familiar with a computer algebra mimic textbooks, even though textbooks
system such as Maple. evolved from lectures and both of those are
targeted toward groups. It is nonetheless
Few IMT developers have experience in all critical to realize that much of the strength
those areas, and there is no comprehensive of an IMT derives from the interactivity of
theory to guide those entering the field of its medium and its opportunity for
IMT design and development. For those who extensive individualization.
like interesting challenges, this presents
the opportunity to develop additional skills If you want to develop your own interactive
and to begin to formulate just such a theory. texts, you should be familiar with a variety
In this paper I will describe a collection of of interactive products, both within your
"wheels," important basic ideas from each own area and across many other disciplines.
of the relevant disciplines, demonstrate how Take time to look at drill and practice
they can be incorporated into a Maple-based software, at tutorial software, at
IMT, and illustrate what can go wrong if interactive multimedia, even at computer
these suggestions are ignored. The "wheels" games. Look for features that make them
to be included will be chosen from those that easy to use, that lead to confusion or
I have found to be general enough to be frustration, that seem to use the medium
useful across a number of different IMT appropriately.
applications and settings. Look for differences in style that depend on
the goal of the activity, such as theory,
practice, application, or interpretation.
51
Visual Displays the question-and-answer sequence with
additional information that the student can
Chabay and Sherwood (1992) emphasize use for self-evaluation. Try to be polite and
that the display is central in on-line friendly throughout your writing, but avoid
materials, and thus tied into almost all being overly "cute" in it.
design decisions. While we can use it to
display text, graphics, and mathematical Use of Graphics
information, we should remember how it
differs from our more traditional methods When writing interactive text materials,
of presentation. Blank space, for example, make liberal use of the computer's graphic
is cheap on-line, so it can and should be display capabilities. Mix text and graphics
used liberally. throughout: use pictures to illustrate
information from the text, and use text to
When writing on-line materials, you should clarify information from the pictures. But
direct the reader by using a variety of don't try to crowd an overwhelming amount
layout details in place of the denser format of information into a visual display. As with
you would use for a printed document. Even text, you are free to use white space
a highly motivated person with good liberally throughout your graphics. Use a
concentration will find that easier to follow series of clearly labeled images to illustrate
than full paragraphs of text on a display a collection of ideas; repeat them in an
screen. Compare this paragraph with the overlaid fashion only at the end, if
following: appropriate, in order to present a final
comparison or contrast among them.
When presenting text on-line:
- avoid paragraphs, Use of Color
- guide the reader's attention,
- set off key ideas. Be careful in your use of color. First of all,
Compare this format with the paragraph make sure that you avoid implying spurious
shown above. correlations. If you use a particular set of
colors, for example, then what does any
Asking versus Telling particular one mean? While you may just
like a particular shade of blue and think that
It takes time to develop a writing style that its appearance doesn't mean anything beyond
is clear and smooth yet also encourages that, your students may assume,
interaction. We are used to writing in an incorrectly, that blue will always represent
expository style, and an interactive style is the derivative or the error term or
more demanding of the author. It is more something else that will eventually lead
demanding of the students as well, which is them astray. Secondly, be extremely wary
actually an improvement over the of using colors to represent specific objects
traditional static presentation. or processes. You can't be sure that the
students will be able to see the same colors
One guideline for authors new to interactive that you see: they may be working on a
text is to try and think about your machine with a monochrome monitor, or one
expectations for the students with each with fewer or different color choices, or
phrase you write. Whenever there is a they may even be working on a color
place where you want the reader to stop and machine but be color-blind themselves.
think about something, to make a connection While the use of color coding to carry
to something that has been done before, to information can be extremely powerful, you
make an inference about what will come should also be sure to give a color key early
next, there your prose should stop and you on for reference and to describe the relevant
should insert a question. In some cases, you distinction in text. Until you gain
will then want your software to evaluate the experience, test your work occasionally
student's reply; in others, you can follow using a monochrome display to see whether
52
you have documented all the color-critical Interaction
information you have included.
Keep the materials as interactive as
Use of Labels possible. Ask, don't tell, the students what
is going on. Keep them working in an active
Whether or not you use different colors to mode. Avoid letting them become passive.
convey information in a plot, it is always a It's fine to break up some passages to fit the
good practice to label each curve with a text screen by having them press the return
description. All axes should be clearly key, but use that approach sparingly. Ask
labeled as well. This is a practice you questions that require them to think about
should model for your students in the the material as they work their way through
materials you write, and it is a reasonable it.
for you to require them to do the same in the
materials they submit. Illustrations or Provide thorough instructions, but keep
other graphic images imported from a them as terse and telegraphic as possible.
drawing program should also be clearly Don't merely tell the students what to do:
labeled. first, show it, and then ask them to perform
a similar task themselves. Keep
Inconsistencies among instructions near the action. On the other
Display Media hand, don't let your lesson introduction get
so bogged down in instructions that the
Some software displays are comparable students become totally bored before they
when shown on different monitors and when ever get to the major points. Start off
printed. Some look similar, but not simply but directly, and add components as
identical. Others appear extremely necessary to build up the required
different. You need to know what your sequences.
software does, and modify your design
accordingly. If you highlight certain areas Input and Output
of text or reposition text or objects in order
to refer to specific elements, make sure that While you want to keep the students active,
these features are carry through on the you also want to minimize the typing that
various display media that your students you expect them to do. While you do want to
will use. require more of the students than simply
reexecuting your input sequences, it is
Interface versus Content reasonable to model a set of commands that
require slight modification by the student.
Teach the interface independently of the Then, depending on the situation, students
content of a lesson. Most first-time may simply modify an initial statement and
developers, as they learn to use a system repeat the sequence of commands that
and develop their first lesson materials in follow, or they may copy the entire sequence
it, have a tendency to mingle interface with into their own file and make a larger set of
content. This is, in fact, one way to get modifications in answering some question
yourself familiar with the software and that you have posed. As they become more
authoring in it all at once, but don't expect familiar with both the package and the
such a lesson to be successful when used by subject matter, you can gradually increase
your students. A much better strategy is to the amount of actual response construction,
teach the interface while covering material with all the attendant typing, that they must
that students already know. Use that as an 00.
opportunity for review! Once they are
comfortable with the interface, then you can Input/Output Plus Text
have them work with it for covering new
material. The use of modern CASs involves more than
just input and output. Their interfaces
53
permit the use of textual information. In and then both observe and talk with your
addition to using that for your own students about their reactions. Don't spend
presentation, require students to use it as so much time on anyone lesson in the
part of their answers. Although it is beginning that you will be hesitant to throw
challenging for students to write, it is now it away and start over for the next time.
quite easy for them to include. Although it Every top software developer can tell you
is challenging for instructors to grade, it is about wonderful ideas that they had to scrap
a powerful method for determining students' when they discovered their limitations in
understanding. Since this will be a new practice. With time, you'll find your voice
requirement, particularly in a mathematics in this new medium, you'll find
course, for many students, it is very collaborators with compatible styles, and
important that you model the expected you'll be ready to take on an even larger
behaviour. As much as possible, extend the project.
learning that takes place by allowing, even
encouraging, revision. Help students to One Final Reminder
learn that the issue is not whether the
answer is right or wrong the first time. As you work, remember to keep asking
Instead, they need to learn that a far more yourself this question: If the machines can
important skill is to critically review what compute the answers, what is it that the
they have done, and continue to revise it students need to learn?
until they do get it right and understand why
that answer is acceptable. SELECTED BIBLIOGRAPHY
Additional Hints and Alessi, Stephen M. & Stanley R. Trollip.
Strategies (1985). Computer-Based Instruction:
Methods and Development. Englewood Cliffs,
A series of additional hints for developers NJ: Prentice-Hall.
can be summarized as follows:
• Explore the medium. Barwise, Jon, & John Etchemendy.
• Try new instructional approaches. (1989). Creating Courseware. In Notices
• Develop interactively. of the AMS, Vol. 36, No 1, pp. 32-40.
• Move from the specific to the general.
• Start at the mid-range of difficulty, Bork, Alfred. (1985). Personal
and adjust as necessary. Computers for Education. New York, NY:
• Test and observe. Harper & Row.
Revise.
Retest. Bork, Alfred. (1987). Learning with
Repeat. Personal Computers. New York, NY:
• Be flexible. Harper & Row.
• Have fun.
Brown, Stephen I., & Marion I. Walter.
Don't take on too large a project from the (1983). The Art of Problem Posing.
start. Instead, pick at most two or three Hillsdale, NJ: Lawrence Erlbaum
topics that seem most suited to this new Associates.
approach and experiment with those.
Working with more than one topic can Chabay, Ruth, & Bruce A. Sherwood.
provide you with a way to compare and (1992). A Practical Guide for the Creation
contrast the use of different approaches for of Educational Software. In Larkin, Jill H.,
different topics. Limiting yourself to a & Ruth W. Chabay (Eds.), Computer-
small handful permits you to try different Assisted Instruction and Intelligent Tutoring
things without worrying so much about Systems: Shared Goals and Complementary
sticking with a consistent style. Discover Approaches. Hillsdale, NJ: Lawrence
approaches that you find comfortable with, Erlbaum Associates.
54
Schoenfeld, Alan H. (1987). Cognitive
Ericsson, K. Anders, & Herbert A. Simon. Science and Mathematics Education.
(1984). Protocol Analysis: Verbal Reports Hillsdale, NJ: Lawrence Erlbaum
as Data. Cambridge, MA: The MIT Press. Associates.
Gallini, Joan K., & Margaret E. Gredler. Shneiderman, Ben. (1987). Designing the
(1989). Instructional Design for User Interface: Strategies for Effective
Computers: Cognitive Applications in BASIC Human-Computer Interaction. Reading, MA:
and Logo. Glenview, IL: Scott, Foresman. Addison- Wesley.
55
Appendix A: CAl vs. CAS
A number of additional guidelines, appropriate for CAl, are much more difficult to
implement in traditional CAS worksheets that support neither individual "page" formats nor
exact placement on the screen. Depending on the sophistication of your students and the
complexity of your topic, you may want to consider writing your instructional materials in
a programming language that does support such features, and using it to make calls to a CAS
as needed. Guidelines for such programs will not be treated in detail in this paper, but a few
important suggestions from the paper by Chabay and Sherwood (1992) will be included to
give some insight into the further issues involved in this type of project.
56
Numeric Capabilities
To begin with, let's just use Maple as a simple calculator. If necessary, use the mouse to
put the insertion point on the following input command (anywhere after the round "bullet"
or "input prompt" but it does not have to be at the end of the line):
• 3 + 5;
8
35
• 2"'100;
1267650600228229401496703205376
Notice that those answers are EXACT. Maple will always give a result in the most accurate
form possible, unless you ask for a decimal approximation (using "scientific notation" if
necessary). In Maple-terms, ask it to .eyaluate the answer in floating point arithmetic:
• eva1f(1/5 + 3/7);
.6285714286
• evalf(2"'100);
31
.1267650600*10
In the above examples, the answers are given with ten significant digits. That 1Q. is the
default value for the number of "Digits" that Maple will use. If necessary, you can specify
that Maple should use more or less than ten:
• evalf(1/5 + 3/7, 5);
.62857
• evalf(2"'100, 20);
31
.12676506002282294015*10
If you want to experiment, enter one or more commands at the following input prompt.
If you want more prompts, put the insertion point in an appropriate place and choose
Insert Prompt from the Format menu .
•
ASK if you get any results you don't expect. When you're done experimenting, continue
below.
57
Maple also uses the traditional order of operations:
1 . exponentiation (either " or **) first,
2. then multiplication (*) and division (/),
3. then addition (+) and subtraction (-)
unless you use parentheses to indicate a particular order. It doesn't hurt to put in extra
parentheses (except for the pain of unnecessary typing).
Try each of the following, and make sure you understand Maple's response to each one.
ASK if any of them seem surprising to you.
• 1/2"'5;
1/32
• 3/2"'5;
3/32
• (3/2) "'5;
243
32
• 1. 5"'5;
7.59375
What happened in that last example? See if you can figure it out before reading further.
Since the input used a floating point number (1.5, not 3/2), Maple completed the
computations in floating point. It didn't use the "default" value of ten digits in the output,
however, since only five are appropriate. Consider these:
• (1.5)"'2;
2.25
• (1. 5) "'6;
11. 390625
• (1.5)"'8;
25.62890625
• (1.5)"'12;
129.7463379
This example also shows us that there are two ways to force floating point evaluation:
through use of the evalfO command and use of floating point numbers.
• 1.5"'15;
437.8938905
• ((3.0)/(2.0))"'15;
437.8938905
• (3./2)"'15;
437.8938905
• evalf((3/2)"'15);
437.8938904
58
Of course, when you are using parentheses, you should make sure that they match up
correctly (two of the next three input commands SHOULD generate an error message):
• evalf( 3/2 A15);
.00009155273438
• evalf( 3/2)A15);
syntax error:
evalf( 3/2)A15);
A
• evalf«3/2 A15);
syntax error:
evalf «312 A15);
In each of the above cases, a space was left on the input line (as a clue for you) where the
missing parenthesis(es) should be.
While Maple doesn't know what you intended to do, so it may not actually point to the place
where your error really is, its error message should still give you some useful
information. With experience, you'll learn how to interpret them yourself. For now, you
can either retype the command yourself (or copy, paste, and edit it) at the prompt provided
below. Alternatively, you can just go up to either of the previous lines, insert an
appropriate parenthesis, and re-execute that command.
One of the real advantages of using Maple is that it has a very useful and extensive Help
system. We will demonstrate it for you in class, and we are providing a little summary of
its features in the Hints document. But if you ever want to learn more about a command that
is introduced in one of these lessons, you can read the relevant help file. For example,
execute the next input line to read more about the "evaluate using floating point arithmetic"
command:
• ?evalf
Symbolic Capabilities
While those numeric capabilities are useful, they are certainly not the only reasons for
using a CAS. Maple can also operate with symbols, as well as numbers:
• factor( xA2 - 5*x + 6 );
(x - 2) (x - 3)
59
{x = 3}, {x = 2}
Some of Maple's symbolic commands also have default values that can save you some typing.
In the case of solveO, if there's only one variable, Maple will solve for that one. If you
just give an expression, it will solve for when that is equal to zero. Thus, the last command
could have been written as follows (but do notice the difference in the format of the output).
• solve( x A 2 - 5*x + 6 );
3, 2
One of the most powerful features of Maple, however, is its ability to do fully symbolic
manipulations. For example, see if you recognize the result when you give Maple a
"generic" quadratic equation to solve:
Maple can also solve systems of equations. We'll do one simple set next. Later this term,
we'll learn two more methods that will be useful with larger systems (one uses this
method, with some typing shortcuts, and the other uses techniques from linear algebra).
A name in Maple:
* must begin with a letter,
* can consist of anywhere from 1 to 499 characters, and
* after the first character, it may contain either letters or numbers.
• eq3 x + y- z = -3;
eq3 := x + y - z = -3
Now that the equations have been set up, we Cqn use the solve command. Notice that both the
list of equations and the list of variables to be solved for are enclosed in pairs of braces:
• solve ({eql, eq2, eq3}{ {x, y, z});
{y = 0, z = 1, x = -2}
The answers may not have come out in the order you expected (Le., they may not be listed as
x, y, z, in that order), but they should all be there. Notice the difference between the above
and the situation where you use fewer equations than you have unknowns:
• solve ({eql, eq2}, {x, y, z});
{y = y, z = - 1/2 Y + 1, x = 5/4 Y - 2}
60
A solution of the form y=y means that the value of y is arbitrary (it can be assigned any
value). Then the other variables, such as x and z, are specified in terms of the chosen y.
Graphical Capabilities
Students quickly learn, in first-semester Calculus, that curve sketching can be a very
time-consuming activity. On the other hand, an image of the function or expression one is
working with can often lead to valuable insights. Luckily, computer algebra systems such
as Maple are extremely helpful in this area.
The simplest form of the plot command just uses Maple's defaults for everything, as
illustrated with the following input. After you have executed the following command,
arrange your windows so that you can see this input, the text that follows it, and your plot,
all at the same time. (ASK if you need help in getting everything visible at once.)
• plot(x * sin(x));
(Students executing this file will see a large plot in its own windoe, rather than the above.)
(When done looking at the plot, click in this window to make it active again, and continue
with the lesson.)
•
Since we are going to plot this same expression, x*sin(x), a number of times, let's give it a
name and then save ourselves some typing by just using that name from now on.
• f := x * sin(x);
f := x sin (x)
For our first improvement on the plot, let's have the horizontal axis go from -3Pi to 3Pi.
• plot(f, -3*Pi .. 3*Pi);
Next, let's make it clear that "x" is the variable represented by the horizontal axis:
61
• plot(f, x=-3*Pi .. 3*Pi);
Note: For this course, you must provide AT LEAST the above information for every plot you
submit for grading. That is, in addition to giving the function you want Maple to plot, you
must indicate at least the variable being plotted and select an appropriate interval yourself.
•
Hint: You will start getting "Out of Memory" warnings or errors if you leave a lot of plot
windows open. It's fine to have a few open at once, particularly if you want to compare the
differences between the results of two different plot commands.
When you are done with a particular plot, close its window.
You can always reexecute the relevant plot command to see it again later!
To close a window when it is active (Le., when it is "in front" and there are horizontal lines
in its title bar), you can:
a. go to the File menu and choose Close, or
b. hold down the Cloverleaf (aka Command) key and press the letter w, or
c. click in the Close-Box at the far left of the plot's title bar.
Back to our function. Let's indicate that the function x*sin(x) is shown on the vertical axis.
Note: The back-quotes, from the key next to the numeral 1 in the upper left corner of the
keyboard, are required because the string contains non-alphabetic characters such as the
asterisk and parentheses.
• plot(f, x=-3*Pi .. 3*Pi, 'x*sin(x)');
u .
6 x*s1.n(x)
4
If you want, you can specify a range for the vertical axis too:
• plot(f, x=-3*Pi .. 3*Pi, 'x*sin(x)'=-S .. 10);
8 x*sin (x)
62
Finally, we can give this plot a title:
• plot(f, x=-3*Pi .. 3*Pi, 'x*sin(x)'=-5 .. 10, title='My first labelled
plot. ' ) ;
My first labelled plot. x*sin(x)
8
Notice that the stated information "just fits" in the default-size plot window. The amount of
information you can conveniently display on a single plot is partly a factor of the
anticipated display format.
If you enlarge the plot window (by clicking in its Zoom-Box, at the far right end of
the plot window's title bar), then everything still fits, and the title will still be
centered along the top of the second quadrant.
If you reduce the plot window (by dragging up on the resize box in the bottom right
of the plot window), however, and make it smaller than the default, then the title no
longer fits in the upper left quadrant. Maple will then center it, overwriting the
label on the vertical axis.
Note: For more information on Maple's plotting routines, look up the help files on plot,
plot3d, plot[options], and other files mentioned within those sources of information .
•
When you have worked your way through all of this, Quit Maple, and then restart it via the
file Problems #01. If you want, you can reopen this file again (after you have the
assignment opened as the primary Worksheet) and use this one as a Scratchpad.
63
II
MAPLE V IN MATHEMATICS
TRUNCATION AND VARIANCE IN SCALE MIXTURES
William C. Bauldry, Jaimie L. Hebert
Dept. of Mathematical Sciences, Appalachian State University, Boone NC, USA
Mullooly demonstrates that for densities and h(t) = I(t)/F(t), the hazard function. It is
satisfying these conditions, there exists a real easily verified that u 2 (0) = u 2 and
number T> 0 such that u 2 ( t) > u 2 for all l~[ du 2(t)/dt] > o. Thus, the algorithm is
t E (O,T). We shall call T the variance inflation based on the fact that u 2(t) must achieve a
boundary for X t • When u 2 (t) > u 2 for all maximum before taking the value u 2 • Using
t E (0,00), we say that T = 00. these expressions, one may show that a lower
Mullooly notes that if T is finite, then it is bound for T is the (1 - c!v )th percentile of the
given by the smallest positive solution of distribution, where CV = p, the coefficient of
2 variation.
u 2 (T) = ~~(T)
F(T)
_ [~(T)] = u 2
F(T) ,
0.1) Barlow and Proschan (1975) note that
lifetime distributions with continuous densities
00 .
where ~j= Jx 3 1(x)dx. Although 0.1) can be and decreasing hazard rates satisfy these
t
solved approximately for any density satisfying conditions. Such distributions are quite useful
the conditions of his theorem, he suggests an in reliability studies. Of particular interest are
algorithm which provides a lower bound on the lifetime distributions possessing completely
monotone hazard rates. (A function h is said to
67
mono tonicity is a sufficient condition for a G(A). Clearly, T is the smallest positive
lifetime distribution to be represented as a scale solution of (1.4) when in fact T is finite.
mixture of exponentials. That is, if f IS The difference in variances may be derived
completely monotone, then there exists a directly in many instances. The value of (1.4)
distribution function G such that is that the difference is obtained by averaging
00
over the hazard rates, i.e., each of the expected
J" exp( - "x)dG("). (1.2)
f(x) =
o values in (1.4) is with respect to G. Such a
We denote by '!f the set of densities which can
representation is useful when studying the
be written in the form (1.2). From the
sensitivity of this difference relative to changes
discussion above, it is apparent that every
in the mixing distribution. Since an exponential
f E '!f will satisfy the conditions of Mullooly's
mixture is uniquely identified by the
result.
corresponding mixing distribution,
Hebert and Seaman (1994), hereafter simply
characteristics of the variance of that mixture
Hebert and Seaman, examine the difference,
are dependent on parameter specifications in
0'2( t) - 0'2, relative to the mixing distribution
the mixing distribution. In this sense,
G("). They provide a general form for the
information concerning the behavior of the
difference in variances, 0'2( t) - 0'2, in terms of
stochastic hazard rate will provide information
the mixing distribution. Specifically, let X
concerning the variance of the mixture.
have density f E '!f and corresponding mixing
Information concerning the change in variance,
distribution G("), let X t = XI(t,oo)(X) and let
relative to the behavior of G, is provided
y = X t - t. They show that the distribution of
through (1.4).
Y can be represented as a mixture of
Hebert and Seaman consider several
exponential densities with mixing distribution
examples in their manuscript. The variance
,\
G*(") = J Hu(t)dG(u) (1.3) inflation boundary, when finite, is provided for
o
each of these examples. In several of these
exp(-ut) {} . examples, the authors compare the actual value
where Hu(t) = .Lt{G(u)} and Lt G(u) IS the
Laplace-Stieltjes transform of G with frequency of T to the lower bound provided by Mullooly's
variable t. Since Y simply represents a change algorithm. In the present manuscript, we
in location in X t' the variance of Y is also 0'2. illustrate the use of Maple in deriving the
Thus, the difference in variance may be calculations in the examples of Hebert and
represented as Seaman and extend the results of their discrete
mixture example. By plotting expression (1.4)
0'2(t)_0'2 = 2EA[A -2(H A(t)-1)]
as a function of the mixing parameters, we
-E~A-l(HA(t)+1)]
investigate the sensitivity of the variance of the
.E A[A- 1 (H A (t)-1)] , (1.4)
truncated random variable relative to these
where E A[ .] denotes expectation with respect to
parameters.
68
2. A discrete mixing distribution approaches zero. Since Mullooly's lower bound
Hebert and Seaman consider the following remains positive, the bound improves as p
example, where G is a discrete distribution. To nears 0.5. Likewise, the bound becomes more
facilitate exposition, we refer to A, the random conservative as p nears zero.
hazard rate, as a random variable with Using Maple, one may generalize this
distribution G( A). Let X be an exponential example by considering the case 2A1 = A2 • We
process with hazard rate A, where find in this case that
P(A = AI) = p and P(A = A2) = 1 - p. It
follows that
00
LdG(u)} = Jexp( -AOdG(A)
o
=pexp( -A 1t)+(I-p)exp( -A 2 t), When Al = 2, we obtain the result discussed by
yielding, Hebert and Seaman. As a more applicable
EA{ A - k H A (t ) } = {p A1- k exp ( - Al t) generalization of this model, we offer the
+(I-P)A2- kexp ( -A 2t)} following result. The proof of this result is
-.;-{pexp ( -Alt) found in a Maple session in Appendix A.
+ (1- p) exp( - A2t)}
Theorem: Let X be a two-point, mixed
From expression (1.4), one obtains
exponential process with mixing distribution
(12(t) _(12 = p(l- p)( A1- 1 - A2-1)2
P(A = AI) = p and P(A = kA 1) = 1 - p. Then
. {{ exp[ - t (AI + A2)]
the variance inflation boundary is given by
-.;-[pexp( -A1t) (2.1)
+(I-p)exp( -A2tW}-I}.
69
gamma distribution are considered by McNolty 0- i evaluated at fJ(A - AO)' Direct calculation
(1964), Harris and Singpurwalla (1968), and provides
McNolty, Doyle, and Hansen (1980). (l-p)
Lt{ } =exp( -Aot) { P+--p-
G(t)
Characteristics of the variance of this model
under truncation are considered by Hebert and .(L)O
fJ + t
0
i~O
- 1 (AO(fJ
i!
+ t)) i}
Seaman. As a generalization of the gamma
model, Hebert and Seaman consider a gamma and (3.1)
mixture with a point mass at an arbitrary EA { A - k H A (t) } = { PA O- k + (1 ;*p)
value AO' We address that example as well in
the present section. All derivations which
appear in the Hebert and Seaman example
were calculated using Maple. In this paper, we
discuss these calculations briefly and use Maple
graphics to examllle some further
characteristics of this model under truncation.
Let X represent the lifetime of a component
which operates in a fixed environment with
probability p and a random environment As in McNolty, Doyle, and Hansen (1980),
otherwise. When operating 111 the fixed we must have 0 > k for these moments to
environment, X has an exponential distribution exist. As an illustration of the characteristics of
with hazard rate h(x) = AO' In the random the difference 0'2(t) - 0'2, Hebert and Seaman
environment, the process is still exponential, consider this model with fJ = 1 and 0 = 3.
but the hazard rate varies with distribution Using Maple one may show that (3.1) and <1.4)
yield expression (3.2)
g(A) = k4~0) AO -1 exp[ - fJ(A - AO)]' A> AO'
0'2(t)_0'2= {2PA o- 2(1-e(t))+21Ji[(t+l)-1
0-1 (AofJt
where k* = ~ --.,-. Thus, the density of X
i =0 z.
is a mixture of exponential densities with
- «t)]}e -1(,) + {v'.Io- 2(e(t)2
-1) + y;2[e(t) (1 + AO)2
mixing distribution
(1- p) 2
G(A) = pJ AO (A) +-r - (( t + 1) - 2+ AO( t + 1) - 1) ]
.°t (A~~)i ,(
1 0- i, fJ(A.- AO) ),
+ 2pAo- 1y;[e(t)(I+Ao)-((t
i = 0 z. r( 0 - z) + 1) - 2 + .10(1 + 1) - 2)]} - 2(,)
where AO> A, J A (A) is a unit step function at
o where y; = 2 1- p and e(t) = p + IJi[A~
A=AO and ,(O-i,fJ(A-AO)) IS the AO + 2Ao + 2
incomplete gamma function with parameter
(t + 1) - 1 + 2Ao( t + 1) - 2 + 2( t + 1) - 2]. One
70
may easily verify that {(O) = 1 and process. The sensitivity of this increase with
lim {( t) = p. respect to the values, Ao and t, is evident in
t--+oo
Using these results, we evaluate (3.2) at 0 Figure 3.1. A similar behavior is evident when
amI taking the limit as t-.oo, we find Ao is fixed. In Figure 3.2, we plot the difference
0- 2 (0) - 0- 2 = 0 and (3.2) as a function of p and t with AO = 1/2.
lim
t--+oo
0-2(t) - 0- 2 = (1- p)[2A~ + A~(5 - p) Again, we see that for p =0 and p = 1, we
- 4Ao(p - 2) - 4(p -1)] have the pure gamma behavior noted by Hebert
+ A~( A~ + 2Ao + 2) 2 and Seaman and the pure exponential behavior,
>0. (3.3) respectively. This is consistent with the form of
the model, since p = 1 would indicate the the
The derivative of the difference (3.2) with
process does not operate in a random
respect to t is easily shown to be positive using
Maple. One may also verify that the derivative
environment at any time and with p = 0, the
process remains in the random environment
is completely monotone, indicating that (3.2)
and possesses a gamma-distributed hazard rate.
approaches (3.3) monotonically. Thus,
truncation of this mixture will increase
Appendix A
variance at all t E (0,00), when p and AO are
Proof of the Theorem of Section 2
fixed, i.e., T = 00. Recall that in such cases
First define sd to he the difference
Mullooly's algorithm is inapplicable, since it
in the variance generated by
assumes that the difference attains a truncation.
maximum.
> sd:=t->p*(l-p)*(lambda[l]A(-l)
-lambda[2]A(-1»-2*(exp(-t*(
In Figure 3.1, we consider the behavior of lambda[1]+lambda[2]»/(p*exp(
(3.2) with p = 1/2 for various values of AO and
-laabda[l]*t)+(l-p)*exp(-lambda
[2]*t»A2 -1);
t. Some notable features of this model are
2
evident in this graph. As AO increases, the sd:= t-+ p (1- p) (\ 1 __1_)
"[1] A[2]
pl'Ocess begins to behave as though it were a
pure exponential process, i.e., truncation does
not effect variance. One may also note that the
contour lines on the plot reaffirm that the
inflation in variance is bounded as a function of Set:
t when AO> 0 is fixed.
> lambda[l] := lambda;
lambda[2] := blambda[l]j
In the pure gamma process, Ao = 0, the 'sd(t) =',sd(t)j
variance increase is unbounded as a function of A[I]:= A
71
> soln_Z := subs( -1+p=l-p, soln_Z ):
solo_z := subs( Z=zA(k-l), soln_Z ):
8010_T := subs( z=TIambda, soln_z ):
solo_t := BUbs( T=exp(t), soln_T );
We look at the numerator then perform a
series of transformations to facilitate
finding roots.
> oumer(sd(t» = 0:
eq_l := combine( ", exp);
+ ]12 z ( - 2k) = 0
Bibliography
> eq_4 := simplify( eq_3*( zA(2*k) ),power );
eq_4 := _ z(k -1) + z(2k - 2)]12 + 2z(k -1)p Bar 1ow, R . E. and F. Proschan (1975),
Statistical Theory of Reliability and Life
_ 2z(k -1)p2 + 1- 2]1 + p2 = 0 Testing: Probability Models (Holt, Rinehart,
and Winston, New York).
> simplify(subs(z=ZA(I/(k-l», eq_4 ), power):
eq_5 := collect( ", Z ); Harris, C. M. and Singpurwalla, N. (1968), Life
Distributions Derived from Stochastic Hazard
eq_5 :=Z2p2 + (_2]12 -1 +2p)Z + 1
Functions, IEEE Trans. on Reliability, R-17,
_2p+p2=0 70-79.
We have arrived at an expression quadratic
Hebert, J. L. and Seaman, J. W. Jr. (1994),
in Z which is simple to solve.
The variance of a truncated mixed exponential
> soln_Z := factor([solve( eq_5, {Z})));
process, Journal of Applied Probability, 31, No.
1 (In Press).
SObLZ:= [ {Z = 1}, { Z = (_I+p)2}]
p2 Jewell, N. P. (1982), Mixtures of Exponential
Distributions, The Annals of Statistics 10, 479-
484.
Now back-substitutions will finish the
derivation.
McNolty, F. (1964), Reliability Density
72
Functions when the Failure Rate is Randomly
Distributed, Sankhya, A-26, 287-292.
Biographies
73
0.015 -
-
0.01
0.005
'V
- 0.005 "
-0.01
- 0.015 -'
p
t
o 1
Figure 2.1 Expression (2.1) with AI = 2 and A2 = 4 as a function of t and p.
10
8
L()
t--
2 o
Figure 3.1 Expression (3.2) with p = t as a function of t and Ao'
3-
2.5 -
2 0-
1.5
1 CD
I'-
o
0.5
0, , " I I j
o 0.2 n ~ n c 0.8
1
p
Figure 3.2 Expression (3.2) with A. o = t as a function of t and p.
Figure 3.2 Expression (3.2) with AD =-t as a function of t and p.
WORKING WITH LARGE MATRICES IN MAPLE
Reid Pinchback
Academic Computing Services, Massachusetts Institute of Technology,
Cambridge MA, USA
77
frequently than others, or when the The resulting computation has more ap-
amount of virtual memory currently be- parent overhead because it must manage
ing exercised is small, page swapping will its own data, but because of the reduced
be infrequent. demands on virtual memory the result is a
computation that can run smaller and
Consider a simple situation where two us- faster in a time-shared environment.
ers initiate processes to manipulate large
arrays, and assume that these processes Maple provides a good prototyping envi-
are similar in size to the physical memory ronment for approaching this problem.
(RAM) of the computer. When the two The challenge was to architect an imple-
user processes start processing the ar- mentation that would be transparent to
rays, operations like array addition will existing Maple routines, thus avoiding the
have the effect of refreshing the access extensive work otherwise needed to re-
time on all of the pages containing the implement packages like linalg. The
array data. For the current process, this indexfcn facility, when combined with a
will force its data pages to be swapped into pre-processor to the array function, makes
memory, and most other pages to be it possible to change the semantics of ar-
swapped out. When the next task switch ray creation and access without requiring
happens, the new process will be missing changes to existing libraries of matrix
its data pages, so they must be swapped in routines.
after other pages are swapped out to make
room. Soon, the system is spending most of Implementation
its time on swapping memory pages in-
stead of being able to allocate CPU time for The partitioning method used here is a
user process calculations. physical scheme, as opposed to a math-
ematical one. Since Maple routines like
Since part of our end-user support phi- 'linalg/add' are not aware of the parti-
losophy at MIT is to help users to become tioning, they do not attempt to manipulate
self-sufficient, we began considering ways the arrays on a partition-by-partition ba-
in which students could approach solving sis. Instead, a partition cache is used to
large problems differently. The ultimate increase the proportion of hits in access-
aim was to document methods and provide ing partitioned arrays.
on-line code samples that would help them
to solve large linear problems more effec- The partitions themselves are a collection of
tively, and towards that end we considered flat (one-dimensional) unpartitioned arrays.
two issues: The original array indicies are mapped onto
the partitions. Such a mapping is potentially
1) Reducing the memory needed for different for each partitioned array, as it
storing array data. must reflect the width of the ranges and the
2) Designing long-running programs number of dimensions.
that could be recovered and re-.
started after interruption. In order to work with partitioned arrays,
we needed three particular facilities or
This paper describes an attempt to address behaviours:
the first of these two issues.
1) A way to calculate with partitioned
Method arrays.
2) A way to create partitioned arrays.
One way to reduce the memory demands of 3) A way to manage the partitions.
large arrays is to partition those arrays
into smaller sections for processing, only The first two issues will be explored in
loading a few of those sections from disk depth, while the third will only be touched
into virtual memory as they are needed. on briefly.
78
# This is the core routine of the partitioning indexfcn.
'index/partitioned' := proc(A, index, isLHS, tbl)
local i,range,position,partition,pindex,phandle,p;
# calculate position, the flattened index into the partitions
position := 0;
for i fran nops (index) by -1 to 1 do
range := tbl['_ranges') [i);
position := 'parray/range.vidth' (range)*position + index[i) - op(l,range);
ad;
partition :=iquo(position, tbl['_Partitionsize'));
pindex : = irern(position, tbl ['_Partitionsize') ) ;
# phandle[partition) will be the partition number, p
phandle := invokePHandle(tbl['-phandle'));
# check to see if the partition exists yet
if not assigned(phandle[partition)) then
i f isLHS then
phandle[partition) := generatePartition(tbl['_Partitionsize'));
else
op(index) ;
REIURN('A[AI)');
fi;
fi;
P := phandle[partition);
# check to see i f the particular element, pindex, of the partition exists
i f isLHS then
pindex;
partitionGache(p);
REIURN('AI [ " " ) ' ) ;
else
i f not assigned (partitionGache (p) [pindex)) then
op(index) ;
REIURN('A[AI) ');
else
REIURN(partitionCache(p) [pindex));
fi;
fi;
end: # proc index/partitioned
Listing 1
79
The ' index/partitioned' routine, together i f not assigned('parray/array') then
with 'parray/rangewidth', maps the ar- # retain access to built-in 'array'
ray index into a corresponding partition 'parray/array' := op(array) :
number and an index into that partition. # change to the nEM funct ionali ty
When referenced to the partition number array := parray:
array (phandle) for the particular array, # to handle type renarrdng confusion
this determines where the desired ele- , type/parray' : = 'array':
ment would be stored. fi:
If an assignment is being attempted
Listing 2
("if iSLHS"), and the corresponding
partition has not yet been created, it
gets created here. If a retrieval is
being attempted, the appropriate ele- parray must be transparent if existing code
ment - if it exists - is returned. is to continue working reliably. Argu-
ments must appear to be processed in the
Creation same way that array normally processes
them, and the results returned must cor-
Creation of partitioned arrays is not a par- respond to those normally returned.
ticularly difficult issue if arrays are only
created intentionally by the user. Unfor- Proper argument handling is possible, but
tunately, packages like linalg internally serves to show a rather unexpected limita-
create non-partitioned arrays during the tion of the Maple type expression facili-
course of computation, so we needed a way ties. A valid argument list for array con-
to make those routines change their de- sists of - in any order - an optional index
fault array creation semantics. Since function, an optional list of initialization
Maple doesn't have any kind of class in- elements, and an optional contiguous block
heritance to make use of, if we are to avoid of an arbitrary number of index ranges.
re-writing existing library code the only This corresponds to the type grammar
workable solution is to change the array shown in figure 1.
function itself.
No Maple type expression can readily de-
There is one complication we must address scribe this kind of argument list. Maple
before proceeding further. Since array is type expressions for structured types (like
a built-in procedure that we need in order list (integer» can apparently only de-
to create the actual array data structures, scribe types corresponding to:
in replacing it we still must have a way to
invoke it. Installation of the new facility • A structured type with a known num-
(called parray) must be handled carefully ber of components with heterogeneous
(see listing 2). types.
• A hierarchical type with components
The changes to array implemented in all of a single type.
Figure 1
80
This means that type expressions like:
[ I, 2.0, 2, 3.0 ]
81
# '!his routine type-checks to see that the argument list passed to 'array'
# is well-formed. Tb do this it uses a 11-state deterministic finite
# automaton to scan the argument list for:
# 1) at most one list of initialization elements
# 2) at most one contiguous block of valid range arguments
# 3) at most one index function, either a string (a name) or a procedure
# and these 3 groups of arguments can appear in any order, and no
# other kinds of arguments can be present.
'type/parrayargs' := proc(arglist)
local state, arg;
state := 'start';
for arg in arglist do
state := procnaroo('DFA') [(state, 'parray/typesyrnbol' (arg»];
cd;
RETURN (evalb (state <> ' error' ) ) ;
end: # proc type/parrayargs
# Map the three kinds of argument types into the integers {1,2,3}:
# index function -> 1
# index range -> 2
# list -> 3
# anything else -> 4
# '!his is used to sinplify examination of the type of arguments passed
# to the ' array' procedure.
'parray /typesymbol' : = proc (arg : anything)
i f type(arg, 'string') or type(arg, 'procedure') then
REIURN(l) ;
elif type (arg , , indexrange') then
REIURN(2) ;
elif type(arg, 'list') then
REIURN(3) ;
else
REIURN(4) ;
fi;
end: # proc parray/typesyrnbol
82
if not assigned (Partitionsize) then
Partitionsize := 10:
fi:
parray : = proc ( )
local indexfn,ranges,elements,volume,partitionable,A,partitions,tbl,iproc;
if not type ( [args], cat (procnarne, , ar' , , gs ' » then
ERROR('Error, invalid parameters for creation of table or array');
fi;
# read routines needed fran the library:
readlib('table/initbds');
readlib('table/initvals');
# Since the argument list is well formed, we can safely separate the
# three kinds of arguments for further (and easier) examination.
indexfn := op(select(x->evalb('parray/typesymbol' (x)=l), [args]»;
ranges : = select (x->evalb ('parray /typesyrnbol' (x) =2), [args]);
elements := op(select (x->evalb( 'parray/typesymbol' (x) =3), [args]»;
# Determine what the ranges should be for the list of elements
i f (ranges = []) and (elements <> NULL) then
ranges := ['table/initbds' (elements)];
fi;
# Check to see i f the total mnnber of elements in the array
# (the "volume" of the array) warrants partitioning.
volume : = convert (map ( 'parray /rangewidth', ranges), ' * , ) ;
partitionable := evalb(volume >= Partitionsize);
# Now, see i f we need to specify a partitioned index function
i f indexfn = NULL and partitionable then
indexfn := 'partitioned';
fi;
# call the appropriate routine to create and initialize the array data structure.
if (indexfn <> 'partitioned') or not partitionable then
A := 'parray/array' (indexfn,op(ranges) ,elements);
else
# ok, time to finally do same partitioning
partitions := 1 + iquo(volume-1,Partitionsize);
# store partition size, partitions needed, ranges,
# and partition table handle in the index function
tbl := table(['_Partitionsize'=Partitionsize,
'-PdXtitions'=partitions,
'_ranges'=ranges,
'-phandle'=generatePHandle(partitions)]);
iproc : = proc (A, index, isLHS)
'index/partitioned' (A,index,isLHS,'TBL')
end;
iproc .- subs('TBL'=op(tbl),op(iproc»;
A := subsop (l=op (iproc) , 'parray/array' (op(ranges»);
# Finally, initialize the elements of the partitioned array
if elements <> NULL then
'table/initvals' (op(A),elements);
fi;
fi;
op(A) ;
end: # proc array
Listing 4
83
if not assigned(phandles) then
phandles : = -1:
fi:
generatepHandle := proc(parts)
phandles := phandles+1i
phandledata[pbandles] := 'parray/array' (0 .. parts-1) i
phandlesi
end: # proc .generatePHandle
partitioncache := proc(pname)
# very simplistic for now, just keeps accumulating partitions
i f not type(pname,name) then
ERROR ( 'invalid name argument, ',pnarne) i
fii
procname(pnarne) := pnarnei
end: # proc partitioncache
Listing 5
84
muddled combination within Maple have sparse_symmetric is by going to
indexfcns. Here are two examples to clarify the further effort of creating it. If
the categories of semantic activity: we have partitioned and diagonal,
then the only way to have
1) Consider the identity indexfcn. part it ioned_diagonal is again to imple-
With this function, no elements ment it from scratch.
need storage in the array, so the
only storage/retrieval semantics • Existing library code has no awareness
are to generate an error whenever of the new indexfcns that have been
an assignment is attempted. The created, and thus no way to benefit
functional semantics determine from them. What is needed is a better
that the diagonal elements have mechanism for specifying indexfcn
value 1, and all off-diagonal ele- properties. This would allow users to
ments have value O. The value se- extend library functionality without
mantics rely totally upon the func- having to re-implement it and without
tional semantics to detennine the resorting to 'back door' approaches
ultimate value of the referenced like re-directing calls to the array func-
element; tion.
85
ray data structure would be saved, not Acknowledgemen ts
the content of the partitions. This is
part of the work on recoverability that I would like to thank my co-workers, Anne
will be attempted in the future. Lavin and Michal Lusztig, for a variety of
background information and ruminations
• Algorithm performance: the design of that provided the initial motivation for
an algorithm will affect the perfor- this work. I would also like to thank Naomi
mance penalities experienced when Schmidt for her review of the various
using partitioning. An algorithm that abstracts and drafts that ultimately evolved
has relatively random access within into this paper.
an array can cause a large amount of
partition-swapping activity, while al- References
gorithms with relatively concentrated
hits will work effectively with a mod- [1] Derick Wood, Theory of Computation,
erately small partition cache. John Wiley & Sons, New York, (1987).
Conclusions
The Maple indexfcn facilities provide many
opportunities for extending the existing
functionality of arrays. Unfortunately,
with the current implementation it is dif-
ficult for users to realize its fullest poten-
tial. This is true of other aspects of Maple
extensibility, as shown by the usefulness
but occasional awkwardness of type speci-
fication. Continued improvement in these
aspects of the Maple language can only
benefit users and developers alike.
86
USING MAPLE FOR ASYMPTOTIC CONVERGENCE
ANALYSIS
Noah H. Rhee
Department of Mathematics, University of Missouri, Kansas City MO, USA
87
R(i,j; q,) (3) step. For a more deta.iled description of the
1
° ° ° Jaco bi annihilator S pq see [2, 3].
° cos q, sin q,
° App [_Oa ~], Aqq = [_01' ~],
° - sin q, cos q,
° Apq = [ : : ] .
° °
where the positions of cos q, are
°
(i, i)
and (j,j).
1
Then the angles q,1 and q,2 are computed from
the formulas
R(i,j;q,) is called the rotation matrix in t~e 2(aw - t'tJ)
tan 2q,1 (4)
(i,j) plane by the angle q, because premultl- a 2 - 1'2 + tJ2 - w2'
f
plication by R( i, j ; q, a.mounts to a counter
tan q,2 -
tJ cos q,l - I' sin q,l
(5)
clockwise rotation of q, radians in the (i,j) co- a cos q,1 + w sin q,1 '
ordinate plane. We will call the transforma-
where -i < q,1 .:::; i and -t < q,2 .:::; t·
tion A ~ R(i,j;q,f A R(i,j;q,) a rota- Suppose that App , Apq and Aqq are changed
tiona.! transformation or a transformation in-
by the transformations involving R~q and R~q
volving R(i,j;q,). Note that R(i,jjq,) is or-
(half step) into
thogona.l, and postmultiplication [premultipli-
cation] by R(i,j;q,) [R(i,j;q,f] affects only
the ith and jth columns [rows]. App = [ -0-0 °
0-] -
,Aqq = [0
-/3 /3] °'
Using plane rotations Spq, p < q, can be Apq [~~ ] .
written
Note that tJ, W have been annihilated and x, y
have not been changed. The angles q,3 and q,4
are computed from the formulas
where
So one step of the Paardekooper method uses Besides the angle determination we have to
four rotationa.! transformations. The trans- specify a pivot strategy in which a method
formation involving R~q [~q] modifies the el- of choosing the order of pivot submatrices is
ements at positions (2p -1,2q), (2p,2q-l) given. In this paper we confine ourselves to
[(2p - 1, 2q - 1), (2p,2q)] in such a way that the row-cyclic strategy. That is, pivot subma.-
the transformation involving R~q [~q] can trices are chosen in natura.! order by rows. By
annihilate them. The skew-symmetry prop-
"cyclic" we mean to repeat the sa.me procedure
erty ensures that zeros obtained at positions
after all pivot submatrices are exhausted. One
(2p - 1, 2q), (2p,2q - 1) are not destroyed by
cyclic procedure is ca.lled a "cycle". We note
the transformations involving R:q and R;q. It
that severa.! well known para.llel cyclic strate-
follows that
gies are closely related to the row-cyclic strat-
S(A')2 = S(A)2 - 211ApqW. egy [6], so phenomena linked with the row-
It is in this sense that A moves closer to cyclic strategy are relevant for those para.llel
its Murnaghan form with each Paardekooper ones.
88
The angle forrrrulas together with the Application to the
row-cyclic strategy define the row-cyclic Paardekooper Method
Paa.rdekooper method for skew-symmetric ma-
trices. It is known (see [3]) that a skew-symmetric
matrix almost in Murnaghan form converges
Ahnost Murnaghan Form quadratically when we apply the row-cyclic
Paardekooper method, provided that the
We denote the eigenvalues of A by ±illj , eigenvalues of A are at most double and the
IIj ~ 0, j = 1, ... ,k. Let 35 be the minirrrum diagonal blocks which are affiliated with the
distance among a.ll two distinct eigenvalues of same value are located in successive positions.
A. We enumerate IIj ~ 0, j = 1, ... ,k, By quadratic convergence we mean 5(A) ~
c5(A)2 for some constant c, where A stands
for the matrix obtained from A after a cycle.
But the method fails to converge quadratica.lly
when multiplicities of some nonzero eigenval-
ues of A are larger than two. To analyse such a
behaviour we need the following lemma proved
and lI. j , j = 1, ... ,r, are a.ll distinct. If in [4] using the relations (8)-(11) together with
S(A) < 5, we say that A is almost in Mur- the angle forrrrulars (4)-(7).
naghan form. In this case we say that the Lemma 2 If App and Aqq (p < q) are afJi.li-
block A pp , p = 1, ... , k, is affiliated with ±ill. j ated with the same II. j > 0, we halJe
(or simply with II.;) if Ila2p-l,2pl- lI' j I < 5.
From an eigenvalue perturbation theory (by
the Hoffman and Wielandt Theorem [5]) it fol-
lows that each block A pp , p = 1, ... , k, is af- where tPl, tP2, tP3 and 4>4 are angles used in the
filiated with a unique value II. j for some j E Jacobi annihilator Spq. •
{I, ... , r}. Then we have the following result
N ow we can argue the failure of the
proved in [4]
quadratic convergence of the row-cyclic
Theorem 1 If e = S(A) < 5 and App and Pa.a.rdekooper method under the presence of
Aqq (p < q) are affliated with the same II. j > nonzero eigenvalues who rrrultiplicities are
0, we halJe greater than two. Let
89
P
Note that A 33 , A 34 , A43 and A44 have not o 1
0 0 0 0 o -t
changed. Because of the row-cyclic strategy 1 0
0 0 0 -t o 0
Ab is the next pivot submatrix. When Ai3 is o 0
0 1 -t 0 o 0
annihilated, the zero block in A' gets contri- 1 o 1 0
0 0 0 -t 0
butions from the elements of A~3 by the skew- o 0 t
0 1 0 o 0
symmetry. Since in general IIA~311 = 0(,,), tOO 0 0 1 o 0
where " = SeA), and the angles involved o 0
tOO 0 1 0
in ~13 can be 0(1) by Lemma 2, the size o 0 0 0 0 o
of the contribution to the zero block can be Note that P is orthogonal, and hence A is or-
O( €) . 0(1) =O( f). This means that there thogona.lly similar to M. This means that A is
might be a 2 x 2 submatrix which becomes skew-symmetric and that ±i are the nonzero
to the order of S( A) after its annihilation. eigenvalues of A of rrroltiplicity 3 and ±2i are
This implies the failure of the quadratic con- simple eigenvalues of A.
vergence.
Note that
What we need to do is to construct an exam-
ple which demonstrates our speculation. We R(5,7j¢)
now demonstrate how Maple can be used for 1 0 0 0 0 0 o 0
this purpose. o 1 0 0 0 0 o 0
o 0 1 0 0 0 o 0
Constructing o 0 0 1 0 0 o 0
and Analysing an ExaIllple oooov'f=t2o i 0
using Maple o 0 0 0 0 1 o 0
o 0 0 0 -i 0 v'f=t2 0
To generate skew-symmetric matrix A of or- o 0 0 0 0 0 o
der 8 we start from the following Murnaghan
form M: and
o 1 R(2,8j¢)
-1 0 1 0 o 0 0 0 0 o
o 1
O~ o 0 0 0 0 t
-1 0
M
o 1
o 0 1 0 000 o
-1 0
o 0 o 1 000 o
o 2 o 0 o 0 1 0 0 o
-2 0
o 0 00010 o
o 0 o 000 1 o
where all unspecified elements are zero. Note o -t o 0 0 0 0 v'f=t2
that ±i are the nonzero eigenvalues of M of
multiplicity 3, and ±2i are simple eigenvalues. We can declare M, P, R(5,7j¢) and
We have generated A by applying the following R(2, 8j ¢) by using Maple. We provide Maple
orthogonal similarity transformation to M: code for M and R(5, 7j ¢), since others can be
declared similarly. In the code R57 stands for
A = QT M Q R(5,7j¢).
90
> M[5,6J:= 1: Note that 5 =
1/3 and S(A) O(t) as =
> M[7,8J := 2: t -+O. Hence the condition S(A) < 5 is ful-
> M[2,IJ:= -1: filled for sufficiently small t. Under that con-
> M[4,3J := -1 : dition we see that All, An, A33 and A44 are
> M[6,5J := -1 : affiliated with 1 and 2, respectively.
> M[8,7J := -2 :
> # We declare R(5, 7; <p). The structure of All demonstrates the va-
> R57:= matrix(n,n,(i,j)- > 0) : lidity of Theorem 1. By the following segment
> for i to n do R57[i, iJ := 1 od: of Maple code we verify the validity of the as-
> R57[5,5J := sqd(I - tI\2): sertions in the relations (8) and (9) of Theo-
> R57[5,7J := t : rem 1. In the code 8gI, 8g2 and 8g3 stand for
> R57[7,7J := sqd(1 - t1\2) : signum( a12), signum( a34) and signum( a56),
> R57[7,5J := -t : respectively. Obviously sgI = 8g2 = -1 and
8g3 = 1 for small t.
Then we can generate A by the following
segment of Maple code:
> sgI := -1 :
> 8g2:= -1 :
> A := multiply(M, P) : > 8g3:= 1 :
> A := multiply(transpose(P), A) : > bI2 := sg2 * A[I,4J - sgI * A[2, 3J :
> A := multiply(A,R57): > bI2 := series(bI2, t = 0,2);
> A := multiply(transpose(R57), A) :
bI2 := 0(t2)
> A := multiply(A,R28):
> c12 :=A[1,3J+8gIug2*A[2,4J:
> A := multiply(transpose(R28), A) : > c12:= 8eries(c12,t = 0,2);
c12 := 0
. t he part!·t·IOn A = [All
Usmg AT A A12] ' > bI3 := sg3 * A[1, 6J - 8g1 * A[2, 5] :
- 12 22
where All is 6 x 6, Maple returns the following > bI3 := series(b13, t = 0,2);
elements of A: b13 := 0(t4)
> c13 := A[I, 5J + sgl * 8g3 * A[2, 6J :
> c13 := 8eries( c13, t = 0,2);
c13 := 0(t 3 )
v1-t 2*t 2 t2
0 l+t 0 -1+t 2 -~ 0
0
2t 2{1- v'f=t2"}
1+t2 0 ~
2t2{ 1-t-l}
- t{v'f=t2"+t2}
1+12
Au = 0 1
-1+t2 ~
t 1-t
l+t
t2
0
t
0 1+t2
)+t:2
1-t
skew-sym. 0 l+t
0
t2 t{v1-t2-1}
-1+1 2 1+t2
2 t..,ll=t2{1 -..,Il=t2}
1+t2 0
t2 2t{ v'f=t2"+t2} 2..,1l=t2{ ~+t2)
A12 = 1+t2 1+t2
, An = [ 0 1+t2
J.
-~
1+1 0 skew-so 0
t2 2t{ v'"f=72+t 2 )
1+t2
t
- t 2{1- ~
1-t 2}
-1+t 2 1+12
91
> b23 := sg3 * A[3, 6] - sg2 * A[4, 5] : > size13:= sqrt(A[1,5]"2 + A[1,6]"2
> b23 := series(b23, 'I = 0,2); » +A[2,5]"2 + A[2,6]"2):
b23 := 0(t 2 ) > size13 := series( size13, t = 0,2);
> c23 := A[3, 5] + sg2 * sg3 * A[4, 6] : size13 := OCt)
> c23 := series( c23, t = 0,2); > size23 := sqrt(A[3,5]"2 + A[3,6]"2
c23 := 0(t 3 ) » +A[4, 5]"2 + A[4, 6]"2) :
> size23 := series( size23, 'I = 0,2);
Note that the output of Maple demonstrates size23 := 0('1)
the validity of the assertions in the relations
(8) and (9) of Theorem 1. It is summarized in Now suppose we apply the row-cyclic
the following Table: Paardekooper method to A. By A(r) = (a~j)
(1,2) 0('12)
°
(1,3) 0('14) 0('13)
The following output of Maple code also we denote the matrix obtained from A after r
demonstrates the validity of the assertions in rotational transformations and by cjJij the an-
the relations (10) and (II) of Theorem 1. gle used in the rotation matrix in the (i,j)
plane. We also denote tan cjJij, sin cjJij and
cos cjJij by '1ij, Sij and Cij, respectively.
> bll := abs(A[l, 2]) - 1
> bll := series(bll, t = 0,2); Because of the row-cyclic strategy the first
bll 0(t 2 )
:= pivot submatrix is A 12 • From the formula (4)
> b22:= abs(A[3,4]) - 1 : we obtain
> b22 := series(b22, 'I = 0,2);
b22 := 0("t2) (12)
> b33 := abs( A[5, 6]) - 1 : 2 a12 a 23 - a34 a 14
> b33 := series(b33, 'I = 0,2); (a12)2 - (a34)2 + (a14)2 - (a23)2 .
b33 := 0(t 2 )
We also note that IIA1311, IIA2311 = 0('1), The following segment of Maple code esti-
which was asserted right after Theorem 1. mates cP13, ct3 and 613 using the relation (12).
This is verified by the following segment of In the code phi13, cl3, 613 stand for cjJ13, C13,
Maple code: S13, respectively.
92
> e.x1 := 2 * (A[1,2J * A[2,3J - A[3,4J * A[I,4])/ where one can verify
»(A[l, 2]"2 - A[3, 4]"2
»+A[I,4]"2 - A[2,3]"2):
al~) (a12 c13 + a23 s 13)C24
> e.x1 := series(e.x1,t = 0): - (a14 c13 - a34s13)S24. (15)
> e.x1 := simp/ily(e.x1) : a25 C24 - a45s24. (16)
> phi13:= ardan(ex1)/2 :
> phi13 := series(phi13, t = 0) : a16, a (4)
56 = a56· ( 17)
93
tion. So this example demonstrates the fail- and Convergence of Parallel Jacobi SVD
ure of the quadratic convergence of the row- Algorithms, Proc. SPIE, Vol. 826, Ad-
cyclic Pa.a.rdekooper method in the presence vanced Algorithms and Architectures for
of nonzero eigenvalues whose multiplicities are Signal Processing: 152-159, 1987.
greater than two.
[7] F. D. Murnaghan and A. Winter: A
We note that in constructing and analysing Canonical Form for Real Matrices under
the example without Maple the calculations Orthogonal Transformations, USA Nat.
would have been extremely tedious. For ex- Acad. Sci. 17: 417-420, 1931.
ample, from the relation (12)
[8] M. H. C. Pa.a.rdekooper: An Eigenvalue
tan(2<,613) = Algorithm for Skew-symmetric Matrices,
_2[2-t2(-t2 + ~)(1 - ~) + t 2] Numer.Math. 17: 189-202, 1971.
w+~)2 -1 +t4 - 4t4(1- ~)2.
[9] R. A. Rosanoff et al. : Numerical Condi-
Clearly it is a tedious job to find the Taylor tions of Stiffness Matrix Formulations for
series of the above expression with O(t 6 ) of Frame Structures, Proceedings of the 2nd
truncation by hands. To analyse our exam- Conference on Matrix Methods in Struc-
ple we need to do such computations over and tural Mechanics, WPAFB Dayton, Ohio,
over. It is precisely in this point where Maple 1968.
comes into play to help us.
References
[1] K. K. Gupta: On a Combined Strum Se- The author Noah H. Rhee studied Mathe-
quence and Inverse Iteration Technique matics at Seoul National University and got
for Eigenproblem of Spinning Struc- his Ph.D. in 1987 from Michigan State Uni-
tures, International Journal for Numer- versity. He is presently an Assistant Profes-
ical Methods in Engineering 7: 509-518 sor at the University of Missouri-Kansas City,
(1973). and his current interests include numerical lin-
ear algebra and numerical analysis. He can be
[2] V. Hari: On Quadratic Convergence reached by the following address:
of the Paa.rdekooper Method I, Glasnik
Matematicki 67: 183-195, 1982.
Noah H. Rhee
[3] V. Hari and N. H. Rhee: On Quadratic Department of Mathematics
Convergence of the Paardekooper Method University of Missouri-Kansas City
II, accepted for publication in Glasnik Kansas City, MO 64110-2499
Matematicki.
E-Mail: [email protected]
[4] V. Hari and N. H. Rhee: A Matrix Pair Tel: (816) 235-2854
of an Almost Diagonal Skew-Symmetric
and Symmetric Positive Definite Matrix,
accepted for publication in Linear Alge-
bra and Its Applications.
94
AN ALGORITHM TO COMPUTE FLOATING POINT
GROEBNER BASES
Kiyoshi Shirayanagi
NIT Communication Science Laboratories, Kyoto, Japan
95
Definition 1 (Monomial Support) The f2 h = x 2y2 - Y + 2 supportwise. Also FII =
fn
--j.
96
6.8, 6.9, and 6.10 etc.) for the details on the con- Furthermore we apply round up with precision
ventional methods. J.l, denoted i fl or simply j, see [1], for the addition
or multiplication of errors. That is, i (a + {3)
(resp. i (a{3)) is the same as a EB {3 (resp. a @
3 Theoretical Foundation {3) except that it rounds the (J.l + l)-th fraction
upward-directedly to 10.
3.1 Basic Notions Note that floating point (and round up) addi-
tion, subtraction, and multiplication with fixed
It is natural to mimic Buchberger's algorithm
precision have difficulties that the associative law
but with floating point coefficients. However, the
or distributive law does not necessarily hold in
largest problem is "how small must coefficients be
general. Fortunately these deficiencies will not
for us to consider them to be zero'?". It should
cause a problem for our algorithm.
be noted that if our algorithm can judge a coef-
We define floating point arithmetic for bracket
ficient as zero iff the corresponding coefficient in
coefficients in BC polynomials. i (a + {3 + r + ... +
Buchberger's algorithm is truly zero, then the re-
e) denotes i (j (... i (j (a + {3) + r) + ... ) + e).
sults are exactly the same in monomial support.
Thus we must provide a useful criterion for this
zero judgement. Our idea is to calculate and keep Definition 4 (BC Arithmetic) With precision
track of an error of every coefficient that occurs J.l,
at each step of the S-polynomial calculation and Addition: [A, a] EB [B,{3] =
[AEBB, j(a+{3+
5 x lQe(AEIlB)-(fl+1»)]
polynomial reduction.
Subtraction: [A, a] e [B, {3] = [A e B, i (a + {3 +
To keep track of the errors, a bracket coeffi-
5 X lQe(A8 B )-(fl+1»)]
cient polynomial, or simply a Be polynomial with
Multiplication: [A, a]0[B, {3] = [A0B, i (i (a{3)+
a given precision J.l is introduced. This is 0 or a
polynomial of the form
i (aIBI)+ i ({3IAI) + 5 x lQe(A0 B )-(fl+ 1»)]
97
= 'L([Aj, O:j] ®I' [Bj, Pj ])tjUj, BC-normal form of f modulo F with preci-
iIi sion /1-, denoted BC-NForml'(f, F), is defined using
BC-reduction, in a manner similar to the conven-
where t, tj, Uj are power products. Here for 0, we
tional normal form.
have
Remark. S-BC polynomial and BC-reduction are
f + 0 = 0+ f = f, slightly different from the conventional definitions
for any BC polynomial f. when using polynomials which have coefficients in
Moreover, as a convention, we apply the follow- a field. However they are natural definitions when
ing laws: working with polynomials which have coefficients
in a ring which is not a field, because we want to
[A, 0:] e [A, 0:] = 0, avoid a division of bracket coefficients.
In both S-BC polynomial and BC-reduction, the
o· t = 0,
resulting coefficients have only two types:
-([A, o:]t) = [-A, o:]t. product type
[A, 0:] ® [B, P]
Note that in general the set of BC polynomials is
and product-difference type
not a ring because, as mentioned above, the arith-
metic operators are not associative and distribu- [A, 0:] ® [B, P] e [C, 'Y] ® [D, 8].
tive in the bracket coefficients.
Because in Buchberger's algorithm, any transfor-
Now we are prepared to define S-BC polynomial mation of polynomials is either an S-polynomial
and BC-reduction. Given an admissible term or- calculation or a polynomial reduction, it suffices
dering, LP(f) denotes the leading power product to consider these two types only as bracket coeffi-
of a polynomial or BC polynomial f. If we write cient calculations.
f = f' + rest (f), then f' is a term of f and rest (f)
is the other terms of f.
3.2 The Key Theorem
We introduce an algorithm called R-GB which
Definition 5 (S-BC polynomial) Let f and 9 we want to mimic. This is a slightly modified ver-
be BC polynomials with precision J.L [A, o:]LP(f) + sion of Buchberger's algorithm. Only the defini-
rest(f) and [B, P]LP(g) + rest(g) respectively. tions of S-polynomial and reduction are changed
And let LCM be Icm(LP(f), LP(g». Then the so that they correspond to Definitions 5 and 6
S-BC polynomial of f and 9 with precision /1- is for BC polynomials. That is, in R-GB, for real
the BC polynomial polynomials f = A . LP(f) + rest(f) and 9 =
B· LP(g) + rest(g), we define the S-R polynomial
LCM LCM of f and 9 by
[B, P] . LP(f) . f - [A, 0:]' LP(g) . 9
LCM LCM
B· LP(f) . f - A . LP(g) . g.
(with precision /1-), denoted S-BCpolYI'(f,g).
And for a polynomial f and a finite set F of poly-
Definition 6 (BC-reduction) Let f be a BC nomials,
polynomial and F a finite set of BC polynomials. f ~F h (R-reduction) iff there are 9 E F and a
with precision /1-. Then, power product U such that f = A . U . LP(g) +
BC
rest(f)(A :f. 0), 9 = B . LP(g) + rest(g), and
f -> F h ("f BC-reduces to h modulo F") h=B·f-A·u·g.
It is clear that R-GB gives the same result as
with precision /1- the usual Buchberger algorithm up to coefficient
normalization (i.e. making all the resulting poly-
'ff
Z
f BC
-> g,tl and h = [B, Pl· f - [A, o:]u, 9 nomials monic).
Now let E be a (possibly zero) real coefficient
(with precision /1-), where f ~ g,tl ("f is BC- of a polynomial 2 at an arbitrary step of R-GB.
reducible using 9 and U") iff there are 9 E F and a
power product U such that f = [A, 0:]' U· LP(g) + .
2 the result or an intermediate polynomial (e.g. B·
t~tn f in the above notation) of an S-R polynomial cal-
rest(f)([A, o:] f. 0), 9 = [B, P]LP(g) + rest(g). culation or an R-reduction
98
Let us consider how E arises. Let C be the set Proof. By induction on the structure of E.
of all coefficients in the input polynomials. Let =
(Base case: E Ai) Obvious since I{A i )", - Ail ~
C = {AdiE[1,1). For each i E [1, I], introduce a 0:; = fW
new indeterminate Ai which corresponds one to (Multiplication Case: E = A . B or -A . B) It
=
one with Ai E C. Let C {Ai}iE[1,1) and X be suffices to see the case E = A . B only. Let
the set (formally) generated by Cwith two binary I{A)", - AI ~ 0: and I{B)", - BI ~ f3 by in-
relations "." and "-". (As the "minus" in usual duction hypothesis. Let d refer to the equation:
arithmetic, this "-" may also work as a unary I{A)", ® {B)",
- ABI·
operator. That is, if :e EX, then -:e EX.) E at When (A) '" ® (B) '" # 0:
an n-th step (n ~ 2) is the result of either ±AB d
(product type) where A and B were coefficients at = I({A)", - A)(B - (B)",) + (B)",({A)", - A) +
an earlier step or A - B (product-difference type) (A)",({B)", - B) + ({A)", ® {B)", - (A)",{B)",)I
where A =
ab and B =
cd where a, b, c, and d were ~ 0:f3 +0:1 (B) '" 1+ f31{A) '" I+5 x 10-(",+1) x lO e((E)I')
coefficients at an earlier step, because E arises by ~fW
S-R polynomials and R-reductions. Then from E When {A)", ® {B)", = 0: {A)",{B)", = 0 and so
we can define E E X inductively as follows: d = I({A)", - A)(B - (B)",) + (B)",({A)", - A) +
{A)",({B)", - B)I ~ 0:f3 + al{B)",1 + f31{A)", I ~ f",
99
lOe((A;),,) and e({A;)I') is bounded on Ji, tl' = In the light of Theorem 1, we put a basic as-
ai --+ O. sumption for the zero judgment in FP-GB as fol-
(Multiplication Case: if; = A . iJ or -A . B) It lows:
suffices to see the case if; = A . iJ only. Let a For any bracket coefficient [A, a] such that A is
and f3 be the errors of (A) I' and (B) p. respectively. product-difference type,
When {E)I' ¥ 0, fp. =i (i (af3)+ i (al{B)I'I)+ i
(f3I{A)p.1) +5 x lOe((E),,)-(I'+1). By induction hy- Assumption Z: [A, a] = 0 iff IAI:::; a.
pothesis, we have a --+ 0 and f3 --+ O. Since I{A)I'L This assumption will be shown to be adequate
I{B)I'I, and e((E)I') are bounded on Ji, tl' --+ O. for our purpose in the correctness (Section 4.2) of
Similar for the case (E) I' = O. FP-GB. Now let us describe FP-GB.
(Subtraction case: if; = A - B) Let a and f3 be
as above. When {E)I' =f:. 0, fl' =i (a + f3 + 5 x An admissible term ordering <T is given.
lOe((E),,)-(p.+1). In the same way, tl' --+ 0 is im- Algorithm FP-GB
plied by that a --+ 0 and f3 --+ 0 by induction hy- Input: a finite set F of real polynomials and a
pothesis and that e({E)I') is bounded on Ji. Simi- natural number Ji.
lar for the case {E)I' = O. • Output: a set GI' of floating point polynomials
Remark. In general, {{1'}1'~1 may not be mono- with precision Ji, such that {Gp.} p. makes a floating
tonically decreasing, as can be seen in the multi- point Grabner sequence of F.
plication case, since when Ji' > Ji, I(A) 1',1 > I(A) 1'1
G := R-to-BC (F, Ji) % Data conversion
may often occur.
to initialize
The following is a key theorem for our algo- B:= {{It,h} I It,h E G,1t =f:. h}
rithm. While B =f:. 0 do
Theorem 1 (Zero Judgment) Let E be a real
(It, h) := a pair in B
B:= B - {{It,h}}
coefficient of a polynomial at any step of R-GB.
h := S-BCpoly (It, 12, Ji)
Then
h' := BC-NForm (h, G, Ji)
E = 0 iff I{E)I'I ~ fp. for all Ji. if h' ¥ 0 then
if h' = a bracket without the
Remark. The following also holds: variables then Return ({ 1}) else
"Let E be a real coefficient of product-difference B := B U {{g, h'} I 9 E G}
type of a polynomial at any step of R-GB. Then G:= Gu {h'}
E = 0 iff I{E)p. I ~ {p. for all Ji." BC-to-FP(G) % Data conversion to finish
In fact, if E is of product type, E cannot be zero % If necessary, the final errors
by the structure of R-GB. can be viewed from G.
Proof. (=}) Immediate from Lemma l. Subalgorithm R-to-BC (F, Ji) % F is a fi-
(¢:) For any Ji, lEI :::; IE - {E)p.1 + I{E)I'I· nite set of real polynomials
IE - {E)p.1 :::; tl' by Lemma 1 and I{E)I'I :::; tl'
by assumption. Thus lEI:::; 2fp. for all Ji. But by BCF:= 0
Lemma 2, fp. --+ 0 as Ji approaches infinity. There- For f in F do
fore E must be O. • n := the number of the terms in f
BCf :=0
For i = 1 to n do
4 The Algorithm Ai := the i-th coefficient in f
T; := the i-th power product in f
4.1 Description (Ai)p. := the floating point approximation
of A; to precision Ji
For simplicity, we describe the algorithm FP- ai := 5 x lO-(p.+l) x lOe((A i ),,) (*)
GB that computes an approximate Grabner basis,
BCf := BCf + [{Ai)p., a;]T;
based on the crude version of Buchberger's algo-
BCF := BCF U {BCt}
rithm ([3], Algorithm 6.2). Thus here R-GB is
the algorithm obtained by replacing S-polynomials Remark (*): If an input coefficient Ai is initially
and reductions in Algorithm 6.2 by S-R polynomi- given by a floating point number with precision Ji,
als and R-reductions respectively. then we can set ai := 0 for it.
100
Subalgorithm S-BCpoly (II, 12, f-L) % II lemma ([6]), because the termination depends only
and 12 are BC polynomials with precision f-L on a property of a sequence of power products, not
on coefficients.
f:= S-BCpolYJ.l(fI,!2)
n := the number of the terms in f Theorem 2 (Termination) For any finite set
fZ :=0 F of real polynomials and any natural number f-L,
For i = 1 to n do FP-GB (F, f-L) terminates.
[E~, t~l := the i-th bracket coefficient in f
'Fi, := the i-th power product in f Proof. Let ti be the leading power product of i-th
if E~ is of product-difference type and Be polynomial hi adjoined to G in the course of
lEiJ.I 1< i
- t J.I FP-GB (i = 1,2, ...). Assume that 3j such that
then fZ := fZ % Assumption Z tj is a multiple of tk for some k < j. Then h j is
else fZ := fZ + [E~, t~l'Fi, reducible using hk. However, by the structure of
FP-GB, hj is a normal form modulo the (j-1)-th
Subalgorithm BC-NForm (I, G, f-L) %f set G including h k . This is a contradiction. Thus
is a BC polynomial and G is a finite set of BC the sequence tl, t 2, ... has a property that, for all
polynomials with precision f-L j, tj is not a multiple of any of its predecessors.
Hence, by Dickson's lemma, this sequence must be
h:= f
finite. •
While 3g E G, u such that h I!!i g,u do
Be The correctness of FP-GB is the following.
choose g E G, u such that h -+ g,u
and u . LP(g) is maximal (w.r.t. <T) Theorem 3 (Correctness) Given a finite set F
[A, al := the bracket coefficient of LP(g) in h of real polynomials and a natural number j.l, let
[B,,Bl := the leading bracket coefficient in g GJ.I = FP-GB (F, f-L). Then {GJ.lh is a floating
h := [B, ,Bl· h - [A, alu· g (with precision f-L) point Grabner sequence of F.
n := the number of the terms in h
hZ:= 0 Proof. By comparison to R-GB. Let G be the
For i = 1 to n do result of R-GB (F). First of all, we prove that
[E~, t~l := the i-th bracket coefficient in h there is an M such that M(GJ.I) = M(G) for all
'Fi, := the i-th power product in h f-L ~ M. As mentioned in Section 3, it is obvi-
if E~ is of product-difference type and ous that if at any stage of R-GB, a coefficient E
lEiJ.I 1<- t iJ.I is zero iff FP-GB judges that the corresponding
then hZ := hZ % Assumption Z [(E)J.I' tJ.ll is zero, then M(GJ.I) = M(G). Here we
else hZ := hZ + [E~, t~lT; could consider four cases:
h :=hZ
R-GB FP-GB
Subalgorithm BC-to-FP (G) % G is a finite (1) E = 0 [(E)J.I' tJ.ll = 0
set of BC polynomials (2) E= 0 [(E)J.I' tJ.ll i= 0
(3) E i= 0 [(E)J.I' tJ.ll = 0
FPG:= 0 (4) Ei=0 [(E)J.I' tJ.ll i= 0
For gin G do
n := the number of the terms in g Cases (1) and (4) are desired for our purpose.
FPg:= 0 Case (2) is impossible by Theorem 1. However,
For i = 1 to n do the undesirable case (3) is possible. Therefore it
[Ei' til := the i-th coefficient in g suffices to prove that there is an M such that for
T; := the i-th power product in g all f-L ~ M case (3) does not occur throughout
FPg:=FPg+Ei·T; FP-GB (F, f-L).
FPG:= FPGu {FPg} Let N be the sum of the numbers of S-R polyno-
mial calculations and R-reductions in R-GB (F).
Note that N is finite. Here when N = 0, it means
4.2 Termination and Correctness
UF = 1, and hence we are done by FP-GB (F, 1),
The termination of FP-GB can be shown in ex- i.e. taking 1 as M. Thus we assume N ~ l.
actly the same manner as Buchberger's proof ([4]) Let {81' 82, ... , 8 N } be the sequence of S-R poly-
for the conventional algorithm using Dickson's nomial calculations and R-reductions such that
101
they are serially performed in R-GB (F) in this ner similar to FP-GB. In fact, the optimum
order. Put Sk = {SI, ... ,Sk} for 1:S k:S N. choice of a pair for S-polynomial, and Criterions 1
We prepare the following lemma3 . and 2 for detecting unnecessary reductions are all
(*) For any k E [1, N], iffor some M o, FP-GB (F, expressed only by the terminology of power prod-
Mo) causes no case (3) for Sk, then there is an ucts, not of coefficients. Obviously the termina-
M'(? Mo) such that for all J.l ? M', FP-GB (F, tion and correctness of the improved FP-GB can
J.l) causes no case (3) for Sk. be proved in the same manner as those of FP-GB
Proof of (*). Assume the if part. If moreover no in Section 4.2.
case (4) occurs in Sk, then it means E = 0 for The original versions of FP-GB and R-GB are
every coefficient E and hence no case (3) can oc- so costly in computing time that they are not
cur for any J.l. Otherwise, let {Ei' [(Ei}1' , f~]h:;i9 appropriate for our experiments. Thus, in this
be all the pairs in case (4) in Sk. Put C = section, we compare the experimental results of
miniE[I,lj(IEil). Since C:f. 0 and I i~ finite, there the improved FP-GB and the improved R-GB,
is an MI such that J.l ? MI ::::} f~ < C /2 for where the latter algorithm gives a reduced Grabner
all i, by Lemma 2. For i E [1, I] and J.l ? M I , basis except that the resulting polynomials are not
we have f~ ? lEi - (Ei)1' I ? IIEil- I(Ei)1'11 by necessarily monic. Let us here call them simply
Lemma 1 and the well-known inequality about ab- FP-GB and R-GB as well.
solute values. Thus when I(Ei)1' I :S IEil, I(Ei)l'l? We implemented them in Maple V /Sun SPARC
IEil- f~ ? C - f~ > f~ and when I(Ei)1' I > IEil, ([5]). For brevity and convenience on Maple, we
I(Ei) 1'1 > lEi I ? C > 2f~ > f~. Therefore, coded the parts of error terms in Definition 4 by
M' = max(Mo, M I ) satisfies the subject of (*) by floating point arithmetic instead of round up arith-
Assumption z. (End of Proof of (*)) metic, assuming that the errors between them are
Now if FP-GB (F, 1) causes no case (3) for negligible. We did not use the built-in function
S N, then we are done by (*). Otherwise, let Ski gbasis4 in Maple for computing Grabner basis even
be the first process such that case (3) occurs. Let in the case of rationals, for the sake of fairness of
E I , ... Em be all the coefficients in case (3) im- the comparison between FP-GB and R-GB. Ta-
mediately after the process Ski' By an argument bles 1 to 5 show G := R-GB (F) and GI' := FP-
similar to the proof of (*), there is a J.lki such that GB (F, J.l) (1 :S J.l :S 10 or 20) with cpu times for
J.l? J.lki ::::} I(Ei)1' I > f~ for all i E [I,m]. More- F in Examples 1 to 5 below, respectively. To pre-
over, since FP-GB (F, 1) causes no case (3) for serve space, in Tables 3 and 4, each coefficient of
Ski-I, by (*) there is an Mki such that for all J.l ? G is expressed by floating point with precision 10.
Mkp FP-GB (F, J.l) causes no case (3) for Ski-I' tdeg (resp. plex) denotes total degree lexicographic
Therefore, when putting Mki = max(J.lk i , MkJ, (resp. purely lexicographic) term ordering. In the
FP-GB (F, MkJ causes no case (3) for Ski' tables except for Table 5, the first precision M
Next if FP-GB (F, MkJ causes no case (3) for satisfying M(G M ) = M(G) is marked in bold.
S N, then we are done. Otherwise, let Sk 2 be the Note that M may not necessarily satisfy the con-
first process such that case (3) occurs. Repeating dition that M(GI') = M(G) for all J.l ? M. In
this argument makes a sequence kI < k2 < k3 < Table 5, the precision such that from it on, a series
... , But since N is finite, this sequence is finite of monomial supports seems to be stable is framed
and hence it proves the existence of M. by a box. Here are the examples:
Moreover, as J.l approaches infinity after M, by
Lemmas 1 and 2, every coefficient of {GI'}I'>M 1. F = {x(3x - 1), x - 1/3}, tdeg.
converges to the corresponding one of G. - •
2. F = {x(3x - 1), x - .3333333333}, tdeg.
5 Examples
We can also consider an improved version of FP-
G B, based on the improved version of Buch-
berger's algorithm ([3], Algorithm 6.3), in a man-
3We need this lemma, since for an E, {tl'}1' may not
be monotonically decreasing as mentioned in Remark after 4This function can be applied only over the rationals,
Lemma 2. but it is much faster than R-GB.
102
4. F = {V2ex 3 Y+V3xy+4, ~x2y2 -v7xy+ seems to be stable on monomial support or seems
e'{fI}, tdeg with x > y, where e is Napier's to converge coefficientwise.
number (2.71828 ... ). We want to stress, however, that our approach is
not only theoretically well-founded, but also could
5. F = {II, h}, tdeg with x > y, where be practically useful, in particular for approximate
!I = 2V2/7rx 3 y + (V3 + 7r)xy + v7/(e - 7r), algebraic computation in multivariate polynomi-
h = (l-eV3)/e'7rX 2y2-(v7- e)xy+e/v!fI. als.
103
Table 1: Example 1
G cpu time (sec)
{x - 1/3} .130
Table 2: Example 2
G cpu time (sec)
{I} 200
104
Table 3: Example 3
floating point expression of G with precision 10 cpu time (sec)
{-.7486148880 X 10 31 ;C + .2938720185 X 10 40 Z~ + .1954874591 X 10 39 ZJ - .3745685851 X 10 36 Z + .1768674726 X 10 33 ,
-.1684383498 X l032y - .2167251711 X 10 39 Z3 _ .1441683806 X 10 38 Z 2 - .4442206312 X 10 35 Z + .5572270445 X 10 32 , 369.16
_ .5081835293 X 10 76 Z4 _ .3068656908 X 10 75 Z3 + .8958744250 X 10 72 Z2 - .8274384887 X 10 69 Z + .2446596580 X 10 66 }
5 {-.11300 X 10 2591 Y + .37380 X 10 2591 , .12153 X 10 1106 .z;, - .50220 X 10 2590 x + .11864 X 10 2592 } 128.216
{.537759 x l025Z - .211101 X 1034Z~ - + .269066 X 10 30 Z - .127046 X 10 27 ,
.140427 X 10 33 Z""
6 .120996 X Io 26 y + .155683 X 10 33 z3 + .103562 X 10 32 z~ + .319102 X 10 29 Z - .400280 X 10 26 , 24.650
-.262230 X 10 64 Z 4 - .158347 X 10 63 Z 3 + .462286 X 10 60 Z 2 - .42695 X 10 57 Z + .12621 X IOS4}
Table 4: Example 4
floating point expression of G with precision 10 cpu time (sec)
{-.1325528855 X 10~Y;S - .1085028162 X 10" u X - .3879281551 X 10" U y,
.3443764079 X 10 9 X" +
.8401300998 X 10 7 y" .4145701265 X 10 9 , + 43.21
.3975253926 X 10 7 xy +
492680.0344Y" - .1293658022 X 107}
105
Table 5: Example 5
G cpu time (sec)
? > 3,600.
J.L G" cpu time (sec)
2 {-12.x~ - 55., 48000.xy + 160000.y~ + 7700., -.38 X 10 0 y" + 580000.x} 3.200
3 {I} 1.550
4 {-.2929 X 10""x, .9853 X 101~y~ - .1421 X 10 10 } 3.883
5 {I} 3.133
+
{-.304467 X 10~y0 - 57296.6x .177025 X 10 y,
0 57131.5x 2 - .349660 X 10 8 y2 +
503082.,
-5860.01xy + 134278.y2 - 958.949}
4.367
106
III
MAPLE V IN SCIENCE AND
ENGINEERING
109
• unrolling loops to avoid branching and sub-
routine calls,
• sharing common sub-expressions.
It is well known that lots of mechanical ma-
trices and vectors contain a large number of zeros
r-- --,
Symbolic
I and ones. For example, any classical cosine ma-
,---
!EquatiOns manipulation
L----
I ------' trix contains at least 4 zeros and one one (when
---.
I Numerical code I Ox, Oyor Oz are typical rotational axis). Proper
propagation of these values by themselves can re-
==n
L_M_~1fer~~ __ ___1
frain the simulation program from making hun-
dreds of unnecessary operations.
~ Numerical
Unneeded subroutine calls represent a severe
Numeric
~ simulation
waste oftime during simulations. Let us consider,
for example, the multiplication of two cosine ma-
trices n l and n 2 :
nl
( e08(,.)
sin(qt)
0
-sin(qt)
cos( ql)
0
0
0
1
),
Figure 1: Organization of a symbolic software
110
Last but not least, common sub-expressions 3 The choice of Maple
sharing may be performed. The detection and
storage into intermediate variables of any expres- Most of the previously mentioned symbolic pro-
sion appearing more than once in the whole sim- grams use a specialized and limited symbolic tool-
ulation will save a significant amount of runtime. box to derive the equations. Their authors usu-
For example, the previous matrices multiplication ally say that general computer algebra systems
will then be translated as follows are efficient, powerful, secure, of great interest,
... but they do not use them! The two princi-
pal reasons advanced are, first, that general alge-
/1 dsin(ql) bra systems are too large (requiring then a great
f2 dcos(ql) amount of storage and computational resources)
and secondary that the number of useful func-
/3 dcos(q2)
tions would represent at most one percent of the
/4 /2 * /3 total amount of functions provided by systems
/5 dsin(q2) like Maple ([7]), Macsyma ([8]) or Mathematica
/6 /1 * /5 ([9]).
In our opinion, we think that these reasons
f7 -/1 * /3 are not valid or, at least, no more valid. New al-
/8 -/2 * /5 gebra systems like Maple even if their library is
Resultl,l /2 rather huge, do not require an enormous amount
Resuitl ,2 f7 of memory to load their kernel (half a megabyte is
usually enough). Systems like Maple can be run
Resuitl,3 /6 on personal computers like IBM-PC or Macintosh
as well as on work stations or big systems. Fur-
Result3,3 = /3 thermore, during the last years, computing power
and calculation speed have fantastically increased
Savings may seem limited but one has to re- while the prices of computers, memory and disks
member that the complete set of equations will have gone down in the same proportion. These
be computed hundreds or thousands of times (de- changes in the computer market have disqualified
pending of the accuracy required and simulation hardware resources limitations. Let's mention,
time interval) during any simulation. indeed, that our prototype has been successfully
Some compiling experts may argue that good tested on a 80386 IBM-PC computer having one
compilers can do the job. That is partially true. megabyte of memory.
In fact, avoiding subroutines calls may be per- Though it is true to say that only a limited
formed by compilers through replacement of each number of the existing functions of an algebra
call by the corresponding subroutine code but the system are necessary to derive mechanical equa-
generated code will still present inefficient loops tions, we think that other facilities provided by
(a typical matrix multiplication routine involves systems like Maple may always be of great in-
two loops). For common sub expressions elimina- terest for a further treatment of the computed
tion, compilers will only detect local redundancy. equations.
That is, an expression expr appearing two times We have chosen to use Maple among other
close one to another will be stored into a register systems for several reasons. First, it is obvious
and immediately reused but the limited number that Maple is one of actual two leading algebra
of registers will imply that registers will soon be systems on the emerging market of symbolic com-
overwritten and a new instance of expr encoun- putation. Then, we are old Maple users and are
tered a few lines forward will be recomputed. industrial partner C.N.E.S. also uses it. The last
but certainly the most important reason is that
Maple is able to handle very large expressions us-
ing a reasonable amount of storage space while
111
keeping good runtime performances. ical equations for a n degrees of freedom system
may be written as follows
112
8ody3 • a data input routine to assign unknowns
(bodies' mass, inertia, vectors' components,
initial conditions, simulation time interval,
... ),
(2)
m3 mass of body 3
q3 generalized coordinate of body 3
u3 generalized speed of body 3 Let us mention that such an inversion can-
13 vector parallel to joining axis between body 3 and body 2 not be performed symbolically because the
gi3 vector from mass center of body 3 to body 2 hinge point
904 vector from mass center of body 3 to body 4 hinge point Mass matrix coefficients are really too enor-
,"3 central inertia dyadic of body 3 mous and the matrix size is equal to the
pas3 rotation matrix between body 3 and body 2 mechanism's number of degrees of freedom
f03 external force upon body 3 center of mass (usually from six to twelve).
t03 external torque upon body 3
• a numerical integration routine to solve the
Figure 2: Formal variables associated to one body final second order differential equation sys-
tem.
4.4.1 translation into Fortran or C Data input is performed via a special file whose
"mask" is generated by the software. Therefore,
For Fortran or C equations translation, we use
the user only has to fill blank spaces to get a
approximately the same algorithm consisting in
complete and ready to use data file. Simulation's
applying the different optimization methods de-
results are written into another file according to
scribed in section 2.1. This algorithm does not
a special format which can easily be modified.
straightforwardly generate code but constructs a
For Fortran inversion and resolution, we have cho-
Macrofort or MacroC sequence of instructions.
sen to use the well known secure and optimized
Macrofort package has been developed by Claude
routines of the NAG Fortran Library [15] even
Gomez ([13]) and I have written MacroC ([14])
when we have written our own C inversion and
which is the C language counterpart for M acro-
resolution routines (see [16]). Fortran integration
fort. Macrofort is already available in Maple of-
routine may be chosen among three : a variable
ficial share library and M acroC will soon follows.
order, variable step Adams method (default); a
Without giving technical details on these pack-
Runge et Kutta - Merson method and a Back-
ages, let us mention that they both allow For-
ward differentiation method for stiff systems.
tran or C code generation within Maple including
Let's add, to be complete, that a Unix shell
data structures definitions and declarations, con-
script is available to perform successively the whole
ditional and iterative instructions, subroutines def-
operations beginning with compilation and end-
initions and calls, C preprocessor facilities and so
ing with a suitable treatment of the results.
on ...
113
mA ks k*(kt %1, k- frame(ll, A, 0),
frame(giA, A, 0»,
possible, in the context of an article, to study > # frame operators hide some
a mechanical system involving more than two or > # frame changes
three degrees of freedom. The considered system > _frame[giB, B, 0];
is a double pendulum (see figure 3 as described &*(pasA, pasB, giB)
by Dan E. Rosenthal in [17]).
> #Let's apply a substitution saying:
> # declare a body A linked with the
> #1) rotational axis of body A is
> # reference inertial body (ground)
> # parallel to first pendulum axis,
> # by a revolute joint
> #2) inertia matrices are null
> declare(body, A, rotation);
> #3) center of mass of body A is
> # situated at hinge point with body B
> # Body B linked to A by a rotation
> mat_subs(&x(ll, giA)=O, inA=O,
> declare(body, B, rotation);
inB=O, goB=O, masse[l,l]);
> # Equations computation
mB &s &*(&t «&- frame(ll, A, 0» &*
> sys_diff 0 ; frame(giB, B, 0»,
&- frame(ll, A, 0),
> # Mass matrix and force vectors
frame(giB, B, 0»
> # are stored in arrays called masse
> # and force
> # Expand the result
> get_dim(masse) , get_dim(force);
[2, 2], [2, 1] > mlCexpand := expand (") ;
m11_expand :=
> # First element of mass matrix (-mB) &s &*(kt giB, kt pasB,
kt pasA,
> masse[l,1J; (t- (pasA &* 11» &~ 2,
&+(&*(kt frame(ll, A, 0),
pasA, pasB, giB)
frame(inA, A, 0),
frame(ll, A, 0»,
114
> # Some global assignments > # MacroC instructions sequence
> # rotation axis > _prog
> 11 := array([O,l,O]): 2
> 12 := array([O,O,l]): [equalC, Cl, L],
115
the total number of terms accepted by the sys- 7 Conclusion
tem (that is 217 - 1 terms). Anyway, we do not
think that this limitation is really severe because Advantages of symbolic simulation softwares ver-
motion equations of systems having more than 15 sus fully numeric ones have been presented. It has
or 20 degrees of freedom are tremendously huge been shown that symbolism could substantially
and cannot be handled in any manner. People increase simulations performances. Furthermore,
interested in so large mechanisms will only plan using a general computer algebra system such
pure numerical simulations and may therefore use as Maple leads to a successful attempt to de-
another simulation specialized software. Other rive and handle explicit equations of motion for
limitations of the program are linked with the multibody mechanisms. A brief description of our
possible extensions described in the next section. Maple prototype has been given and a limited
commented session of its use provided. We are
still going on with the development of the pro-
6.2 future extensions totype and we hope to be able to handle both
We are developing our prototype and future de- hinge actuators and flexible structures. We think
velopment axis will be determined with involved we have proven that building such a simulation
users. Nevertheless, we already plan to work in software on top of Maple could lead to an effi.-
the following directions cient and easy to use program.
116
[7] Bruce W. Char, Keith O. Geddes, Gaston H. biography
Gonnet, Benton L. Leong, Michael B. Mon-
Patrick Capolsini is a Ph.D. student in the Safir
agan, and Stephen M. Watt. Maple V Lan-
project which is common to INRIA, CNRS and
guage Reference Manual. Springer-verlag,
University of Nice.
1992.
He is interested in symbolic computation of
[8] Symbolics-Inc. Macsyma User's Guide. mechanical equations and their optimized numer-
Symbolics-Inc., 11 Cambridge Center, Cam- ical transcription. He belongs to the 13S labora-
bridge MA 02142, 1988. tory, 250 Avenue Albert Einstein - 06560 VAL-
BONNE - FRANCE ([email protected]).
[9] S. Wolfram. Mathematica - A System for
Doing Mathematics by Computer. Addison-
Wesley Publishing Company, Redwood City,
California, 1988.
[10] Duc Minh Tran. Une presentation de la
methode de Kane pour la formulation des
equations du mouvement. La recherche
Aerospatiale, 3, 1991.
117
SENSITIVITY ANALYSIS OF NONLINEAR PHYSICAL
SYSTEMS USING MAPLE
Stephen Carr, Gordon J. Savage
Dept. of Systems Design Engineering, University of Waterloo, Waterloo ON, Canada
118
assembled and much of the correspondence be- matrix when n = 1.
tween the mathematics and the system structure
is lost. Under these circumstances it is not obvi-
ous how the sensitivity equations are to be con- 2 Nominal System Model
structed. However, in graph-theoretic sensitiv-
ity models, derivatives are taken at the compo- 2.1 A Little Systems Theory
nent level first, then the system-level sensitiv- The 'system variables' which describe an engi-
ity models are assembled. Using the standard neering system are its characterizing measure-
methods of systems theory [1, 4, 11, 15, 13], the ments. These variables fall into two generalized
'nominal' system equations, 'First-Order Sensitiv- categories, 'through' and 'across'. Examples of
ity (FOS)' equations, 'Second-Order Sensitivity through variables, denoted as y, are current, flow
(SOS)' equations, etc. , can all be built up auto- rate, force, etc.. Across variables, denoted x,
matically from the system description. Each suc- include voltage, displacement, temperature, and
cessively higher-order sensitivity model incorpo- pressure drop as examples.
rates the solutions of the preceding models. The According to systems theory, a system is com-
GTSM method allows sensitivity analysis to be pletely described by three sets of equations. Two
viewed as a simple matrix algebra problem, with- sets of equations, known collectively as the 'in-
out appealing to the abstract notion of an "ad- terconnection equations', describe the constraints
joint" system [14]. Also, because it is a direct imposed on the system variables by the intercon-
method, calculation of the complete sensitivity nection of the components in a system. The in-
information of a chosen order is obtained from terconnection equations are the 'circuit equations'
a single solution of each of the models in the hi- and the 'vertex equations', which are generaliza-
erarchy. tions of Kirchhoff's Voltage Law and Kirchhoff's
Symbolic computation has been found to be Current Law, respectively. The interconnection
very useful for the construction and solution of equations are always linear, and may be written
both nominal and sensitivity system models. This in matrix form in terms ofthe 'incidence matrix',
paper attempts to demonstrate this utility using A, a matrix of ±1's and D's, which describes the
Maple [6] software. A brief introduction to some system topology. The system topology is repre-
systems theory concepts and the solution of non- sented by a 'system graph' of directed line seg-
linear system models is given in Section 2. (For ments which indicate the polarity of through and
details, interested readers are directed to the cited across measurements.
references.) Section 3 describes the development The vertex equations are
of the system sensitivity equations. In Section 4
sensitivity analysis methods are applied to a sim- Ay=O (2)
ple nonlinear pipe network. Finally, we provide
some concluding remarks. and, a special form of the circuit equations is the
'nodal transformation equations'
For convenience in dealing with matrix expres-
sions, we invoke operations from matrix calculus x = ATxn (3)
and the 'Kronecker product' operator, "®". Rel-
evant definitions are given in Appendix A. As no- which introduces an additional set of across vari-
tation, we denote nth order derivatives of a ma- ables, X n , the 'nodal' variables. The nodal vari-
trix A with respect to another matrix B with ables represent measurements between the com-
the superscript notation A (nB). By convention, ponents' terminals of interconnection and an ex-
we write all vectors as column vectors but de- ternal datum, e.g. gauge pressure or displacement
note the nth derivative of a vector by a vector as with respect to an inertial frame of reference.
oa/obT == a(nb). The derivative is written with The remaining set of equations needed to de-
respect to the transpose of b in order to corre- scribe the system is the governing equations, or
spond with the familiar definition ofthe Jacobian 'terminal equations', of the system's components.
119
The terminal equations of a component are de- the number of equations equals the number of
rived by characterizing measurements taken with unknown through and across variables. The com-
respect to the terminals ofthe component. A sim- bined system of equations is known as the 'system
ple electrical resistor, for example, has the single equations', or simply the 'system model'. Var-
terminal equation, v = =
r i (or ;J: r y). Any ious formulations of the system model are pos-
nonlinearities in the system model arise from the sible, varying from the complete solution for all
terminal equations. For example, the :flow in a unknown through and across variables to more
pipe as a function of the pressure drop is given by compact formulations which directly provide only
the empirical Hazen-Williams equation: a subset of the unknown system variables. Often,
we are just interested in the nodal variables. A
q = 9 hO. 54 (4) convenient and compact formulation is the 'mixed
where q is the pipe :flow (through variable) and h nodal tableau (MNT)'(also known as the 'modi-
is the pressure drop (across variable). The coeffi- fied nodal' formulation) where all unknown sys-
cient, 9 is a function of other input parameters: tem variables have been eliminated except the
nodal variables and the through variables corre-
Cd 2 . 63
(5) sponding to the across excitations.
9 = klo. 54
with C, the Hazen-Williams pipe roughness; d,
the pipe diameter; I, the pipe length; k, a con- 2.2 Solution of Nonlinear Systems:
stant determined by the units used. A compo- the N ewton-Raphson System
nent which has a single terminal equation, as in
the above examples, has only two terminals with The solution of the nominal system is the 'nom-
which to connect to other components. In gen- inal response', which is determined for any set
eral we can write the terminal equations ~f two- of fixed input values. If the terminal equations
terminal 'constitutive' components as a system of are nonlinear, the nominal response must be de-
equations termined iteratively by e.g. the Newton-Raphson
(6) Method.
where the subscript c indicates system variables The general nonlinear system model can be
associated with constitutive components; f(xc) is written in matrix form as in equation (1). We
a vector of nonlinear functions of xc. The matrix construct the MNT formulation from the basic
G in equation (6) is a diagonal matrix with el- equations (2), (3), (6) and (7) as
ements gi(U), where vector U is a set of inputs.
The more general case of multi-terminal compo-
nents is discussed in [13].
h = [ AcGf(A~7) + Aa.Ya. + AtYto]
Aa. Xn - Xa.O
[0]
0
The terminal equations for the through and (8)
across 'excitations', or 'drivers', provide specified where partitions of the incidence matrix, A, cor-
functions of time, and they are respectively responding to the various component types are
indicated by subscripts. The first row in (8) is
Yt = YtO(t); Xa. = xa.o(t) (7) just the vertex equations written in partitioned
where subscripts t, a, and 0 denote "through", form, with terminal equations and nodal trans-
"across", and "specified". Excitations often arise formation equations (where possible) substituted
from uncontrolled environmental conditions act- into the first and third terms. The second row is
ing on the system, but may also be components the terminal equations of the across excitations,
which supply energy to the system, e.g. voltage with the nodal transformation substituted for Xa..
sources or pumps. The response variables z = [xn Ya.JT are implicit
Together, the two sets of interconnection equa- in (8).
tions plus the set of terminal equations of all com- To solve (1) or (8) using the Newton-Raphson
ponents constitute a determinate system where method, we expand h in a linear Taylor series
120
about operating point zk as where G is treated as constant, and the deriva-
tive of the matrix product (6) is defined in Ap-
pendix Aj operating point values x~ may be ob-
tained from zk by the nodal transformation (3).
Equation (9) may be written as a linear system of The term in braces in equation (14) may be con-
equations sidered to be a "pseudo" through excitation which
appears in the Newton-Raphson system model
but not in the real (physical) system. Note also
that some care must be taken with the signs of
where LNR is the Jacobian, Mlz)(zk)j rNR(zk)
terms in (14) so that the Yc's change sign only
is -h(zk)j and .6.z k == z - zk. The Newton-
when zc's change sign [5].
Raphson system, (10), may be solved for the
Newton-Raphson "step", .6.z k , which suggests the The nominal interconnection equations, (2) and
iteration scheme zk+1 = zk + .6.z k • (3), and the terminal equations of excitations
However, it is more convenient to use the tech- (7), remain unchanged in the formulation of the
niques of systems theory to build up the Newton- Newton-Raphson MNT, equation (13).
Raphson system directly from component infor-
mation [4, 5]. If we rearrange (10) to put only z
on the LHS, we get
3 Sensitivity System Models
In sensitivity analysis, we are interested in the
The response, z, ofthe nominal system is obtained sensitivities of responses, z, with respect to the
at the convergence of the iteration set of the inputs of the system model. Inputs
may be physical or geometric parameters of sys-
tem components or values of system excitations.
We write the inputs as a vector of length m as
Writing (8) in the form of (11) we obtain the
Newton-Raphson MNT formulation
[ Ac G f(1zc1t~ x!) A~ ~a] [;: ] The 'design variables' of the system constitute
some subset of the inputs, e.g. the geometric pa-
rameters.
[ -Ac {G f(A~ x!) - G f(1zc)(A~ x!) A~ x!}
XaO The nature of the nominal system model out-
-At YtO ] lined in the previous section can be extended to
(2xl)
models that have derivatives of the through and
(13) across variables with respect to the input vector,
The Newton-Raphson MNT (13) may be built u. A separate 'sensitivity model' is developed for
using systems-theoretic concepts by developing each order of derivatives required.
modified terminal equations for the constitutive
components. For the nonlinear constitutive
equations of the form given in equation (6), and 3.1 FOS System Equations
treating G as constant, we obtain the first-order
Taylor expansion Let us now take the derivatives of the vertex and
nodal transformation equations, (2) and (3), in
Yc [Gf(1zc)(x~)] Xc (14) the nominal model. We proceed by using the rule
for the derivative of a matrix product given in
+ {Gf(x~)- [Gf(1zc)(X~)] x~} Appendix A. Since the incidence matrix,A, is con-
121
stant, for the vertex equations we obtain the solution to the nominal system is available.
Note that (17) is the same as (14) except for the
OYl/OUm
OY2/ 0U m
1 form of the pseudo through excitation.
FOS terminal equations for the excitations are
much simpler. Applying the Chain Rule to equa-
tions (7),
OYp/OUm
Y t(lU) -
_ y(h)v(lU). X(lu) - x(lv)v(lu) (18)
to 'a -aO
+ (v(lu) ® f(be)x~lU»)] }
yi lU ) = [Gf(b e)] x~lU)+G(1'II) (v(lU) ®f) (17)
All the terms encompassed by the braces in (21)
Equation (17) is linear in the FOS constitutive may be evaluated given the nominal and FOS so-
across variables, x~l u), since the second term (a lutions and constitute a pseudo through excita-
pseudo through excitation) may be evaluated once tion. Note that (21) is also the same as (14) and
122
(17) except for the form of the pseudo through across measurements taken at nodes A through C,
excitation. The second-order derivatives of the and ql is the flow through the fixed-head pump.
excitations usually vanish. The system excitations are the demand flows
The SOS system model may also be formulated at nodes Band C, and the head supplied by the
as a linear system of equations of the form pump at node A. These are all assumed to be
constant: q4 =
l.547(ft. 3/s); q5 =
l.0(ft. 3/s);
L(u, z) z(2u) = Rsos(u, z) (22) hI = 196.8(ft.).
The constitutive equation for the pipes is the
where, again, L = LNR. The SOS response vari- Hazen-Williams equation, given in (4) and (5),
ables, z(2u), form a matrix with m 2 columns. where C = 100, d = 10(in.), k = 852000, and
I = 3280(ft.). C and d are parameters, while k
and I are considered to be fixed constants in the
4 Pipe Network Example design. In order to take advantage of the nota-
tional convenience of (5), we define two sets of
As an example, consider the simple pipe net- input variables: v = [ht, g2, g3, q4, q5]T and
work system shown in Figure 1 a). The through u = [ht, C 2, C 3, d 2, d 3, q4, q5]T. The trans-
formation from u to v is given by (5) for g2 and
g3, and the remaining variables are unchanged in
A 2 B 3 the transformation. Written in the matrix form
... e of (6), the constitutive terminal equations are
h1 = 196.8 It.
[
Figure 1: a) Simple Pipe Network 27 9.2 0
50 Ihl-h~IH
b) System Graph Yc 27 9.' ] x,
0
50 Ih~-h~IH
and across variables for this system are y =
[
23 g2(hl-h~)
[qt, q2, qa, q4, q5]T and x = [hI, h2' h3, h4' h 5]T , 50lhl_hklH
+ (24)
1
i.e. the flows through and heads across the com- k fJ k
23 g.(ht!,-h-r)
ponents shown in Figure 1 a). Orientations of 50 Ih~-h~IH
the through and across measurements are repre-
sented by the system graph shown in Figure 1 b). where operating point values h2 and h3 have been
If the Mixed Nodal Tableau is used to formulate replaced with nodal variables via the nodal trans-
the system equations, the solution variables are formation (3), and ha has been replaced by the
z = [ha, h/3' h-y, ql]T, where the heads are nodal specified across driver value, hI. The pseudo
123
through excitation is the second term in (24). The cept for the pseudo through excitation term:
:
Newton-Raphson MNT, equation (13), may be
built in symbolic form using Maple. The so-
o
[
lution ofthe Newton-Raphson MNT provides the
iteration (12)
o
hk+l
a hl o
-1- ( -50q41h 1 - h{3I5O
: :1
h (3k +1 k ..
27g 2 o
+ 50g2hl - 23g2h~ (26)
k .. ) a (2 x 7) matrix where the columns contain deriva-
50q51h 1 - h{3I5O (25)
tives with respect to ht, C2, C a , d2, d a , q4, and
h -yk +1 -1- ( -50gaq41h 1 -
k ••
h{3I5O Q5, respectively.
27g2ga Since all sensitivity system models are linear,
+ 50g2gahl - 50g2q51 h{3 - h-y I'"
k k"
we may obtain the exact symbolic FOS solution
k •• )
as a (4 x 7) matrix
23g 2gah-yk - 50gaq51h 1 - h{3l5ii"
q~+l -q4 - q5 1 o o
1 o
(shown here as separate equations).
1
For starting guess ha = 196.8, h{3 = 195,
h-y = 190, and ql = -2.5, equation (25) stabilizes o
with errors less than 0.001 after four iterations to
give the solution [196.8, 154.7, 147.3, -2.547jT. o o
Note that in this problem ha is just the across ex-
citation and ql is determined by the vertex equa-
o
tions applied at the datum node in Figure 1 b), so
. I
the iteration (25) is not a function of these vari-
ables. The full solution for all across and through
variables may be retrieved, if desired, by back- o o
substitution into the nodal transformation equa- _ 50 !h 1 -htl!5O
tions (3) and the constitutive terminal equations 27 •• g. ••
_ 50 g.!htl- h .. !5O +g.!h 1 -htl!5O
(23). 27 g.g.
-1
(27)
where rows correspond to ha, h{3, h-y, and qt, and
columns contain their partial derivatives with re-
4.2 FOS solution spect to hl' C 2 , C a, d2 , d a, q4, and Q5, respec-
tively. This expression may be evaluated once the
The FOS system model is constructed as de- nominal solution is available, since it requires h{3
scribed in Section 3. Of particular interest are the and h-y. Errors in h{3 and h-y are carried over from
FOS terminal equations of the constitutive com- the nominal solution.
ponents which are obtained by differentiating the The complete FOS solution for all through and
nominal terminal equations using equation (17). across varaibles in the system model may be re-
These equations are the same as (24), above, ex- covered by substitution of (27) into (16) and (26).
124
4.3 SOS Solution 4. Since the sensitivity models of any order are
always linear, exact symbolic solutions can
The SOS solution may also be obtained in exact
always be obtained, even though symbolic so-
symbolic form. For this example, the SOS MNT
lutions are not generally available for nonlin-
solution, Z(2u), is a matrix of size (4 x 49), and
ear nominal system models. The availability
is too large to show here. The full SOS solution of symbolic solutions facilitates study of the
may also be recovered by substitution into the behavior of the sensitivities as functions of
SOS nodal transformation equations and the SOS the inputs.
constitutive equations.
Of particular interest for optimization ofthe de- 5. Given the symbolic sensitivity solutions, nu-
sign are the second-order partial derivatives ofthe meric values may be obtained by simple sub-
heads at nodes Band C with respect to the pipe stitution ofthe nominal responses and the in-
diameters. The non-zero second partial deriva- put values. For nonlinear physical systems,
tives are the calculated nominal response values are
inexact.
8'h fJ _ 8'h
::::.....:.:.l: _
nun)
8d~ - 8d~ -
W
- 263C,(h 1 -hfJ) ( 20251C,d: (kl) 50 -4401dpm g,(kl)" A Matrix Calculus
II
145800g~(kl) 50
Definitions
The following definitions have been adapted from
8'h
::::.....:.:.l: -
8d~ -
Graham [9]. These operations are easily imple-
mented in Maple procedures [3]. In the following,
-263Cs(hfJ-h .. ) (20251Csd:n- (kl)H +4401dfio gs(kl)*)
t.
3. Solution ofthe nominal system model may be 8A 8A 8A
8b l1 8b" 8b ..
obtained exactly in symbolic form for linear A(lB) = vA =
systems. For nonlinear systems, it is possible vB [ eA 8A 8A
to obtain the symbolic expression for for the 8b r1 8b r , 8b r •
125
A.3 Product Rule [2] S.M. Carr and G.J. Savage. Comparison of
chance-constrained and structural reliability
When q = r and for differentiation with respect
formulations ofreliability-based design. Sub-
to a vector, v, we can define
mitted to: Reliability Engineering and Sys-
tem Safety, May 1993.
where I is an n x n identity matrix. [3] S.M. Carr and G.J. Savage. Maple proce-
dures for matrix calculus. Internal Report,
Department of Systems Design, University of
AA Chain Rule Waterloo, May 1993.
Let elements of A be functions of v and let ele-
ments of v be functions of u. Then [4] M. Chandrashekar and H.K. Kesavan.
Graph-theoretic models for pipe network
analysis. Journal of the Hydraulics Division,
ASCE, 98(HY2):345-364, 1972.
Applying the Chain Rule to a matrix product,
for q = r [5] M. Chandrashekar and K.H. Stewart. Spar-
sity oriented analysis of large pipe networks.
Journal of the Hydraulics Division, ASCE,
101(HY4):341-355, 1975.
A.S Kronecker Matrix Product
[6] B.W. Char, K.O. Geddes, G.H. Gonnet,
anB
[ a21B
a12B
a22 B aalqB
2q B 1 B.L. Leong, M.B. Monagon, and S.M.
Watt. Maple V Language Reference Manual.
A®B= .. ..
. . Springer-Verlag, New York, 1992.
aq1B aq2 B a qq B pr xq.
(34) [7] A. Deif. Sensitivity Analysis in Linear Sys-
tems. Springer-Verlag, Berlin, 1986.
A.6 Kronecker Product Rule [8] M. Eslami and R.S. Marleau. Theory of sen-
The derivative of a Kronecker product with re- sitivity of network: A tutorial. IEEE Trans-
spect to a vector , v, is actions on Education, 32(3):319-334, 1989.
(A ® B)(11I) = A(lv) ® B + U(B(11I) ® A) (35) [9] A. Graham. Kronecker Products and Ma-
triz Calculus with Applications. Ellis-Howard
where U is a permutation matrix defined as Ltd., Chichester, 1981.
p r
[10] E.J. Haug, K.K. Choi, and V. Komkov. De-
U = LLEii ® Ei; (3(i) sign Sensitivity Analysis of Structural Sys-
i=l i=l
tems, volume 177 of Mathematics in Science
and Eii is an 'elementary' matrix of size p x r and Engineering. Academic Press, New York,
with single non-zero element eii = 1. 1986.
126
[13] P.H.O'N. Roe. Networks and Systems.
Addison-Wesley, Reading, Mass., 1966.
[14] G.J. Savage. Automatic formulation of
higher-order sensitivity models. To appear:
Civil Engineering Systems, 1993.
[15] G.J. Savage and H.K. Kesavan. The graph-
theoretic field model - I: modelling and for-
mulations. Journal of the Franklin Institute,
307(2):107-147,1979.
Biographies
Gordon Savage is an Associate Professor, and
Stephen Carr is a doctoral student, in the Depart-
ment of Systems Design Engineering at the Uni-
versity of Waterloo. Research interests of both
authors include modelling and simulation of en-
gineering systems using graph theory, with appli-
cations to design based on reliability and quality
criteria.
The authors may be reached at
Department of Systems Design
University of Waterloo
Waterloo, Ontario
Canada, N2L 3G 1
[email protected]
[email protected]
127
EXACT CALCULATION OF THE KAPLAN-MEIER BIAS
USING MAPLE SOFTWARE
Brenda Gillespie, Justine Uro
Department of Biostatistics, University of Michigan, Ann Arbor MI, USA
128
on computer simulations. However, it 2. Calculation of the Kaplan-Meier
is possible to express the bias exactly in bias
terms of multiple integrals. If these inte- In the original definition of the KM es-
grals are explicitly evaluable, then one can timator (Kaplan and Meier, 1958), the es-
compute the bias exactly using symbolic timator is not defined past the fast data
mathematical software such as Maple. We point if that point is censored. To compute
have developed a Maple program to per- the bias, however, some definition must
form these calculations. Higher moments be given in this situation. So-called com-
of the KM estimator (yielding variance, pletion methods have been developed by
skewness, etc.) may be computed in a sim- Efron (1967), Gill (1980), Brown, Hollan-
ilar manner using this program. der and Korwar (1974) and Moeschberger
The program is based on expressing the and Klein (1985). Estimators based on
probability of each possible KM estimate completion methods are bounded below
value as a multiple integral, given known by the method of Efron, who suggested
survivor and censoring distributions. We S(t) = 0 for t > tn, the last observation,
enumerate all possible cases, i.e., all pos- whether or not tn is censored; they are
sible values that the KM estimate could bounded above by the estimator of Gill,
assume. For a given sample size nand who suggested S(t) = S(tn) for t > tn.
a fixed point in time t, the value of the
KM estimator depends on how many sam- We denote the Gill version by Sa(t), and
ple values are less than t, and the pattern note that this is the definition that was
of censored and uncensored values among used in expression (1). We illustrate the
those observations. If there are r < n sam- calculation of the KM bias with the Gill
ple values less than t, there will be 2r sit- completion method in this paper, although
uations to evaluate since each value may modification of the bias calculation for
be either exact or censored. To enumerate other completion methods is straightfor-
these cases, we generate a sequence of bi- ward. In the sequel, we use the notation
nary integers from zero to 2r -1 (left-filled Sa(t) whenever the statement applies only
with zeros), where in each binary number, to the KM estimator with the Gill comple-
a zero digit represents a censored observa- tion method. If the statement applies with
tion and a one represents an exact observa- any completion method, we use the nota-
tion. Each binary string defines a multiple tion S(t).
integral, with integrand components speci-
fied by the binary sequence. Evaluation of The bias of S(t) as a function of t, B(t),
the multiple integral yields the probability is formally defined as B(t) = E[S(t)] -
of the associated KM estimate, from which S(t), where E[.] is the expectation (mean)
the KM expectation and the bias can be operator. The bias of S(t) has been
calculated. discussed by Efron (1967), Meier (1975j'
This application of Maple has resulted Chen et al. (1982), Geurts (1985, 1987 ,
in an exact result where only an approxi- Klein (1988), and Gillespie et al. (1992.
mate result was previously available. Sam- The bias of Ba(t) is positive (Klein, 1988)
ple size is a limiting problem since the to- and increases to an asymptote as t --+ 00.
tal number of integrals to be evaluated is
2n+1_ 2, where n is the sample size. Some Let X and Y denote the (unobserved)
improvements to the algorithm which re- random variables for the failure and cen-
duce the number of calculations are cur- soring times, respectively, and assume that
rently under investigation. X and Yare independent. The observed
random variables are T = min (X, Y) and
Statistical details of the calculation are
given in Section 2. A description of the
a, the censor code, which equals 1 if X ~
Y and zero otherwise. Sample values of
Maple implementation is given in Section the ~iven random variables are denoted
3. Some efficiency considerations are dis- (ti' ai). The method for computing mo-
cussed in Section 4, and conclusions are ments of the KM estimator in the gen-
given in Section 5. eral case can be given in terms of inte-
129
grals of the joint distribution of T and O. f(x) and g(y), respectively. Let the sup-
The number of multiple integrals which port (i.e., the range of values where the
must be calculated equals the number of random variable has positive density) of
possible values that S(t) may take at any f(x) and g(y) be (0, u x ) and (0, uy), re-
time point with various sequences of fail- spectively, where U x and U y could be infin-
ures and censored values. For example, ity. Then the joint c.d.f. of T and 0 (the
to calculate the KM bias at some fixed joint c.d.f. of a continuous and a discrete
time t, first suppose that t falls between random variable) is given by:
the ith and (i + 1)th observation, i.e.,
ti < t < ti+l. Then there are 2i possi- FT,s{t,o = 0) = Jo{tlU,,"
y f(x) g(y) dx dy,
ble unique sequences of Os and Is prior to
t, and thus 2' potentially unique values of
S(t). Taking the sum over the i = 0 ... n
possible positions for t relative to the tis
FT,S(t,o = 1) = lot i U
7/ f(x) g(y) dy dx
and summing the geometric series, we have
with the densities, fT,S(t,o = 0) and
fT,s( t, 0 = 1) obtained by differentiation
with respect to t. The regions of integra-
tion above are illustrated in Figure 1 be-
low, where region A applies to FT,s(t,o =
This is the number of cases which must 0) and region B applies to FT,S(t, 0 = 1).
be considered, but the single case when all Figure 1. Regions of integration
data values are greater than t does not re-
quire integral evaluation. Thus, the num-
ber of multiple integrals which must be uyt------,
calculated is 2n +1 - 2, which will be com-
putationally feasible for small n. Table 1 (0 = 1)
below gives some values of 2n +1 - 2 for il-
lustration. Y
Table 1. Number of integrals B
evaluated for several values of n
t
n Number of Integrals
A (0 = 0)
2 6
5 62
10 2,046 t
20 2,097,150 X
We can combine the two sub-densities into
The cumulative distribution function a single expression for the joint distribu-
(c.d.f.) of a random variable, X, is the tion of T and 0 using indicator functions.
probability that X is larger than some For compact notation we define fa (t) =
fixed value, say x, as a function of x, and fT,s(t,o = 0) and fb(t) = fT,S(t, 0 = 1).
is usually given an upper case letter, e.g.,
F(x). Note that the c.d.f. is 1 minus
the survivor function for continuous ran-
fT,s(T,o) = fa(t) 1[0 = 0] + fb(t) 1[0 = 1]
dom variables. The density function is the where 1[·] is an indicator function which
derivative of the c.d.f.; the probability that equals one if the condition is true and zero
X falls into a certain interval can be ob- otherwise. This joint distribution will be
tained by integrating the density function used below.
over that interval. With these informal
definitions, denote the c.d.f.s of X and Y The method of obtaining the expected
by F(x) and G(y), and the densities by value of S(t) uses conditioning: Let the
130
set of possible sequences of Os and Is prior e- 2t, and P(W2) = J~ go e-Xe- Y dx dy =
to t be denoted by 11, where 11 has 2n-Fl_1 1- ~e-2t. Thus,
elements, generically denoted w. Then
131
to get n!(a1a2 + a1b2 + b1a2 + b1b2), we from which the bias is obtained by sub-
have the sub-densities for every arrange- tracting S(t).
ment of censored and exact values (i.e., 3. Maple implementation
(0,0),(0,1),(1,0),(1,1)). Then, for exam-
ple, if Wi = {I}, which indicates that The first part of the program defines the
T1 ~ t < T2 and 61 = 1, then P(Wi) = failure and censoring densities, f( x) and
g(y), and the sub-densities (fT,s(t,6) for
It' I~ fb(t1)(fa(t2) + fb(t 2)) dt1dt2· Note 6 = 0,1), which we refer to as fa(t) and
that for positions for which t < Ti, the
terms for fa and fb may be summed. fb(t), respectively.
In general, if Ti is the ith order statistic pdf1:-proc(x) f(x) end:
with associated censor code 6i , the joint pdf2:=proc(y) g(y) end:
distribution of (Tb 61 , ••• , Tn, 6n) is given fa:=proc(t)
by n! times the following product: diff(int(int(pdf1(x) *pdf2(y),
x=y .. ux) ,y=O .. t) ,t)
(fa(t1) 1[61 = 0] + /b(t1) 1[61 = 1]) end:
·(fa(t2) 1[62 = 0] + fb(t 2) 1[62 = 1]) fb:=proc(t)
diff(int(int(pdf1(x) *pdf2(y),
y=x .. uy) ,x=O .. t) , t)
end:
'(fa(tn) 1[6n = 0] + fb(t n) 1[6n = 1]). fab:=proc(t)
Multiplying out, this expression equals a fa(t)+fb(t)
sum of terms, each corresponding to a end:
unique sequence of O's and 1'so
For example, if n = 4 and {61 , ••• ,64 } = The structure of the program after these
{O, 1, 1, O}, the correspondmg term is function definitions is illustrated in Figure
4! fa(t1) fb(t 2) fb(t 3) fa(t 4). This term 2 below.
can be integrated to give probabilities of Computation of the expected value of
corresponding ws. To find P(w) for cases S(t) entails enumerating the elements w of
in which t is not larger than all data val- n. This is done by considering two nested
ues, the terms for fa and fb are summed do .. od loops, as shown below.
for the positions after t since S(t) only de-
pends on censor codes prior to t. For ex- for i from 0 by 1 to n do
ample, to find P(w) for w = {O, 1, I}, with
n = 4, we have
for j from 0 by 1 to (2 i)-1 do
A
bj:=convert(j,binary):
P(w) = P[t3 < t < t 4, and lbj:=length(bj):
if j=O then lbj:=1 fi:
61 = 0, 62 = 1, 63 = 1, 64 = {O or I}] x:=1:
Gshat :=1:
= 1 00
lot fot3 fot2 4! fa(td fb(t2) fb(t3) (other program statements)
od:
'(fa(t4) + fb(t 4)) dt 1 dt 2 dt3 dt 4. od:
The Kaplan-Meier estimate, given w is:
The outer loop, indexed by i, is the num-
2 1 1 ber of sample values that are less than t.
S(t) I w = 1 . 3' 2: = 3'
A
132
converting the integers from 0 to 2i_1 to a puted. To compute the probability, an n-
binary string, b j. If j =0, corresponding to fold integral is evaluated. The limits of in-
all observations censored prior to t, then tegration for the probability depend on i,
the length of bj must be set equal to one. and the integrand of the multiple integral
If the length of the string generated, 1bj, depends on the pattern of the Os and Is
is less than i then i -1 bj zero( s) could be and on i. Each computation requires indi-
added to the left of the string to yield i vidually stepping through all n positions to
digits. As an alternative to actually left- iteratively calculate the KM estimate and
filling with zeros, we loop over these po- to iteratively perform the multiple integra-
sitions separately, as shown in Figure 2. tion. The n steps are performed within do
Thus, left-filling with zeros is implied but . . od loops, split into three cases (see
not actually performed. Figure 2). The first case, indexed by k1,
Since the calculations are built as suc- loops through any leading zeros; the sec-
cessive products, we initialize the proba- ond case, indexed by k2, loops through the
bility, x, to 1 and the expected KM (Gill binary digits from the first 1 until the i th
version) estimate, Gshat, to 1. digit; the third case, indexed by k3, loops
through the positions following i. In the
Figure 2. Structure of the program first two loops, the KM estimator is re-
Generate all Wi E O. cursively calculated. In all three loops the
i=l to n Each Wi is a binary calculation of P(Wi) is continued.
j=l to 2i_1 string of length i, In the first loop, indexed by k1, no up-
constructed by con- date of the KM estimator is needed since
verting j to binary censored observations do not change the
form, with leading value of the KM estimate. The contribu-
zeros implied. tion of these censored observations to the
probability P(w..} is obtained by calcu-
lating an (i-1bj)-fold integral as follows,
where the appropriate t variable (tb t 2,
k1=1 to i-1bj etc.) is obtained by concatenating t with
the looping index, k1:
(1ooP. through the for k1 from 1 by 1 to i-1bj do
leadmg zeros)
x:=int(x*fa(t.kl),
(t.kl)=O .. (t.(kl+l)))
od:
k2=i-1bj+1 to i
(1~op
The lower limit of integration is always 0
and the upper limit of the kith integral is
thrqugh the
[ bmary dIgitS) tlc1+l'
Next we loop over the index k2, which
consists of the (i-1bj+1)th digit to the
k3=i+1 to n i th digit of the binary string constructed.
The KM calculation is performed (Gshat),
which only requires updating at an uncen-
(loop through the sored value, i.e., a censor code equal to
digIts after t) 1. The KM estimate decreases by a fac-
tor of (~~j~~)l) if a 1 is encountered and
does not change if a zero is encountered.
The calculation of P( Wi})' is continued as
1bj steps of the multiple integration. We
For each W€O, the KM estimate and the define fs:=fa(t.k2) when a 0 is encoun-
corresponding probability have to be com- tered and fs :=fb(t .k2) when a 1 is en-
countered. The variable d stands for delta
133
(8), which is the censor code, and d takes integral whose upper limit is the upper
the value of each digit of the binary string, bound of the support of the failure distri-
one by one. Since the substring operator bution.
cannot be applied to an integer (Le., bj), At this point, we now have the KM es-
we concatenate the single letter q to the timate (Gill version) and the associated
front of bj. The positions read in the bi- probability, given by P(Wij) = nIx for this
nary string are then from 2 to lbj+1. specific element of n. The two are mul-
tiplied together and accumulated in the
for k2 from i-lbj+1 by 1 to i do variable Gm (for the Gill version) as given
d:=substring(q.bjJ(k2-i+lbj+1) .. in equation (2).
(k2-i+lbj+1»: After the outer loops are completed, the
if d='O' then bias is attained as the difference between
fs:=fa(t.k2): the true survival time based on the actual
else failure density and the expected KM esti-
fs:-fb(t.k2): mate (accumulated in Gm).
Gshat:=Gshat*«n-k2)/(n-k2+1»:
fi: Some results from this program are pre-
if k2<i then sented in Table 3 below. In the situa-
x:=int(x*fs J (t.k2)=O .. tions where exact values can be checked
(t . (k2+ 1) ) ) : (Case 1 in the table), the Maple results
elif k2=i then agree exactly with the theoretical results,
x:=int(x*fsJ(t.i)=O .. t): as expected. In other situations (Case 2
fi: in the table), the Maple results give much
od: more accuracy than was available from
published simulations.
Observe that the lower limit of integration
is always zero and the upper limit of the Table 3: Results from a
k2th integral is tk2+1 except for the i th in-
Maple program
tegral which has upper limit t.
We are finally left with the n-i outer- Case 1: X and Y both have the
most integrals which correspond to those exponential(.A = 1) distribution
observations which are greater than t (Fig- Exact bias Exact bias
ure 2). It does not matter whether these (Maple) (Chen et al.)
observations are exact or censored: The
calculation of the KM estimate only de- t = 1/2 -.0017 -.0017
pends on observations up to the i th, and t =1 -.0339 -.0339
for the calculation of P(Wij), integration is t=2 -.0742 -.0742
over the sum, fab(t)=fa(t)+fb(t) which Case 2: X distributed exponential(l), Y
is the marginal density of t. The do .. distributed Uniform(O, b), where b is spec-
od loop, indexed by k3 gives the contribu- ified to give P( censoring)=1/3
tion of these observations to P(Wij).
Exact bias Simulated bias
for k3 from i+1 by 1 to n do (Maple) (Geurts)
if k3<N then t = 1/2 -.000006 -.00
x:=int(x*fab(t.k3)J t =1 -.004279 -.00
(t.k3)=t .. (t.(k3+1»):
else t=2 -.045279 -.05
x:=int(x*fab(t.n)J(t.n)=t .. ux): Although the current program is only
fi: usable with density functions which are re-
od: peatedly integrable, it may be possible to
use Taylor series or other integrable ap-
The lower limit of integration is t while proximations for densities which are not
the upper limit is tk3+b except for the last explicitly integrable.
134
4. Efficiency considerations satisfaction of obtaining an exact rather
We were able to run this program with than an approximate answer.
n as large as 9. We were able to get results References
for n = 10 by running the outer loop sep-
arately for i=l to 9 and i=10, and sum- 1. Brown, B.W., Hollander, M. and Ko-
ming the results. The program for n = 9 rwar, R.M. (1974). Nonparamet-
took several hours on a SUN Sparcstation ric tests of mdependence for cen-
2 with 16 megs of RAM. sored data, with applications to heart
It is unlikely that significant savings can transplant studies. In Reliability and
be obtained by modifications of the exist- Biometry, Statistical Analysis of Life-
ing program. We have considered switch- length, F. Proschan and R.J. Ser-
ing the order of the two outer loops in or- fling (Eds.), Philadelphia: Society for
der to save some intermediate calculations Industrial and Applied Mathematics,
for future steps. An alternative which may 327-358.
be more promising may be inferred from
Meier (1975), who suggested that con- 2. Chen, Y.Y., Hollander, M. and Lang-
tributions to the Kaplan-Meier bias only berg, N.A. (1982). Small-sample re-
arise from the situation when t is beyond sults for the Kapfan-Meier estimator.
the last data point. If we could limit our- J. Am. Statist. Assoc. 77,141-144.
selves to this case, we would save a power
of 2 in the number of calculations required. 3. Efron, B. (1967). The two sample
In addition, another power of 2 could be problem with censored data. Proceed-
saved since all strings ending in 1 (when ings of the Fifth Berkeley Symposium
t > Tn) have KM estimate set) = 0,
on Mathematical Statistics and Prob-
ability 4, 831-852.
so P(Wj) need not be calculated. Thus,
the numbe~ of integrals to, be calculated 4. Geurts, J.H.J. (1985). Some small-
would be 2,-1 instead of 2'+1 - 2. These sample non-proportional hazards re-
improvements would potentially raise the sults for the Kaplan-Meier estimator.
evaluable sample size to between 10 and Statistica Neerlandica 39, 1-13.
15. Since the KM bias becomes negligible
for sample sizes larger than, say, 25, there 5. Geurts, J.H.J. (1987). On the small-
is still a gap between current computing sample performance of Efron's and of
power and desired results. Gill's version of the product limit es-
5. Conclusions timator under nonproportional haz-
ards. Biometrics 43, 683-692.
The Maple program described here car-
ries out an exact calculation for a problem 6. Gill, R.D. (1980). Censoring and
which was previously thought to require Stochastic Integrals. Mathematical
computer simulation. The Maple meth- Centre Tract No. 124. Amsterdam:
ods which proved useful were the ability Mathematisch Centrum.
to generate all possible cases using incre-
mented binary strings, and then using the 7. Gillespie, B.W., Gillespie, J.A. and
generated sequences to specify the compo- Iglewicz, B. (1992). A comparison
nents of multiple integrals. of the bias in four versions of the
Drawbacks of the Maple implementa- product-limit estimator. Biometrika
tion include the large memory (RAM) re- 79, 149-155.
quirements, and the length of time re-
quired to run the program, both of which 8. Kaplan, E.L. and Meier, P. (1958).
limit the possible sample size. In addition, Nonparametric estimation from in-
this method only yields exact results when complete observations. J. Am.
the original functions are explicitly inte- Statist. Assoc. 53, 457-481.
grable. The advantages of the Maple im- 9. Klein, J.P. (1988). Small sample
plementation are greater accuracy and the properties of censored data estimators
135
of the cumulative hazard rate, sur-
vivor function, and estimators of their
variance. Research Report 88/7, Sta-
tistical Research Unit, University of
Copenhagen.
10. Meier, P. (1975). Estimation of a
Distribution Function from Incom-
plete Observations. In Perspectives
in Probability and Statistics, J. Gani
(Ed.), Sheffield, England.: Applied
Probability Trust, 67-87.
11. Moeschberger, M.L. and Klein, J.P.
(1985). A comparison of several
methods of estimating the survival
function when there is extreme right
censoring. Biometrics 41, 253-259.
Biographies
Brenda Gillespie is an Assistant Pro-
fessor in the Department of Biostatistics,
University of Michigan. She received her
Ph.D. in Statistics in 1989 from Temple
University in the area of survival analy-
sis. Contact address: Department of Bio-
statistics, University of Michigan, 109 S.
Observatory, Ann Arbor, MI 48109-2029.
e-mail: [email protected].
Justine Uro is a doctoral student in the
Department of Biostatistics, University of
Michigan. He obtained his B.S. (1987)
and M.S. (1990) in Mathematics from the
University of the Philippines, and M.S.
(1992) in Biostatistics from the University
of Michigan. Contact address: same as
above. e-mail: [email protected]
136
ROTATIONAL ENERGY DISPERSIONS FOR VAN DER
WAALS MOLECULAR CLUSTERS
Lawrence L. Lohr, Carl H. Huben
University of Michigan, Ann Arbor MI, USA
°
SF6 • More detailed studies followed (Refs. (2-4» for
H20, 3 , and PH3 , as well as an outline of a
generalized extension of the method (Ref.(5». The
Mathematical Computation with Maple ~
Ideas and Applications procedure is structurally oriented, that is, it focuses
10m Lee, Editor on the question of the size and shape of molecules
@1993 Birkhliuser Boston with nonzero rotational angular momentum.
137
Centrifugal distortion spectroscopic constants are a fragmentation of the cluster Ar l3 • Our study is
very useful form of our computational output, focused on the smaller clusters A3, A4 , and ~, where
providing an important and indispensable basis for A is an unspecified "particle" having UO
comparison to experimental observations, yet their interactions, with most of the results being obtained
computation is in a way secondary to the main task. and characterized analytically by use of the Maple V
Stated differently, our studies are an exploration of system.
molecular energy in those regions of nuclear-
coordinate hyperspace which are accessible by IT-Outline of Procedure
centrifugal distortions from the equilibrium geometry .
In the most recent of our studies (Ref.(6» For a polyatomic molecule we consider the
we confined our attention to diatomic molecules as total electronic energy Ecl (within the Born-
modeled by harmonic oscillator (HO) , Morse Oppenheimer approximation) as a function of a set of
oscillator (MO), and Lennard-Jones oscillator (UO) internal nuclear coordinates Q = {Qi}, that is,
potential energy functions. By drawing upon the Ecl = Ecl(QIQ2Q3···Q,) = Ecl(Q)· (1)
capabilities of the Maple V mathematical problem- The energy of rotation about the center of mass may
solving system we obtained closed-form analytic be expressed classically in terms of these same
expressions, parametric in the centrifugal coordinates via the moment of inertia tensor I(Q) and
displacement, for the dependence of the classical the rotational angular momentum J, where J = 1&,
rotational energy upon the rotational energy with t> being the angular velocity, as
momentum, that is, the rotational energy dispersion E rot = Erot(Q,J) = (1I2)J1 r l J, (2)
for each of these three model potentials. Further, where I-I is the inverse of the matrix I and J 1 is the
through power-series reversions of the angular transpose of the vector J. Thus the effective
momentum as a function of displacement we obtained "potential" energy governing the motion of the nuclei
Pade approximants for the rotational energy is given by the J-dependent sum of Ecl and E rot , that
dispersions which approximate well the exact is, by
parametric solutions and which may be used for Eca{Q,J) = Ecl(Q) + Erot(Q,J), (3)
fitting experimental spectroscopic data as they do not where the Q dependence of E rot and thus of EcIT is
display the high angular momentum divergences via the moment of inertia tensor I(Q).
associated with traditional power series For a number of purposes we seek extrema
representations of the energy. A particularly in nuclear coordinate space Q = {Qi} of the effective
interesting result for the diatomic UO is that the energy EcIT. One important purpose is to find the
maximum stable centrifugal displacement is only rotational energy dispersion Eca{J) corresponding to
(5/2)1/6_1 = 0.16499 in units of the equilibrium the set of minima which classically are continuous
separation for the non-rotating molecule; larger with respect to both the magnitude and direction of J
separations lead spontaneously to dissociation. in the molecular frame. For such extrema of EcIT' not
In our present study we continue the use of
only do we require that V(EcIT) = 0, but also that the
the Maple V system to obtain and characterize
Hessian (second-derivative) matrix have positive
analytic descriptions of the rotational energy
eigenvalues. In many cases the rotational energy will
dispersions for deformable molecules. Specifically
we expand the previous study (Ref. (6» of the depend on only a subset, say m in number, of the
Lennard-Jones (UO) diatomic to include larger total number, say n, of nuclear coordinates {Q;}. In
clusters formed from atoms (or molecules) bou~d such cases there will for a given J m equations of the
together by pairwise-additive UO interactions. Such type Vi(Ecl + E~ = 0 and (n - m) of the type ViEcl
systems serve as excellent models for real clusters = o. These conditions defines in principle a
formed from rare-gas atoms or other closed-shell centrifugal distortion pathway Q(J), although
moieties. Indeed there have been many studies in typically we cannot obtain it analytically and thus
recent years (Refs.(7-20» describing the structures, cannot obtain the desired rotational energy dispersion
stabilities, and dynamics, both rotational and Eca{J) analytically. However expressing the pathway
vibrational, of such clusters with a particular focus on as J(Q) and substituting in Eca{Q,J) yields Eca{Q),
those formed from the rare-gas argon (Ar). Perhaps which together with J(Q) defmes the dispersion
the closest in style to our present study is that of Li parametrically. Thus in many cases we can represent
and Jellinek (Ref. (13», who used a simulation the dispersion Eca{J) by the pair of analytic
program to explore the distortion, isomerization, and relationships Eca{Q) and J(Q). In the remainder of
138
this paper we present such analytic parametric diatomic Ar2 are the same as those used by Leitner et
rotational energy dispersions for van der Waals al. (Ref. (12» in their study of the cluster Ar3,
molecular clusters and show how they may be used namely q = 3.40 A, corresponding to re = 3.82 A,
to extract higher-order (quartic and above) and d = 84.1 cm- I • Other sets of Ar2 parameters
spectroscopic constants. have also been proposed or used (Refs.(21-25». For
the isotopic species 4OAr2 the rigid-rotor constant Be
ill - The Lennard-Jones (6-12) Potential = 1i2/2p,re2 = 0.058 cm- I , where Ii is Planck's
and van der Waals Clusters constant h divided by 271" and p, is the reduced mass
m(40Ar)/2, so that the dimensionless reduced rigid-
The molecular systems whose rotational rotor constant (3 = B.Jd = 6.878 x 1<r4.
energy dispersions we wish to characterize are the
weakly bound clusters of closed-shell molecules IV - Analytic Rotational Energy Dispersions
known as van der Waals clusters. Typical examples
include clusters of rare-gas atoms or clusters of such In Table I we present analytic rotational
molecules as carbon dioxide CO 2 or sulfur energy dispersion relationships parametric in centrifu-
hexafluoride SF6. Such clusters, and particularly gal displacements for a number of simple cases,
those comprised of rare-gas atoms, are often modeled namely for the UO clusters A2, A3 (J II C3 and J II C~,
by a total electronic energy EelQ) taken as a sum of A4 (J II S4 and J II C3), and ~ (J II C4 and J II C3), with
pairwise-additive Lennard-Jones (6-12) oscillator the expressions for ~ being for the simplified model
(UO) potential energy terms, where each term is of neglecting the three trans interactions. For simplicity
the form of notation we denote the dimensionless reduced
V(r) = 4d[(olr)12 - (O/r)6]. (4) effective energy Een<Q)/d = een<Q) as "e", with no
In the above d is the well depth and q is the subscript. In each case the expressions are in terms
"collision diameter." The attractive (negative) r·6 of a single structural parameter z = (1 + Xy2, where x
represents the London dispersion energy associated is the reduced displacement, with the tabulation
with the interaction of instantaneous electric dipole giving the integer coefficients a and b which multi-
moments, while the repulsive (positive) r- 12 term is a ply the basic expressions. Further, the angular
convenient representation. The equilibrium separa- momentum J is taken as dimensionless (as a multiple
tion re is given by 2116q . For purposes of this study of Ii) throughout this entire section and considered
we find it convenient to re-write Eq. (4) by defining classically, so that J may be aligned with a principal
a reduced displacement x = (r - rJ/re and a new rotation axis of the molecule. If desired the quantity
variable z = 1/(1 + X)2 = (re/r)2, and by adding d to Y may be equated to the quantum number expression
the energy, giving J(J + 1). For the simple cases in Table I we fmd:
V(z) = d (1 - z/)2. (5)
(7)
Further, dividing by d yields the dimensionless
reduced form
v(z) = V(z)/d = (1 - z/)2. (6)
(8)
This form resembles that for the harmonic (Hooke's
Law) oscillator, but with the potential energy being
proportional to the square of a function of the The (3 parameter in Eq.(7) and in Table I is for
displacement instead of to the square of the displace- diatomic A2 in each case; this enables direct compari-
ment itself. Further, as will be shown, many analytic sons of the expressions for different sized clusters.
relationships for pairwise-additive UO systems have In the remainder of this Section 'We present the
the form of polynomials in the displacement-related corresponding expressions for several cases not
parameter z. representable in terms of a single structural parame-
While most of our results will be presented ter.
and discussed for the dimensionless reduced form For A3 (D3J with J.L C3 and C2 (the Jy case)
(Eq. (6» for the UO potential energy, thus making the actual molecular symmetry is C2v ' with two edges
them applicable to any UO clusters made up of extended and one (parallel to J) slightly compressed.
identical moieties, we do present some numerical We designate the two structural parameters as z =
results for one very important class of examples, (l+x)-2 and Z=(1+X)-2, respectively, where x and
namely van der Waals clusters of argon (Ar) atoms. X are the corresponding reduced displacements. The
The parameters we have selected for the reference dispersion relations may be expressed parametrically
139
in terms of these two variables as follows: ciated atoms the energy at J = 0 is (588/257)-15, or
-12.71206. Note also that {3 in Eqs. (12) and (15) is
(9) the value for diatomic A2 , so that rigid-rotor energy
is given by (3Pz)4.
Again for the ~ cluster but with J I C4 , so
that the actual symmetry is D 4h , there are 4 edges
(10)
described by the parameter z, 8 edges by the parame-
ter t, two trans distances described by z/2, and the
unique trans distance, that parallel to J, described by
Z. The moment of inertia, as for the case of J I ~,
(11)
depends only upon z. The rotational energy disper-
sion is represented by the following:
Because of the interdependence in Eq. (10) of the pJ2=96z 2(1-z3) + 24(z/2i(1-(z/2)3) (16)
parameters, the energy depends in effect on a single - 48(Z4/Z 2)(1-Z3)
variable.
For ~ (OJ symmetry with J II C3 the actual
molecular symmetry is D3d , with the 12 edges being
(17)
comprised of two sets of 6, described by the parame-
ters z and t, and the 3 trans distances being equal
and described by the parameter Z, with the moment
of inertia depending only upon z. The rotational
Z=z(f(2(2z-m (18)
energy dispersion, including these latter interactions,
is represented by the following:
140
Eqs. (9-11). The Maple V system was invaluable in value for diatomic A z; these may be converted
the solution of these and related non-linear equations (Ref. (1» to the "spherical" and "cubic" tensor
through the ease with which one can obtain numerical coefficients o. and Ot as shown. The latter has a
solutions. We note that the ratio E.lEy, identically limiting value of 11160 in units of the diatomic o.
equal to unity for a rigid symmetric top, falls to Although small, this coefficient is the critical measure
0.97738 at the maximum of Ex = 1.8. Similarly the of the nonspherical effects of centrifugal distortion
ratio 2E.lEy rises from unity to a value of 1.11812 at and is a measure of the associated splittings of the
the maximum for Ey. These deviations from unity rigid spherical top rotational energy levels. Finally
reflect the non-rigidity of the A3 rotor. In Figure 1 we note for A4 that the square-planar structure,
we show the rotational energy surface in J-space, that unstable for zero or low angular momentum with
is, the variation of the energy E with respect to the respett to an out-of-plane puckering leading to a
direction of J in the molecular frame for some fixed tetrahedral structure, actually becomes the stable
magnitude of J. The surface is not cylindrically form past the energy maximum of 3.6 for the J " S4
symmetrical as it would be for a rigid symmetric top, case; this behavior, in which the tetrahedron "collaps-
but rather possesses six-fold rotational symmetry es" into a plane, is similar to that described above for
(there are three C z axes, with clockwise and coun- A3 becoming linear past the energy maximum of 1.8
terclockwise rotations about each having the same for the Jx case.
energy, hence there are six equivalent directions in J- The octahedral cluster ~ differs from the
space). We further note that past the energy maxi- preceding in that there is no arrangement permitting
mum of 1.8 for the Jx case that the preferred struc- all interacting pairs to be at the diatomic equilibrium
ture is actually collinear; the triangular molecule separation rc. The resulting "compression" of the
"snaps" open! octahedron was discussed in Section IV. Reduced
It is useful to extract (Ref.(1-6» reduced energies were found for three cases, namely J " C3
quartic coefficients 0 from these energies, that is, the (D 3d), J II C z (D~, and J II C4 (D~. All interac-
coefficients of J4 in traditional power series expan- tions, including the three trans interactions, were
sions of rotational energies. We do this not from included in each case. As with tetrahedral A 4 , the
rotational constants and vibrational frequencies but case with J II C3 is highest in energy, thus corre-
rather from the "centrifugal stabilization energies," sponding to eight energy maxima on the rotational
defined as the difference in energy between rigid and energy surface. This result is somewhat surprising,
non-rigid rotors with the same angular momentum. as the molecules CH4 (tetrahedral) and SF6 (octahe-
Specifically the quartic coefficient is taken as the dral) are known (Ref.(27» to have opposite behav-
limit as J approaches zero of the stabilization energy iors; the J II C3 corresponds to rotational energy
divided by J4; in reduced units of the diatomic Az maxima for CH4 but minima for SF6. Thus the
well depth it becomes the limit of the reduced reduced quartic coefficient Ot for ~ has the same sign
stabilization energy divided by the square of {JP. as that for A 4 , although the magnitude is a factor of
Expressed in these reduced units the diatomic value seven smaller (0.00093 for ~ vs 11160 = 0.00625
of 0 is {Jz/36; the J = 0 limiting values for A3 are the for A4). The Maple V system was again a very
fractions 1, 1, and 1112 of this diatomic value for the powerful tool, greatly facilitating the determination of
Jx' Jy, and Jz cases, respectively. The fact that the these limiting (as the angular momentum approaches
values are the same for the Jx and Jy cases indicates zero) reduced quartic coefficients.
that the energy differences between these two cases
as shown by the rotational energy surface are associ- VI - Swnmary
ated with a higher-order term, namely sextic (J6), in
a power series expansion, corresponding to the six- We have made extensive use of many
fold symmetry described above. features of the Maple V problem solving system in
We similarly obtained numerical results for carrying out a theoretical and computational investi-
the tetrahedral cluster A 4 • The two cases are for J " gation of the properties of van der Waals cluster
C3 (C3v) and J " S4 (D2d). The striking result is that molecules. Specifically we have studied the rotation-
the latter is energetically preferred for a given al energy dispersions of small clusters bound by pair-
angular momentum, that is, this deformable spherical wise Lennard-Jones interactions; these clusters model
top will make itself into a symmetric top with a those formed from rare-gas atoms or other closed-
preferred S4 axis. The reduced 0 values have J = 0 shell moieties. The dispersion, which represents the
limits of 1112 and 118 in units of the corresponding variation of the energy of the deformable molecule
141
with respect to the magnitude and direction of its 16. T. R. Horn, R. B. Gerber, J. J. Valentini, and
rotational angular momentum, is typically represented M. A. Ratner, J. Chem. Phys. 94, 6728 (1991).
by sets of equations parametric in centrifugal dis- 17. H. Cheng and R. S. Berry, Phys. Rev. B45,
placement coordinates. The Maple V system has 7969 (1992).
been used in the derivation of the dispersion equa- 18. D. M. Leitner, J. D. Doll, and R. M. Whitnell,
tions, in the characterization of their properties, in J. Chem. Phys. 96, 9239 (1992).
the numerical evaluation of their solutions, and in the 19. C. D. Maranas and C. A. Floudas, J. Chem.
two- and three-dimensional plotting of the numerical Phys. 97, 7667 (1992).
results. 20. X. Hu and W. L. Hase, J. Phys. Chem. 96,
Our specific results include quartic spectro- 7535 (1992).
scopic constants obtained analytically from the 21. R. A. Aziz and H. H. Chen, J. Chem. Phys.
rotational energy dispersion relationships for the 67, 5719 (1977).
clusters A 3 , A 4 , and A 6 • Results are expressed in 22. E. Scoles, Anou. Rev. Phys. Chem. 31, 81
reduced, dimensionless units and are thus applicable (1980).
to a wide range of systems, although specific applica- 23. M. J. Ondrechen, Z. Berkovitch-Yellin, and J.
tion is made to argon clusters. A striking result is Jortner, J. Am. Chem. Soc. 103, 6586 (1981).
that for both A4 and ~ the sign of the cubic anisotro- 24. C. Douketis, G. Scoles, S. Marchetti, M. Zen,
py in the dispersions is such that these nominally and A. L. Thakker, J. Chem. Phys. 76, 305 (1982).
spherical tops each display a preference for the 25. R. A. Aziz and M. Salman, Mol. Phys. 58, 679
rotational angular momentum to be along a four-fold (1986).
rotation axis, with angular momentum along a three- 26. L. L. Lohr and C. H. Huben, to be published.
fold axis representing a rotational energy maximum. 27. For a review see G. Natanson, Rev. Mod.
Phys., in press.
References
142
Legend for Figure Biographies of Authors
1. Rotational energy surface for the DO cluster Lawrence L. Lohr, Professor of Chemistry, has
A3• While the (undistorted) molecular symmetry is been on the faculty of the University of Michigan,
D3h , that for the surface is D6h • The upper figure (a) Ann Arbor, since 1968. He is spending the 1992-93
is to scale based on energies of 1.8, 1.84166, and academic year as the Program Officer for Theoretical
0.96800 (units of diatomic A2 dissociation energy) for and Computational Chemistry at the National Science
Jx ' Jy , and J., respectively ({jJ 2 = 9(2/5)5/3 = Foundation, Washington, DC. He received a B.S.
1.95438) and is obtained by interpolations assuming Chemistry degree from the University of North
cos(6lj» and cos(20) dependences. The lower figure Carolina, Chapel Hill, in 1959, and a Ph.D. in
(b) has greatly exaggerated angular variations for physical chemistry from Harvard University in 1964.
emphasis. He spent two years as a Research Associate at the
University of Chicago and three years as a Research
Scientist at the Ford Motor Co. Scientific Laboratory
(Dearborn, MI) before joining the University of
Michigan faculty. He has spent extended periods at
Bell Telephone Laboratories (Murray Hill, NJ), The
a)
University of California (Berkeley), The University
of Georgia (Athens), The Institute for Molecular
Science (Okazaki, Japan), and The University of
Helsinki (Finland). He is the author of more than
one hundred journal articles on various aspects of
both theoretical and experimental physical chemistry.
b)
143
SYMBOLIC COMPUATION IN COMPUTABLE GENERAL
EQUILIBRIUM MODELING
Trien T. Nguyen
Department of Economics, University of Waterloo, Waterloo ON, Canada
The availability of modeling software such as Symbolic computation software such as Maple
GAMS (General Algebraic Modeling System) (see (Char et al. [1991ab)) can be used to assist model-
Brooke et al. [1992]' Meeraus [1983]), originally ers in the process of model building. In this paper,
developed at the World Bank, has allowed mod- we present an interface approach in which Maple
elers to concentrate on economic modeling issues can be used as a front-end preprocessor generat-
while leaving numerical computational aspects to ing outputs in GAMS format which can be later
solvers such as MINOS (Murtagh and Saunders processed by GAMS for large-scale numerical cal-
[1987]). As more modelers in government agencies culations. Conversely, though not considered in
and research institutions are using modeling soft- the paper, it is also conceivable that GAMS (us-
ware for policy analysis, it is much less often that ing the PUT facility) can be used as a back-end
modelers have to write their own solvers in higher postprocessor to generate outputs in Maple format
programming languages such as FORTRAN, Pas- which can be processed by Maple for post-optimal
calor C. analysis such as sensitivity, stability, multiplicity,
and graphical presentations. That is, a two-way
While GAMS allows modelers to concentrate on communication can be made between these two
modeling issues, it is however in this modeling part powerful software tools for the benefits of model-
ers.
The organization of the paper is as follows: sec-
Mathematical Computation with Maple ~
Ideas and Applications tion 2 provides the theoretical background for a
10m Lee, Editor simple illustrative example in CGE modeling. Sec-
©1993 Birkhauser Boston tion 3 shows how the example is numerically solved
144
using a manually-coded GAMS program. This sec- mathematically formulated as the following classi-
tion also serves as an exposition on the structure cal constrained optimization problem:
of GAMS programs for readers who are not fa-
miliar with this modeling tool. Section 4 demon- maxlffilze Ui (Xi!, ... , Xin)
n
strates how Maple can contribute to the modeling
process with Maple-assisted GAMS version of the subject to L Pj Xij = Yi (3)
j=l
program. Section 5 concludes the paper with a
brief summary and conclusions. which can be solved either manually or with
Maple (see subsection 4.2) for household demands
XiI"'" Xin:
2 A Simple Economic Model (Cobb-Douglas)
145
in which case the corresponding price vector is 3.1 Parameter Specification
called an equilibrium price vector. The existence
proof for such an equilibrium price vector is a The data file gexparam. inc listed below declares
non-trivial one requiring fixed-point arguments, in GAMS format various model parameters for
usually in the form of fixed-point theorems by our simple illustrative example. The file consists
Brouwer or Kakutani (see Debreu [1959], Wein- of two declarations: model dimension and pa-
traub [1983]). Much of the development of mod- rameter specification. For model dimension, the
ern mathematical economics during the last four SETS statement defines two index sets, namely,
decades has been centering around this concept of j = {C1, C2, C3} for commodities and i =
general equilibrium. {HI, H2} for households. For parameter specifica-
tion, the PARAMETERS statement declares elastic-
ities of substitution sigma(i), share parameters
3 Anatomy of GAMS delta(i,j), and initial endowments W(i,j).
H2.C1 .2500000000
C1 C2 C3 C1 C2 C3 H2.C2 .3333333333
HI 1 2/9 1/3 4/9 2 3 4
H2.C3 .4166666667
H2 2 1/4 1/3 5/12 3 4 5
I
W(i,j) initial endowments
I
Because GAMS follows the algebraic representa- H1.C1 2.
tion of the model as closely as possible, its pro- H1.C2 3.
gram structure is quite intuitive and transparent. H1.C3 4.
GAMS statements are in free format with a max-
imum line length of 120 characters. Comment are H2.C1 3.
marked by an asterisk (*) in the first column and H2.C2 4.
inline comments are user-definable. Unlike Maple, H2.C3 5.
GAMS is not case sensitive. Separators are com-
I;
mas, semi-colons, and newline characters but re-
laxed punctuation is permitted.
Subsection 3.1 presents the GAMS data file 3.2 The Manually-Coded GAMS
gexparam. inc which specifies necessary param- Solution
eters of the model while subsection 3.2 presents
the main program gexgams. gms which numeri- The manually coded GAMS program gexgams. gms
cally solves the model using a nonlinear program- follows closely, almost in a step-by-step fashion,
ming method. The main program was manually the theoretical framework in section 2. The pro-
coded as usually the case of actual modeling work. gram consists of five building blocks as follows:
146
1. The parameter block reads the data file The objective function object basically re-
gexparam. inc with the $INCLUDE statement. flects the sum of squared deviations of the
Model dimension and parameters are declared value of all market excess demands Zj evalu-
in this block. ated at current market prices. An optimal so-
lution at which this objective function is mini-
2. The variable block has two variable declara- mized, therefore, can be viewed, for practical
tion statements. The POSITIVE VARIABLES purposes, as an approximation of a general
statement declares variables which accept equilibrium with zero market excess demands.
only nonnegative values such as prices p(j),
endowment incomes I (i), and household
Listing of the manually-coded GAMS program
demands X(i,j). On the other hand,
gexgams . gms is as follows:
the FREE VARIABLES statement declares un-
bounded variables such as market excess de-
mands Z(j) and objective function object. ***** GAMS FILE gexgams.gms *****
***** manually-coded *****
3. The equation block spells out the alge-
braic structure of the model and the ob- $INCLUDE "gexparam. inc"
jective function with four EQUATIONS state-
ments: EQ_Y(i) for endowment incomes POSITIVE VARIABLES
Y(i) as in (2), EQ.Jt(i,j) for household p(j) prices
demands X(i,j) as in (4), EQ.2(j) for Y(h) endowment incomes
market excess demands Z(j) as in (6), X(h,j) household demands;
and EQ_obj ect for the objective function
=
object Ej=l (pjZj)2 ~ O. FREE VARIABLES
Z(j) market excess demands
It is this equation block that computer alge-
object objective function;
bra software such as Maple can assist model-
ers in the problem-solving process. The fol-
lowing features of GAMS syntax are notewor- * -----------------------------------
EQUATIONS
thy: (i) the ALIAS (j ,k) statement defines k
EQ_Y(h) endowment incomes (2)
as an additional running index equivalent to
EQ_X(h,j) household demands (4)
j; (ii) summations are written as sum(j, ... )
EQ_Z(j) market excess demands (6)
in contrast with sum(. .. ,j=1. .n) in Maple;
EQ_object objective function;
(iii) the equal sign in equation statements is
denoted by "=E=" in contrast with the usual
ALIAS(j ,k) ;
equal sign "=" in assignment statements.
4. The model block consists of, in this simple EQ_Y(h) .. Y(h) =E=
example, a single MODEL statement which in sum(j,p(j) * W(h,j»;
effect defines the model name as gex (gen-
eral equilibrium in exchange). The specifica- EQ_X(h,j) .. X(h,j) =E=
tion / ALL/ means that all equations EQ_Y (i) , «delta(h,j)/p(j»**sigma(h» *
EQ.Jt(i,j), EQ.2(j), and EQ_object of the Y(h) /
equation block, are used to describe the sum(k,(delta(h,k)**sigma(h» *
model. (p(k)**(1.0-sigma(h»»;
5. The solve block consists of two parts: (i) EQ_Z(j) .. Z(j) =E=
initializing variables by setting lower bounds sum(h,X(h,j) - W(h,j»;
using . LO suffixes for positive variables
(0.000001 for prices to avoid division by zero) EQ_object .. object =E=
and setting levels using . L suffixes for rele- sum(j,(p(j) * Z(j»**2);
vant variables; and (ii) solving the model with * -----------------------------------
the SOLVE statement which in effect instructs
GAMS to minimize the objective function us- HODEL gex /ALL/;
ing a nonlinear programming solver such as
MINOS. Y.LO(h) = 0;
147
X.LO(h,j) = 0; out in full and correctly. Given this analytical
p.LOU) = 0.000001; structure, the remaining task is to code it into
p.L(j) = 1.0; proper G AMS format before specifying a nonlinear
Z.L(j) = O·, programming solver such as MINOS for numeri-
cal solutions. No measurements of time costs to
SOLVE gex MINIMIZING object USING NLP; modelers have been recorded for this tedious and
error-prone manual process of analytical deriva-
GAMS produces the following general equilibrium tion of the equation block required by GAMS. In
solution which shows that household H1 buys C1, this section, we present an interface approach (see
C2 and sells C3 while household H2 sells C1, C2 and figure 1) in which tools in symbolic computation
buys C3. Speaking of the economy as a whole, such as Maple can be successfully used in conjunc-
quantities demanded by both households match tion with modeling software like GAMS. The gen-
exactly with total endowments available. In other eral idea is to use Maple as a front-end processor
words, market excess demands are zero for all com- generating outputs in GAMS format which can be
modities as required by theory. later processed by GAMS for numerical calcula-
tions.
Commodities
C1 C2 C3 4.1 Parameter Block
148
econlib.mpl
gexparam.mpl
,.
gexmaple.mpl
,.
Maple
"
gexparam.inc gexparam.inc gexparam.inc
gexmaple.eqn gexmaple.inc
manual
editing
"
gexgams.gms gexmaple.gms
149
writeto('gexparam.inc'); ity maximization problem (3) for household de-
lprint('***** GAMS FILE mands Xij. Using the Lagrangian method, the
'gexparam.inc *****'); problem is transformed into one of maximizing
lprint (' SETS') ; the Lagrangian .c = Ui (Xil , ... , Xin) + >'(Yi -
lprint(' j commodity I', "£';=1 pjXij) and solving the following first-order
seq(cat( 'e' ,jj,' ,') ,jj=l .. n-l), conditions:
cat ( 'e' ,n) , ' I') ;
lprint(' i household I',
seq(cat('H' ,ii,', ') ,ii=1. .h-l), mrSjk == Pj (8)
cat (' H' ,h) , 'I; ') ; Pk
lprint();
lprint('PARAMETERS'); n
lprint(' sigma(i) L Pj Xij = Yi (9)
'elasticity of substitution'); j=l
lprint(' I');
In economic jargon, mrSjk is called the marginal
for i from 1 to h do
lprint( ,
rate of substitution to describe the extent to which
commodities j and k can be marginally substi-
cat('H' ,i),
tuted for each other without jeopardizing house-
evalf(sigma[i]»
hold utility. The exponential term -(lilT;) on the
od;
unknown variable Xij in equation (8) is the main
lprint(' I');
source of nonlinearity which makes a direct ap-
lprint(' delta(i,j), ,
plication of Maple's built-in solve routine unsuc-
'share parameters');
cessful. However, a bit of human touch by raising
lprint ( , I' ) ;
both sides of equation (8) to the exponential power
of IT;
for i from 1 to h do
for j to n do 8i/"; Xij
lprint( , (10)
8i k q; Xik
cat ( , H' ,i, ' . e' ,j) ,
evalf(delta[i,j]» will remove the nonlinearity and the built-in solve
od; routine now can be successfully applied to the lin-
if i < h then lprint() fi; ear system (10, 9). This suggests that the powerful
od; mathematical capability of Maple should be meant
lprint ( , I' ) ; to complement rather than substitute modelers in
lprint(' W(h,j) the problem-solving process. Listing of the Maple
'initial endowments'); program econlib.mpl is as follows:
lprint(' I');
for i from 1 to h do ##### Maple file econlib.mpl #####
for j to n do ##### included by gexmaple.mpl #####
lprint( ,
cat ( 'H' ,i, ' . e' ,j ) , ##### utility function in (1) #####
evalf(W[i,j]) ) cdces := proc(sigma,n,delta,x)
od; local j, rho;
if i < h then lprint() fi; if sigma=l then
od; product(x[j]·delta[j],j=l .. n)
lprint( , I; '); elif sigma<>O then
rho := 1 - (l/sigma);
(sum«delta[j]*(x[j] ·rho»,
4.2 Household Demands j=1. .n»·(l/rho)
else
The Maple file econlib.mpllisted below consists ERROR('zero sigma')
of two procedures. The procedure cdces is a di- fi;
rect translation of the utility function Ui (1) into end:
Maple format. The procedure umax solves the util-
150
##### household demands in (10,9) ##### and household H2 with CES utility function:
umax := proc(umax_u,s,n,
umax_p,umax_i,umax_x) 1/2
local i, j, U[2] .- ( 1/4 X[2, 1] +
mu, mrs, 1/2
ce, eqnset, varset; 1/3 X[2, 2] +
for j from 1 to n do 1/2 2
mu[j] := simplify( 5/12 X[2, 3] )
diff(umax_u,umax_x[j]»
od: p [3] p [2] DEI
mrs := array(1 .. n,1 .. n); X[2, 1] := 9 -------------
for i from 1 to n do p[1] IUM
for j from 1 to n do
# see equation (8) p[3] p[1] DEI
mrs[i,j] := simplify( X[2, 2] := 16 -------------
mu[i]/mu[j]) ; p[2] IUM
if s=1 then
ceCil := mrs[i,j] = p [2] p [1] DEI
umax_p[i]/umax_p[j]; 1[2, 3] .- 25 -------------
else p[3] IUM
lhs := simplify(
mrs[i,j]A(-S) ,power); IUM = (9 p[3] p[2] + 16 p[3] p[1] +
rhs := (umax_p[i]/ 25 p[2] p[1])
umax_p [j]) A(-s);
# see equation (10) DEI = (3 p[1] + 4 p[2] + 6 p[3])
ceCil := lhs = rhs;
fi;
od; 4.3 Market Excess Demands
od:
# see equation (9) The Maple interface program gexmaple. mpl first
ce[n] := sum(umax_p [k]*umax_x DtJ , reads associated files econlib.mpl, gexparam.mpl
k=1 .. n) = umax_i; and then proceeds to calculate market excess de-
eqnset := convert(ce,set); mands in the following order: utility functions as
varset := convert(umax_x,set); in routine cdces, endowment incomes as in equa-
assign(solve(eqnset,varset»: tion (2), utility maximization as in routine umax,
end: household excess demands as in equation (5), and
finally market excess demands as in equation (6).
Maple returns the following demands by household
H1 with Cobb-Douglas utility function: ##### Maple file gexmaple.mpl #####
151
# defined in econlib.mpl 2 2
U[i] := cdces(sigma[i],n, 108 p [3] p [2] + 1200 p[2] p[l]-
[seq(delta[i,jj] ,jj=1. .n)], 2 2
[seq(X[i,jj],jj=l .. n)] 585 p [3] p [2] - 1040 p[3] p[l])/
);
# see equation (2) (p[3] (9 p[3] p[2] + 16 p[3] p[l] +
Y[i] := sum(p[k]*WEi,k],k=1. .n);
# defined in econlib.mpl 25 p[2] p[l]»
umax(U[i] ,
sigma[i] ,n,p, YEi], Both the Maple program gexmaple .mpl of this
[seq(X[i,jj] ,jj=1. .n)] section and the manually-coded GAMS program
); gexgams . gms of the previous section follow closely
for j from 1 to n do the theoretical framework outlined in section 2.
# see equation (5) However, while the GAMS program builds its cal-
Zij[i,j] .- eval(X[i,j]) - W[i,j] culations of market excess demands based on pre-
od; viously defined variables such as endowment in-
od; comes, household demands and excess demands,
for j from 1 to n do the Maple program eliminates all intermediate val-
# see equation (6) ues and expresses market excess demands as fi-
Z[j] .- sum(Zij[k,j], k=1..h); nal expressions in terms of prices alone. Although
Z[j] .- simplify(Z[j]); this feature of Maple can easily produce unwieldy
od; messy outputs, it clearly shows the basic tenet of
economic theory, namely, prices alone are the key
Maple returns market excess demands as a system driving force of a market economy.
of nonlinear equations in terms of prices alone as
follows:
4.4 Equation Block
Z[l] := - 1/9 (- 170 p[3] p[l] p[2] +
2 2 The remaining portion of the Maple interface pro-
656 p [3] p [1] + 1025 p[l] p[2]- gram gexmaple. mpl is basically a GAMS genera-
2 2 tor which writes the Maple outputs of market ex-
378 p [3] p [2] 150 p[2] p[l]- cess demand functions in suitable GAMS format.
2 2
477 p[3] p[2] 128 p[3] p[l])/ ##### Maple file gexmaple.mpl #####
##### GAMS program generator #####
(p[l] (9 p[3] p[2] + 16 p[3] p[l] +
##### write GAMS equation block #####
25 p [2] p [1] ) ) interface(quiet=true);
writeto('gexmaple.eqn');
Z[2] := 2/3 (11 p[3] p[l] p[2] + lprint('***** GAMS FILE
2 2 'gexmaple.eqn *****');
88 p[3] p[l] + 25 p[l] p[2]- Iprint('EQUATIONS');
2 2 for j from 1 to n do
81 p[3] p[2] - 225 p[2] p[l] + lprint(cat(' EQ_Z' ,j,
2 2 , market excess demand'»
18 p[3] p[2] + 152 p[3] p[l])/ od;
lprint() ;
(p[2] (9 p[3] p[2] + 16 p[3] p[l] + lprint(' EQ_object
'objective function; I);
25 p[2] p[l]» IprintO;
lprint(' EQ_object ..
Z[3] := 1/9 (- 236 p[3] p[l] p[2] + 'object =E= I);
2 2 lprint('sum(j,(p(j) * Z(j» ** 2);');
128 p[3] p[l] + 875 p[l] p[2] + lprint();
152
for j from 1 to n do sed -e 's/\[/("C/g'
lprint(cat(' EQ_Z' ,j, -e 's/\]/")/g'
, Z("C',j,''') =E= I»~; gexmaple.eqn > gexmaple.inc
lprint(Z[j],';') ;
lprintO; • Secondly, the lprint routine of Maple is not
od; sophisticated enough to be able to break lines
at relevant breaking points. Instead, it simply
Maple returns the output file gexmaple. eqn in folds lines at length specified by screenvidth
GAMS format as follows: (default 79 characters). If the line is split
right in the middle of two double quotes de-
***** GAMS FILE gexmaple.eqn ***** limiting an array element as in the following
EQUATIONS example:
EQ_Zl market excess demand
EQ_Z2 market excess demand -1/9*(-170*p("C3")*p("Cl <-----
EQ_Z3 market excess demand ")*p("C2")+656*p("C3 <-----
EQ_object objective function; ")*p("Cl")**2
153
EQ_Z1 .. Z("C1") =E=
-1/9*(-170*p("C3")*p("C1")*p("C2")+ * -----------------------------------
666*p("C3")*p("C1")**2+1026* * include equation block generated
p("C1")**2*p("C2")-378*p("C3")* * by the Maple interface gexmaple.mpl
p("C2")**2-160*p("C2")**2* $INCLUDE "gexmaple.inc"
p("C1")-477*p("C3")**2*p("C2")- * -----------------------------------
128*p("C3")**2*p("C1"»/p("C1")/
(9*p("C3")*p("C2")+16*p("C3")* MODEL gex /ALL/;
p("C1" )+26*p("C2") *p("C1"»
p.LO(j) = 0.000001;
EQ_Z2 .. Z("C2") =E= p.L(j) = 1.0;
2/3*(11*p("C3")*p("C1")*p("C2")+ Z.L(j) = 0;
88*p("C3")*p("C1")**2+26*
p("C1")**2*p("C2")-81*p("C3")* SOLVE gex MINIMIZING object USING NLP;
p("C2")**2-226*p("C2")**2*
p("C1")+18*p("C3")**2*p(IC2")+
162*p(IC3 )**2*p("C1 »/p(IC2")/
1 1 There are some structural differences between
(9*p(IC3 )*p(IC2 )+16*p("C3")*
1 1 the Maple-assisted GAMS program in this sec-
p(IC1 )+26*p(IC2 )*p(IC1"»
1 1 tion and the equation block of the manually coded
GAMS program gexgams. gms of subsection 3.2.
EQ_Z3 .. Z(IC3") =E= The manually coded GAMS program follows the
1/9*(-236*p(IC3 )*p(IC1 )*p("C2")+
1 1 algebraic structure of the model as closely as pos-
128*p(IC3")*p(IC1")**2+876* sible by writing equations with general index sets
p(IC1 1 )**2*p(IC2 1 )+108*p(IC3")* j, i as abbreviations of a multitude of equations
p(IC2 )**2+1200*p(IC2")**2*
1 numerically indexed by j =
1, j= 2, j= 3 and
p(IC1 )-686*p(IC3")**2*p(IC2")-
1 i =
1, i =
2. On the other hand, the Maple-
1040*p(IC3 1 )**2*p(IC1 1 »/p(IC3")/ assisted program writes equations as final expres-
(9*p(IC3")*p(IC2 )+16*p(IC3")*
1 sions with the indices even being evaluated to nu-
p(IC1 1 )+26*p(IC2 1 )*p(IC1"» merical values 1,2,3 for j and 1,2 for i. That
is, the elegance of GAMS as an "general alge-
braic modeling system" language was sacrificed for
4.5 The Maple-Assisted GAMS the practical symbolic manipulation capability of
Solution Maple. It is probably still a long way for Maple to
develop an ability which can, like the human brain,
Output files gexparam. inc and gexmaple. inc extract and reduce unwieldy arithmetic details to
simple and meaningful intelligent expressions, i.e.,
from the Maple interface gexmaple .mpl now can
"artificial theorizing".
be included in the following GAMS program
gexmaple . gms which produces exactly the same The following table provides a comparison of
general equilibrium solution as that reported by statistics on GAMS solutions by the manually
the manually-coded GAMS program gexgmas. gms coded program gexgams. gms and the Maple as-
in subsection 3.2. sisted program gexmaple. gms both executed on a
33Mhz 486 personal computer with 8 Mbytes of
***** GAMS FILE gexgams.gms ***** memory running DOS 5.0. As expected, because
***** Maple-assisted ***** the Maple assisted program is unable to write com-
pact formulas for the equation block, it is more
$INCLUDE gexparam. inc
II II bulky with code length almost double (1.9004 ra-
tio) that of the manually coded counterpart. This
POSITIVE VARIABLES explains a thirty percent (1.29 ratio) longer time
p(j) prices; required for compilation and execution. However,
its model specification has two-thirds fewer equa-
FREE VARIABLES tions (0.3333 ratio) and one half fewer variables
Z(j) market excess demands (0.4667 ratio) which results in one fourth smaller
object objective function; resource usage (0.7562 ratio) and less than one half
as many iterations and objective function calls for
154
the MINOS solver. explore areas of research which used to be con-
sidered technically forbidden. For example, with
Maple's ability to derive explicit functional forms
Manually Maple Ratios for market excess demands and GAMS's abil-
Coded Assisted ity to numerically solve for general equilibrium
(2) price solutions, stability and uniqueness condi-
(1) (2)
(1) tions for general equilibrium solutions can be di-
rectly checked either analytically or numerically or
both. Consequently modelers will not have to re-
Model Statistics sort to an inefficient grid search (Kehoe and Whal-
Single equations 12 4 0.3333 ley [1985]) nor simply assume away the problem as
Single variables 15 7 0.4667 often practiced in the field.
Nonzero elements 48 19 0.3958
Derivative pool 9 11 1.2222
Code length 522 992 1.9004 References
Constant pool 11 25 2.2727
[1] Brooke, A., D. Kendrick, and A. Meeraus
Time in Seconds (1992) GAMS 2.25 A User's Manual. San
Compilation 0.170 0.220 1.2941 Francisco: The Scientific Press.
Execution 0.380 0.490 1.2895
Total 0.550 0.710 1.2909 [2] Char, B., et al. (1991a) Maple V Language
Reference Manual. New York: Springer-
Solver Statistics Verlag.
Resource usage 1.813 1.371 0.7562
Iteration 42 23 0.5476 [3] Char, B., et al. (1991b) Maple V Library Ref-
Obj. func. calls 104 49 0.4712 erence Manual. New York: Springer-Verlag.
155
[10] Scarf, H. E. (with T. Hansen) (1973) The
Computation of Economic Equilibria. New
Haven: Yale University Press.
[11] Scarf, H. E. and J. B. Shoven, eds. (1984)
Applied General Equilibrium Analysis. New
York: Cambridge University Press.
156
CALCULATION OF THE STATE TRANSITION MATRIX
FOR LINEAR TIME VARYING SYSTEMS
J. Watkins, S. Yurkovich
Department of Electrical Engineering, Ohio State University, Columbus OH, USA
This paper discusses how Maple can be used 4>(t, to) = A(t)cI>(t, to), cI>(to, to) = I, (2)
to calculate the state transition matrix for sev-
eral classes of linear time-varying (LTV) systems. where I is the identity matrix. The state transi-
The state transition matrix is essential in deter- tion matrix is essential in determining the com-
mining the complete solution, stability, control- plete solution, stability, controllability, and ob-
lability, and observability of LTV systems. Un- servability of (1). It is also useful in design of
fortunately, a closed form solution for the state controllers and observers for (1).
transition matrix exists only when the LTV sys- Unfortunately, a closed form solution to (2) ex-
tem satisfies certain properties. Maple routines ists only when A(t) satisfies certain properties.
are discussed which have been written to find the Maple can easily find the solution of (2) when A(t)
state matrix when these properties are satisfied. is constant or satisfies a well known commutative
Examples and applications to control system de- property. This paper describes routines written to
sign are given. expand the class of systems for which Maple can
easily calculate cI>(t, to) to include systems where
A(t) is triangular or A(t) satisfies certain bracket
properties. Routines have also been written to cal-
I. Introduction culate the general solution of (2) to any arbitrary
order, to check when A(t) satisfies the commuta-
tive property, and to check whether a given cI>(t, to)
Applications oflinear, time-varying (LTV) sys- satisfies (2).
tems include rocket dynamics, time-varying linear
circuits, satellite systems, and pneumatic actua-
tors. LTV structure is also often assumed in adap- II. State Transition Matrix Properties
tive and standard gain-scheduled control systems.
The motivation for this work is an investigation
of an alternate approach to gain-scheduled control The state transition matrix is an integral com-
systems. ponent in the study of LTV systems of the form
In particular, we are interested in LTV systems given by (1). It is used for determining the com-
of the form plete solution, stability, controllability, and ob-
servability. It can also be used in the design of
z(t) A(t)x(t) + B(t)u(t), (1) controllers and observers for (1). In this section
we will discuss these uses along with some of the
y(t) C(t)x(t) + D(t)u(t),
properties of the state transition matrix.
The state transition matrix, which satisfies
where x(t) E lRn is the state vector, u(t) E lRm
is the control input, and y(t) E lRP is the system 4>(t, to) = A(t)cI>(t, to), (3)
157
q>-l(t, to) q>(to, t) (5) III. Calculating the State Transition
q>(t2,tO) q>(t2,t1)q>(t1,tO). (6) Matrix
1 t
to
q>(t, r)B( r)u( r)dr + D(t)u(t).
and B E ~pxq is defined to be
158
Table 1: Stability Bounds on 4)(t, to)
the Peano-Baker series [2] For time invariant systems, that is, when A(t) =
A where A is a constant matrix, the state transi-
4)(t, to) = I + it A(T1)dT1 (15)
tion matrix is given as
it lTl
to
(16)
+ A( Tt} A('T2)dT2 dT1 + ....
to to When A is time invariant, Maple can easily calcu-
late 4)(t,t o) using exponential(A, t-tO).
The following procedure, peano(A,n,tO), allows If A{t) satisfies the commutative property,
(1: (1:
us to calculate this series to any desired order:
159
where the Oi(t)'S are linearly independent time We note that multiple solutions are possible; the
functions and the Ai'S are constant matrices, and user should therefore choose the free parameters
then checking if the Ai'S form a commuting family, such that Al and A2 are time invariant if possi-
that is AiAj = AjAi, Vi,j. When the system is ble. If a time invariant solution exists, ~(t, to) is
commutative, the state transition matrix is given given by multiply(exponential(Al, t-tO), ex-
by ponential(A2, t-tO}}.
=II eA;P;(t,t o),
q
The class Al can be extended as follows [8]. If
~(t, to) (21)
A{t) and h(t) exist, where h(t) is a nonzero scalar
;=1
time function, and there is a constant matrix Al
where {3;(t, to) = fcto o;(r)dr [5]. The solution of which satisfies
(19) and (21) are equivalent; however, the solution
of (21) may result in a simpler form. For another d (A(t»)
dt h(t) = AlA(t) - A(t)At 'tit ~ to, (25)
decomposition method, see [6]. Clearly, constant
matrices and diagonal matrices both satisfy the
commutative property. then
If A(t) exists and there is a constant matrix Al
which satisfies ~(t, to) = eAlg(t)eA2g(t) 'tit ~ to, (26)
d
dt A(t) = AIA(t) - A(t)Al 'tit ~ to, (22) = =
where get) ftto h{r)dr and A2 limt_to{~g?)
At. If A(t) satisfies (25), it is said to be a mem-
then ber of the Ah class. A necessary condition to sat-
isfy (25) is that the eigenvalues of A(t) are con-
stants multiplied by h{t). This can be checked
=
using eigenvals(A}. When h(t) 1 this class re-
where A2 = A(to) -AI [7). If A(t) satisfies (22), it verts to the Al class, and when h(t) = l/t the
is said to be a member of the Al class. A necessary Euler-type differential equation can be solved [9].
condition to satisfy (22) is that the eigenvalues of The following proce-
A(t) are time invariant. Stability for members of dure, fah(A,AhO,Al,A2,tO,h,g), also uses the
Al can be completely determined from the eigen- Kronecker product and returns Al , A2 and g:
values of Al and A 2 •
The Kronecker product is used to transform (22) fab:=
to proc(i,AhO,i1,A2,tO,h,g)
local ad,Ad,a1,Al,n,Ah,t1;
(AT ® I - I ® A)vec At = vec A, (24)
g := eval(int(subs(t = t1.h),t1=tO .. t»:
which can be solved for vec At using linsolve. n : = linalg [rolldim] (A) ;
The following procedure, fal(A,AO,Al,A2), Ah := evalm(1/h*A);
transforms (22) to (24) and returns Ao, AI, and Ad := map(diff,Ah,t):
A2: ad := vec(Ad);
Al := add (kron (linalg [transpose] (A),
fa1:= eye(A»,-kron(eye(i),i»;
proc(A,AO,A1,A2) a1 := linalg[linso1ve] (Al,ad);
local ad,Ad,a1.A1,n; =
if a1 lULL then
n : = 1inalg [rolldim] (i) ; ERAOR('no solution possible') fi;
Ad := map(diff,i,t); AhO := map(limit,Ah,t = to);
ad := vec(id); A1 := invec(a1.n,n):
A1 := add(kron(lina1g[transpose](A), A2 := evalm(AhO-A1)
eye(A»,-kron(eye(A),A»; end
a1 := 1inalg[linso1ve](Al,ad);
if a1 = lULL then Again, if a time invariant solution for Al
ERROR('no solution possible') fi; and A2 exists, ~(t, to) is given by multi-
AO := msubs(A,t = 0): ply(exponential(Al,g),exponentia1(A2,g».
A1 := invec(a1,n,n): The state transition matrix can be found when
A2 := eva1m(AO-i1) A{t) is triangular. If A(t) = [aij(t)] is lower tri-
end angular, that is aij(t) = 0, Vj > i, then the state
160
transition matrix has elements given by phi[i,i] := exp(int(subs(t = t1,
A[i,i]),t1 = to .. t))j
o i<j for j from i+1 to n do
e
J: to
Oii(T)dT
i=j 1 := j-i+1j
sumk := subset = t.l,sum(A[i,k]*
Itto tPii(t, r)x phi[k,j],k = i+1 .. j))j
i-I
(I: ai/,,( r)tPkj( r, to))dr i > j, phi[i,j] := phi[i,i]*int(subs(t = to,
subs(tO = t.l,phi[i,i]))*
k=j sumk,t.l = to .. t)
where <T>(t, to) = [tPij(t, to)]. The following pro- od
cedure, ltriangle(A), calculates <T>(t, to) for lower odj
triangular matrices: map(simplify,phi)j
RETURI(")
ltriangle:= end
procCA)
local phi,n,i,sumk,k,j,lj Triangle matrices can be extended to block tri-
n := rowdim(A)j angular matrices. Let A(t) = [Ai;(t)], where each
phi := map(O,A)j Ai;(t) has dimensions ni x n;, and <T>(t, to) =
for i to n do [<T>i;(t, to)], where <T>i; (t, to) has dimensions ni X nj.
phi[i,i] := exp(int(subs(t = t1, If A(t) is lower block triangular, that is Ai;(t) = 0,
A[i,i]),t1 = to .. t))j Vj > i, then the state transition has blocks given
for j to i-1 do by
1 := i-j+1j
sumk := subset = t.l,sum(A[i,k]* o i<j
phi[k,j],k = j .. i-1))j <T>ii i=j
phi[i,j] := phi[i,i]*int(subs(t = to, .'F.. ••
~'J
(t ,t)
0 =
ftfo(l}ii(t,r)x
Jj
i-I
subs(tO = t.l,phi[i,i]))*
sumk,t.l = to .. t) (I: Aik(r)<T>kj(r, to))dr i > j.
od k=;
odj L I.keWlse,
. .f (). (27)
I A t IS upper block triangular, that is
map(simplify,phi)j
Ai;(t) = 0, Vi > j, then the state transition has
RETURN(")
blocks given by
end
If A(t) is upper triangular, that is aij(t) = 0, o i>j
Vi > j, the state transition has elements given by <T>ii(t, to) i =j
Itto <T>ii(t, r) x
o i>j ;
ftt
eJ,o
0ii (T )dT
i =j
( I: Aik(r)<T>k;(r,to))dr i < j.
Itto tPii(t, r)x (28)
;
(I: aik(r)tPkj(r,to))dr i<j.
While (27) and (28) hold for all lower and
upper block triangular matrices, respectively,
k=i+I <T>(t, to) can be calculated explicitly only when the
<T>ii(t, to)'s are known. Therefore, if every Aii(t) is
Note that a diagonal matrix is both lower and
from a class of matrices from which <T>ii(t, to) can
upper triangular. The following procedure, utri-
be calculated, <T>(t, to) can also be calculated. Note
angle(A), calculates <T>(t, to) for upper triangular
that a block diagonal matrix is both lower and up-
matrices: per block triangular. While no Maple procedures
utriangle:= have been written to work directly with block tri-
procCA) angular matrices, the Maple procedures discussed
local phi,n,i,sumk,k,j,lj earlier would make this calculation easier.
n := rowdim(A)j Two decomposition schemes exist which expand
phi := map(O,A)j the class of systems for which (I}(t, to) can be cal-
for i from n by -1 to 1 do culated. The first one can be found in [10]. Let
161
A(t) be decomposed as ERROR('no solution possible') fi;
B := invec(b,n,n)
m
F;(t) = Ii:?l (t)A;(t)11_1(t) i = 1,2, ... , m, Assuming Phil has been found, <}(t, to) is given
by add(multiply(map(int, msuhs (Phil,
and t=t1), t1=tO .. t}, msubs(A, t=tO}), eye(A»).
11(t) = <}i(t,0)11-1(t) i = 1,2, ... , m - 1, If (35) is not solvable using any ofthe previous pro-
cedures, (34) can be differentiated. If a solution to
To(t) I.
the Riccati equation B(t) + B2(t) = C(t)B(t) ex-
Then we have that ists, this procedure can be repeated until <}(t, to)
m
is found, or until the Riccati equation has no so-
<}(t, 0) = II <};(t, 0). (31) lution.
Lastly, we discuss the procedure used to verify
;=1
that a given <}(t, to) satisfies (14). From (14), we
Again, while no Maple procedure has been written know that
to deal with this decomposition scheme directly,
the procedures discussed to this point are useful A(t) = <}-l(t, to)4>(t, to) (37)
in doing so. It is interesting to note that this de- <}(to, to) = I.
composition scheme can be used to show that any
arbitrary A(t) can be decomposed into two normal The following procedure check(Phi) returns
systems [11]. Consequently, if closed form solu- <}-l(t, to)4>(t, to) and <}(to, to):
tions exist for these normal systems, a closed form
check:=
solution exists for any arbitrary A(t).
proc(phi.t.tO)
A second decomposition scheme can be found in
local a,Id;
[12] and [13]. Differentiating (7) results in
a := multiply(map(diff,phi,t),
x = (A(t) + A2(t))X(t). (32) inverse (phi) );
Id := map(limit,phi,t = to);
If RETURI(map(simplify,Id),map(simplify,a»
A(t) + A2(t) = B(t)A(t), (33) end
for some B(t), then (32) can be rewritten as In this section, several classes for which the state
transition matrix can be calculated were given.
x = B(t)2:. (34) These include constant matrices, matrices which
satisfy the commutative condition, the A1 class,
If a solution for B(t) exists, the following proce- the Ah class, triangular matrices, and block tri-
dure, hemami(A}, returns B(t): angular matrices whose block diagonal matrices
are solvable. Two decomposition schemes which
hemami:=
extend these classes were also given. Maple pro-
procCA) cedures were given which aid in this calculation.
local ad.Ad.b.B.n.Al;
n := linalg[rowdim] (A);
Ad := map(diff,A,t); IV. Examples
ad := vec(evalm(Ad+A-2»;
Ai := kron(linalg[transpose](A),eye(A»;
b := linalg[linsolve] (Al,ad); In this section, we will apply the Maple proce-
if b = NULL then dures discussed earlier to two LTV systems. In
162
exposition of the examples, we include diary-like > A1:=msubs(A1,t4=w*g,t5=O,t9=0)j
output from the Maple implementation to assist
the reader in reproducing these results. [ 0 g w o]
Example 1 [ ]
Consider Euler's equations for the rigid body A1 := [ - g w 0 o]
[2]: [ ]
[ 0 0 o]
12 - Is 1
= -1- 1 -W2(t)WS(t) + h U1(t) > A2:=msubs(A2,t4=w*g,tS=O,t9=0)j
Is - 11 1
= ~W3(t)W1(t) + 12 U2(t) (38) [ 0 o g]
= . -I-W1(t)W2(t)
h -12 ]
1 [
+ -U3(t) A2 := [ 0 o 0]
1 13
[ ]
where the Wi are the angular velocities, the Ii are [ 0 o 0]
the principal moments of inertia, and the Ui are
the applied torques. If we let 11 = 12 = I (sym- Now 4>(t, to) can be calculated as in (23) with
metrical body) and linearize about the nominal > phi:=map{simplify,multiply(
trajectory U1 = U2 Us 0 and = = exponential{A1,t),exponential(A2,t»);
Wl(t) sin(wgt),
[cos (wgt) sin(wgt) cos(wgt) t g)
W2(t) = cos( wgt), [ ]
ws(t) = w, phi:=[-sin(wgt) cos(wgt) -sin(wgt) g t]
[ ]
where 9 = 1
1 13 , we obtain the state equation [ 0 0 1 ]
~(t) = A(t)w(t) + B(t)u(t), (39) Finally, checking our results (according to (37))
163
is known at time t, but not necessarily a priori phi:=[ - sin(Y,l) cos(Y,l) 0 ]
[14]. [ ]
The control structure tla(t) = -Iak(z - zreJ) is [ 0 o exp(- k t) ]
proposed to drive z(t) to zreJ and maintain sta-
bility of the system where k is a positive constant. t
Substituting tla(t) into (40), we obtain the follow- /
ing closed loop matrix for A(t), I
Y,1 := I g z(t1) dt1
> A:=matrix([[O,g*z(t) ,0] , I
[-g*z(t) ,0,0], [O,O,-k]]); /
o
[ 0 g z(t) 0 ]
[ ] Checking our proposed 4>(t, 0),
A := [ - g z(t) 0 0 ]
[ ] > check(phi,t,O);
[ 0 0 - k ]
[1 0 o] [ 0 g z(t) o ]
Taking the Peano-Baker series to the 5th order [ ] [ ]
results in [0 1 0], [ - g z(t) o o ]
[ ] [ ]
> peano(A,5,O); [0 0 1 ] [ 0 o - k ]
2 4 3
[1-1/2 Y,1 + 1/24 Y,1 , Y,2 - 1/6 Y,2 , 0] the identity matrix and A(t) are returned as ex-
pected. By examining 4>(t, 0), it can be seen that
3 2 4 WI and W2 are stable and that z is asymptotically
[Y,1-1/6 Y,1 , 1 - 1/2 Y,2 + 1/24 Y,2 , 0] stable as desired.
2 2 3 3 4 4
[0, 0, l-k t+l/2 k t -1/6k t +1/24k t ] v. Conclusion
t
/ In this paper, we have examined how Maple
I could be used to calculate the state transition
Y,1 := I - g z(tl) dtl matrix for several classes of LTV systems. We
I motivated the problem by arguing that the state
/ transition matrix is important for understanding
o stability, controllability, and observability of LTV
systems. Classes of systems for which the state
t transition matrix can be calculated include con-
/ stant matrices, matrices which satisfy a commuta-
I tive condition, the Al class, the Ah class, triangu-
Y,2 := I g z(tl) dt1 lar matrices, and block triangular matrices whose
I block diagonal matrices are solvable. Maple proce-
/ . dures to aid in this calculation were given. Finally,
o examples showing how the state transition matrix
can be calculated and used for analysis of LTV
By examining the Peano-Baker series and checking systems were discussed.
a table of Taylor series, it is proposed that 4>(t, 0)
is of the following form:
Appendix
> h:=int(g*z(tl),tl=O .. t):
> phi:=matrix([[cos(h) ,sin(h) ,0] ,
[-sin(h),cos(h),O],[O,O,exp(-k*t)]]); In the following we list several well known Theo-
rems (involving the state transition matrix) which
are referenced in the text.
[ cos(Y,l) sin(Y,l) o ]
[ ] 1. Stability [1]:
164
Theorem 1 Every equilibrium state of (7) [6] L. A. Zadeh and C. A. Desoer, Linear system
is stable in the sense of Lyapunov at to if and theory; the state space approach. New York:
only if there exists some constant k which McGraw-Hill, 1963.
depends on to such that II <)(t, to)1I ~ k < 00 [7] M. Y. Wu, "A new method of computing the
for all t ~ to. If k is independent of to, it is state transition matrix of linear time-varying
uniformly stable in the sense of Lyapunov. systems," in Proceedings of the IEEE Inter-
2. Asymptotic Stability [1]: national Symposium on Circuits and Systems,
pp. 269-272, San Francisco, CA, April 1974.
Theorem 2 The zero state of (7) is asymp-
totically stable at to if and only if [8] M. Wu, "Solution of certain classes of linear
1I<)(t, to)1I ~ k(to) < 00 and 1I<)(t, to) II - 0 time-varying systems," International Journal
as t - 00. The zero state is uniformly of Control, vol. 31, no. 1, pp. 11-20, 1980.
asymptotically stable over [0,00) if and only [9] E. A. Coddington and N. Levinson, Theory of
if there exist positive numbers k1 and k2 such Ordinary Differential Equations. New York:
that 1I<)(t, to)1I ~ k 1 e-j,2(f-f o) for any to ~ 0 McGraw-Hill, 1955.
and for all t ~ to.
[10] M. Wu, "A successive decomposition method
3. Controllability [2]: for the solution of linear time-varying sys-
Theorem 3 The LTV system (1) is con- tems," International Journal of Control,
trollable on [to, t1] if and only if the control- vol. 33, no. 1, pp. 181-186, 1981.
lability Gramian [11] J. Zhu and C. D. Johnson, "New results in
the reduction of linear time-varying dynam-
ical systems," Siam Journal of Control and
Optimization, vol. 27, no. 3, pp. 476-494, May
is invertible. 1989.
4. Observability [2]: [12] H. Hemami, "On a class of time-varying
systems," IEEE Transactions on Automatic
Theorem 4 The LTV system (1) is observ- Control, vol. AC-13, no. 5, p. 589, October
able on [to, il] if and only if the observability 1968.
Gramian
[13] T. L. Niemeyer, "Exact state transition ma-
trix solutions to time-varying systems," M.S.
Thesis, The Ohio State University, 1969.
[14] J. S. Shammaand J. R. Cloutier, "Trajectory
is invertible.
scheduled missle autopilot design," in Con-
ference on Control Applications, pp. 237-242,
References Dayton, OH, September 1992.
John Watkins ([email protected])
[1] C. Chen, Linear System Theory and Design. received the B.S. degree in electrical engineering
Orlando, Florida: Holt, Rinehart and Win- from the University of Nebraska-Lincoln in 1989
ston, Inc., 1984. and the M.S. degree in electrical engineering from
[2] W. J. Rugh, Linear System Theory. Engle- The Ohio State University in 1991. He is currently
wood Cliffs, New Jersey: Prentice Hall, 1993. pursuing his Ph.D. degree in electrical engineer-
ing at The Ohio State University where he is sup-
[3] R. A. Horn and C. R. Johnson, Topics in Ma-
ported by the United States Air Force Laboratory
trix Analysis. New York: Cambridge Univer-
Graduate Fellowship Program. His research inter-
sity Press, 1991.
ests include nonlinear and linear control systems,
[4] B. A. Kinariwala, "Analysis of time varying system identification, and the control of flexible
networks," in IRE Int. Conv. Record, Part ./, mechanical structures.
pp. 268-276, 1961. Stephen Yurkovich ([email protected])
[5] M. Wu and A. Sherif, "On the commutative received the B.S. degree in engineering science
class of linear time-varying systems," Inter- from Rockhurst College in Kansas City, Missouri,
national Journal of Control, vol. 23, no. 3, in 1978, and the M.S. and Ph.D. degrees in electri-
pp. 433-444, 1976. cal engineering from the University of Notre Dame
165
in 1981 and 1984, respectively. He held teach-
ing and postdoctoral research positions at Notre
Dame in 1984 prior to moving later that year to
the Department of Electrical Engineering at The
Ohio State University, where he is currently As-
sociate Professor. He has published extensively in
the fields of system identification and control, and
in application areas including flexible mechanical
structures, robotic systems and automotive sys-
tems. Prof. Yurkovich teaches a wide range of un-
dergraduate and graduate level courses in control
theory, and has authored the text Control Systems
Laboratory. He is past Chairman of the Stand-
ing Committee on Student Activities, and imme-
diate past Chairman of the Standing Committee
on Publications, in the IEEE Control Systems So-
ciety, where he is currently an Executive Officer
and member of the Board of Governors. In Jan-
uary 1993, Dr. Yurkovich became Editor in Chief
of IEEE Control Systems.
166
IV
MAPLE V IN SCIENCE AND
ENGINEERING
Part B: Design
ALGEBRAIC COMPUTER AIDED-DESIGN WITH MAPLE V 2
C.T. Lim, M.T. Ensz, M.A. Ganter, D.W. Storti
Department of Mechanical Engineering, University of Washington, Seattle WA, USA
169
e2 choice is that the nth root in the power law relation can
be deleted without altering the extent of the solid. For
[(~) e22+ (~) e2
2]el 2
example, a sphere of radius 4 centered about the point
+ (~) el (1) (0, 0, 0) is expressed as:
abc
170
help ease the strain of examining long and complicated In_on of f1 and f2
implicit rational functions which are most suitable for > f2:= Translate(Squaroid(3/2,4),[-3/2,O]);
> surface1 :=Difference([f2,f1),4);
use in computer algebra systems.
> surface2:=lntersect([f1,f2).4);
One of the constraints of ASM is that exponents > surface3:=Unite([f1,f2).4);
used in defining superelliptic primitives and modified
Ricci algebraic-Boolean operations must be integers, FIGURE 1: Boolean Operations on 2-D Sections.
so that the resulting expressions are rational functions.
As a result, algebraic solid models (ASM) are generat- demonstrated in Figure 2 and will be discussed in the
ed by rational functions, a set which is closed under al- Coordinate Transformation section.
gebraic-Boolean operations.
Figure 1 includes 2-D sections of a squaroid and a
circle used to demonstrate the algebraic-Boolean oper- Primitive Solids
ations intersection, union, and difference produced via The primitive solids included in iIrplicit_solids
iIrplicitplot. The command implici tplot in Ma- are sphere, cuboid, and superellipsoid. They can be
ple V2 allows visualization of implicit functions by created by the following commands:
simply supplying the defining function and the range
in each axis. Note that the corners of the squaroid are
not very sharp because the defining function is a 4th
degree polynomial. Sharper corners can be produced > Sphere;
171
The solids obtained above can be displayed using > read implicicsolids;
Warning: new definition for norm
Maple's ilrplicitplot3d Examples of the results of Warning: new definition for trace
inplici tplot3d are shown in Figure 2, 3, and 4. The
> 11 :-Cuboid(4);
input arguments to inplicitplot3d are very similar
to ilrplicitplot; the implicit defining function of the
> 12:-Translate(Rotate(Stretch(I1,[I,I,4]),x,10),[3,3,O]);
object has to be supplied together with the ranges for
each of the axes x, y, and z. Once the object has been
displayed, the view of the solid can be rotated by
4 (60
j2:=(x-3) + 61 Y -6T-61 z
180 11 J 1 (11
+25661Y-61+61z
33 60 J
"grabbing" the box that bounds the solid with the > implid1plot3d((I1-1 ,12-1 1,x--312.. 4,y--312 .. 5,z=-5 ..5,grid=[35,35,35]);
Coordinate Transformations
The four basic transformations provided are Trans-
late, Stretch, Magnify, and Rotate. These transfor-
mations operate on the defining expressions of the
solids. For example, Translate takes a list [x, y, z] as
argument where each component of the list represents
the corresponding displacement component in that di-
rection. Figure 2 illustrates a unit cuboid of deoree
to 4
stretched, rotated, and then translated. Stretch, simi-
lar to Translate, takes a list of the stretch factors in
the x, y, and z directions. Note that stretch factors less
than 1 produce results equivalent to compressing the
solid.
Rotate takes the axis of rotation and the anole ofro-
tation in degrees as arguments. It uses a look:p table,
in the form of an array read in from an external file, to
find the closest approximation to the transcendental
FIGURE 2: Linear Transformations.
functions in the rotation matrix in terms of rational
fraction. The transformation matrix is an exact rotation Composite Solids
matrix corresponding to an angle close to the angle of
Composite solids can be created by combining prim-
rotation specified. The desired angle is rounded to the
itive solids via algebraic-Boolean operations on them.
nearest degree before a corresponding pair of rational
The three commands Intersect, Unite, and Differ-
coefficients are found from the look-up table. Higher
ence take the defining functions and the blending de-
accuracy is possible using the algorithm by Canny
gree as arguments.
[Canny et al. 1992], but for simplicity only values for
Figure 3 illustrates an example of non-trivial com-
integer degrees are generated and stored in the look-up
posite solids that can be generated using inplicit__ .
table. By using rational fractions in the computations,
solids. The toy truck [Marshall 1986] is created using
the defining functions can be maintained in polynomi-
the basic primitives and the defined Boolean operators.
al form with rational coefficients, and hence aloebraic
It is displayed using MapleV2's inplicitplot3d The
solid models are attained. The result of performing Ro-
detailed steps of creating and displaying the object are
tate on the cuboid is shown in Figure 2. Note that the
also included in Figure 3. For a complex object such as
resulting equation after rational rotation contains only
the truck, the time needed to display the object may be
rational coefficients and polynomials. The conversion
significant if a fine grid is used. The Maple plot shown
of the desired angle of rotation to rational coefficients
in Figure 3 requires more than 30 minutes to generate
is performed in the background, so that the whole op-
on a HP 700 series workstation. If the object has to be
eration is invisible to the user. The advantage of this is
displayed more than once, the plot can be saved to a
that the user can concentrate on using the basic ASM
variable and then re-displayed at a later time. A ray-
commands. The concatenated commands used to gen-
traced picture of the toy truck is also included in Figure
erate the extruded cuboid in Figure 2 are listed to dem-
3 for comparison.
onstrate the compactness of the code.
172
Swept Solids
More complex shapes that do not rely on the basic
primitives can also be created by implicit solid model-
ling. Extrusions, or swept solids, are one such exam-
ple. These are created by defining a solid and a path
along which this solid moves. For simplicity, a one pa-
rameter path specified by (xo(t), yo(t), Zo(t)) will be
considered here.
The family of solids obtained by simultaneously
considering the solid associated with all values of t can
be thought of as a parametric solid. The surface which
lies on and is tangent to a member of this family is
called the envelope [Salmon 1934J. This envelope pro-
vides the defining function for the desired swept solid.
To develop the envelope, the free parameter is elim-
inated from the defining function of the original solid
and the derivative of that solid's defining function with
Maple implicit plot. respect to the free parameter. This can be easily ac-
complished through the use of MapleV2's resul tant
or Grobner basis function (gbasis).
> read implicicsolids;
> wheel:~ Extrude(Magnify(Circle,518),3/4,6);
The power of this method is that the primitive solid
> axle :=Extrude(Magnify(Cirde,l/8),21/8,6) ; does not have to remain constant as it progresses along
> axleholder:=Unite([Stretch(Cuboid(6) ,[514,1/4,7/8)), the path. For example, if the primitive solid is a sphere,
Stretch(Cuboid(6),[1/4,l/4,ll/8))),6); the radius of the sphere can be related to the position
> truck:=Unite([axleholder,Translate(axle,[l,O,O)) , on the path. Further, a non-symmetrical object, such as
Translate(axle,[-l ,0,0)), Translate(wheel,[ 1 ,0,9/8)), an ellipse, can be rotated (using rational rotation tech-
Translate(wheel,[1 ,O,-9/8)),Translate(wheel,[-1 ,0,918)), niques) as it is translated.
Translate(wheel,[-1,O,-9J8])],6);
The envelopes as described allow the free parameter
> truck1 :=Rotate(truck,x,90);
to take on all values in the domain _00 < t < 00. To cre-
ate a finite object, the parameter range can be limited
Maple commands.
by intersection with a range function, R, that satisfies
O~ R ~ 1 on tmin ~ t ~ t max and R > 1 elsewhere. After
intersecting the defining function with the range limit-
ing function, the envelope criterion is applied.
As an example of these methods, consider creating
the dumbbell-shaped object displayed in Figure 4 us-
ing inplici tplot3d The primitive solid was defined
as a simple sphere:
xp = 4t; yp = 0; zp =0 (9)
Ray-traced image.
The radius of the sphere is determined by a parabolic
function :
7 2 1
FIGURE 3: An Example of a Composite Solid. rad = -1 +- (10)
4 4
173
> Xjlath :=4·t;
> Yjlath :=0;
> Zjlath:=O;
> rad :=((7/4)"tA2+(1/4));
> sphere:=((x-xjlath)A2+(Y-Yjlath)A2+(Z-ZJlath)A2)1(rad A2) ;
> R:~tA2 ;
> f:=sphere+R-1;
> nf:=numer(normal(f);
> dnfdt:=diff(nl,t);
> res :=resultant(nf,dnfdt,t) ;
> readlib(factors) ;
> res2:=factors(res)[2)[ 1][ 1);
(11)
174
Conclusions Ganter, M.A., Storti, D.W., "Algebraic Methods for
rnplicit_solids features compact and easily ex- Implicit Swept Solids", submitted to Advances in De-
tensible code working behind a user-friendly interface sign Automation, 1993.
provided by MapleV2. Users can employ the basic Marshall, N., The Great All-American Wooden Toy
primitives and Boolean set operations provided to cre- Book, Rodale Press, 1986, pp. 126-127.
ate new composite solids and formulate new approxi- Requicha, A.A.G. and Voelcker, H.B., "Historical
mations to Boolean set operations. It is the authors' Summary and Contemporary Assessment", IEEE
hope that this package will demonstrate the potential Computer Graphics and Applications, Vol.2, No.2,
of implicit solid modeling and make ISM available to 1982, pp. 9-24.
a broader audience. Ricci, A., "A Constructive Geometry for Computer
Features that the authors are considering adding to Graphics", The Computer Journal, Vol. 16, No.2,
the future version of iIrplicit_solids include an op- 1973, pp. 157-160.
tion to the rational rotation function which provides an Salmon, G., A Treatise on Higher Plane Curves,
algorithm for computing the rational coefficients for Stechert, NY, 1934, (Photographic Reprint of 3rd Ed.
transcendental functions to arbitrary accuracy instead 1879), pp. 73.
of using a look-up table. This option will produce
more accurate angle representation in rational coeffi-
cients at the cost of possibly slowing down the func- E-Mail
tion evaluation and plotting processes. The authors [email protected] (C.T. Lim)
find that the union of a computer algebra system and a [email protected] (M.T. Ensz)
solid-modeling system is a natural extension of both [email protected] (M.A. Ganter)
problem domains. [email protected] (D.W. Storti)
References Biographies
Barr, A.H., "Superquadrics and Angle-Preserving C. T. Lim is a Post-Master's student in the mechan-
Transformations", IEEE Computer Graphics and Ap- ical engineering department at the University of Wash-
plications, Vol. 1, No.1, 1981, pp. 11-23. ington. He received a Master's degree in mechanical
Blechschmidt, lL. and Nagasaru, D., "The Use of engineering from the University of Washington in
Algebraic Functions as a Solid Modeling Alternative: 1992. His primary interests are in the areas of automat-
An Investigation", Advances in Design Automation, B. ic controls, manufacturing, and CAD/CAM.
Ravani, ed., ASME Design Conference, Chicago, II., M. T. Ensz is a Master's degree candidate in the me-
1990, pp. 33-41. chanical engineering department at the University of
Canny, J., Donald, B.R., Ressler, E.K., and Rote, G., Washington. He received his Bachelor's degree in me-
"A Rational Rotation Method for Robust Geometric chanical engineering from Utah State University in
Algorithms", Proc. ACM Symp. on Computational Ge- 1992. His primary interests are in the area of CAD/
ometry, Berlin, 1992. CAM.
Char, B.W., Geddes, K.O., Gonnet, G.H., Leong, M. A. Ganter is an assistant professor of mechanical
B.L., Monagan, M.B., and Watt, S.M., First Leaves: A engineering at the University of Washington. After re-
Tutorial Introduction to Maple V, Springer-Verlag, ceiving a Ph.D. from the University of Wisconsin, he
1992. has continued to pursue research interests in computa-
Foley, J.D.,van Dam, A., Feiner, S.K., and Hughes, tional geometry, solid modeling, computer graphics,
J.F., Computer Graphics: Principles and Practice, 2nd kinematics, and applications to manufacturing systems
ed., Addison-Wesley, New York, 1990. automation.
Ganter, M.A. and Storti, D.W., "Object Extent De- D. W. Storti is an associate professor of mechanical
termination for Algebraic Solid Models", Advances in engineering and adjunct professor of applied mathe-
Design Automation, D.L. Hoeltzel, ed., DE-Vol. 44-2, matics at the University of Washington. He received a
1992, pp. 275-283. Ph.D. in theoretical and applied mechanics from Cor-
nell University. His earl y research in nonlinear dynam-
Ganter, M.A. and Storti, D.W., "Algebraic Solid
ics and vibrations led to recent investigations of
Modeling: A Renewed Method for Geometric De-
analytic solid modeling using symbolic computation.
sign", ASME Resource Bookfor Innovation in Design
Education, 1992.
175
THE ROLE OF A SYMBOLIC PROGRAMMING
LANGUAGE IN HARDWARE VERIFICATION: THE CASE
OF MAPLE
Farhad Mavaddat
VLSI Group, Dept. of Computer Science, University of Waterloo, Waterloo ON, Canada
176
(3) 3. The Maple Model of Hardware
In Sections 2, we outlined a functional formalism
for the specification of the behaviour of hardware
where modules and their composition into larger designs.
B(Sb S2, ... , Sq) is the behavior of B at state In this section, we express our formalism in terms
of the Maple language constructs [11], and show
(Sb S2, ... , Sq) [ 6].
how a single, hierarchically-defmed, Maple func-
Eb E 2 , ... , En are the n output-port values tion can be used to specify and derive a design's
produced in response to the corresponding combinational and sequential behaviours.
input-port and input-state values at all times.
3.1. The composition model
Fb F 2 , ... ,Fq are the q next-state values
produced in response to the corresponding A typical design, denoted by j, composed of
input-port and input-state values at every sub-modules f, g, and h, is shown in Figure 1.
step; they are evaluated at the time of transi- The general format of a Maple function that
tion to the next state. represents j follows the defmition scheme formu-
The two components of B can be combined into a lated in (5). Of the three sub-modules, f and h
single recursive defmition [7]: are are sequential with (R1) and (R2, R3) as their
respective state-variables. g is a combinational
B(Sb S2, ... , Sq) = (4) module with no state-variables. According to (5),
the composite module j inherits the sub-modules'
A(111,T\2,' .. ,11m)' «E I '£2,' .. ,En), B(FI ,F2" .. ,Fq».
state-variables and, therefore, has R1, R2, and
R3 as its state variables.
For a more complete discussion of this model,
see[8,9].
The Maple function corresponding to the design of
2.3. Composite modules Figure 1 is shown in Figure 2. The differences
between the Maple and the functional models of
An m x n-put composite module fC is defined as j, as defined in (5), are explained below.
the interconnection of w sub-modules
fl, f2, ... , fW, and a (hypothetical) n x m-put Line 01 corresponds to
environment module fa. The input and output fC (SI,S2, ... ,SW)=A(Yo) in (5). The
ports of fa define the output and input ports of fC , first parameter, called mode, is used to dis-
respectively. tinguish between the calls made to the com-
binational (mode = 1) or the sequential
To capture the net connections of module (rnode=O) behaviours of the device. The
f j (m j x nj -put, qj -state), state variables (R1, R2 , R3) and input vari-
ables (w, x) of j are on the same side and
we write ( yj) = f tmb(Sj)( X j ) where combined.
yj = ( yf, yd, ... , y~j) and X j = ( xl, xd, ... , x mj l·)
Line 02, required by Maple, and implied by
are the values of the nets connected to the the functional model (5), corresponds to
corresponding ports, and sj = (sf, sd, ... , S~j) is declaring X j and yj, 1 S; j S; w, in (5).
the list of state-variables of f j • T1, T2, and T3 are temporary variables to
Thus, according to (4), the combined behavior of be discussed later. The remaining signals,
P, Q, R, S , u, Y, and z, are the internal net
the module fC can be written as
names, shown in Figure 1.
fC (Sl, S2, ... , SW) = (5) Lines 03 to 12 correspond to
A (yo). (rec (yj = ftmb( sj)(X j ), 1 S;j S; w)
rec ( yj = f tmb( sj)( X j ), IS; jS; w) in (5).
The sub-module connections, in the form of
in (Xo,fc(fieq(sj)(X j ), lS;jS;w» ), Maple equations, are passed as arguments to
the Rec function. A discussion of the Rec
where rec and in are defined as in [10]. function itself is the subject of Section 3.2.
The calls g(S,X), f(comb,R1,P,W),
and h ( comb, R2 , R3 , Q, R, U) are calls to
the Maple models of f , g, and h.
Currently, Maple does not support multiple-
output functions. Therefore, we use a list to
return function values. Each module's
177
01 j := proc(mode,R1,R2,R3,W,X)
02 local T1,T2,T3,P,Q,R,S,U,Y,Zi
W 03 Rec(T1 g(S,X),
04 U T1 [1] ,
05 Z T1 [2] ,
f: Rl 06 T2 = f (comb, Rl, P, W) I
07 Q T2 [1],
08 R T2 [2],
S X 09 S T2 [3] ,
10 T3 h ( comb, R2 , R3 , Q, R, U) ,
11 P T3 [1],
p Q R g 12 Y T3[2] )
13 if mode then [Y,Z]i
14 else h(sequ,R2,R3,Q,R,S)i
U Z 15 f(sequ,R1,P,W) ;
16 fii
17 endi
h: R2, R3
Figure 2: The Maple function j
specifies the behaviour of the compo-
Y site module 'j' in terms of calls to the
behaviours of 'f', 'g', and 'h' sub-
modules.
178
Del := proc (mode, N, In) Finally, at the heart of our system is the implemen-
if mode then Memo[N] tation of the Rec function, shown in Figure 4.
else Memo[N] .- [ In ] fi; The Rec function receives the design topology as
end; a set of connectivity equations which are referred
(a) to as args, and which specify the interconnec-
tion of the modules according to (5). On invoking
Sel := proc (Inl, In2, C) Rec with a set of connectivity equations, the pro-
[ If ( C, In2, Inl) ]; cedure recursively evaluates and then compares the
end; two sides of every equation; it assigns the right-
(b) hand-side expression to the left-hand-side variable
until the two sides of every equation evaluate to
the same expression. On completion, all left-
Figure 3: (a) The procedure Del real- hand-side variables of a well-defmed module, i.e.,
izes the unit-delay primitive. A com- one with at least one unit-delay element in each
binational execution of De 1 connectivity cycle, will be defmed only in terms of
(mode=true=l) simply returns the the input variables, and are returned to the calling
value in the N-th position of the global environment.
array Memo. A sequential execution
(mode=false=O) updates the N-th Another useful function at the heart of the system
position by the input to the unit-delay is the If defmition given in Figure 5. We use
element. (b) Sel simply calls If. this definition rather than the Maple supported 'if'
Since it is a combinational device, to introduce some sophistication into the evalua-
there is no need for any 'mode' control tion of the multiplexor (selector) primitive. If
of Sel's execution. Note that the tries to recognize the control inputs that compare
returned values are always lists. two signals for equality ( expressed by the 'Equal'
function ), and makes a more informed decision
about potential equality than simply deciding on
the basis of a numerical comparison.
Rec := proc() local Rhs,Lhs,Fin,Xi;
Fin := false; If .- proc(c, t, e)
while not Fin do if type(c,function)
Fin := true; and op(O,c) = Equal
for Xi in args do and type(op(l,c),numeric)
Rhs .- eval (op(2,Xi)); and type(op(2,c),numeric)
Lhs . - op (1, Xi) ; then if op(l,c) = op(2,c)
if Rhs <> eval (Lhs, 2) then t else e fi
then Fin := false fi; elif type(c,function)
assign(Lhs, Rhs) and op(O,c) = Equal
od; and op(l,c) = op(2,c) then t
od; elif t = e then t
end; elif c = true then t
elif c = false then e
else 'If(c,t,e)'
Figure 4: A possible implementation fi
of Rec in Maple. 'op(l, Xi)' and end;
'op(2,Xi)' refer to the two sides of the
equation 'Xi'; 'eval(E,i)' evaluates E
°,
recursively to depth 'i'; 'eval(E)' Figure 5. A possible implementation
evaluates 'E' to the largest depth pos- of I f in Maple. op ( c) refers to
sible. the function name of the function call
c. The type function works in the
obvious way. Expressions enclosed in
quotes are returned unevaluated.
179
4. Interactive Proof Techniques and Examples
To simulate a module and obtain its symbolic
behaviour, one has to invoke the Maple package
and read the ftle containing its Maple definition A
into the Maple environment. After reading the B
ftle, one has to initialize each unit-delay to its ini-
tial symbolic values. Each module may then be c
executed by entering the corresponding function
name with a set of actual symbolic values. To D
clock a sequential design once, we first invoke the E
design's model with mode=1. This is followed
by invoking it with mode=O. The effect of F
sequential behaviours must be derived by inspect-
ing the unit-delay elements after executing the G
corresponding procedures. The behaviour of other H
modules can be derived in similar ways.
We now outline two proof techniques that can be I
applied to three categories of digital designs con-
sidered in this report. The first technique applies
the Maple model to the design of combinational Figure 6: An implementation of the
and a special category of sequential circuits, and odd function defined by (6). Note that
requires little designer intervention. The second the implementation uses exclusive-nor
technique, applicable to some other sequential cir- and inverters instead of the exclusive-
cuits, requires designer intervention and is carried ors implied by (6).
out interactively.
the implementation correct, the derived behaviour
4.1. Proof of combinational circuits expression is compared with the specification
In principle, combinational circuits can be expression (6) using Maple's bequal function.
modeled as a straight-line-code of Maple state- An edited Maple session demonstrating the
ments ordered by their data dependencies. In prac- correctness of the proposed implementation is
tice, the use of the Rec function and the design shown in Figure 6.
hierarchies simplify the modeling and eliminate
the potential for introducing errors in the sequenc- 4.1.2. Register-transfer combinational proof.
ing of the statements of a large design.
The technique of verifying a combinational
To prove a combinational design correct, the sym- register-transfer implementation is similar to the
bolic expression representing the result of evaluat- method used in the Boolean domain. The differ-
ing its model is compared with a reference Maple ence is in the use of Maple's normal function in
expression using the built-in Maple facilities. The comparing the reference to the derived behaviours,
reference expression is either the Maple definition as opposed to those of bequalor taut used in
of the expected behaviour (the so-called specifica- the Boolean domain. We illustrate the techniques
tion), or obtained by evaluating the Maple model with one example.
of a design known to be correct. We now present
an example of the proof of correctness of a gate- In Figure 7, two implementations of a register-
level combinational design. transfer design are shown. Aside from syntactic
differences, the two differ in the modularity of the
4.1.1. Boolean combinational proofs specifications. To prove the two designs
Figure 6 shows a proposed implementation of the equivalent, their Maple models are evaluated, their
9-input odd function, F, with the following resulting polynominal expressions are subtracted
Boolean specification: from each other, and a single difference-
polynominal is formed. If the two designs are
F(A,B,C,D,E,F,G,H,/)= (6) identical, the difference polynominal should evalu-
A tBB tBC tBD tBE tBF tBG tBH tB/. ate to zero. Maple's normal function, applied to
the difference-polynominal, guarantees a return of
zero if the difference-polynominal evaluates to
To derive the implementation's behaviour, its
zero[121. An edited Maple session demonstrating
Maple model is called at the Maple command level
the equivalence of the two implementations is
with suitable symbolic input variables. To prove
180
> read OddSpec;
Xor := proc(Inl,In2)
(¬(Inl) &and In2) &or
(Inl &and ¬(In2)) end
OddSpec := proc(A,B,C,D,E,F,G,H,I)
local Y;
Y Xor(A,Xor(B,Xor(C,Xor(D,
Xor(E,Xor(F,Xor(G,I)))))))) ;
Y
end
#
> tempSpec:=OddSpec(a,b,c,d,e,f,g,h,i);
#
> read OddImp;
#
Xnor := proc(Inl,In2)
[(¬(Inl) &and ¬(In2))
&or (Inl &and In2)] end
181
#
> read RT_Implementation;
#
Add .- proc(In1,In2) [In1+ln2] end
Mod2 := proc(In1,In2,In3,In4)
local T1,T2,Y1,Y2;
Rec(T1 Mod21(In1,In2,In3),
Y2
Y1 T1 [1] ,
T2 Sub(Y1,In4), YI
Y2 = T2 [1] ) ; X
[Y2]
end
Mod3 := proc(In1,In2,In3,In4)
local T1,T2,T3,T4,Y1,Y2,Y3,Y4;
Rec(T1 = Mul(In1,In2),Y1 = T1[1],
T2 Mul(In1,In3),Y2 = T2[1],
T3 Add(Y1,Y2),Y3 = T3[1],
T4 Sub(Y3,In4),Y4 = T4[1]);
[Y4]
end
#
> Imp1 .- Mod2( a, b, c, d ) ;
#
> Imp2 .- Mod3( a, b, c, d ) ;
#
> normal( Imp1[1] - Imp2[1] ) ; Y3
0
182
implementation of the BCD code defmition. It We now discuss the use of the Maple model of the
accepts the code to be recognized in a parallel design as an aid to deriving the induction step. To
form. The sequential form is designed to produce this end, starting from an initial configuration, we
the same result in four steps. It accepts the code to clock the model through a few steps, comparing
be recognized in serial form. We prove that the the unit-delay (symbolic) values (i.e., the state
two behaviours are functionally equivalent. variables) at successive steps. Based on the succes-
Both of the designs are expanded to include their sion of the observed values, we (try to) conjecture
input and output sequences. This helps to capture the behaviour values at the k-th and the (k+ 1)-th
a sequential design's interaction with the environ- steps. This is followed by assigning the conjec-
ment in a precise form, and minimizes the amount tured expressions, for the k-th step, to correspond-
of user intervention between the steps of sequential ing unit-delay element, in effect, bringing the sys-
behaviour. For the sake of uniformity, we also tem into the k-th step.
expand combinational designs to include their Finally, we use the design's Maple model to verify
input and output, necesitating the application of a the conjectures. This is done by stepping the
single pulse to the combinational circuits. To updated design ( the one with unit-delays
prove the two designs functionally equivalent, we representing the k-th step) by one step, to the
evaluate their respective Maple models and use (k+ 1}-th step, and comparing the new unit-delay
Maple's bequal function to test their identity. values with those of (k+l)-th step, also conjec-
tured and stored in the temporary variables.
To evaluate each design, the input unit-delays are Should the conjectures be correct, the anticipated
initialized, the circuit's Maple model is evaluated, (k+ l)-th step expressions and those derived by
and the output unit-delays are inspected. The sym- stepping the model should be equivalent. In addi-
bolic expression assigned to the output unit-delay tion to the normal, bequal, and taut facili-
is the circuit's symbolic output. ties discussed before, the Maple environment pro-
To evaluate the sequential design, the circuit's vides additional useful facilities for the manage-
Maple model has to be stepped four times, passing ment of induction steps, including that of subs
the state values between the state transitions via which helps with unit-delay updates to the k-th
Maple's global variables. A lightly edited Maple step, thereby minimizing the potential of mistakes
session demonstrating the equivalence of the two in the handling of large expressions.
implementation is shown in Appendix I.
Figure 11 shows a sequential design, proposed by
4.2.2. Sequential circuits with an unknown Gordon[14l, for computing the product of two
number of steps integers held at its inputs X and Y throughout the
In this section, we consider designs whose computation. The output 'DONE' is initially a '1',
behaviour can be modeled by a single while-loop. and the device is stepped until the 'DONE' output
Although this may seem restrictive, it can be becomes '1' again, at which time the product of
shown to be an appropriate model for a large input values is available at 'OUT'. A Maple ses-
number of application-specific designs. sion demonstrating the correctness of the design,
using the method discussed above, is shown in
What distinguishes these designs from those Appendix II. During the session we show that
requiring a fixed, a priori known, number of steps cond( k ) == ( a-k = 0 ) v ( b = 0 ), and result( k )
is the need for a status output (called cond) that == (if ( a = 0 ), 0, b ) x k. Using the values of cond
signals the step at which the data output(s) (called and result at the kth step, one can easily prove (7),
result) produce their results. In effect, we have to shown by:
show
( a-k = 0 ) v ( b = 0 ) ::> ( if ( a = 0 ), 0, b ) x k
cond( k ) ::> result( k ) == specification, (7)
== a x b. (8)
where cond( k ) and result( k ) are the symbolic
output expressions at cond and result at the k step.
As the value of k for which (7) holds is not known,
this leads to an unpredictable number of computa-
tion steps. J. L. Paillet has shown that by induc-
tion on the number of steps we should be able to
reason about such behaviour[13]' but the deriva-
tion of the induction steps is left to the designer.
183
Mechanized logics, such as the Boyer-Moore[15]
x y and HOL[16] systems, are designed to construct
theories and reason about them. They allow the
user to specify data types; they provide a way to
describe how elementary values are interpreted
without saying how those values are represented.
We believe that the formal-methods community
should retreat from the notion that the design
domain can be encompassed by a single logical
framework. The reason is that the proof aids,
because they are so general, are too weak to be
practical. Efforts to compensate by making
theorem provers 'programmable' aren't going to
payoff soon enough.
We also believe that too few people realize that the
research in the area is as much about methodology
as it is about proving circuits. The methodology is
intimately related to the modeling framework and
the reasoning tools: identifying this relationship
presents a primary research goal.
DONEout 6. Acknowledgements
Figure 11: A proposed implementation The author would like to acknowledge the support
of the multiplier. Boxes with V and by the Natural Sciences and Engineering Research
f- inside, represent the multiplexor Council of Canada under research grant
and unit-delay elements, respectively. OGPOOO5515, and the University of Waterloo
Functional units are shown by boxes funding and computing facilities used to carry out
with their common algbraic symbol some of the work reported here. The author also
inside. Boxes with no inputs, gratefully acknowledges K. Geddes, B. Leong, M.
represent constants. A box with string Monagan, and A. Pathria of Waterloo's Maple
'ff inside, represents a flipflop. group, for their assistance with Maple related
issues at different stages of this work.
5. Conclusions
Tautology checkers derive their power from their
restriction to boolean theory, and therefore can
exploit the specialization of that theory. As. long as
we can specify our design within that theory, a tau-
tology checker is going to give us a very effective
way to determine correctness. On a negative side,
we have to cast every aspect of the design that
concerns us into a binary representation. There is
a trade-off between a more fully automatic proof
capability and the degree to which the engineer
must interpret the representation over which the
proof is done.
We followed a similar procedure in the Maple
demonstrations, casting our designs in the arith-
metic theory for which Maple is specialized. One
reason this worked well was that the aspect of
design with which we were concerned was readily
represented by an arithmetic formula.
184
7. References 13. Paillet, J. L., "A Functional Model for
Description and Specification of Digital
1. Fitch, J., "Solving Algebraic Problems with Devices," pp. 21-42 in From HDL Descrip-
REDUCE," Journal of Symbolic Computa- tions to Guaranteed Correct Circuit
tion, 1 pp. 211-217 (1985). Designs, ed. D. Borrione, Elsevier Science
2. Pavelle, R. and Wang, P. S., "MACSYMA Publishers B. V. (North Holland), Amster-
from F to G," Journal of Symbolic Compu- dam, netherlands (1987).
tation, 1 pp. 69-100 (1985). 14. Gordon, M. J. C., "Why Higher Order Logic
3. B.W. Char, GJ. Fee, K.O. Geddes, G.H. is a Good Formalism for Specifying and
Gonnet, and M.B. Monagan, "A Tutorial Verifying Hardware," Technical Report No.
Introduction to Maple," Journal of Symbolic 77, Computer Laboratory, University of
Computation, 2 pp. 179-200 (1986). Cambridge, Cambridge, England (Sep-
4. Mavaddat, F., "Inductive Assertions on tember 1985).
Algorithmic State Machines A Maple-Based 15. Boyer, R. S. and Moore, J. S., A Computa-
Register-Transfer-Level Proof System," pp. tional Logic, Academic Press, New York
257-266 in Formal VLSI Correctness Verifi- (1979). .
cation, VLSI Design Methods-II, ed. L.J.M. 16. Gordon, M. J. C., "HOL A Machine
Claesen, North Holland, Amsterdam, Neth- Oriented Formulation of Higher Order
erlands (1990). Logic," Technical Report No. 68, Computer
5. Gordon M., "A Model of Register Transfer Laboratory, University of Cambridge, Cam-
Systems with Application to Microcode and bridge, UK (1985).
VLSI Correctness," CSR-82-81, University
of Edinburgh, Dept. of Computer Science, 8. Biography
Edinburgh, Scotland (March 1981- revised Farhad Mavaddat received the PhD degree from
May 1982). Imperial College of Science and Technology, Lon-
6. Gordon, M. J. C., "The Denotational don, England. From 1968 to 1979 he was with
Semantics of Sequential Machines," Infor- Arya Mehr University of Technology, Tehran,
mation Processing Letters, 10(1) pp. 1-3 Iran. Since 1979 he has been with Department of
(February 1980). Computer Science, University of waterloo, Water-
7. Milner, R., "Processes: A Mathematical loo, Ontario, Canada. His present research
Model of Computing Agents," pp. 157-173 interests include the use of formal methods in
in Logic Colloquium '73, ed. H.E Rose and design. He can be reached by electronic mail sent
J. C. Shepherdson, North Holland Publish- to '[email protected]'.
ing Company, Amsterdam, Holland (1975).
8. Mavaddat, F., "Designing and Modeling
VLSI Systems at Register Transfer Level,"
International Journal of Computer Aided
VLSI Design, 2 pp. 281-314 (1990).
9. Mavaddat, F., "A Functional Model of
Register-Transfer Designs," Proceedings of
Twentieth Annual Pittsburgh Conference on
Modeling and Simulation, (May 1989).
10. Landin, P. J., "The Mechanical Evaluation
of Expressions," Computer Journal,
6(4) pp. 308-320 (Jan. 1984).
11. Char, B. W., Geddes, K. 0., Gonnet, G. H.,
Monagan, M. B., and Watt, S. M., MAPLE
First Leaves: A Tutorial Introduction to
Maple, Springer-Verlag, New York (1992).
12. Geddes, K.O., Gzapor, C., and Labahn, G.,
Algorithms for Computer Algebra, Kluwer
Academic Publisher, Boston (1992).
185
Appendix I
186
Appendix II
187
A SYMBOLIC CSG SYSTEM WRITTEN IN MAPLE V
Darren Thompson, Tom Trias, Laurence Left
Department of Computer Science, Western Illinois University, Macomb IL, USA
188
in, on, or off the primitive.
function edgelist (T); Figure 1 demonstrates how the
/*T is a CSG tree segment is bubbled up through
(returns a list of the tree. We perform a table
edges on the boundary look-up in order to obtain the
of the object new values produced when
represented)*/ performing one of the
edgelist <- nil difference, intersection, or
for each primitive Pi union operations of a segment
for each edge E of Pi and a primitive. The segment
(EinS, EonS, EoutS) being classified against each
<- M[E,T] primitive is rectangle A's
merge (EinS, EonS, bottom segment.
EoutS) with edgelist
end /*for*/ A
end /*for*/
remove edges in or out
of object leaving edges B
,----
on
end /*edgelist*/ c
I I
Table I CSG Boundary
Representation
Algorithm [TIL81]
U
..
ON
OFF
• I
ON ON
•
.. ..OFF
/ \
our code will take this
ON ON
/ \
C
•
OFF
. ON
189
function M (Edge,T);
6 RETURN(['off',nil]) 3S fii
7 else 36 fii
8 RETURN(['On',bit1])i
9 fii
10 elif status1 = 'on' and
11
12
status2 = 'in' then
RETURN(['off',nil])i
Notice that in Figure 1,
there is a difference operation
==
13 elif status1 'on' and between rectangles A and B.
14 status2 'off' then The segment being classified is
lS RETURN(['On',bit1])i completely on A and only partly
16 elif status1 = 'in' and on B. Our program compares
17
18
status2 = 'on' then
RETURN(['on',
these two classifications and
bubbles up the result. When
19 revbit(bit2)])i our program sees on and off, it
20 elif status1 = 'in' and looks at lines 13-15 and
21 status2 = 'off' then returns the result on. When it
22 RETURN(['in',nil])i compares on and on and sees
23 elif status1
24 status2
=
=
'in' and
'in' then
that both bits 1 and 2 are the
same, it returns off. Both
2S RETURN(['off',nil])i bits are the same since the
26 elif status1
27 status2
=
=
'off' and
'off' then
rest of rectangle A is above
the segment being classified
28 RETURN(['off',nil])i and the rest of rectangle B is
29 elif status1
30 status2
=
= 'off' and
'in' then
also above the segment being
classif ied. The same procedure
31 RETURN(['off',nil])i takes place for every other
32 elif status1
33 status2
=
=
'off' and
'on' then
segment in each primitive. The
resul t is then unioned together
34 RETURN(['off',nil])i to form the resulting object.
190
III. The Classification of an object conceptually
Segments different from the object they
initially entered. For
We classify general example, a plate with a hole in
segments against one another by it may be divided into two
a procedure called pieces as the value of the
seqment classify. This parameter giving the dimension
procedure is important to our of the hole becomes large
program for two reasons. enough. Some systems
First, it generalizes the supporting parameters in
routine to classify two mechanical engineering CAD do
segments against one another. not generate the needed
Secondly, this routine has the constraints. Thus, physically
power of MAPLEV. Our main code unrealizable shapes may be
is designed to handle simple produced as parameters vary--an
cases which have been example is given in [GOS88].
preprogrammed for efficiency These constraints correspond to
(e. g., classifying a horizontal the "side conditions" of
segment against a vertical or [BOT82]. The second list of
vice versa). On the other lists produced by
hand, seqment classify is segment classify is the
designed to handle any curve return value list.
types which can be defined in Return value list contains the
MAPLEV. In order to classify followIng information:
two segments correctly, all
points where they intersect [[iteml - atom stating whether
need to be found. If MAPLEV the segmentl is on,
can find those points of off, or in segment2,
intersection, then item2 - if iteml is on, this
seqment classify has the will be 0 or 1 (as
ability-to return the correct per cbit) otherwise
values. null,
item3 - [left-hand-point -
seqment classify takes two symbolic value,
arguments: -segment to be grounded value],
classified (seqmentl) and item4 - [right-hand-point -
segment to be classified symbolic value,
against (seqment2). This grounded value]]
procedure will return two
important lists of lists. The We use the qsolve routine from
first is an inequality list the Grobner Basis package to
which will provide the solve for the intersections.
necessary constraints for the We did this in order to find
segments. It also enables the all intersections when dealing
user to change the values of with polynomials.
the parameters and MAPLEV makes
sure the constraints hold. If IV. Database.z
the constraints do not hold,
the user will be made aware Database. z is a file which
that their input will produce contains all definitions of
191
curves .and primitives. We prim[rectanqle,2,ft]:=1;
designed our system to be user I => HORIZONTAL FT
expandable. We knew we prim[rectanqle,2]:=yll+s2,
couldn't come up with all xll,xll+s1;
possible curve and primitive
definitions to meet every prim[rectanqle,3,ft]:=2;
user's needs; theref ore, the I => VERTICAL FT
user has the ability to define prim[rectanqle,3]:=xll+S1,
their own curve or primitive yll+S2,yll;
and add it to this file. All
the user has to do is put their prim[rectanqle,4,ft]:=1;
definition in the same format I => HORIZONTAL tT
as our definitions. Below is a prim[rectanqle,4]:=yll,xll+S1,
definition of a quadratic xlI;
curve.
The xll, yll, sl, and s2
#----------------------------
1FT'S OF TYPES
variables are assigned the
lower-left x- and y-
IQUADRATIC CURVES coordinates, length, and
width. with these values,
ft[S,vars] :=[a,b,c]; MAPLEV can construct the
=
ft [ S , vs ] : 3; rectangle.
ft[S,v1] := a;
ft[S,V2] := b; V. Advantages of Programming
ft[S,v3] := c; in MAPLEV
ft[S,peqx] := p;
ft[S,peqy] := a*p A 2+b*p+c; The key advantage of
MAPLEV in our research was the
We assigned each curve an ability to represent arbitrary
ft type. This curve definition expressions and curves. This
just happened to be fifth in would allow the engineer to use
the list, so the number has no the full mathematical
other special meaning. Vars repertoire of MAPLEV to
gives the variables required to represent the curves in the
define an infinite curve of object they are designing,
this type. We found that rather than being limited to a
defining all curves specific set as in a
parametrically allows greater conventional CAD system. We
generality of programming. A also rely on the ability of
rectangular primitive MAPLEV to solve two equations
definition is shown below. simultaneously to determine the
points of intersection of these
1=====RECTANGLE ====== segments.
prim[rectanqle,arq]:=xll,yll,
sl,s2; Another advantage is our
ability to generate a plot with
prim[rectanqle,1,ft]:=2; a single statement. It would
I => VERTICAL FT take us countless hours to
prim[rectanqle,l]:=xll,yll, program this ourselves. We
yll+S2; need the ability to plot the
192
1 para1istqen:=proc(segm,seqp1ace)
2 local temp,eq1ist;
3 eq1ist:=[];
4 for temp from 1 to nops(ft[seqp1ace[1],VarS]) do
5 eq1ist:=[op(eq1ist),ft[seqp1ace[1],vars][temp] =
seqp1ace[temp+1]];
6 od;
7 para1ist:={op(para1ist),subs(eq1ist,[ft[seqp1ace[1],
peqx],ft[seqp1ace[1], peqy],
p=segm[3][2] •• segm[4][2]])};
8 end; # para1istqen
193
when temp is 2, the code would next important set of
sUbstitute a specific number information used to plot the
for b in the curve. In line object is the second entry of
7, the sUbstitutions defined by the table. This segment is on
eqlist are applied to the the object. This list is in
parametric equation for the the format of the
segment. Ft[Seqplaoe[l],peqX] return value list described
is the equation for x in the above. There are eight entries
parametric representation of in the seqmentsets data
the curve--and similarly for structure since the obj ect
ft[seqplaoe[l],peqy]. generated has eight sides--each
of which is a line segment of a
Another example of the unique infinite line.
ability of Maple to easily
define powerful data structures MAPLEV also saves us a
is given in Text Box 2. It considerable amount of time
shows an entry in the when writing code. This is
seqmentsets data structure, the because MAPLEV contains some of
most widely-used data structure the LISP functions (e.g., map,
in our system. It shows one of subs, member). For example, we
the eight entries generated frequently had to SUbstitute
when the CSG expression defined the nominal values of the
in section VII is given to this parameters into various
program. The first 1 in [1,1] structures and expressions.
specifies the ft type of the section VII shows example input
segment (e.g., horizontal, data for a symbolic CSG
vertical). situation. Observe the
definition of the bs vector
which describes the nominal
[[1, 1]= table([ values for the parameters of
1 =[[0, 1],
[a + side1, 2],
the actual CSG expression. We
use the procedure subsbs,
[c + side2, 3]] listed below, to SUbstitute
2 =[[on, 1,
[a + side1, 2],
these nominal values for the
corresponding parameters for
[c + side2, 3]]] us.
3 = [8] ]) subsbs := proc(expr);
Text Box 2 Part of subs(op(op(bs»,expr);
seqmentset's end;
data structure
If we had to write the code to
A segment of ft-type 1 is perform these operations, it
a horizontal line. The second would take us a significant
1 gives the grounded value to amount of time.
define an infinite curve of
this type. Therefore, this In many instances of our
segment is a horizontal line program, we had to keep what
with a y-value of 1. op(l,n) computer scientists refer to as
is used to index [1,1]. The a dictionary. For example, we
194
had to keep track of all the let us down on what would seem
segments that potentially to us as simple cases. We
overlapped. More specifically, represent all curves as
we had to keep and process parametr ic equations. Below,
together all of the segments of is an example of our
the same infinite curve. diff icul ties with the important
job of intersecting a circle or
Another example of this is an arc with a line. Solve and
keeping track of the fsolve are unable to find all
information for each primitive. the roots to trigonometric
We simply write functions.
prim[rectangle,2,ft] to obtain
the ft-type for the second f:=cos(P)=p 1 i
segment of the rectangle. Note f := cos(p) = p1
that the first parameter of the
prim hash list gives the g:=sin(p)=Oi
primitive name, which of course 9 := sin(p) = 0
can change as the user adds a
new primitive. The second solve({f,g},{p,p1})i
gives the number of the segment {P = 0, p1 = 1}
within the primitive (there may
be an arbitrary number of fsolve({f,g},{P,P1},
segments within each {p=Pi/2 •• 3*Pi/2,p1=-1.5 •• 0})i
primitive) • The third {p = 0, p1 = 1.}
parameter tells the system we
need the information on the ft- cos(Pi)i
type. -1
sin(Pi)i
All this clearly could o
have been done using linked
lists or binary trees in a Notice that a range was
conventional programming placed on p and p1 to help
language such as C or PASCAL. fsolve find the solution {p =
However, both of these pi, p1 = -1}. Unfortunately,
subfunctions and many other this has slowed down our
similar subfunctions in our progress in dealing with
program, would have had to be trigonometric curves. We are
implemented separately, each now taking an alternative
requiring dozens of lines in a approach by using polynomials
more typical language. since MAPLEV is more successful
in finding their roots.
VI. Disadvantages to
Programming in MAPLEV We have wasted a
considerable amount of time
As mentioned in the debugging our code due to the
previous section, we were lack of strong typing in
relying on the MAPLEV solve MAPLEV. For example, we have
function to intersect the an array of lists called
curves composing the primitive segments. Many of our
shapes. Unfortunately, it has subroutines required a segment
195
as one of the parameters. In friendly when it comes to
some cases, the segment itself errors. When there is an error
would be passed. In other in our 1600-line program, it
cases, the subscript to the takes us more time than
segments array would be passed. necessary to find it due to the
Needless to say, when the lack of good error checking
subscript was passed where the and/or a better way of
segment itself was needed, or informing the programmer that
vice versa, diff icul t-to-f ind an error has occurred. When F3
bugs were encountered. This is pressed to exit fred, MAPLEV
problem would be analogous to then reads in the file. The
passing the pointer to a entire file scrolls up the
structure instead of a screen; this can happen too
structure to a subroutine. A quickly to watch on a fast
good typed system catches any computer. If the word "error"
errors. written with an arrow pointing
to the error is not seen, an
MAPLEV does not have a attempt is made to run the
stand-alone compiler. This has program and the mistake in
been a serious drawback since syntax is not found until
our program is 1600 lines and incorrect results are produced.
growing. Every time we want to If the syntax is wrong, MAPLEV
make changes in our code, we will ignore that statement, if
have to call fred «filename», not the whole procedure. The
make changes and then exit. programmer has the alternative
When we exit, MAPLEV has to to send the output to a file,
read in every line of code. but then they would have to
This can take some time if the inspect the output file and
user is on a slow machine. One check to see if there are any
way to reduce the time it takes syntax errors.
to read in a file is to break
it up into sub-files. The user We do know that there is
then has to keep track of when an add-on MAPLE-callable
they need to read in a file to package for the C programming
re-initialize variables. If environment; unfortunately, we
the user is in the middle of a have not had the opportunity to
fred session, and wants to test try it. This package would
the syntax before coding it in provide us a command-line
the program, they have to exit compiler, tighter error
fred. This means MAPLEV will checking, and allow us to
have to read in the entire define data types.
file. The user can then test
their idea; if it works, they VII. Results
then have to go back into fred
to edit their file. Therefore, Shown below are the
a stand-alone compiler would results of a simple example
enhance the MAPLEV programming input and output from our code
environment tremendously. unioning two squares. The
input to our system was as
MAPLEV is not programmer- follows:
196
csq:=squara(a,~,sid81) iunioD c + sida2, d, d, d + side2,
squara(c,d,side2); c + side2, d, d + side2,
~s[a]:=o; d < 4 + sid82, a + sidel, ~,
I:»S[I:»]:=O; + sidel, a + sidel,
I:»
I:»s[sidel]:=2; a + sidel, ~, ~ + sidel,
I:»s[c]:=l; + sidel, ~ < d,
I:»
I:»s[d]:=l; d < ~ + sidel, a, ~,
I:»s[side2] :=2; ~ + sidel, a, 1:», ~ + sidel,
~ + sidel, ~ < ~ + 8idal, d,
This input defines square1 as a d, c, a, a + sida2, d, c,
square with its lower-left x- a + side2, a < a + 8idel,
and y-coordinata at (0,0) and a + sidel < a + sid82,
its side being length 2. d + side2, c, a,
Square2 has x- and y- a + 8ide2, d + 8ide2, a,
coordinates (1,1) and its side a + 8ide2, c < a + 8id82]
is also length 2. The output
from our system was the Keep in mind that the
inequality list shown below. entries ~, a, etc. imply ~ > 0,
a > 0, etc. You may notice
[I:», a, a + sidel, 1:», a, some redundancy in the list; we
a + sidel, a + sidel, have not yet dealt with the
a < a + sidel, ~ + sidel, a, task of deleting redundant
a + sidel, I:» + sidel, inequalities. A method of doing
I:» + sidel, a, a + sidel, this, and arquments regarding
a + sidel, a < c, time complexity can be found in
a < a + sidel, c, c, d, d, [LEFF90]. A plot of the
d + side2, c, d, d + side2, resulting object is shown
d < I:» + sidel, below.
I:» + sidel < d + side2,
3-
2.5
1.5
0.5
I 1.5 2 2.5 3
0.5
197
References
198
About the Authors
199