0% found this document useful (0 votes)
302 views201 pages

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

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
302 views201 pages

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

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 201

Mathematical Computation

with Maple V:
Ideas and Applications
Mathematicai Computation
with Maple V:
Ideas and Applications

Proceedings of the Maple Summer


Workshop and Symposium,
University of Michigan,
Ann Arbor, June 28-30, 1993

Thomas Lee
Editor

SPRINGER SCIENCE+BUSINESS MEDIA, LLC


ThomasLee
Waterloo Maple Software
Waterloo, Ontario
CANADA N2L 5J2

Printed on acid-free paper


© Springer Science+Business Media New York 1993
Originally published by Birkhauser Boston in 1993
Maple and Maple V are registered trademarks ofWaterloo Maple Software.

Copyright is not claimed for works of U.S. Govemment employees.


AII rights reserved. No part of this publication may be reproduced, stored in a retrieval
system, or transmitted, in any form or by any means, electronic, mechanical, photocopy-
ing, recording, or otherwise, without prior permission of the copyright owner.

Permission to photocopy for internal or personal use of specific clients is granted by


Springer Science+Business Media, LLC for Iibraries and other users registered with
the Copyright Clearance
Center (CCC), provided that the base fee of $6.00 per copy, plus $0.20 per page is paid
directly to CCC, 21 Congress Street, Salem, MA 01970, D.S.A. Special requests should
be addressed directly to Springer Science+Business Media, LLC.
ISBN 978-1-4612-6720-1 ISBN 978-1-4612-0351-3 (eBook)
DOI 10.1007/978-1-4612-0351-3

Camera-ready text prepared by the Authors.

9 8 7 6 5 432 1
Contents

Preface . . . . . . . . . . . . . . . . . . . . . vii

I. Maple V in Education 1

Introductory Quantum Mechanics Using Maple V


Yutaka Abe . . . . . . . . . . . . . . . . 3
Combinatorial Objects and their Generating Functions:
A Maple Class Room Environment
John S. Devitt . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Experiences with Maple in Engineering Education at the


University of Waterloo
Mustafa Fofana, Ian LeGrow, Stephen Carr . . . . . . . . . 27

On Integrating Computers into the Physics Curriculum


Ronald L. Greene . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Using Maple and the Calculus Reform Material
in the Calculus Sequence
David C. Royster . . . . . . . . . . . . . . . . . . . . . . . 43
Interactive Mathematics Texts: Ideas for Developers
Carol Scheftic . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

II. Maple V in Mathematics . . . . . . . . . . . . 65


Truncation and Variance in Scale Mixtures
William C. Bauldry and Jaimie L. Hebert . . . . . . . . . . . . . . . 67
Working with Large Matrices in Maple
Reid Pinchback ......... . . . . . . . . . . . . 77

Using Maple for Asymptotic Convergence Analysis


Noah H. Rhee . . . . . . . . . . . . . . . . . . . . . . . . 87
An Algorithm to Compute Floating Point Groebner Bases
Kiyoshi Shimyanagi . . . . . . . . . . . . . . . . . . . . . . . . 95
III. Maple V in Science and Engineering
Part A: Modeling and Simulation . . . . . . 107
The Use of Maple for Multibody Systems Modeling and Simulation
P. Capolsini . . . . . . . . . . . . . . . . . . . . . . . 109
Sensitivity Analysis of Nonlinear Physical Systems Using Maple
Stephen Carr, Gordon J. Savage . . . . . . . . . . . . . . 118

Exact Calculation of the Kaplan-Meier Bias using Maple Software


Brenda Gillespie, Justine Uro . . . . . . . . . . . . . . . . 128
Rotational Energy Dispersions for van der Waals Molecular Clusters
Lawrence L. Lohr, Carl H. Huben ............... 137
Symbolic Computation in Computable General Equilibrium Modeling
Trien T. Nguyen . . . . . . . . . . . . . . . . . . . . . . . 144
Calculation of the State Transition Matrix for Linear Time Varying Systems
J. Watkins, S. Yurkovich . . . . . . . . . . . . . . . . . . . . . 157

IV. Maple V in Science and Engineering


Part B: Design . . . . . . . . . . . . . . 167
Algebraic Computer Aided-Design with Maple V 2
C. T. Lim, M. T. Ensz, M.A. Ganter, D. W. Storti . 169
The Role of a Symbolic Programming Language in Hardware Verification:
The Case of Maple
Farhad Mavaddat . . . . . . . . . . . . . . . . . . . . . . . . . 176
A Symbolic CSG System Written in Maple V
Darren Thompson, Tom Trias, Laurence LeJJ 188
PREFACE

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.

One of the most encouraging aspects of the


paper sessions was the impressive breadth. It is
a clear demonstration of the influence that Maple
V is having on the research and academic
community. As important as the specific
technical topics are, it is equally important to note
the differences in basic approaches to Maple V-
based problem solving. The collection includes
a wide range of perspectives - from
-computerization- of classical theory to facilitate
more efficient and accurate problem-solving, to
the development of complete Maple V-based
systems for the automatic solution of problems in
ways that are not possible with conventional
computing systems. If this volume is any
indication of the future of mathematical
computing, then it is very clear that we will
witness an even more impressive proliferation of
computer algebra in the years to come.

MSWS '93 and this volume could not have been


achieved without the invaluable assistance of
many dedicated and enthusiastic people. The
Editor would like to express his gratitude to the
reviewers who served to ensure overall quality in
the papers. Furthermore, the assistance of
Paola O'Alessandro, Karin Turner, Jeff Watling,
Lee Liming, Melanie Mclnness, Ann Kostant and
Edwin Beschler is greatly appreciated.

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

This article discusses a set of There is much talk about


Maple programs developed to computer-aided instruction in
reinforce understanding of basic the field of physics and engin-
concepts presented in an eering;' but it seems that the
introductory quantum mechanics computer as a learning device
course. It was designed so that has provided little help for
the solutions of the problems students trying to grasp the
were analytically tractable as basic ideas in these fields.
well as numerically obtainable. Of course, various packages for
We note that there exist various numerical computations are now
approaches to a simple quantum available [1], and it is very
mechanical problem. For example, easy for instructors to introduce
for the problem of bound-states these packages in their classes.
with a one-dimensional potential, In my experience, this type of
the transfer matrix method, the instruction has never succeeded
Laplace transform method, and the in extending a student's ability
Feynman path integral method for a further understanding
can equally be applied. We of physics. There are always
believe that this type of program certain barriers between a lec-
is extremely useful for igniting turer's analytical description
the student's interest and widening on a blackboard and the output
his or her viewpoint. of numerical computations by a
Several examples, such as the computer. Sometimes the result
solution of various one-dimen- in a classroom has been destruc-
sional potential problems and the tive, in that the students under-
solution of the one-dimensional stand less physics and get fewer
Schroedinger wave equation, are computational skills. Actually,
discussed in order to indicate numerical computations cannot
how constructive reinforcement teach students real physics.
is established. On the other hand, it is true
that there are a few problems in
Mathematical Computation with Maple Yo physics that can be solved analy-
Ideas and App/icalions tically. For example, if you
10m Lee, Editor
©1993 Birkhiiuser Boston
wish to explore the behavior of an

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

_ _ _ _--'- •••••• . ••••• ~_____ x


1 + R A + B
-a o a

A exp(- beta a) + B exp(beta a) = T


Fig. lOne-dimensional exp(I alpha a)
square potential barrier.
1. I alpha - 1. R I alpha - 1. A
beta + 1. B beta
Now let us try to find the
solutions for the above problem. - 1. A beta exp( - 1. beta a) + B
We obtain 4 linear equations from beta exp(beta a)
the boundary condition at x =0 and
x=a. The solutions for A, B, T, T I alpha exp(I alpha a)
and Rare

• fl := x -> exp(I*alpha*x) + We obtain 4 linear equations from


R*exp(-I*alpha*x): the boundary conditions at x=O and
f2 := x -> A*exp(-beta*x) + x=a. The solutions for A, B, T, R
B*exp(beta*x) : are;
f3 := x -> T*exp(I*alpha*x):

• el:= 1 + R = A + B:
e2:= I*alpha - R*I*alpha = -A*beta + B*beta:
e3:= A*u + B*v = T*s:

e4:= -A*beta*u + B*beta*v = T*I*alpha*s:


solve({el,e2,e3,e4},{R,T,A,B})i

5
v 1 alpha (1 alpha - beta)
{A 2 --------------------------
%1

(beta + 1 alpha) u 1 alpha


B - 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

Here, u=exp(beta a), v= exp(beta 2iaf3


a), and s = exp(i alpha a). expQ a a){( a 2 -132 )sinh(f3 a)+2i af3 cosh(f3a)}
Substituting these values into the
expressions of T, R, A, and B, the (2.4)
amplitudes of the wave functions
are completely determined. For The transmission coefficient TT*
example, is, therefore

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»;

I alpha beta exp(- I alpha a)


T2 .- - 2
2 2
(alpha - beta 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 )

NUmerical Examples of the


Transmission Coefficients

• 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)

• plot(log(p), ep=O.Ol .. O.4B);

O. 1 0.2 0.3 0.1


-2

- 3

- 1
•8
8
- 5
tJl
0
~
-6

electron energy (eV)

Fig. 2 Tansmission coefficient as a function


of energy of incident electron. The width of
the barrier 10 angstrom and the hight of the
barrier is 0.5 eV.

We have illustrated the quantum approaches for this elementary


mechanical tunneling phenomena problem.
using the symbolic manipulation Of course there are various
program. It is seen that there is interesting approaches to this
well-balanced combination of potential problem. How can you
treat a one-dimensional potential
analytical as well as numerical

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]),

solution for very general potential


barrier can be obtained by a large
i =1,2,.. ,n
(2.6) •
number of segments of constant
height, as shown in Fig. 3.
For convenience, we assume all the
Essentially this is the same
Vi satisfy Vi> E. Defining k 2 and
concept that a definite integral of
some function can be evaluated by as
summing the segments covered over
the integral area.
(2.7)

the solution of the Schroedinger


60
equation within the barrier is

50
1/Ji =Ai exp( ai x)+ Bi ex]:( -ai x)
(2.8) .
40

On the other hand,the solutions in


)( 30 Ain
:0- the regions outside the barrier are
20
Bin 1/Jin =Ain ex]:(ikx)+ Bin exp( -ikx)
1 (2.9) ,
10

0 and
1 2 4

x 1/J out = Aout exp(ikx)


(2.10) .
Fig. 3. Approximation of potential
by segments of flat barrier. The boundary conditions of the wave
function ant its derivative at x-1,
l+w, 1+2w, ..... , 1+ nwestablishes
Indeed, Kalotas and Lee[4] have a linear relation between the A and
reported the exact formulation of B coefficients. The relation can
this general approach. We follow be expressed in a matrix form and
their suggestions in Maple V this is called the Transfer Matrix.
procedures. For example, '" and "" at x=l
The continuous potential V(x) is lead to

9
Ain exI(ikl)+Bin exp(ikl)=Al exp(all)+ Bl exp( -all) (2 .12b) .

ikA.In exp(ikl) - ikB.In exp(ikl) =

The relation between Ainl BinI and


Aoutl Bout is
(2.11) .

[Ain] -M -1 [1,ik]K[ alow]K[a2 W ]. ••• K[an,w]


This can be expressed as Bin '

[ exp(ikl exp( -ikl) ][Ain] xM[I+nw,ik] [ Aout]


ik exI(ikl) -ikl exp( -ikl) Bin = Bout
(2.13) I

[ exp(all) exp(-all) ] [A out 1


al exp(all) -al exp(-all) Bout
where

(2 .12a) I

cosh ( aiw) -(1/ ai )sinh( ajw )]


K[a' w]- [
/' -aisinh(ajw) cosh(aiw)
M[I,ik][A~n ]=M[I,a1] [Aout ]
Bin Bout
(2.14) .

Calculation of M[L,al] M-l[l+w,


al]

• with (linalg):

• ml:=matrix{[[exp{al* 1), exp{-al* 1)], [al*exp{al*l), -al*exp{-


al*l»)));

exp(a1 1) exp (- all)


m1 .-
a1 exp(a1 1) - a1 exp(- all)

m2:=matrix{[[exp{al*{l+w», exp{-al*{l+w»], [al*exp{al*{l+w»,


-al*exp{-al*{l+w»]]);

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 exp(a1 (1 + w)) 2 exp(a1 (1 + w)) a1


m3 .-
1 1

2 exp (- a1 (1 + w)) 2 a1 exp (- a1 (l + w))

• evalm(ml &* m3);

%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))

%1 .- exp(- a1 1) exp(a1 (1 + w))

%2 .- exp (a 1 1) exp (- a 1 (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) .

1/1 II =A cos(y a)+B sin(y a)


When vi< E, a becomes imaginary,
a=i~ , so that the assumption of Vi where
< E can be relaxed to all the
values of a particle energy.

Calculation of RR*

• R:=(alpha A 2 -gamma A 2)*sin(gamma*a)/«alpha A 2 +


gamma A 2)*sin(gamma*a) + 2*I*alpha*gamma*cos(gamma*a»;

2 2
(alpha - gamma) sin (gamma a)
R .- -------------------------------------------------------------
2 2
(alpha + gamma sin (gamma a) + '2 I alpha gamma cos (gamma a)

• RC:=(alpha A 2 - gamma A 2)*sin(gamma*a)/«alpha A 2 +


gamma A 2)*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 )

From Eq. (2.17) it is easily seen


that RR* approaches zero when the
electron energy is large enough electron energy (eV)
compared with V. However, due to
sin2 (ga). factor involved in Fig.4. Numerical example of
Eq. (2.17), there is resonant resonant scattering by one-
scattering of electrons from the dimentional square barrier.
potential barrier.
We have shown several examples
Numericalexample of the resonant of how to use Maple V for simple
scattering. one-dimensional potential
problems. Some of the results
• m:=9.01*lOA{-31): can be easily extended to solve
hbar:=1.0546*lOA{-34): the electronic states in one-
v:=O.5*1.602*lOA(-19): dimensional periodic potential
en:=ep*1.602*lOA(-19): arrays [5], which is the basis of
g:=sqrt(2*m*(en-v»/hbar: the general theory of band
a:=lO*lOA(-lO): structures in solids. The
pl:=v A2*{sin{g*a»A2: Laplace transformation method [6]
p2:=v A2*{sin{g*a»A2 + 4*en*{en-v) is one of the more powerful
r:=pl/p2: approaches to periodic potential
plot(log(r), ep=1 .. 20,
problems.
numpoints=500);
A weakly coupled harmonic
oscillator is one interesting
It is seen from Fig. 4 that problem, from which we can intro-
there are resonant transmission duce the model of lattice
of incident electrons when ba=n vibrations in a simple crystal.
pi. We can expect that similar Feynman's path integral is
resonant transmission can be another approach to the
observed in a one-dimensional tunneling problem [7]. Although
square well potential. it is necessary to give a
comprehensive introduction to

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

3. Time-Dependent Solutions of (3.2a)


Wave Packets
is also the solution of the wave
equation, where pn corresponds to
We have shown several typical
different momenta pn. Replacing
examples of stationary state wave
the sum by an integral, we have
functions in simple potentials in
the previous sections. The time- 00
dependent behaviors of the wave 'l/J(X/)= ff(P)¢ipn(x-xQ,t)dp
functions are one of most difficult -00

problems for the undergraduate


students to grasp their physical (3 .2b),

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) .

"'" -1/2 [-i(Et-PX)]


¢i P = (2m I) exp 1) Using the Fourier transformation,
the probability density for
(3 .1a), observing the free particle at
position x and time t is given by
which satisfies the time-dependent
Schroedinger equation

1'l/J (x,t )12 = 1


~exp
[[X-(XQ
2
+vt)2]
",2:Jrax 2a
x

(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

A very important point about the


wavepacket is the fact that it must 8'l/J( x ;r:) 112 a2'l/J( x ;r:)
satisfy Heisenberg's Uncertainty aT: 2m ax 2
Principle. In fact, the widths
ax and op satisfy the relation (3. 5a),

and this is a typical diffusion


equation with a diffusion constant
D, where
Examples of the wavepacket
dispersion and the propagation of 1')2
wavepacket are illustrated in Fig. D=-
2m
5a and Fig. 5b. (3. 5b) .

(al (bl

Fig. 5. (a) Diffusion of a Gaussian


wavepacket.
(b) Propagation and diffusion of a
Gaussian wavepacket.

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)

technique for this problem is the


~
finite difference method in which '0
Q)
the wave equation is replaced by ....N
..-1
the corresponding difference
e
CIS

equation:
~
0
-1.0 1.0

Normalized x

Fig. 6. Monte Carlo Simulation


of the ground-state of simple
harmonic oscillator.

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.

2) It is very dangerous for the


instructor to overestimate the
effect of numerical results on
the basic understanding of
physics. The instructors should
endeavor to seek creative
computer programs which involve
well-balanced analytical and
Fig. 7. Transmission and numerical solutions. These
reflection of a Gaussian programs may continue to keep
wavepacket by square potential the student's interest and we
well. a) t=O, b) t=300. can expect these kinds of
programs to reinforce the
student's basic understanding of
quantum mechanics.
5. Concluding Remarks
3)The instructors should
We have shown several well- illustrate the fact that there
balanced computational programs exists basic principles which
for elementary quantum mechanics can be applied for a wide
which involve analytical as well variety of the problems.
as numerical calculations using
We have concretely shown that
the symbolic manipulation
Maple V offers excellent tools
programs, Maple V. We would
to satisfy the above mentioned
like to point out the following
facts.
remarks for this program:

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.

[5] Y. Abe, "Bound-State Solutions


for One-Dimensional Periodic
Potential with Multiple Barriers
per Period, Bulletin of the Faculty
of Engineering, Hokkaido
University, 158, (1992) 57-69.

[6] P. H. A, Santana and A. Rosato,


"Use of the Laplace transformation
to solve the one-dimensional
periodic potential problem", Am. J.
Phys. 41, (1973) 1138-1144.

[7] B. R. Holstein and A. R. Swift,


"Barrier penetration via path
integral", Am. J. Phys. 50, (1982)
833-839.

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

1 Introd uction In this paper we introduce a package that is spe-


cially designed to address these two key points and
Combinatorial generating functions are an impor- which is in use across all introductory combina-
tant part of any introduction to combinatorics. A torics sections at the University of Waterloo. The
good introduction to them must reenforce the con- package includes support for the representation of
cepts of weight functions and the existence of a infinite sets, the systematic generation of portions
one to one correspondence between the monomi- of those sets, and for obtaining multivariate gen-
als representing the objects in the combinatorial erating functions in closed form. There are a wide
set and the objects themselves. An entire set is variety of specialized operations for binomial series
represented by a sum of monomials. The combi- and their combinations.
natorial information about the set is deduced by We begin with several examples of how the pack-
simplifying or manipulating that sum. age can be used to solve enumeration problems for
An effective computational environment for sequences over a finite alphabet. This is followed
studying this topic must include facilities for the by a discussion of the key issues that arise in at-
generation and manipulation of a large variety of tempting to deal with these types of problems and
sets of combinatorial objects and the correspond- some concluding remarks.
ing generating functions. There must also be con-
trol over the amount of user interaction required
to complete each transformation. 2 Examples
While considerable support for generating com-
binatorial objects already exists in Maple through We focus primarily on sequences over a finite al-
the use of lists, sets and through various routines phabet though other combinatorial objects can
in packages such as combinat and numtheory and a be supported using the same tools. The class of
variety of representations of generating functions sequences we are concerned with are those con-
by way of packages such as genfunc, powseries and structed by regular expressions.
other generating function packages found in the
Example 2.1 Generate the collection S of all se-
share library none of these address two important
quences over the alphabet {O, 1, 2}.
questions:

1. The automatic construction and manipula-


Solution: For example, the collection S of all
tion of generating functions using one or more sequences over the alphabet {O, 1, 2} can be gen-
weight functions simultaneously. erated as
> A := alphabet(O,1,2);
A := {O, 1, 2}
2. The extension of these tools to infinite combi-
natorial sets often arising in connection with > Star({O,1,2});
the representation of generating functions in [{O, 1, 2}]

closed form.
>S := genseq(");
S := [phi, 0, 1, 2, 00, 10, 20, 01, ii,

21, 02, 12, 22, 000, 100, 200, 010,


Mathematical Computation with Maple ~ 110, 210, 020, 120, 220, 001, 101,
Ideas and Applications
10m Lee, Editor 201, 011, iii, 211, 021, 121, 221,
©1993 Birkhauser Boston 002, 102, 202, 012, 112, 212, 022,

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

To compute the average number of blocks we > c2 := getcoeff(",x,n);


n n
must be able to extract coefficients. To get the c2 := 1/2 2 + 1/2 2 n
coefficient of xn in the series corresponding to f
we do so that the average number of blocks is just
> normal( subs(u=l,c2/c1) );
> fl := convert(f,Series,x); 1/2 + 1/2 n
infinity
nl n1
\ u (u + 1) x
fl:= ) 2 --------------- The specialized series represented by Series can
/ u + 1
be manipulated in a manner similar to Maple's
nl = 0 ordinary series data structure. Consider the two
> cl := getcoeff(" ,x,n); senes
n > sl := convert( 1/(1-x)-2,Series );
u (u + 1) infinity
cl := 2 ----------
u + 1 \ n1 [ -2] n1
sl:= ) (-1) [ ] x
which simplifies to 2n. / [ n1 ]
> subs(u=l,"); n1 =0
n
2 > s2 := convert( 1/(1+x)-3,Series );
infinity
To compute the average number of blocks of size
n we need to compute \ [ -3] n1
s2:= ) [ ] x
/ [ n1 ]

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

2 Solution: The set of all 0-1 sequences is gener-


+ 12 (k + 1) k + 4 (k + 1) k ated by
2 2 > alphabet (0 ,1);
- 14 (k + 1) - 8 (k + 1) k {O, 1}

>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.

+ 2 x 2. The sets of sequences constructed by way of


> closedform(II);
these regular expressions are typically infinite
closedform: in size.
You may vant to compare this estimate
vith the next order of approximation! 3. A naive cartesian product between two even
3
1 + 1/2 x modestly sized sets results in objects that are
too large to manipulate or to deal with visu-
3
1 - 2 x + 1/2 x ally.

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

6 7 8 Though they print as if concatenated they are


+ 52 x + 193/2 x + 179 x
actually represented as by an unevaluated function
9 10 call. They are constructed by the command Seq( )
+ 332 x + O(x )
as m

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,

> Seq(1,10): 011, 001, 0111, 0000, 1111, 0011,


1_10
0001, 00000, 11111, 01111, 00111,
and are actually objects such as
00011, 00001] + Objects(nops = e)
> Iprint(II):
_sequence(1,10) takes full advantage of the fact that a truncated
A typical infinite set is generated by an expres- representation of these infinite sets is in use and
sion like {O,l}*. We call this the "star" product that the elements are sorted.
and enter it as The routine genfunc( ) works with either regu-
> Star({O,1}): lar expressions or the combinatorial sets produced
[{O, 1}] *
by genseq( ). The regular expressions are used
to construct a closed form if a closed form is re-
Sequence concatenation is denoted by a list as in quested for a combinatorial set provided that such
> [Seq(2),",Seq(2)]: information is available.
[2, [{O, 1}] , 2]* > genfunc( S , x, nops , closedform):
1
in which each element is either an alphabet symbol
2
or a regular expression or a set of sequences or (1 - x)
alphabet symbols. We can also represent unions
If the argument is an infinite set and no closed
as '+' as in form has been requested then an explicit count of
> A := [ Seq(O,1,2,1,O) ]:
A := [01210] the sequences of the various weights is made and
the truncated series corresponding to these sam-
> B := [ Seq(2,1,O,2,2) ]:
B := [21022] ple sequences is given. The command closedform(
) simply used pade approximates to guess at the
> S := genseq(3*A + B):
S := [3 01210, 21022] closed form.
> genfunc(S,x,nops):
The result is actually an multiset and it is some- 2 3 4 5
what analogous to Maple's truncated series ob- 1 + 2 x + 3 x + 4 x + 5 x + e x
jects. e
> Iprint(S): + O(x )
_Genseq([[3, _sequence(O,1,2,1,O)], [1,
_sequence(2,1,O,2,2)]],nops,30,false,5,2 > closedform(II):
,3*_sequence(O,1,2,1,O)+_sequence(2,1,O, closedform:
2,2» You may vant to compare this estimate
vith the next order of approximation!
Typically only a sample of the sequences are gen- 1

erated and displayed. This is the first component 2


of the data structure and lists some of the se- 1 - 2 x + x
quences along with their multiplicity (or more gen- We also support multivariate generating functions.
erally their coefficient from the sequence monoid). The generating function is regarded as a formal
The remaining information is used to keep track univariate series in the first variable.
of, for example, which weight function was in use, > alias(v=countsubstring):
whether or not there are sequences in the set which > genfunc(S, [x,s,t], [nops,v[O] ,v[1]]):
2 2 2
are not displayed, the size of the set, the weight 1 + (s + t) x + (s + t + S t) x
function used to sort the sequences, and finally a
3 3 2 2 3
regular expression which can be used to regenerate + (s + t + s t + S t) x
the set if a larger sample of sequences is requested.
3442234
The concatenation of two sets as in + (s t + s + t + s t + S t) x
> A := Star(O):
+
A := 0
*
55 423324
> B := Star(1): (s + t + s t + s t + s t + S t)

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,

0000, 1111, 0011, 0001]


Biography
or
> select(nops> 8,5); J. S. Devitt completed his Masters degree in Com-
[]
binatorial Number Theory under the supervision
In addition, some indexed families of functions of Richard Guy at the University of Calgary in
have been provided to aid with selections and 1976. His Ph.D. in Combinatorics and Optimiza-
as weight functions. We have seen examples of tion was completed under the supervision of David
countsubstring( ). Another useful one is Jackson at the University of Waterloo in 1981. He
> select( hassubstring[O,O,1,1] , 5 ); has been on staff at the University of Saskatchewan
[0011, 00111, 00011]
since 1984 where he is currently an associate pro-
or fessor of Mathematics. He is author of the recent
> select( Rot(hassubstring[O]) , 5 ); text Calculus with Maple V and has had extensive
[phi, 1, ii, iii, 1111, 11111] experience in adapting Maple to specific courses.
Where possible, the extendable Maple com- His research interests include the construction of
mands have been used to implement these objects environments for exploring specialized computa-
and to facilitate interaction with these new ob- tional domains. Current projects include inter-
jects. For example, each of series(), diff() and active environments in support of combinatorics,
value( ), have enhancements. convex analysis, and the exact solutions of partial
differential equations.

4 Concluding Remarks [email protected]


This package arose primarily as a vehicle to de-
liver tutorials for the introductory combinatorics
course taught at the University of Waterloo. This
course is taught at the second year level and is
approximately half generating functions and half
graph theory. It is based on departmental notes
that have been refined over the past decade. Re-
view material and assignments on enumeration
and graph theory have been constructed using
Maple V release 2 worksheets and now form part
of that course. The objective is to give students
a chance to discover the close correspondences be-
tween algebraic and set theoretic operations and
to apply them to substantial problems.
The extent to which we have been able to ac-
commodate all of the techniques dealt with in that
course has been pleasantly surprising. The level of
support this package provides for the basic opera-
tions provides a truly exciting way to experiment
with combinatorial sets of a size that begins to

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

Abstract The introduction of Maple software has been


at the initiative of the instructors of these
At the University of Waterloo, several courses, and with the support of the facilities
faculty members in Engineering have and expertise offered by the Engineering
attempted to introduce Maple software into the Education Research Centre (EERC).
engineering curriculum. Most of these The EERC has a mandate to support
attempts have been conducted with the the effective use of new information
assistance of the Engineering Education technologies in engineering education.
Research Centre. This paper summarizes some Engineering Computing and the EERC
of the difficulties, successes, and lessons currently support networks of Unix
learned in these ventures, and provides some workstations and Macintoshes in specialized
recommendations for future endeavours. teaching laboratories. In addition, a large
network of PCs is available for general use by
engineering undergraduates.
The motivations for introducing Maple
1. Introduction into the engineering curriculum are many.
Perhaps the primary reason is to remove the
The recent availability of symbolic tedium associated with "hand" calculations,
computation languages and their demonstrated freeing the student to explore the subject
effectiveness in academic applications has material through a "What if .... ?" process
fostered several enthusiastic attempts to which enhances understanding. Maple's two
introduce Computer Algebra Systems (CASs) and three-dimensional plotting capabilities,
into the engineering curriculum at the though lacking at the time of the initial trials,
University of Waterloo. Because of its was a motivating factor in subsequent efforts.
availability and the existence of a local support An additional motivation for one of the earlier
structure, Maple Software has been the projects (Lee and Heppler [1990)) was to
package of choice at the University of introduce "higher level" concepts into the
Waterloo. Courses in which Maple software curriculum, such as an appreciation for the
has been introduced are: Ordinary Differential difficulties of actual engineering design. Such
Equations, Partial Differential Equations, attempts at introducing deliberately under-
Structural Mechanics, Dynamics, System defined design problems would be untenable
Modelling, Linear Control Systems, etc. These within the time constraints of an average
courses are typically offered in the second or undergraduate course without the powerful
third years of the engineering curriculum. analytical capabilities of CASs and
complimentary numerical analysis packages.

Mathematical Computation with Maple V:


Ideas and Applications
10m Lee, Editor
©1993 Birkhiiuser Boston

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).

In the differential equations courses, examples


2. Course Organization were provided from a library compiled by the
EERC teaching assistant (T.A.). Some of
these examples worked out with the students
In all courses, Maple software was
are as follows:
introduced in optional tutorial sessions as a
supplement to regular lectures, assigrunents
# (QI). Define differential equation
and tutorials. Because this approach imposes
an additional workload for the students, the use
> de I :=diff(y(x),x)-y*cot(x)=2 *x *sin(x);
of Maple software was not mandatory.
However. in the case where challenging design
projects were assigned. this was significant
incentive for the students to participate
del: = dax (y(x) ) - ycot (x)
(Heppler [1989. 1990]). =2xsin (x)
The computing platform selected for
all but one course was the Project Beacon
Laboratory, a network of IS Unix
# General solution
workstations. The remaining courses selected
the Project Libra Laboratory. a network of IS
> ygsl:=dsolve(del,y(x»;
Macintosh II series workstations. The choice
of computing platform was for the most part
determined by the superior computing power del: =y(x) = sin (x) Xi +
of the Unix workstations compared to the other sin(x)Cl
platforms, along with the lack of
complimentary numerical analysis software the
Libra Lab. Note, however, that within the last
# Graphs of y(x) for arbitrary values of CI
year hardware improvements to the PC
network has also made it a viable platform
> s:= {};
option. Since the students were less familiar
with the Unix operating system and supporting S : = {}
software such as text editors, it was further
necessary to include familiarization tutorials on
> for i from -4 by 2 to 30 do
these subjects. The typical organization of the
optional Maple sessions was:
> CI:= O.S*i;
> s:=s union {sin(x)*xI\2 + C I *sin(x)};
• Introduce the operating system > od:
> plot(s,x = -Pi .. 2*Pi);
(approximately 1/2-1 hours);

28
> simplify(");

Seos (xl =Seas (x)

#(Q3). Define differential equation

> de3:=x"2*diff(y(x),x$2)+5*x*
diff( Y(X),x)+4*y( x)=x"2+ 16*(\n( x»"2:

de3 : =x 2 ( a~2 y (xl l +

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

> subs(y(x)=rhs(ygs2).de2); # Checking the general solution

(i:2 ~ cos (x) - sin (x) + > subs(y(x)=rhs(ygs3 ),de 3);

Cle 'x +C2e X ) -4( a lcos(x) x2 ( a2


1 %1) ... 5 x ( a 1 %1 '
Tx7 d?R TxTb'
-sin(x) +Cle l '''+C2e X ) + ... 1 %1 = x 2 ... 161n (x) 2
~cos (x) - 3 sin (x) +
"4
3 Cl e1x + 3 C2 eX '" 5 cos (x) %1 : =~ ( X4 + 641n (x) : x2 -
X"
1281n (x) x" + 96x 2 +
16Cl + 16C2In (x) )

29
> simplify ("); a2 1 2 28 122
(
dx2 - ""S" x - 7S" x - "T25" +

x' + 161n (x) c =x~ + 161n (x) 2


b11 eX + ~e107 -5x) + 4 ( a -
I:JU Tx
1 x2 28 122 11
""S" - 7S"x - T2"5' + b eX +
107 -5x) 2 28 122
# (Q4). Define differential equation
""7"S"O e +x +"""'5"" x + """7s- -
55 107_
b eX - T'5O e 5X =x 2 + 4 x
> de4:=diff(y(x),x$2)+4*diff(y(x),x)-
5*y(x)=x"2+4*x;

> 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

# Define two initial conditions # (Q5). Define differential equation

> icl:=y(O)=l; > de5:=diff(y(x),x$3)-2*diff(y(x),x$2)-


5*diff(y(x),x)+6*y(x)=exp(3*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

# Note that D is the differential operator > icl:=y(O)=O;

# Particular solution icl :=y(O) =0

> yps4:=dsolve( {de4,icl ,ic2} ,y(x»;

> 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:

• Students often became frustrated with having


to learn a new operating system and text editor
(Le. Unix and vi-editor).
# Checking the particular solution • The Maple Symbolic language has a
relatively steep learning curve. Students found
> subs(y(x)=rhs(yps5),de5); the Maple syntax to be "unnecessarily strict"

( a:"J ~ e'x + ia- xe3X -


(see Heppler 1990, SDE 353 course critique),
referring to ":=" and the terminating n;n. The
language also includes unfamiliar data
1 eX+ 4 e-2x) -2 (a 2 3 e 3x structures such as sets and lists as separate
TI 15 dxr TOO from arrays. Most other complaints have been
+~xe3X-~eX+~e-2X) _ addressed in subsequent versions of the
10 12 75 program, with the notable exception of the
inability to list user-assigned variable names.

• Students were daunted by the broad scope of


Maple, often fmding it difficult to find the
proper functions necessary to complete an
operation.

• There was little incentive to learn Maple and


a new operating system. Students wanted to
ensure that is was worth their while to put in
the extra effort to do so.

• Students complained that too much new


> simplify("); information was presented at once. In many
courses, the introductions to Maple software
and the Unix operating system were presented
together in a single one or two-hour session
which was overwhelming to the students.
Also, this was done at the beginning of the
semester when unfamiliar course material
It is noteworthy that Maple software being presented in the classroom.
allowed solutions to assigmnent and tutorial
problems to be distributed as "solution • In those course-experiments which were
templates" written in the Maple language. initiated by the EERC rather than by the
This approach forced the students to actively course instructor, there was often a lack of
work through the solutions themselves, continuity between the terminology and
simultaneously reinforcing Maple syntax and examples used in the classroom and those
course concepts. presented in the optional Maple sessions.

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.

Heppler, G. R, Course Critique of Systems


Design (SD) 352 - Linear Control Systems,
Internal Report, 1990.

33
ON INTEGRATING COMPUTERS INTO THE PHYSICS
CURRICULUM
Ronald L. Greene
Department of Physics, University of New Orleans, New Orleans LA, USA

Abstract changing; the computer is entering our core


lecture courses. 9 Despite this progress, however,
Abraham, et al. 10 recently expressed a widely-held
In this paper I present a case for using a
view when they wrote, "How to accomplish the
unifying computational tool in core upper division
integration of computing into the undergraduate
physics lecture courses to help elucidate the
[physics] major is an important question for the
physical principles discussed. I argue that a
profession. "
computer algebra/calculus system such as Maple
is the most appropriate software class for such a
role, and discuss several guidelines for its use.
Some experiences acquired in using Maple V in A Unifying Computational
junior level classical mechanics at the University Tool
of New Orleans are used to illustrate the
argument. Three problems taken from the course
In my view, the most effective way of
are presented to illustrate the use of Maple.
integrating computers into a diverse set of upper
division lecture courses is to provide students with
working knowledge of a unifying interactive
Introduction computational tool. If students are taught to use
the tool early in their studies, instructors of
At most colleges and universities in the U.S. advanced classes can utilize this common
the lecture portion of the core undergraduate computational background to present
physics curriculum has remained substantially demonstrations or make computationally intensive
unchanged for over 20 years. In particular, we homework assignments, without the necessity of
physics professors have been very slow to spending class time teaching computer techniques
incorporate the use of computers into our lecture rather than physics. Students could reap the
courses, despite the fact that we routinely use pedagogical benefits of interactive computing
them in our research. Historically, technological without having to learn different software
limitations (expensive hardware and poor quality packages for each course. Furthermore, if the
pedagogical software), together with faculty tool is powerful enough, students will find it
inertia, have discouraged us from breaking with helpful not only in their physics and other course
the status quo. work, but also in their future employment.

Now, however, the technological barriers Computer Algebra/Calculus Systems (CACS)


have all but disappeared. Hardware has become offer the most promise for providing a powerful,
quite affordable, even for poorer departments. yet easy to use computational tool. (The potential
Excellent demonstration software and textbooks on for using CACS in physics courses has been
applying computers to physics problems and recognized by a number of other physicists; see,
simulations have appeared. I -8 Things are for example, Refs. 11-15.) Their major advantage
over other software tools such as spreadsheets and
conventional programming languages or
Mathematical Computation with Maple ~
Ideas and Applications
environments is that they are readily used in a
10m Lee, Editor non-declarative programming mode. This allows
©1993 Birkhiiuser Boston users to specify what is to be solved, without
concern for the details of how it is to be solved.

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.

4) Do not insist on using the CACS for


My guiding principle for using a CACS, or
things that are more easily done by hand.
any other computational tool, in an undergraduate
One of the things that can take the most
course is this: The primary purpose of the
time and require the most experience for
computational tool is to enhance students'
success is cajoling the computer to yield
understanding of physics. This principle has led
the "simplest" form for an expression.
me to adopt several guidelines for incorporating
In learning to use a CACS it can be very
the use of CACS in physics courses.
frustrating for a user to see an obvious
simplification that the computer refuses to
1) The effort required to learn to use the
make. If simplification is necessary (It is
system should be minimal. This can be
not for such tasks as plotting or for
achieved by teaching students to use a
intermediate results that will be used to
highly restricted subset of the program.
get limiting cases.), and it is easier for
For example, a small subset of Maple V
students to work out the simplified form

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

Undergraduate classical mechanics at the


University of New Orleans is taught as a series of
two courses, one at the junior level and the other tutorial (about 65 pages total). Table I gives a
at the senior level. I taught the junior level course listing of most of the basic functions that I
in the Fall 1992 semester, incorporating the Maple recommended students use for their assignments.
V system into the course. The brief explanation describes what the given
function was used for in the course; many have
The first few weeks of the course were other uses as well. In addition to these basic

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.

The version of Maple V, Release 1 used in


the course was installed on our departmental IBM
RS/6000 workstation network, running AIX with
Xwindows. However, every function we used is
also available on the MS-DOS and Macintosh
Student Versions, which are available from
Brooks/Cole Publishing.

One characteristic of Maple is that if you type


in a syntactically correct command with a function
name which has not been defined (perhaps a
mispelled or improperly cased name for one of the Figure 1. Sketch of the system of Example 1.
predefined functions), the program will return the Masses Ml and M2 slide toward each other with
expression as typed, with no comment. Every coefficients of friction J-t.
student was baffled by this at one time or another.
However, they learned to carefully check their Let us consider the case in which M 1 and M2
typing and function names when the expected are each initially moving toward the center of the
answer failed to appear. More troublesome were figure. Applying Newton's 2nd law to the three
the occasions when Maple was given a command masses (assuming positive directions given by the
that it apparently could not compute, and it simply arrows in the figure) we get the following three
returned a prompt for the next expression. This equations:
lack of explanation was annoying and puzzling to
both students as well as the instructor. J-tMlg - T = Mlal
J-tM 2 g - T = M2~
M3g - 2T = M3~ .
Example Problems
There is, in addition, a constraint due to the fact
In order to provide a clearer picture of how that the length of the rope is constant. This
Maple can be used in the first classicial mechanics requires that Xl + x2 + 2 x3 = constant, or
course, I present three example problems below.
The purpose of these examples is to give a flavor
of how solutions can be obtained and analyzed
using Maple. The first example is a homework This example is typical of the kind of
problem taken from the review chapter of the Newton's 2nd law problem that students work in
their introductory course. Since all the forces and
mechanics textbook. The second is a problem
taken from one of the exams, while the third is a accelerations are constant, obtaining the solution
requires simultaneously solving four linear
look at a sinusoidally driven harmonic oscillator
algebraic equations, a trivial job with Maple. As
(which was presented in a class lecture).
instructors of the junior level classical mechanics
course, we would like to insure that our students
Example 1 can correctly set up the coordiates and second law
The system shown in Fig. 1 consists of two equations for these kinds of problems, and
masses (Ml and M2) sliding on horizontal properly visualize limiting cases of the motion.
surfaces, each with a coefficient of friction J-t. However, the tedium of solving multiple equations
The third mass (M3) is connected to a frictionless by hand normally prevents us from assigning very

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

sol: = dsolve( {eqx,eqy,vx(O)=vOx,vy(O)=vOy}, X := (b,t) -> int(VX(b,s),s=O .. t);


{vx(t),vy(t)}); . Y : = (b,t) -> int(VY(b,s),s=O .. t); .

(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
" \
\
,
\

the velocity as a function of time for three


different drag coefficients: b=O, 1, 10 kg/so The
"
\
\
\

command is " " "


.,
plot({limit(VY(b,t),b=O), VY(I,t),
VY(IO,t)},t=O .. I);

Figure 3. Tr~ectory of the projectile described


in Example 2 for three different values of the
- ... . . drag coefficient.
., "
"" yields the three curves shown in Fig. 3. The
decrease in range and the increasing deviation
from parabolicity with increasing b are quite
., evident in the figure .
"
., " Example 3
"" The last example problem is that of a
" sinusoidally-driven, underdamped harmonic
oscillator. A lot of physics can be extracted from
the harmonic oscillator in its many forms.
Figure 2. Vertical component of the velocity as However, for the sake of brevity, let us consider
a function of time for the projectile described in one specific aspect of the problem --- that of
Example 2. energy absorption by the oscillator from the
driving force.
The results are shown in Fig. 2. The b=O curve The following is the equation of motion for a
shows the expected linear dependence of the
damped, sinusoidally-driven oscillator (not the
velocity upon time. The b= 10 kg/s curve, which
most general form):
corresponds to a small density object like a
styrofoam ball, clearly shows the rapid onset of F sin (lI) t) -b dx( t) -.kx( t) =m d 2 x( t)
terminal velocity. o dt dt2
Dividing by m and rearranging terms yields
To see the effect of drag upon the trajectory
of a projectile in two-dimensions, we change the
values of vox and vOy' and use Maple's parametric

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); .)

We could examine the solution at this point


and discuss transient and steady state terms.
However, we will instead concentrate on the
energy of the oscillator. We first define the
kinetic and potential energies:
Figure 4. The energy of the sinusoidally-driven,
K : = m*v A212; underdamped harmonic oscillator of Example 3 as
U : = m*(wO*x(t))A2/2;
a function of time, for three values of the driving
frequency.
In order to plot results, we need to assign
numerical values to the parameters; for example,
we get the result shown in Fig. 4. At this point in
m:=l; wO:=l; F:=l; gam: = 1110; the course the students had already seen that the
energy of the undriven, undamped oscillator is
Note that this corresponds to a lightly damped constant, and that of the undriven, damped
oscillator. Furthermore, by taking -y to be 1110 oscillator decreases in time. Thus it was clear to
rather than 0.1, we avoid problems arising from them that the initial increase in energy in this case
rounding of floating point numbers (which can comes from the driving force. The meaning of
lead to small, but non-zero imaginary parts). steady state is also clarified by the long-time
behavior of these curves.
Let us first look at the total energy of the
oscillator as a function of time for three values of The effects of resonance, which are suggested

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

starting times below (By t= 10/)' the transients t .s


I I
I I
have effectively died out, as Fig. 4 showed, I

whereas at t=O they are very much present.):

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

Abstract sequence. The derivative was developed graphically


Computer Mathematics Systems and Calculus Re- as the slope of the tangent line and the tangent line as
form Material are topics of discussion in many the limit of secant lines, but when it came time to
Mathematics Departments. There are many ques- work with the derivative we would retreat to our
tions about how to best use each of these in mathe-
symbolic representation. The integral is introduced as
matics courses. Research into the way that college
students learn mathematics will have a great
area under a curv~adding up the areas of small rec-
impact on the way that we teach mathematics and tangles based on the value of the function at some
how we use these tools. We discuss some of the point in each subinterval: the Riemann sum. We
questions and offer my experience in using both would do a Riemann sum for very few functions and
tools together to have one reinforce the other. immediately would retreat to the Fundamental Theo-
rem of Calculus as a tool for evaluating definite inte-
Introduction grals. In fact most students did not see the mathe-
matical excitement of the Fundamental Theorem of
In 1986 a call went forth to consider seriously the Calculus. They saw it only as a tool for evaluating
Calculus sequence. In response to that call a confer- integrals.
ence was held at Tulane University and issuing forth
therefrom came Toward a Lean and Lively Calculus Using multiple representations to a better pur-
[Doug86]. This was the first concerted effort to look pose was seen as one way in which the Calculus cur-
at the calculus sequence and see what, if anything, riculum should chang~to give equal importance to
needed to be changed. Many threads were started at each of the different representations and work with
this workshop that are today weaving their way the different representations throughout the course.
through the mathematics curriculum. However, numerical representations took a long time
to compute and were rarely done. To fmd a zero of a
The National Science Foundation listened to the function we would use Newton's method if it con-
call made in this workshop and seeded projects to verged quickly, but would rarely use the bisection
make changes in the Calculus curriculum. In the in- method, though pedagogically simpler to motivate.
tervening 7 years major changes to the Calculus cur- The time required to do these computations was a re-
riculum have been proposed. While not all of the stricting factor. In addition, it was difficult to use the
projects started with the same goals, certain ideas graphical representation, because it took a lot of time
came to the forefront in each of the projects. One of to draw the graphs and then they were not necessarily
the basic tenets that arose in each project was that drawn well.
each of the basic concepts of Calculus should, if at all
possible, be presented symbolically, graphically, and At this time there were computer programs
numerically. This idea of multiple representations is available that could deal with the graphical represen-
not new to Mathematics or Mathematics Education, tation, the numerical representation, and the symbolic
but it was not used to any great extent in the Calculus representation. They were not widely available and
the delivery of these progrruns to a large audience
was a concern. At about this time the graphing
calculator fortuitously arrived on the scene. Also in
Mathematical Computation with Maple ~ the late 1980s, the computer mathematics systems
Ideas and Applications
began to expand their different abilities and availabil-
10m Lee, Editor
©1993 Birkhiiuser Boston ity on different platforms and their user in

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.

[Pa1m91] Jeanette Palmiter. Effects of computer


algebra systems on concept and skill
acquisition in calculus. Journal for Re-
search in Mathematics Education,
22(2):151-156,1991.

[RaI90] Anthony Ralston. the effect of technol-


ogy on teaching collegiate mathematics.
In Franklin Demana, Bert K. Waits, and
John Harvey, editors, Proceeding of the
Conference on Technology in Collegiate
Mathematics, pages 78--82, Reading,
MA, 1990. Addison Wesley

[SH86] Donald B. Small and John M. Hosack.


Computer algebra systems, tools for
reforming calculus instruction. In Ronald
G. Douglas, editor, Toward a Lean and
Lively Calculus, pages 143-156, Wash-
ington DC, 1986. the Mathematical
Association of America. MAA Notes 6.

[Zom90] Paul Zorn. Algebraic, graphical and


numerical computing in elementary
calculus: Report of a project at St. Olaf
College. In Franklin Demana, Bert K.
Waits, and John Harvey, editors, Pro-
ceeding of the Conference on Technology
in Collegiate Mathematics, pages 92-95,
Reading, MA,1990. Addison Wesley

David C. Royster received his B.A. in mathematics from


the University of the South, Sewanee, TN in 1973 and his
Ph.D. from Lousiana State University in 1978. His thesis
was written under the direction of Pierre Conner. His
research interests are group actions on manifolds, differen-
tial topology and geometry. After teaching at the Univer-
sity of Virginia and the University of Texas, Austin, he is
currently an associate professor of mathematics at the
University of North Carolina at Charlotte. Current research
involves research into the learning of calculus and the use
of computer mathematics systems in college level courses.
He can be reached at:
Department of Mathematics
UNC Charlotte
Charlotte, NC 28223
USA
email:[email protected]

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.

The following sections will cover a number


Mathematical Computation with Maple ~
of such characteristics that arise often,
Ideas and Applications particularly for beginning IMT developers;
10m Lee, Editor as you gain experience, you will be able to
©1993 Birkhiiuser Boston extend this list yourself.

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.

Gardner, Howard. (1983). Frames of Mind: Steinberg, Esther R. (1991). Computer-


The Theory of Multiple Intelligences. Basic Assisted Instruction: A Synthesis of Theory,
Books. Practice, and Technology. Hillsdale, NJ:
Lawrence Erlbaum Associates.
Heines, Jesse M. (1984). Screen Design
Strategies for Computer-Assisted Walker, Decker F., & Robert D. Hess.
Instruction. Bedford, MA: Digital Press. (1984). Instructional Software:
Principles for Design and Use. Belmont, CA:
Johnson, D. W., & F. P. Johnson. (1987). Wadsworth.
Joining Together: Group Theory and Group
Skills (Third Ed.). Englewood Cliffs, NJ: Zimmerman, Walter, & Steve Cunningham
Prentice- Hall. (Eds.). (1991). Visualization in Teaching
and Learning Mathematics. MAA Notes
Johnson, D. W., & R. T. Johnson. (1975). Number 19.
Learning Together and Alone: Cooperation,
Competition, and Individualization. About the Author
Englewood Cliffs, NJ: Prentice-Hall.
Carol Scheftic has a B.S. in Mathematics
Kearsley, Greg. (1986). Authoring: A from Carnegie-Mellon University (1971),
Guide to the Design of Instructional and both an M.A. in Mathematics Education
Software. Reading, MA: Addison-Wesley. (1973) and a Ph.D. in Educational
Technology (1985) from the University of
Keller, Arnold. (1987). When Machines Pittsburgh. In the process of researching
Teach: Designing Computer Courseware. appropriate applications of technology in
New York, NY: Harper & Row. education, she has taught mathematics and
computer science at all levels from
Larkin, Jill H., & Ruth W. Chabay (Eds.). elementary school through post-graduate
(1992). Computer-Assisted Instruction professional education. She is currently a
and Intelligent Tutoring Systems: Shared Lecturer with the Department of
Goals and Complementary Approaches. Mathematics at Carnegie Mellor., where she
Hillsdale, NJ: Lawrence Erlbaum directs projects on collaborative learning
Associates. and the uses of computer algebra systems in
undergraduate mathematics. She also
Moursund, Dave. (1986). Computers and teaches workshops for collegiate
Problem Solving: A Workshop for mathematics faculty via the MAA's
Educators. Eugene, OR: International Interactive Mathematics Text Project. She
SOCiety for Technology in Education. will spend the 1993-94 academic year as
Associate Technology Editor with
Robbat, Richard J. (1985). Computers Brooks/Cole Publishing, where her
and Individualized Learning: Moving to responsibilities will include interactive
Alternative Learning Environments. texts.
Eugene, OR: International Society for
Technology in Education.

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.

Display issues include: Interaction issues include:


• Build displays up piece by piece. • Consider validity.
• Maintain visual context, Anticipate common syntactic and
but avoid clutter. semantic errors.
• Clearly make connections between • Allow synonyms.
text and graphics(e.g., use arrows) Mathematical or verbal.
• Balance adjacency versus • Ignore blank inputs.
consistency. But do check for a student who
• Balance consistency versus variety. hasn't a clue what to do.
• Avoid browsing.
InpuVOutput issues include: Require more than just pressing
• Avoid mixing input modes the return key.
(e.g., use keyboard or mouse). • Give clear, explicit feedback.
• Assist the student's concentration • Avoid dead ends.
by avoiding distractions.

Appendix B: Sample Interactive Text for an Introductory Calculus Course.


This is the first lesson in the course. It is used to review algebra, not to introduce calculus
topics themselves. This sample is fully executed, i.e., after a student has worked through it.

Computer Algebra Systems (CASs) typically have three types of features:


1. numeric,
2. symbolic, and
3. graphic.
In this lesson, you will get a brief introduction to each of them. Throughout this course,
you will learn more about the specific features that are relevant to your first-year
calculus course. In addition, you should learn enough about Maple itself, how to navigate
through its help files, and how to move back and forth between "textbook mathematics" and
"computer algebra systems" that you will be able to pick up additional skills, as needed, for
later courses in mathematics, science, engineering, computer science, etc.

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

Notice these aspects of the above sequence:


a the input line finished with a semi-colon,
b. the output was centered on the line below the input.
c. if you place the insertion point on either the input or the output line,
then the "mode" buttons in the will ruler change to reflect that;
b. if you place the insertion point inside this outline,
then it will indicate that this is text.

Now, try executing the following couple of commands:


• 1/5 + 3/7;
22

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.

Notice the difference in the error messages:


* in the first case, the caret points to a right parenthesis
indicating that there was no opening parenthesis that will match it, but
* in the second case, the caret comes at the end,
indicating an open right parenthesis that wasn't closed before the final semicolon.

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.

Maple's Help System

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)

• solve( xA2 - 5*x + 6 0, {x});

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:

• solve(a*x A 2 + b*x + C = 0, x);


2 1/2 2 1/2
- b + (b - 4 a c) - b - (b - 4 a c)
1/2 --------------------- 1/2 ---------------------
a a

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).

To set up a system of m equations in n unknowns, is it useful to assign each equation to a


name.

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.

Notice that Maple is sensitive to case:


* a lower-case x and an upper-case X are treated as two distinct characters.
• eql .- -2*x + Y - 3*z = 1;
eql := - 2 x + Y - 3 z = 1

• eq2.- 2*x - 2*y + z = -3;


eq2 := 2 x - 2 Y + z = -3

• 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.)

Notice that the plot defaults include:


* horizontal axis from -10 to 10,
* vertical axis scaled to whatever Maple thinks is appropriate for the graph,
* tickmarks on the axes,
* no labels anywhere.

(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

(This plot was copied from the default-size plot window.)

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

1. Introduction variance inflation boundary, T, which is


Let X be a continuous nonnegative random calculationally simpler. He shows that the
variable with density I, mean 1', and finite variance of the truncated random variable, X t'
variance u 2 • Mullooly (1988), hereafter simply and its derivative can be represented as
Mullooly, has shown that if I is positive on the u 2(t) = 2W(t) + M2(t)
and
interior of its support, lim I(x) > 0, and
3:-+0
r, > I,
,..
du 2 (t)
(it = 2h(t) Wet),
then u 2 may be increased by truncation. where
Denote by u 2 (t), the variance of the truncated
Wet) = (I/F(t»)7 [x -(~l(t)F(t) )]F(x) dx,
random variable X t == X f(t,oo)(X), where fA t
00
is an indicator on the set A. Specifically,
M(t) = (I/F(t)}J F(x)dx,
t

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

Mathematical Computation with Maple ~


be completely monotone if (-1)" d~"[h(x)]~ 0
Ideas and Applications
'Ibm Lee, Editor
for n = 1, 2, ... , assuming these derivatives
01993 Birkhiiuser Boston exist.) Jewell (1982) has shown that complete

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}.

To illustrate the dependence of T on p,


Hebert and Seaman consider the mixture with
One may note that for k = 2, we obtain
Al = 2 and A2 = 4. Setting expression (2.1)
expression (2.2), The value of (2.3) is that it
equal to zero and using Maple, we find that the
positive root of the equation is t = In ( 1 ; p). represents all possible two-point mixtures. If Al
and A2 are any points in (0,00), one may
When p < 0.5, this root is positive. Thus, the
determine the variance inflation boundary by
variance inflation boundary is given by
T = max{ 0, In ( 1 ; p)}. The actual change in
taking k = ~2 and using expression (2.3). In
1
such cases, the sensitivity of the T with respect
variance, (12( t) - (12, is plotted as a function of
to the mlxmg probability, p, can be
the parameters t and p in Figure 2.1.
represented graphically, as in Figure 2.1.
Using Mullooly's algorithm, one obtains a
lower bound for T of approximately 0.03, as
3. A composite mixing distribution
compared to the actual value
Properties of the mixture (1.2) when A has a
T = In(3) ~ 1.099. As p-0.5, the root of (2.1)

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

t, see Hebert and Seaman. The point mass A[2] := kA 2

illcluded in the present model dampens the sd(t) =, p (1- p) (!-lA)


variance increase observed in the pure gamma

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);

eq_l := p( -1 + p)(k_l)2( _ e - t(,x + kA)

+ p 2 e - 2M + 2pe - ,xt - k,xt


- 2 ]1 2e -,xt - k,xt + e - 2k,xt > op(map(solve,soln_t,{t}»:op("[I));
_ 2]1e - 2k,xt + ]12e - 2k,xt) =0 op("" [2));

> subs( t=ln(T), eq_l / (p*(-I+p)*(k-l)"2) ): (l)


eq_2 := simplify( ", exp );
( (k:l))
-' - ,x(1 + k)) + p 2 -l '' - 2,x)
eq_2 := - l ' t = In ( - 1 +;: - p2 )
+ 2pT- - ,x(1 + k)) _ 2lT- - ,x(1 + k))
+ T- - 2k,x) _ 2pT- - 2k,x) > t_s:=[t=0,t=2/lambda/(k-l)*ln«1-p)/p)];
+ p2 T- - 2kA) = 0

> subs( T=zA(I/lambda), eq_2 ):


[ m(~)l
eq_3 := simplify( ", power ); L s:= t = 0, t = 2 ~(k _ 1) J
( _ 1 - k) p2 ( - 1 - k)
eq_3:=-z +2" +211Z >
_ 2p2z ( -1- k) +~(- 2k) _ 2 p 2z ( - 2k) QED

+ ]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.

McNolty, F. , Doyle, J. and Hansen, E. (1980),


Properties of the Mixed Exponential Failure
Process, Tecltnomeirics, 22, 555-565.

Mullooly, J. P. (1988), The Variance of Left-


Truncated Continuous Nonnegative
Distributions, The A merican Statistician 42,
208-210.

Biographies

William Bauldry received his PhD from


Ohio State. His thesis and subsequent research
was in Approximation Theory. Currently, he is
co-principle investigator of an NSF consortium
building a Maple laboratory at Winston-Salem
State University. Present research interests
include graph coverings and moments of
distributions. Currently, he is an Associate
Professor in the Department of Mathematical
Sciences at Appalachian State University,
Boone, NC 28608.

Jaimie L. Hebert received his PhD in


Statistics from the University of Southwestern
Louisiana in May 1990. His research interests
include characteristics of exponential mixtures,
estimation with truncated data, and estimation
of location parameters in a random
environment. Currently, he is an Assistant
Professor in the Department of Mathematical
Sciences at Appalachian State University,
Boone, NC 28608.

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

Introduction that needed to run uninterrupted compu-


tations for one or two days. Since the
Many engineering and scientific prob- single-user workstations that form the
lems can be solved by linear methods, but bulk of our resources are only available to
non-trivial examples of these problems students for short periods of time, we
may require large amounts of memory to worked to provide a batch computing fa-
represent and even larger amounts of com- cility that could handle these special cases.
puting time to solve. As more degrees of
freedom, n, are added to a problem, the The resource provided for batch process-
growth in memory and processing time ing was a very fast VAXlUltrix machine -
can be 0(n2) and 0(n3 ), respectively. the VAX 9000 - configured as a multiuser
timeshared facility. When students began
This is a situation that experienced faculty running jobs on it, the result was a fast
and research staff are generally well ac- machine that periodically thrashed to the
quainted with,-and they have learned to point of being unusable. The hunt was on
effectively match the problem size and to find the source of the problem.
choice of algorithms with the available
computing power. On the other hand, It turned out that a small number of users
students - and particularly graduate stu- were simultaneously running a few large
dents - tend to underestimate the compu- jobs, often to solve large linear problems.
tational demands of problems they attempt The effect was increased swapping of vir-
to solve; the situation deteriorates further tual memory pages, which increased sys-
when the algorithms they use are chosen tem overhead, which in tum resulted in a
for their simplicity instead of their com- decrease in available computing time for
putational effectiveness. In a multiuser users, which resulted in more frequent
timesharing facility, the resulting long task switching, and so on through the
and large jobs can present a strain on the vicious cycle. We learned that a situation
available resources. that was merely undesireable for a single-
user workstation became dramatically
History worse in a time-shared environment, pri-
marily because these users were forcing
A situation where a computation is very the virtual memory system to manage their
big or takes very long is undesirable, be- data for them instead of managing it them-
cause generally the student does not have selves.
access to more powerful equipment to al-
leviate the performance problems. At MIT To set the problem in a clearer light, the
we were experiencing a small, but con- virtual memory system creates an address
tinual, stream of requests from students space larger than the available RAM, and
swaps memory pages to and from disk as
Mathematical Computation with Maple ~
they are needed. This works well when the
Ideas and Applications rate of page swapping is small relative to
10m Lee, Editor the rate of process task switches. When
©1993 Birkhiiuser Boston some memory pages are accessed more

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

# '!his routine determines the width of an index range


'parray /rangewidth ' : = proc (r: indexrange)
REIURN(op(2,r) - op(l,r) + 1);
end: # proc parray/range.vidth

Listing 1

Calculation All we need is an indexfcn that under-


stands how the arrays are partitioned.
To use partitioned arrays in calculations,
we need to be able to store data to - and Each partitioned array is given its own
retrieve data from - the array. In order to unique indexfcn which has a table con-
do this, we create an indexfcn. When a taining some basic information used to
new indexfcn is implemented correctly, it locate the partitions belonging to that ar-
will allow assignment to an array element, ray. Each of these indexfcn's call a com-
retrieval of an array element, and it will mon routine, 'index/partitioned', to do
cope with unassigned elements properly. the actual work (see 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.

<arglist> ::= [ <indexfcn-arg> , <range-args> , <initialization-arg> ]


I [ <initialization-arg> <range-args> <indexfcn-arg> ]
<indexfcn-arg> ::= string I procedure I A
<ini tialization-arg> ..-- list (any thing) I A
<range-args> ::= <range-arg> , <range-args> I A
<range-arg> ::= range(integer)

Figure 1

80
This means that type expressions like:

[ inte;;:Jer, float, inte;;:Jer, float ]

can describe the type of objects like:

[ I, 2.0, 2, 3.0 ]

but not arbitrarily long (finite) lists like:

[ I, 2.0, 2, 3.0, 3, 4.0, ... ]

nor is there a type expression that de-


scribes anything remotely like:

[true, 1.0,2.0,3.0, ... ].

There is no Maple type-expression equiva- Notes:


lent of a regular expression or a head- 1) For clarity, the error state Is not shown.
2) Transitions to the error state are not shown.
versus-tail list expression syntax, so there 3) All states shown are valid final states.
is no convenient way to express hierar-
chical types like list ( (inte;;:Jer , float) ) or Figure 2
have types described by regular expres-
sions such as [ inte;;:Jer, float *, inte;;:Jer ].
This allows the default to change for fu-
If a regular expression would achieve what ture array creations without invalidating
we need, then a procedural type that imple- the partitioning assumptions of existing
ments the regular expression would do the arrays.
job. Since a regular expression has an
equivalent deterministic fmite automaton Any indexfcn other than pC).rtitioned will
(See [1] for proofs and general background be processed by the built-in array func-
information), a procedural type imple- tionality, so there is no such thing as a
menting the DFA can be used. Figure 2 diagonal or symmetric array that is also
depicts the DFA, and listing 3 shows its partitioned. If necessary, ranges will be
implementation in Maple. set and initialization elements processed
by the undocumented Maple routines
The II-state minimal DFA implemented , table/initbds' and' table/initvals' ,re-
here is just a combination of three simple spectively.
recognizers corresponding to each of the
three kinds of valid arguments. The pro- Partition Management
cedural type for indexrange performs a
litte extra work to verify that each range Partition management is primarily an is-
a .. b satisfies the constraint a £ b. sue of creating a scheme for deciding when
to move data to and from disk, and storing
Once we know we have a valid argument the data in such a way as to defeat un-
list, we can go on with processing the wanted garbage collection. A crude proto-
arguments and creating partitioned ar- typical partition manager was created for
rays (see listing 4). testing the creation of and calculation with
partitioned arrays (see listing 5). A de-
Any array containing more than a default tailed implementation that actually moves
number of elements, Parti tionsize, will the data to and from disk has not been
be partitioned, and the current value of developed at this time, but in the future
Partitionsize is cached with the array. will be bundled together with developing

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

, type/parrayargs' (' DFA') : = table ([


seq ( ('start' ,i)=op(i, [3, 2, 4, 'error']) ,i=1. .4),
seq((2,i) =op(i,[5, 2, 6, 'error']),i=1..4),
seq((3,i) =op(i,['error',7, 8, 'error']),i=1..4),
seq ( (4, i) =op (i, [8, 9, , error' , , error' ] ) , i=1. .4) ,
seq((5,i) =op(i, ['error', 'error' ,10, 'error']),i=1 .. 4),
seq((6,i) =op(i,[10, 'error','error' ,'error']),i=1 .. 4),
seq((7,i) =op(i,['error',7, 10, 'error']),i=1..4),
seq ( (8, i) =op (i, [ , error' , 8, , error' , , error' ] ) , i=1. .4) ,
seq((9,i) =op(i,[10, 9, 'error' ,'error']),i=1 .. 4),
seq((10,i) =op(i, ['error' ,'error' ,'error', 'error']),i=1 .. 4),
seq(('error' ,i)=op(i,['error' ,'error','error' ,'error']),i=1 .. 4)
] ): # table type/parrayargs (DFA)

# 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

# 'Ibis type-checks for a valid array index range.


# '!he argument rrust be an integer range a .. b where a <= b.
'type/indexrange' := proc(arg)
type (arg, 'range(integer)') and evalb(op(l,arg) <= op(2,arg»;
end: # proc type/ indexrange
Listing 3

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

if not assigned (partsGenerated) then


partsGenerated : = 0:
fi:

generatePartition : = proc (partSize)


local parts i
if not type(partSize,posint) then
ERROR('invalid partition size, ',partSize)i
fii
parts : = partsGeneratedi
partsGenerated := partsGenerated+1i
'-P' .parts := 'parray/array' (0 .. partSize-1) i
partitioncache ('-P' .parts) i
end: # proc generatePartition

Listing 5

mechanisms for recovering long-running 2) Functional semantics - Given only


interrupted jobs. the index of an element in an array,
how can its value be determined
Array Semantics independent of storage? These se-
mantic actions implement or con-
There is more than one category of seman- strain the mathematically inter-
tic activity or interpretation happening, esting properties of an array, such
when we consider array access as it is as symmetry or diagonality.
implemented by the indexfcn facility.
These categories can be loosely divided 3) Value semantics - Given the index
into: of an element of an array, deter-
mine its value. These semantics
1) Storage/retrieval semantics - determine how to intepret or pri-
When we store a value into an ele- oritize the combined results of the
ment of an array, just where does storage/retrieval semantics and the
that value really get put? These functional semantics.
semantic actions implement the
storage/retrieval of the unique data Unfortunately, these three semantic
content of an array. intepretations are implemented in a rather

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.

2) Consider the sparse indexfcn. Here, Limi tations


the only storage space needed is for
the elements actually stored, so the There are several important limitations to
storage/retrieval semantics in- the current attempt to prototype parti-
volve locating and storing/retriev- tioned arrays which must be acknowl-
ing the elements from the appro- edged, and addressed in the future.
priate data structure. The func-
tional semantics can be viewed as • Partitioning criteria: at present, ar-
giving all elements the value O. The rays are partitioned according to the
value semantics return the re- number of elements in the array, and
trieved value if such exists, other- not according to the size of the ele-
wise return the result of the func- ments. For numerical applications this
tional semantics. is not a problem since all elements are
the same size, typically the size of hard-
Having all three kinds of semantics works ware floats. For more general use in
well enough for these two examples, but Maple, the type and size of individual
there are some unfortunate limitations to elements can vary greatly.
the approach used by Maple:
• lifetime of elements: types that obey
• Non-trivial indexfcn routines are dif- last-name evaluation are not viable
ficult to implement and debug, in part array element types for partitioning,
because you have to figure out which since only their names are stored in
pieces of semantic activity to deal with the array partitions. The problem with
at various points in the code. Getting this is that the original objects may be
all the cases covered properly can be garbage collected while a partition is
tricky, and is almost guaranteed to ex- swapped out.
ercise several obscure bugs in Maple
itself. • Use of partitions between sessions: at
present, partitions behave much like
• There is no way to generate new Unix swap space. A partitioned array is
indexfcn combinations from the only guaranteed to be meaningful for
desireable properties of existing the current Maple session; storing it in
indexfcns. If we have sparse and a me and attempting to use it in future
symmetric then the only way we can sessions won't work since only the ar-

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).

• Arrays are not the only large objects:


only array partitioning is implemented Reid M. Pinchback is a Faculty Liaison
here, but large grids and tables could with the Academic Computing Services de-
equally benefit from the ability to par- partment of MIT, responsible for main-
tition. Partitioning grids might be par- taining Unix and Macintosh installations
ticularly useful since it would allow of Maple and other software packages
users to create more complicated plot for educational use. He writes introduc-
structures on machines with a small tory Maple documentation and provides
amount of RAM and swap space. support and training for end users and
other MIT computer consultants. email
• Use of undocumented and built-in rou- address: [email protected].
tines: while the approach described in
this paper was an effective way of try-
ing to extend Maple functionality, it is
a method that is likely to be unreliable
in the long run. It is handy for
prototyping code, but not satisfactory
for creating products for end-users.
Whenever a back-door approach like
this is used, it probably reflects either
a weakness in the design, a weakness
in Maple functionality, or both.

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

of A and zero matrix corresponding to zero


Introduction eigenvalues of A. This direct sum is called
Murnaghan form [7] of A.
With prevailing trend of parallel processing
diagonalization methods for solving eigenvalue The Paardekooper method [8] is a Jacobi-
problems came into renewed interest of numer- type method for reducing a skew-symmetric
ical analysts. In order to study the asymptotic matrix to its Murnaghan form. We note that
convergence rate of such methods it is useful skew-symmetric eigenvalue problems appear
to use the qualitative analysis with O-symbol. in practice (e.g. structural mechanics) [1, 9).
The O( ) term in a series indicates the order
of truncation of the series.
Let A = (aij) be a skew-symmetric matrix
of order n. In order to avoid inessential dif-
The Paardekooper method is a typical di-
ficulties in the description of the method, we
agonalization method for solving eigenvalue
assume n to be even. We write
problem of skew-symmetric matrices. In this
paper we show how Maple's facilities can be
used to construct and analyse an example that
demonstrates the failure of the quadratic con-
A = [:::
Au: 1' (1)
vergence of the Paardekooper method in the Akk
presence of nonzero eigenvalues whose multi-
plicities are greater than two. The example where each Aij is 2 x 2 and hence k = nJ2.
is presented and analysed mathematically in Instead of (I) we also write A = (Apq). With
[4]. Here we focus on how to use Maple. We the partition (I) is associated
will see that without Maple the analysis is ex-
tremely tedious.

Paardekooper Method which is called departure from the Murnaghan


form. In (2) as well as throughout the whole
It is well known that any skew-symmetric paper II . II stands for the Euclidean matrix
matrix A is orthogonally similar to a matrix, norm, that is, IIAW = trace(AT A).
which is the direct sum of 2 x 2 matrices of
the form One Itep of the Paardekooper method uses
an orthogonal similarity transformation (d.
[8])
AI = o.T
:-Spq
A 0.
:-Spq, P < q,
corresponding to pairs of complex conjugate
(purely imaginary) eigenvalues ±ill (II > 0) to make A~q zero. The matrix ~pq is called
[2, 3] Jacobi annihilator of A pq , and Apq is
called pillot ,ubmatrU:.
Mathematical Computation with Maple ~
Ideas and Applications The tools of describing ~pq are plane rota.-
10m Lee, Editor tions. Let R(i,jj,p) stand for the rotation ma.-
©1993 Birkhauser Boston trix in the (i, j) plane by the angle ,p, that is,

87
R(i,j; q,) (3) step. For a more deta.iled description of the
1
° ° ° Jaco bi annihilator S pq see [2, 3].

To simplify notation we set (d. [8, 2]).

° 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

R~q R(2p - 1,2q - 1; q,d, 0- 2_ /32+ x 2 _ y2' (6)


R(2p, 2q; q,2), X cos q,3 + /3 sin q,3
R;q (7)
R(2p - 1,2q;q,3), 0- cos q,3 + y sin q,3 '
R;q where -i < q,3 .:::; i and -t < q,2 .:::; t· For
R;q R(2p,2q - 1; q,4). more thorough angle formulas see [8, 2].

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

Uqa 2p-l,2q Upa 2p,2q-l O( e2), (8) A12 A13


A22 A 23
a2p-l,2q-l + UpUqa2p,2q O( e2), (9) A32
A42
A33
A43

la2p-l,2P I - IIS1 O( e2), (10) be a given 8 x 8 skew-symmetric matrix almost


la2q-l,2q 1- II sj O( e2), (11) in Murnaghan form. We further assume that
All, A22 and A33 are affiliated with the same
where Ui = signum(a2i-l,2i), I ~ i ~ k, and 11" > 0, and A44 is affiliated with 11'2' Suppose

signum(x) = 1 if x ~ 0 and -1 otherwise. • we apply the row-cyclic Paardekooper method


to A. Because of the row-cyclic strategy the
To be precise in the relations (8)-(11) 0(e 2 ) first pivot submatrix is A 12 . After the anni-
actua.lly means O( em), m ~ 2. Theorem 1 re- hilation of A12 we have A~2 = 0, that is, we
veals a special structure of a skew-symmetric have
matrix almost in Murnaghan form. We note
that the relations (8) and (9) do not force
IIApq II to be O( e2). In general we have IIApq II =
O( e). Later we will see it through an example.
A' = [

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¢).

where Q = P R(5, 7j ¢) R(2, 8j ¢) with ¢ = > with(linalg):


arcsin i (reca.ll (3)) and > n:= 8:
> # We declare M.
> M:= matrix(n,n,(i,j)- > 0):
> M[1,2]:= 1:
> M[3,4] := 1 :

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)

(p,q) O"q a 2p-l,2q - O"p a 2p,2q-l a2p-l,2q-1 + O"pO"q a 2p,2q

(1,2) 0('12)
°
(1,3) 0('14) 0('13)

(2,3) 0('12) 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)

> phi13 :~ simplily(phi13) : The following segment of Maple code esti-


> eua/l(phi13)j mates 115 using the relations (14)-(17). In the
-0.5535743590 + O(t4) .. d
co d e alJA (4)
enote aij :
> cl3 := cos(phi13) :
> cl3 := series( cl3, t = 0) :
> cl3 := simplilY( cl3) : > a12A:= (A[1,2J * cl3 + A[2,3J * 113) * c24
> s13 := sin(phi13) : »-(A[1,4J * cl3 - A[3,4J * 113) * 824:
> s13:= series(s13,t = 0): > a12A:= limp/ilY(leries(a12A,t = 0»:
> s13 := simplily(s13) : > a25A := A[2, 5J * c24 - A[4, 5J * 824 :
> a25A:= 8imp/ilY(leriel(a25A,t = 0»:
Note that the output of </>13 demonstrates the > a16A := limp/ilY(leriel(A[1,6]' t = 0» :
validity of Lemma 2. > a56A := limp/ily( leries( A[5, 6], t = 0» :
> ex2 := 2 * (a12A * a25A - a56A * a16_4)/
Using the formular (5) we have »(a12_4"2 - a56A"2 + a16A"2 - a25A"2) :
> ex2:= limp/ily(seriel(ex2,t = 0»:
t24 = _ a14 c 13 - a34 s 13 . (13) > phi15 := ardan( ex2)/2 :
a12 C13 + a23 s 13 > phi15 := limp/ily( leries(phi15, t = 0» :
The following segment of Maple code esti- > 115:= limplilY(leriel(sin(phi15),t = 0»:
mates C24 and S24 using the relation (13).
During the transformation
involving R(1,5j</>15), (1,2) block gets contri-
> t24:= -(A[1,4J * cl3 - A[3,4J * s13)/ butions from (2,3) block by skew-symmetry.
»(A[1,2J * cl3 + A[2,3J * s13) : In particular
> t24 := simp/iIY( series(t24, t = 0» :
(5) (4) (4) (4) ()
> phi24:= simp/ily(series(ardan(t24),t = 0»: a 13 = +
a 3S '15 = a 35 SIS, 18
a 13 C15
> c24:= simp/ily(series(cos(phi24),t = 0»: since ai~ = 0, where one can verify that
> s24:= simp/ily(series(sin(phi24),t = 0»:
a 3(4)
5 = a3S c13 + a15'13. (
19 )
The final segment of Maple code estimates
Note that </>14 = </>23 = 0, since al~ = a13 =
ai~) using the relations (18) and (19):
o and a~!) = a24 = O. This means that we do
not need to consider the transformations in-
volving R(1,4j</>14) and R(2,3j</>23), because > a35A:= A[3,5J * cl3 + A[1,5J * 113:
they are identity transformation. > a35A := limp/ily( seriel( a35A, t = 0» :
> a13_5 := a35_4 * 115 :
Because of the row-cyclic strategy Ai~ is > a13_5 := simp/ilY( 8eriel( a13_5, t = 0» :
the next pivot submatrix. Using the formula > a13_5 := eua/l(a13_5)j
(4) we have a13..5 := -0.2612289826 t + O(t 3 )
tan(2</>15) = (14) From the output we see that al;) = OCt).
(4) (4) (4) (4) Since SeA) = OCt), we conclude that (1,2)
2 a 12 a 25 - a 56 a 16
block becomes the order of SeA) by later
(ai;)2 - (a~!)2 + (aWF - (aWF '
rotational transformation after its annihila-

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.

[5] A. J. Hoffman and H. W. Wielandt: The


Variation of the Spectrum of a Normal
Matrix, Duke Math. J. 20: 37-39,1953.

[6] F. Luk and H. Park: On the Equivalence

94
AN ALGORITHM TO COMPUTE FLOATING POINT
GROEBNER BASES
Kiyoshi Shirayanagi
NIT Communication Science Laboratories, Kyoto, Japan

1 Introd uction computing a GB for which it is only necessary to


compute an AGB. Moreover, for numerous exam-
Grabner basis (GB) techniques are a valuable tool ples, it is much faster to compute an AGB than a
for solving many problems in polynomial ideal the- GB.
ory. As is well known, the process of computing
In Section 2, a new notion of convergence of a
a GB may involve large numbers of intermediate
sequence of floating point polynomials and an ap-
coefficients - say from a field k - even when the
proximate GB are defined to describe what our al-
final GB does not involve many coefficients. In
gorithm does. We present an example illustrating
fact, the cost of performing exact arithmetic in k
why the most naive approach does not work. In
with the intermediate coefficients is a major factor
addition, possible applications are mentioned. In
determining the computational cost of computing
Section 3, basic notions for our algorithm are pro-
the GB. This paper proposes a new approach us-
vided as well as a key theorem. Bracket coefficient
ing floating point computation that can be applied
polynomials are introduced. They playa central
when k is a subfield of the real numbers. 1
role in this paper. The key theorem presents a
Basically we mimic Buchberger's algorithm in
criterion for deciding whether a true coefficient is
[3]. However, the big question then would be "how
zero, in terms of bracket coefficients. In Section 4,
small must floating point coefficients be, to be con-
the algorithm is described and the termination and
sidered zero?". The subject ofthis paper is to pro-
correctness of it are proved. In Section 5, examples
pose a criterion for answering this question. Our
of running the algorithm are presented. The algo-
key idea is to calculate and keep track of an error
rithm is implemented in Maple V /Sun SPARe. In
term for every coefficient that occurs at each step
Section 6, the experimental results are discussed
of the S-polynomial calculation and polynomial re-
by comparing them to those of the conventional
duction, and to judge coefficients as zero by esti-
algorithm. Finally, an important open problem is
mation of their accumulated errors. To keep track
given.
of the errors, bracket coefficients for polynomials
are introduced. These are based on floating point Throughout this paper, we assume that the set
numbers together with error terms. The arith- of all floating point numbers is contained in the
metic for bracket coefficients is a kind of interval real field R. When we simply say a polynomial,
arithmetic (see, for example, [8], [1], and [9]). it denotes a floating point polynomial or a real
The proposed algorithm gives a sort of approx- polynomial in variables Xl, ... , Xn •
imate GB (or AGB), not a true GB. There are a
number of problems which are typically solved by
1 While our approach applies to the case that k is the
field of rational numbers, several other approaches apply
there as well. We refer the reader to p-adic or modular
2 Floating Point Grabner
approaches as found in [11], [12], [10]. Sequence

In this section, we introduce a sequence of sets


of floating point polynomials that converges to a
Mathematical Computation with Maple Yo
Ideas and Applications true Grabner basis in a strong way. First of all,
10m Lee, Editor we define the monomial support of a polynomial
tC1993 Birkbauser Boston or a finite set of polynomials.

95
Definition 1 (Monomial Support) The f2 h = x 2y2 - Y + 2 supportwise. Also FII =
fn
--j.

monomial support of a polynomial {ff, F = {fl, h} supportwise. However,


--j.

for f3 = 1I~1 x 3 y - ~x + 1 and fa = x 3 y + 1,


f - '"""
- ~ 1 ... xi"
a'IlJ .. ·,l.n x il n f3 fa coefficientwise but f3 ft fa support wise,
--j.

il , ... ,in since M(f3) :I M(fa) for any v.


is the set of power products The aim of this paper is to provide an algorithm
that computes a set GI-' for each J-l where {GI-'} I-' is
{ X'l·l .. 'X in" I a''1, .. ,i" r-I- O} , supportwise convergent to a true Grabner basis G.
Let us call such a sequence {G I-'} I-' a floating point
denoted M(f). The monomial support of a fi- Grobner sequence. If {G I-'} I-' is any floating point
nite set F = {It, ... , fn} of polynomials is Grabner sequence, there is an M where M(G Il ) =
the set of subsets of the set of power products: M(G) for all J-l ? M. For J-l ? M we shall call Gil
{M(fd, ... , M(fn)} , denoted M(F). a floating point Grobner basis with precision J-l, or
simply an approximate Grabner basis.
Note that M(O) = 0.
Of course there is an obvious way to construct
Example. For f = 2.99x2 + .999xy2 - l.002z +
a floating point Grabner sequence. That is,
.249, M(f) =
{x 2, xy2,z,I}. For F {3x 2 + = (1) Compute a true Grabner basis G by the con-
xy2 - Z + 1/4, 1/3x + y2 z + 1/2, x 2z - 1/2x _ y2},
ventional Buchberger's algorithm ([3]), and then
M(F) = {{x 2, xy2, Z, I}, {x, y2z, I}, {x 2z, x, y2}}.
(2) For each J-l, truncate the coefficients of G to
Next we discuss the general notion of (coeffi- precision J-l.
cientwise) convergence and the specialized notion However, our algorithm avoids exact arithmetic
of supportwise convergence which we require. and the associated memory requirements. On the
The natural definition of the coefficientwise con- other hand, we must be able to compute with ar-
vergence of a sequence of polynomials is given by bitrarily high precision coefficients.
the following. For this purpose one naive idea may be first to
take FI-' that is the floating point approximation of
F in coefficients to precision J-l, and then to apply
Definition 2 (Coefficientwise Convergence) Buchberger's algorithm to Fw Such an approach
Let {fv}v be a sequence of polynomials and f be a fa.ils before the GB computation begins. This is
polynomial. Then, fv coefficientwise converges to seen by the trivial example {3x-l, x-l/3}. With
f (fll f coefficientwise)
--j.
any truncation of 1/3, the first polynomial is no
iff f 1/ " . . al( . x il .. ·xin"
L...,.,'ll""Zn 'l, ... ,'n 1
and longer a scalar multiple of the second one, and
f .....,1n. a''1,·""11.
"L...,,'1, . X1" " ' X in" such that the ideal generated by them has changed to R[x].
limll ..... oo at, ... "" = ai" ... ,i" for all i l ,···, in· See Section 5 for the result of our algorithm for a
similar and less trivial example.
The stronger property of supportwise conver- Let V be the quotient algebra
gence is one of the central themes of this paper:
R[xl, ... , xn]/Ideal(F),
Definition 3 (Supportwise Convergence)
Let {f1l}1I be a sequence of polynomials and f be a where Ideal(F) is the ideal generated by F. Once
polynomial. Then, fll supportwise converges to f an approximate Grabner basis GI-' is obtained,
(fv f supportwise) iff there is an N such that'
--j. the following problems can be solved not approx-
(1) M(fv) = M(f) for all v? N, and imately but strictly by the conventional methods,
(2) {fll }II>N is coefficientwise convergent to f. since M(GI-') = M(G) for a true Grabner basis G.
M oreov~r let {FII}v be a sequence of finite sets (1) Decide whether V is finite-dimensional or not
of polynomials and F be a finite set of poly- as R vector space,
nomials. Then, FII supportwise converges to F (2) Compute an R-basis of V,
(Fv --j.F supportwise) iff FII = {ff,··., f~} and (3) Decide whether the system F of polynomials
F = {fl, ... , fn} such that Jr fi supportwise --j. is solvable or not,
for all i E [1, n]. etc.
Moreover, the system F may be approximately
Example • Let f"1 -- _"_ 3 _ II-l x +l and /"-
11+1 x y II 2 - solved, since every coefficient of GI-' converges to
";lx2y2_y+ };1' Then If It = x 3 y-x+l and --j. the corresponding one of G. See [3] (Methods 6.6,

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»)]

Remark. In the above addition, if A EB B = 0,


then the term 5 x lQe(AEIlB)-(fl+1) in the error is
dropped. In the case of general base b of floating
where Ai1, ... ,i n and ai1, ... ,i n are floating point num- point numbers, 5 x lQe(AEIlB)-(fl+ 1 ) is replaced by
bers with precision J.l. Ai1, ... ,i n and ai1, ... ,i n are rb/21 x be(AEIlB)-(fl+1), where rb/21 is the minimal
intended to be an approximation of a true coeffi- integer not less than b/2. Similar for the subtrac-
cient and its error, respectively. A special symbol tion and multiplication.
o is permitted in place of [Ai1, ... ,i n , ai1, ... ,iJ. The adequacy of this definition will be shown to
Next we have to define S-BC polynomial and be clear in Lemma 1 later. BC arithmetic may be
BC-reduction for BC polynomials. In this paper, a kind of interval arithmetic ([8]), more precisely
using 10 as the base, a floating point number A machine (or rounded) interval arithmetic ([1]) or
with precision J.l is expressed by circular arithmetic ([1], [9]), although the defini-
tions of these arithmetic are slightly different from
A -- ± .ala2·· .afl x 10 e(A) , ours. However, the emphasis of this paper is not
on the choice of arithmetic, but on the idea of
where 1 :S al :S 9, 0 :S a; :S 9 (2 :S i :S J.l), and keeping track of errors and more importantly on
e(A) is the exponent of A. For floating point arith- the zero judgement of coefficients by estimation of
metic, we apply the roundoff manipulation, which the accumulated errors.
means counting .5 and higher fractions as a unit Consider BC polynomials with a given precision
and cutting away the rest. In this paper we assume J.l. We can add, subtract, and multiply such poly-
that transgressions of the range of numbers (un- nomials as well as usual polynomials as follows:
derflow and overflow) do not happen. Following
[7], we use a notation EEl fl , efl' and 0fl (or sim- [A, a]t + [B, {3]t = ([A, a] EBfl [B, {3])t
ply EEl, e, and 0 when there is no confusion) for
floating point addition, subtraction, and multipli- (or [A,a]t- [B,{3]t = ([A,a]e fl [B,{3])t),
cation with precision J.l, respectively. Throughout
this paper, floating point division is not considered ~)Ai' ai]t; . ~)Bj, {3j]Uj
because of its complicated error analysis. j

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",

A. B if E is the result of (By Remark after Definition 4).


E= { (Eesp:. -A· B) AB (resp. -AB) (Subtraction Case: E = A-iJ) Let I{A)",-AI ~ a
A- B if E is the result of and I{B)", . .:. . BI ~ f3 by induction hypothesis. Let
A-B dd refer to the equation: 1({A)",e{B)",)-(A-B)I.
When {A)", e {B)", # 0: If {B)", # 0, then there
Moreover let BC be the set of bracket coefficients are two cases:
and their negatives. For a precision Jl we define a (1) {A)", e {B)", # {A)", (normal case), and
map u", : X --+ BC by the following: (2) {A)", e {B)", = {A)", (loss of information).
In case (1), dd = I({A)",-A)+(B-{B)", )+{({A)i'e
(B)p') - ({A)", - (B)",)} I ~ a + f3 + 5 x 10-(",+1) x
lOe~(E)I') ~ fW
In case (2), it is easy to see from floating point
where (Ai)", is the floating point approximation
arithmetic that e({B)",) ~ e({A)",) - Jl and when
of Ai to precision Jl and 0:; is its roundoff error
5 x 10-(",+1) x lO e((Ai)l') , and·, '"
the equality holds, Imantissa of (B) '" I ~ . ~
For :e,Y E X,
..---.....
'"
(i.e ..~ . 500 ... 00 if (B) '" is positive, and
..---.....
'"
< . 500 ... 00 otherwise). Hence when the equality
u",(:e· y) = u",(:e) ®", u",(y), holds, (B)", ~ .5 x lO e((B)I') =
.5 x lO e((A)I')-"'.
u",(:e - y) = u",(:e) e", u",(y). Then dd = I({A)", - A) + (B - (B)/1) + (B)", I ~
a + f3 + I{B)", I ~ a + f3 + 5 x lO e({E)I')-(",+1) ~ fW
Recall Definition 4 for BC arithmetic. For E we Ifthe equality does not hold, dd ~ 0:+ f3+ I(B) '" I <
hereby write a + f3 + 1 x lO e((E)I')-(",+1) < fW
[(E)"" f",] On the other hand, if (B)", 0, then dd= =
I({A)", - A) + (B - (B)",)I ~ a + f3 < f",.
as the result of u",(E). When (A) '" e (B) '" = 0: we have (A) '" - (B) '" = 0
For example, if E = (2/5). «1/3). (3/4)- (5/6). from floating point arithmetic, and hence dd =
(1/7))-(1/2).(2/3), then this means that E arises I({A)", - A) + (B - {B)",)I ~ a + f3 ~ f", •

by 2/5 X (1/3 x 3/4 - 5/6 X 1/7) - 1/2 X 2/3, and


{E)5 is the result of .40000 ® (.33333 ® .75000 e Lemma 2 (Error Convergence) For the nota-
.83333®.14286)e.50000®.66667. As to the error, tion as above,
in general, we have the following lemma. lim
1-'"-+00
f", = o.
Lemma 1 (Error Analysis) I{E)", - EI ~ f", Proof By induction on the structure of E.
for all Jl. (Base case: E = Ai) Since ai = 5 x 10-(",+1) x

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.

Remarks. 1. In Example 3, the reason why only


Acknowledgment
the leading coefficients have small numerators and This research is supported in part by the United
denominators is that MC= 6) was small. Accord- States Army Research Office through the Army
ing to our experiments, M was 14 when they were Center of Excellence for Symbolic Methods in Al-
all replaced by a rational number with numera- gorithmic Mathematics (ACSyAM), Mathemati-
tor and denominator of about 15 digits. (It took cal Sciences Institute of Cornell University, Con-
261.150 sec. for M = 14, whereas R-GB required tract DAAL03-91-C-0027.
1278.63 sec. ) In the case of rati.?nal field, in gen- The author is grateful to Moss Sweedler for
eral, we have a conjecture that M depends largely his helpful discussion and valuable comments in
on the sizes of the numerators and denominators preparing this paper. Also the author wishes
of the leading coefficients of input polynomials. to thank James Davenport, Jerry Marsden, and
2. Our approach could be useless if input poly- Dana Scott for their suggestion of some relation-
nomials contain a polynomial of too high degree ship to interval arithmetic, and Tateaki Sasaki and
or with too many terms, because even using float- Matu-Tarow Noda for their encouragement.
ing point computation does not solve the prob-
lem of the number of reductions or the number
of polynomials which we must retain to make S- References
polynomials. In fact, it was not possible to com-
pute a lexicographic floating point Grabner basis [1] Alefeld, G. and Herzberger, J., Introduction
of the "Rose system" (see [2]) which has a polyno- to Interval Computations, Computer Science
mial with 21 terms, using FP-GB within a rea- and Applied Mathematics, Academic Press
sonable time. Our approach will be useful when (1983).
the growth of coefficients is the main reason why
[2] Boege, W., Gebauer, R., and Kredel, H.,
the computation of a Grabner basis by the usual
Some Examples for Solving Systems of Al-
Buchberger algorithm is slow (see Examples 3,4,5).
gebraic Equations by Calculating Groebner
Bases, J. Symb. Compo 1 (1986), 83-98.
6 Conclusion [3] Buchberger, B., Grabner Bases: An Algo-
rithmic Method in Polynomial Ideal Theory,
Our algorithm FP-GB turns out to be more ef- Chapter 6 in Multidimensional Systems The-
ficient than the conventional R-GB, in particu- ory (N. K. Bose ed.), D. Reidel Publishing
lar when the coefficients of input data are compli- Company (1985), 184-232.
cated, such as real numbers including irrational or
transcendental numbers, and the growth of inter- [4] Buchberger, B., An algorithmical criterion for
mediate coefficients is the major factor determin- the solvability of algebraic systems of equa-
ing the computational cost. The algorithm can be tions (German), Aequationes mathematicae
easily extented to complex numbers as well. 4(3) (1970),374-383.
Unfortunately, up to now, we do not have a rea- [5] Char, B. W., Geddes, K. 0., Gonnet, G. H.,
sonable upper bound on M such that M(G~) = Leong, B. 1., Monagan, M. B., and Watt, S.
M (G) for all j1 ~ M. That is, we cannot strictly M" First Leaves: A Tutorial Introduction to
determine M in advance where GM is an approx- Maple V, Springer- Verlag (1992).
imate Grabner basis. In this sense, the algorithm
is probablistic. In practice, currently, one should [6] Dickson, L. E., Finiteness of the odd per-
guess M by detecting a subsequence of {G ~} ~ that fect and primitive abundant numbers with n

103
Table 1: Example 1
G cpu time (sec)
{x - 1/3} .130

Ji- G,.. cpu time (sec)


1 {1.x - .3} .233
2 {1.x - .33} .167
3 {1.x - .333} .200
4 {1.x - .3333} .184
5 {1.x - .33333} .184
6 {1.x - .333333} .183
7 {1.x - .3333333} .167
8 {1.x - .33333333} .150
9 {1.x - .333333333} .167
10 {1.x - .3333333333} .183
11 {1.x - .33333333333} .200
12 {1.x - .333333333333} .183
13 {1.x - .3333333333333} .200
14 {1.x - .33333333333333} .200
15 {1.x - .333333333333333} .183
16 {1.x - .3333333333333333} .200
17 {1.x - .33333333333333333} .216
18 {1.x - .333333333333333333} .184
19 {1.x - .3333333333333333333} .200
20 {1.x - .33333333333333333333} .200

Note. G/-, gives an approximate GCD of the input polynomials.

Table 2: Example 2
G cpu time (sec)
{I} 200

Ji- G/-, cpu time (sec)


1 {1.x - .3} .150
2 {1.x - .33} .183
3 {1.x - .333} .134
4 {1.x - .3333} .134
5 {1.x - .33333} .116
6 {1.x - .333333} .150
7 {1.x - .3333333} .134
8 {1.x - .33333333} .150
9 {1.x - .333333333} .150
10 {1.x - .3333333333} .150
11 {1.x - .3333333333} .150
12 {I} .217
13 {I} .200
14 {I} - .217
15 {I} .216
16 {I} .233
17 {I} .217
18 {I} .217
19 {I} .200
20 {l} .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 }

I' G" cpu time (sec)


1 {-A X 10 11 $2, -B.x + 1000., -20.y - lOOOOO.z} 1.833
2 {-.46 x 10 168 .1'_ .48 X 10 173 .a: + .61 X 10 171 , -.10 X 10 169 y, .24 X 10 152 .&:2 + .14 X 101.51", - .18 X IO} 12.000
3 {-.349 X 10 126 J:2, .136 X l0143 y + .478 X 10 146 .z - .464 X 10 143 , .607 X lO142 x } 8.817
{.3025 x l01576 y+ .7964 X 10 1579 z - .1002 X 10 1577 ,
4 102.600
.1344 X 10 1576 .1' + .6750 X 10 1580 ,:: - .3169 X 10 1577 , -.9180 X lo 771 .t 2}

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}

{_ .5377591 X 10 25 x + .2110991 X 10 34 .z;3 + .1404259 X 10 33 .z; 2 - .2690671 X 10 30 + .1270510 X 10 27 , .&

7 -.1209958 X Io 26 y _ .1556817 X 10 33 .z: 3 - .1035615 X 10 32 .:: 2 - .3191010 X l029.z; + .4002777 X 10 26 , 24.567


-.2622272 x 10 64 .z;4 - .1583455 X 10 63 .z 3 + .4622788 X 10 60 .. 2 - .426967 X 10 57 .z; + .126248 X IOS4}

{-.74861510 X 10 31 + .29387212 X 10 40 .,.3 + .19548753 X 10 39 .z 2 - .37456868 X 10 36 :: + .17686754 X 10 33 ,


%

8 - .16843840 X 10 32 Y - .21672524 X 10 39 .z: 3 - .14416843 X 10 38 .z 2 - .44422077 X 10 35 .z + .55722718 X 10 32 , 30.100


-.50818387 x 10 76 .z 4 _ .30686591 X 10 75 ",3 + .8958751 X 10 72 ",2 - .8274391 X 10 69 ", + .2446602 X 1066}

{.115073820 X 1028 x _ .451727265 X 10 36 ",3 - .300494807 X 10 35 ",2 + .575770523 X 10 32 ", - .27187297 X 10 29 ,

9 .258916096 X 10 28 y + .333140493 X 10 35 ",3 + .221609356 X 10 34 ",2 + .68283661 X 10 31 ", - .85654515 X 10 28 , 27.483


.120076142 x 10 69 ",4 + .725077583 X 10 67 ",3 - .211681686 X 10 65 .z: 2 + .19551130 X 10 62 ", _ .5780940 X lOSS}

{.5377596431 X 10 25 X - .2110998780 X 10 34 Z" - .1404263631 X 10 33 Z..-. + .2690674097 X 10 30 Z - .1270508920 X 10 27 ,

10 .1209959197 X 10 26 y + .1556822505 X 10 33 z3 + .1035618421 X 10 32 Z 2 + .3191012254 X 10 29 Z - .4002781954 X 10 26 , 24.617


-.2622286133 x 10 64 z4 - .1583462665 X 10 63 z3 + .4622816264 X 10 60 z2 _ .426967888 X 10 57 Z + .126247231 X 1054}

Note. Even for I' = 100, it took only 35.250 sec.

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}

I' G" cpu time (sec)


1 {-80.x + 30.y, 7000.y~ + 20000.y· + 500000.} 2.267
2 {83.x· + 100., -2400.xy - 690.y" + 730., -63000.y~ - 620000.x} 2.567
3 {l} 2.900
4 {I} 2.700
{-229890.y;S - .18815 X 10 X - .67274 X 10 y,
5 -597150.X" - 14570.Y" - 718900., 3.550
-6892.6XY - 854.35Y" + 2243.1}
{-.132550 X 10~y~ - .108499 X 10" U x - .387913 X 10" U y,
6 .344366 X 109x2 + .840125 X 10 7 y2 + .414559 X 10 9 , 4.583
.397519 X 10 7 xy + 492664.y2 - .129365 X 107}
{-.1325529 X 10~y~ - .1085029 X 10" U x - .3879282 X 10" U y,
7 .3443766 X 109x2 + .8401299 X 10 7 y 2 + .4145703 X 10 9 , 4.983
.3975255 X 10 7 xy + 492680. 1y 2 - .1293659 X 107}
{-229800.22y" - .18810585 X 10 x - .67253136 X 10 y,
8 -597027.96x 2 - 14564. 909y 2 - 718719.25, 3.566
-6891.6968xy - 854.13454y2 + 2242.7495}
{-.132552891 X 10~y~ - .108502819 X lO" U x - .387928170 X 10" U y,
9 .344376416 X 10 9 x 2 + .840130139 X 10 7 y2 + .414570140 X 10 9 , 4.583
.397525401 X 10 7 xy + 492680. 049y 2 - .129365806 X 107}
{ - .1325528856 X 10~y" - .1085028160 X 10" U x - .3879281549 X 10" U y,
10 .3443764073x 10 9x 2 + .8401301011 X 10 7 y2 + .4145701258 X 10 9 , 4.967
.3975253922 X 10 7 xy + 492680.0346 y 2 - .1293658021 X 107}

Note. Even for I' = 100, it took only 8.517 sec.

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

{523698. 7y 0 + 985.5738x - 30450.19y,


7 982.7229x 2 - 601411.7y 2 + 8653.376, 3.883
-100.7948xy+ 2309. 56y 2 - 16.49430}
{-.30449275 X 10 8 y3 - 57303.400x+ .17704401 X 10 7 y,
8 57137.690x 2 - .34967823 X 10 8 y2 +
503126.47, 4.750
+
-5860.4880xy 134285.50y2 - 959.02183}
{-.304493527x 10 0 y" - 57303.5247x+ .177044409 X 10 y,
9 57137.8102x 2 - .349679197x 10 8 y2 +
503127.527, 4.767
-5860.49750xy+ 134285.767y 2 - 959.023145}
{-.3044934742X lQOy" - 57303.51814x+ .1770443855 X 10 y,
10 57137.80337x 2 - .3496791346 X 10 8 y2 +
503127.4531, 4.316
-5860.497001xy+ 134285.7486y2 - 959.0230326}

Notes. 1. R-GB (F) was not obtained after 3,600 sec.


2. For J.L == 1, the constant term of II is ill-defined since e - ".
3. Even for J.L == 100, it took only 7.950 sec.

distinct prime factors, Am. J. of Math. 35 Brief Biography of the Author.


(1913), 413-426. Date and Place of Birth: 10 December 1957,
Shizuoka, Japan. Degrees: B.Sc. (Math.) 1982,
[7] Knuth, D. E., The Art of Computer Program- M.Sc. (Math.) 1984, Ph.D. (Math. Sc.) 1992,
ming, Vol. 2, Addison- Wesley (1969). University of Tokyo. Current Employment: Se-
[8] Moore, R. E., Interval Arithmetic and Auto- nior Research Scientist of Nippon Telegraph and
matic Error Analysis in Digital Computing, Telephone Corporation (NTT), Visiting Scholar
Ph.D. Thesis, Mathematics Dept., Stanford
of MSI, Cornell University (1992-1993). Research
Univ., October (1962).
Interests: Computational algebra, Computer Go,
Machine Learning. Academic Societies: Editorial
[9] Petkovic, M., Iterative Methods for Simulta- Board of Japan Society for Symbolic and Alge-
neous Inclusion of Polynomial Zeros, L. N. braic Computation. Address: NTT Communi-
Math., Springer- Verlag 1387 (1989). cation Science Laboratories, Hikaridai, Seika-cho,
Soraku-gun, Kyoto 619-02 Japan (Email:
[10] Sasaki, T. and Takeshima, T., A Modu- [email protected]).
lar Method for Grabner-basis Construction
over Q and Solving System of Algebraic
Equations, J. Information Processing 12(4)
(1989), 371-379.

[11] Trinks, W., On Improving Approximate Re-


sults of Buchberger's Algorithm by Newton's
Method, SIGSAM Bull. 18(3) (1984), 7-11.

[12] Winkler, F., A p-adic Approach to the Com-


putation of Grabner Bases, J. Symb. Compo
6/2,3 (1988), 287-304.

106
III
MAPLE V IN SCIENCE AND
ENGINEERING

Part A: Modeling and Simulation


THE USE OF MAPLE FOR MULTIBODY SYSTEMS
MODELING AND SIMULATION
P. Capolsini
Projet SAFIR, INRIA - Universite de Nice Sophia-Antipolis, France

While these general-purpose multibody pro-


Abstract grams are still being widely employed they can
Conventional numerical general-purpose mechan- become inadequate to provide efficient simulation
ical simulation programs require more time for code for a given system. A newer approach con-
performing simulations than do special-purpose sists in deriving, directly from the description of
"symbolic" ones. In addition, these softwares, al- the mechanism, a specialized numerical simula-
though said to be "symbolic" fail to provide ex- tion code. This method leads directly to the equa-
plicit motion equations of the considered system. tions of the considered mechanism and is there-
It is shown, in this paper, that the use of a gen- fore much more efficient.
eral computer algebra system like Maple can be Indeed, the newest widespread method con-
used to write a new complete and efficient sym- sists in writing new "symbolic" special-purpose
bolic program which presents both advantages to simulation programs. Let's cite, among others,
provide explicit equations as well as excellent run- AUTOLEV [2], DYNAMICA [3], MESA-VERDE
time numerical simulations. [4], SD-EXACT, SD-FAST [5] and so on ... These
softwares are all said to be "symbolic" because
the user is not compelled to give explicit numeri-
1 Introduction cal values to all the indeterminates and they use
some typical symbolic algebra methods. Although
This paper intends to deal with multibody sys- these new programs supply efficient simulation
tems' dynamical equations derivation. The prob- codes, they still fail in providing explicitly the set
lem is rather old but still has a modern flavor of equations governing the behavior of the mech-
with the recent needs of the spacecraft industry. anism. Let us notice that these equations may be
Handwriting such equations, even for a modestly so interesting to analysts that a few of them still
complex system, is a tedious, long and expensive go on deriving motion equations by hand!
work and leads to equations subject to careless During the last decade, the arrival of com-
errors. Accordingly, much attention has been di- puter algebra has offered a new mean to supply
rected toward the development of computer pro- explicit equations as well as simulation codes.
grams to solve the problem. Oldest attempts at
writing softwares (such as ADAMS [1]) consisted
in establishing the equations of the considered 2 Symbolic architecture
mechanism by specializing a set of generic equa-
tions derived from a large and general system. All aforementioned "symbolic" simulation soft-
wares share, with other programs like our own
prototype or JAMES [6], approximately the same
architecture which is described in figure 1. The
greatest difference between these two families of
symbolic programs is that the latter provide the
Mathematical Computation with Maple ¥.
Ideas and Applications
capability to manipulate the computed equations
10m Lee, Editor though the former only provide a numerical (For-
@1993 Birkhauser Boston tran, C, Pascal, ... ) simulation code including

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

subroutines representing the equations.


This architecture presents undoubtedly two
1l, = U 0
COS(q2)
sin(q2)
0
-sin(q2)
COS(q2) )
great advantages compared to a full numerical the first and easiest solution to compute this
one with regard to simulation. First, once the product consists in calling a multiply subroutine
simulation code has been established, the user
can perform, by changing the numerical values call multiply(R l , R 2, 3, 3, 3, Result)
of the meaningful physical parameters as well as
by giving new initial conditions, a wide set of sim- which requires one subroutine call and 27 mul-
ulations without the waste of time to recompute, tiplications each time the product has to be com-
after each change, the complete set of equations. puted. This computation can occur up to hun-
Also, symbolic methods can dramatically improve dreds of times during a single integration step.
simulation performances which is clearly a very Another solution consists in doing the multiplica-
desirable property. tion at the symbolic level (before numerical code
generation) and generate the minimum correspon-
ding code to compute the result. Of course, the
2.1 numerical simulation perform- code generation time will increase but we think
ances of symbolic softwares that is a small disadvantage compared to the sim-
Computational efficiency is often advanced as the ulation time improvements. Indeed, the result
primary reason for choosing symbolic multibody will be computed by a set of 9 assignments re-
programs over their numerical counterparts. The quiring no call and only 4 multiplications.
three most important concepts leading to efficient
simulation routines are, according to our experi- Resultl,l COS(ql)
ments: Resuitl,2 = -sin( ql )cos( q2)
• propagating known numerical values (espe- Resuit l ,3 = sin(qt)sin(q2)
cially zeros and ones) throughout all invoed
expressions,
=
Result3,3 COS(q2)

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

4 Overview of our prototype Massu + f = 0 (1)


Our prototype is now ful~perational and widely M ass being an n x n matrix, it the vector of
validated. We called it L§YGMMAE for SYmbol- Kane's generalized speeds time derivatives and f
ical Generation and Manipulation of Mechanical a vector including all inertial and external forces.
Algebraic Equations. It is completely written in
Maple programming language and works on top 4.3 equations generation and han-
of Maple so that any symbolic calculation can
dling
be performed during a session. In this section,
we shall first expose some of the most important Once the structural data of the system (number
features of the software and then detail its use and names of different bodies, type of the links,
throughout a simple example in section 5. external forces and torques ... ) have been de-
scribed, ~yGMMAE can establish the correspon~­
4.1 the considered mechanisms ing motion equations using a set of formal vafl-
abIes (see figure 2) attached to each body. The
According to its actual state ~yGMMAE can de- equations are established according to a pure lit-
rive the motion equations of any mechanism com- eral matrix form using several specific matrices
posed of an arbitrary number of rigid bodies hav- operators. In spite of Maple existing linear al-
ing a simple kinematic chain structure (no closed gebra facilities, we have rewritten new operators
loop) and arbitrary distributed prismatic or rev- so that trivial and less trivial simplifications are
olute joints. The first body of the chain may be automatically performed and expressions are de-
declared as free in the space and therefore have rived according to a pseudo canonical form allow-
six degrees offreedom. The system can be subject ing therefore simplifications such as A * Id = A,
to any kind of external forces or torques including A*O = 0, A*2B = 2(A*B), A.B - B.A = 0
gravity. (scalar product), A x B + B x A = 0 (cross
The mechanism may be defined either interac- product) and so on ....
tively during a Maple session or by means of a de- Motion equations can be manipulated in many
scription file containing specific declarative com- different ways using our own specialized tools (ex-
mands and optional Maple assignments to fix, if pansion, transformation according to a set of equa-
needed, some of the numerous parameters of the tions, optimization, linearization, explicit evalu-
mechanism. ation, numerical code translation ... ) as well as
with Maple standard library functions.
4.2 the formalism employed
During the past decade, the leading and increas- 4.4 numerical code generation
ingly popular method to derive motion equations In most cases, the final goal of any mechanical en-
is to use Kane's formulation (sometimes called gineer consists in simulating the behavior of the
"Lagrange's form of d'Alembert's principle") to considered mechanism. Our prototype provides
obtain the governing dynamical equations of <:t the capability to construct complete and ready
multibody system. Kane's equations (see [10], to compile Fortran or C simulation code. To get
[ll] or [12] for technical details) have be~n shown a complete simulator code, one successively has to
to lead directly to the simplest possible form of translate the equations into the desired language
the equations. In fact, Kane's equations possess and generate all the complementary routines to fi-
the advantages of both Lagrange's and Newton- nally integrate the second order differential equa-
Euler's methods avoiding their corresponding dis- tion set.
advantages. Let's notice that Kane's final dynam-

112
8ody3 • a data input routine to assign unknowns
(bodies' mass, inertia, vectors' components,
initial conditions, simulation time interval,
... ),

• a results output routine,


.....
,,""lOr • a numerical matrix inversion routine to tran-
sform system (1) into a form suitable to the
integration routine that is :

(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 ...

4.4.2 complementary numerical routines 5 An exanlple of the use of


To be complete and ready to compile and use, the our prototype
simulation code must include at least four com-
plementary routines : In this section, we give a complete session de-
scribing the use of our prototype and its features.
Mechanical expressions are so large that it is not

113
mA ks k*(kt %1, k- frame(ll, A, 0),
frame(giA, A, 0»,

k*(kt frame(ll, A, 0),


q1 frame(inB, B, 0),
frame(ll, A, 0»,

mB &s «&t &+«-1) &s %1,


h«k- frame(l1, A, 0»,
frame(goB, A, 0»,
body A
(-1) &s «&- frame(ll, A, 0» &*
frame(giB, B, 0»» &*
&+«-1) ts %1,

(&- frame(ll, A, 0» &*


frame (goB , A, 0),
bodyB (-1) &s «&- frame(ll, A, 0» &*
frame(giB, B, 0»»

Figure 3: A double pendulum system %1:= (&- frame(l1, A, 0» h


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],

> # pendulum arms [equalC, C2, mB Cl],


> giA := array([O,-L,O]):
> giB := array([O,-L,O]): [equalC, C3, cos(q2)],
2
> # inertia matrices [equalC, C4, C3 ],
> inA := 0:
> inB := 0: [equalC, C5, - mB Cl C4],

> # vector from center of mass [equalC, C6, C2 + C5],


> # of body A to hinge point vith
> # body B [ C6 o]
> goB := 0; [matrixm, masse_ev, [ ]]
[ 0 C2 ]
> # Evaluate the expression using
> # the involved matrices explicit > # Effective code generation
> # coefficients > genC ( [II] ) ;
> evalmat(mll_expand);
2 2 2 2 Cl = L*L;
mB L sin(q2) (cos(ql) + sin(ql) ) C2 = mB*Cl;
C3 = cos(q2);
> # Maple standard routines C4 = C3*C3;
> # are still available C5 = -mB*ChC4;
> simplify(II); C6 = C2+C5;
2 2 2 masse_ev [0] [0] C6;
mB L - mB L cos(q2) masse_ev[O] [1] 0;
masse_ev[l] [0] 0;
> # The final fully evaluated matrices masse_ev[l] [1] C2;
> masse_ev:=map(simplify, evalmat(masse»;
> # Generation of a full and
[ 2 2 2 ] > # complete simulator including files
[ mB L -mB L cos(q2) 0 ] > # dpendulum.c source code
masse_ev:=[ ] > # dpendulum.data data file (to fill)
[ 2 ] > # dpendulum.res result file
[ 0 mB L ]
> simulateur('dpendulum', c);
> force_ev:=map(simplify, evalmat(force»;
2
force_ev:=[ 2 mB sin(q2) L u2 cos(q2) ul, 6 Limitations and future ex-
2
- mB cos(q2) L sin(q2) ul
2
]
tensions
> # Translate the masse_ev matrix into C 6.1 limitations
> CC(masse_Ev); The greatest limitation of ~yGM~lAE is the size
of the considered mechanism. When we say size
that means the mechanism total number of de-
grees of freedom. Like every Maple application
we are limited by the total number of terms ac-
cepted by the system (that is 217 -1 terms). Any-

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.

• define new types of joints. For the moment,


only free, prismatic and revolute joints are Acknowledgments
allowed. Assuming that any type of joint
can be decomposed into prismatic and rev- The work reported in this paper has been par-
olute joints, we plan to extend the joints tially supported by the Spatial mathematics de-
library, partment of the French Spatial Agency C.N .E.S.

• write new functions to handle large expres-


sions in good conditions. This may be done References
by using Maple optimize facilities,
[1] R.R. Ryan. Adams multibody system analys
• add a new graphic interface for system ar- software - an introduction. Technical report,
chitecture definition. This XII interface is Mechanical Dynamics Incorporation, 1989.
already being developed and we wish to use
[2] Thomas R. Kane and David A. Levinson.
it in the next months,
Dynamics: Theory and Applications. New-
• model hinge point actuators. This is un- York McGraw-Hill Book Company, 1985.
doubtedly the most important and interest-
ing point. Actuators can be modeled as ex- [3] Pierre Coste. Dynamica user's guide, matra
ternal forces or torques acting on the mech- espace - toulouse edition, 1990.
anism but this approach cannot be used [4] J. Wittenburg. The dynamics of systems of
for spatial mechanism for which actuators' rigid bodies. 1987.
mass and inertia cannot be neglected to-
wards mass and inertia of the involved bod- [5] Symbolic Dyn-Inc. SD-EXACT/FAST
leS, User's manual. Symbolic Dynamics Incor-
poration, symbolic dynamics incorporation
• extend the family of treated bodies to be edition, 1985.
able to handle flexible bodies. Flexible stru-
ctures modeling is a hard task and will im- [6] Christophe Garnier and Pascal Rideau.
ply a strong cooperation with good special- Manuel d'utilisation du logiciel James (ou
ists. Gemmes), aerospatiale - cannes edition,
1989.

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.

[11] Thomas R. Kane and David A. Levin-


son. The use of Kane's dynamical equations
in robotics. The International Journal of
Robotics Research, 2(3), 1983.

[12] Thomas R. Kane, P. W. Likins, and DavidA.


Levinson. Spacecrafts Dynamics. Mc Graw-
Hill New-York, 1983.
[13] Claude Gomez. Macrofort : a fortran code
generator in maple. Rapport technique 119,
Institut National de Recherche en Informa-
tique et en Automatique, 1990.
[14] Patrick Capolsini. MacroC : C code genera-
tion within Maple. Rapport technique 151,
Institut National de Recherche en Informa-
tique et en Automatique - Laboratoire Infor-
matique Signaux et Systemes de l'Universite
de Nice Sophia-Antipolis, 1992.
[15] NAG Incorporation. The NAG Fortran li-
brairy Manual, 1990.

[16] W.H. Press, B.P. Flannery, S.A. Teukolsky,


and W.T. Vetterling. Numerical recipes in C
: the art of scientific computing. Cambridge
University Press, 1988.

[17] Dan E. Rosenthal. An order n formulation


for robotic systems. Technical report, Sym-
bolic Dynamics, Mountain View, California,
1987.

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

Abstract 1 Introd uction


Sensitivity analysis of engineering models is an es-
sential part of the design process. The 'sensitivity
factors', or simply 'sensitivities', are the partial
derivatives of the responses of the system model
with respect to its parameters, or 'inputs'. Sensi-
Sensitivities are the partial derivatives of system
tivities have long been used to measure the "im-
responses with respect to the parameters of a de-
portance" of individual parameters in the model
sign model. These have long been used as mea-
[7,8], but are also required in reliability and qual-
sures of the "importance" of individual parame-
ity analyses [2, 17, 12], and design optimization
ters in the model, but are also required in reli-
[10, 16].
ability and quality analyses, and for design op-
Sensitivities are typically calculated numeri-
timization. Sensitivities are typically calculated
cally, either estimated using finite differences, or
numerically, either estimated using finite differ-
calculated directly using techniques derived from
ences, or calculated directly using techniques de-
systems theory 1 , such as the well-known Adjoint
rived from network theory, such as the well-known
method. Direct methods make use of the true
Adjoint method. Direct methods make use of the
derivatives of system equa.tions and have the ad-
true derivatives of system equations and have the
vantage of requiring many fewer system analyses
advantage of requiring many fewer system analy-
than the finite difference methods; they are also
ses than the finite difference methods; they are
exact for linear system models. In this paper we
also exact for linear system models. Symbolic
demonstrate a direct method, Graph-Theoretic
computation software, such as Maple, can further
Sensitivity Models (GTSMs)[14], using Maple.
increase the computational efficiency of the di-
The mathematical model of an engineering sys-
rect sensitivity analysis methods. The gain arises
tem is often in the form of a system of nonlinear
from the ability to solve the sensitivity models
equations
in algebraic form. The algebraic solution need
only be performed once. The numerical work
h(v, z) = 0 (1)
is thus reduced from repeated generation of Ja- where z and v are vectors of system responses
cobians and inverses at each operating point to and inputs, respectively. A system model in this
simple evaluation of the algebraic sensitivity ex- form is implicit in the response variables, z, and
pressions. For nonlinear system models numerical the solution must be obtained iteratively by, for
solution, e.g. by the Newton-Raphson method, example, the Newton-Raphson method.
cannot be avoided but many of the advantages Traditionally, the sensitivity problem is ad-
of using Maple remain. Sensitivity analysis us- dressed after the system equations (1) have been
ing Maple is demonstrated for a simple, nonlinear 1 Also known as network theory, or graph-theoretic
pipe network system. modelling.

Mathematical Computation with Maple Yo


Ideas and Applications
10m Lee, Editor
@1993 Birkhiuser Boston

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

Given the FOS interconnection equations, (15)


and (16), and the FOS terminal equations, (17)
and (18), the FOS system model can be formu-
In the superscript notation described above we lated (using e.g. the Mixed Nodal Tableau) as a
can simply write linear system of equations in the FOS response
variables:
Ay(lU) = 0 (15)
L(u, z) z(lu) = Rpos(u, z) (19)
Similarly, for the nodal transformation equations where L is the same as LNR in (11) and only the
we obtain RHS is different. The FOS response variables,
(16) z(lu), form a matrix with m columns, where m is
Note that we now have m sets of vertex equa- the length of vector u.
tions and m sets of nodal transformation equa-
tions written in compact form; the vectors of 3.2 SOS System Equations
system variables in the nominal interconnection
equations now become matrices of FOS system We obtain the SOS system equations by differen-
variables. tiating the FOS equations again with respect to
Now we derive the FOS terminal equations u.
for constitutive components of the form given The SOS vertex and nodal transformation
in equation (6). We define the vector v = equations simply become
[xaO, g( d), Ytof where the elements of vector Ay(2u) = 0; x(2u) = AT X~2U) (20)
g( d) are the diagonal elements of matrix G in
(6) which are functions of physical properties and The SOS terminal equations for the constitu-
design variables, d; XaO are across excitations and tive components become, after some manipula-
YtO are through excitations. The vector u is de- tion,
fined as u = [xaO' d, YtOf. We define the trans-
formation between v and u as v = v(u). The yi 2U ) (Gf(b e») xFu) (21)
set of inputs v contain variables such as g wJ:tich + { Gf(2"'e)(x~lu) ® x~lU»)
we use only for notational convenience. We re-
quire sensitivities with respect to the actual mea- + G(2V)(v(lU) ® V(lu) ® f)
surable quantities contained in u. Applying the G(lv) [(v(2U) ® f)
+
Chain and Product rules of matrix calculus (see
Appendix A) to equation (6) we obtain + U(f(be)x~lU) ® v(lU»)

+ (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.

q4 = 1.547 1t.3/s q5 = 1.0 1t.3/s (23)


a)
where h?·54 in (4) has been rewritten as
Ih i 10. 54 hi / Ih i 1= hi Ih i 1- 0.46 in order to ensure that
the signs (directions) of q2 and q3 change with
those of their respective pressure drops [5].

4.1 Nominal Solution


datum Since the constitutive terminal equations are non-
linear, we build the Newton-Raphson system (11)
b) and solve for z iteratively using (12).
The constitutive terminal equations, (14), are

[
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)*)

145800g~(kl) * let A be p x q matrix and B be r x s. Let v be a


column vector of length n and u be of length m.

5 Conclusions A.1 Derivative of a Matrix


With Respect to a Vector
Maple has been shown to be useful for the con-
struction and solution of sensitivity models in the 8A
8v n
]
pxnq
following respects: (28)
Note that in this definition the vector v is trans-
1. Maple's symbolic differentiation capabilities
posed. This produces a matrix which has the
are used to differentiate the component's con-
same form as the Jacobian matrix ofa vector func-
stitutive equations to produce the Newton-
tion.
Raphson model ofthe nominal nonlinear sys-
Similarly for higher-order derivatives,
tem and the sensitivity models.
8A(lv) ]
2. Maple programs can be written to build up ----e:;;;:- p X n' q
the nominal and sensitivity models in sym- (29)
bolic form using systems theory (given a data
file describing the types of components in the A.2 Derivative of a Matrix
system and their interconnections). With Respect to a Matrix

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 •

Newton-Raphson iteration, equation (12). (30)

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.

[11] N. C. Lind. Analysis of structures by system


References theory. Journal of the Structural Division,
ASCE, 88(ST2):1-22, 1962.
[1] G.C. Andrews and H.K. Kesavan. The
vector-network model: a new approach to [12] H.O. Madsen, S. Krenk, and N.C. Lind.
vector dynamics. Journal of Mechanisms and Methods of Structural Safety. Prentice-Hall,
Machine Theory, 10:57-75, 1975. Englewood Cliffs, NJ, 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.

[16] J.N. Siddall. Optimal Engineering Design.


Marcel Dekker, Inc., New York, 1982.

[17] R. Spence and R.S. Soin. Tolerance Design


of Electronic Circuits. Addison-Wesley, New
York,1988.

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

1. Introduction Meier (KM) estimator is commonly em-


ployed. The KM estimator is a non-
In many medical studies and industrial parametric maximum-likelihood estimator
experiments, the outcome of interest is the of the survivor function in the presence of
time to some event such as death, disease censored data, and reduces to the empiri-
recurrence or component failure. The in- cal survivor function when censoring is not
vestigators often want to find the distribu- present. The Kaplan-Meier estimator of
tion of these times, as well as characteris- S(t) is given by:
tics of the distribution such as the mean
median, dispersion and skewness. In such
studies it is usually impractical to wait un- S(t)=II[ n-i ]6; (1)
til all items or subjects have failed and i:ti~t
n-i+1 '
those which have not failed at the ti~e of
data analysis are right-censored, meaning
that the times recorded are lower bounds ~her~ i = ~, ... , n. Note that S(t)
on the actual failure times. IS a rIght-contmuous, non-increasing step
function starting at S(t) = 1 for t less
In the censored data setting, the ob- ~han the first uncensored point, and with
served data are ti, the observed failure or Jumps down at the uncensored points. If
censoring time, and 6i, the censor code the largest data value is uncensored then
which equals 1 if ti is a failure time and "
S(t) '
jumps down to zero at that point.
zero if it is a censoring time. A data set
is of the form (tb 61 ), (t2' 62 ), ... ,(tn, 6n). Each term of the KM product is the es-
For the purposes of this paper, we assume timated conditional probability of surviv-
no tied values in the sample data. To sim- ing to time ti, given survival to time
plify notation, let the sample ti's be or- ti-l. If these were the actual probabili-
dered such that tl < t2 < . . . < tn. ties, their product would yield the uncon-
ditional probability of surviving to time t.
The distribution of these "survival The KM estimator can be intuitively un-
times" is usually expressed in terms of derstood from this perspective.
the. surv,ivor function, S.(~) = P(T > t),
whIch gIves the probabIlity of surviving The bias of an estimator is the expected
longer than time t. Here, T is the ran- value (Le., mean of the estimator under
dom variable representing the time to fail- , repeated sampling) minus the true value
ure. If data were all uncensored, then this being estimated. Since an entire survivor
function is estimated by the proportion of function is being estimated, the bias of the
items which have not failed by time t i.e. estimator must be evaluated at each point
the empirical survivor function. Whe~ th~ of time, t. The KM estimator is known to
data include censored values, then a modi- be biased, but the bias as a function of t
fied estimator is required, and the Kaplan- cannot be expressed in closed form unless
strong assumptions are made about the re-
lationship between the survivor and cen-
Mathematical Computation with Maple ~
soring distributions (Chen, Hollander and
Ideas and Applications Langberg, 1982). Previous investigations
10m Lee, Editor of the bias of the KM estimator in the gen-
@I993 Birkhauser Boston eral case have used approximations based

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

E[S(t)] = Eo[E[S(t)lw]] E[Sa(t)] = e- 2t + (1 - ~e-2t) = 1 + ~e-2t.


2"+1_1
= E E[S(t)lwi]' P(Wi). (2) Since S(t) = 1 - F(t) = e- t , the bias as a
i=l function of t is then obtained as BG(t) =
(1 + ~e-2t) - e- t •
Given Wi, ErS(t)lwi] is simply S(t)lwi'
which is a KM calculation following (1). For n = 2, 11 has 7 elements: <p, {O},
Calculating P(Wi), however, requires eval- {I}, {O,O}, {0,1}, {1,0}, and {1,1}. The
uation of a multiple integral. first element corresponds to the case t <
Tl < T2 , the next two elements to the case
The method is first illustrated for n = 1 T1 :5 t < T2 , and the last four elements
and n = 2, and then generalized to larger to the case Tl < T2 :5 t. The correspond-
n. Note that the time, t, for which we are
calculating the KM bias is fixed, and Ti, ing values of E[S(t)lwi] (which is simply
the data values, are the random variables. S(t)IWi) are given in Table 2 below.
For n = 1, 11 = {<p, {O}, and {I}}, where Table 2: Values of Sa(t)lwi
<p denotes the case where t < 1'1 (i.e., t is
prior to the first and only data value), and for n = 2
the other two cases refer to T1 :5 t (i.e., the
data value, Tl, is :5 t, and 61 is either zero W SG(t)/w
or one). Denoting the above elements of
11 as Wll W2, and W3, respectively, and sub- <p 1
stituting into expression (1) to compute {0} 1
S(t)IWi, the resulting values are 1, 1, and {1} 0.5
0, respectively. Thus, { 0,0 } 1
{ 0,1 } 0
E[Sa(t)] = 1· P(W1) + 1· P(W2) +O· P(W3) { 1,0 } 0.5
where P(W1) = P(t < T1) { 1,1 } 0
For n = 1 we needed the joint distri-
= P(X > t) . P(Y > t) bution of T and 6. For n = 2 we need
= (1 - F(t))(l - G(t)) the joint distribution of T1 , T2 , 61 and 62 ,
where 61 and 62 are the censor codes cor-
and P(W2) = P(t ~ T1, 6 = 0) responding to Tl and T2 • Again, this is
a partly discrete, partly continuous joint
distribution with a separate term for each
= fat JT,s(t, 6 = 0) dt unique sequence of Os and Is. For n = 2
there are four terms, each of which is a
= FT ,s(t,6 = 0). continuous function of t1 and t 2. (Recall
that Tl and T2 refer to the ordered values,
Similarly, P(W3) = FT,s(t,6 = 1), although i.e., the order statistics.) The joint dis-
it need not be calculated since its coeffi- tribution of (T1' 61 , T2 , 62 ) is given by the
cient is zero. Note that calculating P(W1), following product:
i.e., the probability that all data values
are greater than t, does not require in-
tegration. For example, suppose X and n!(Ja(t1)I[61 = 0] + Jb(t1)I[61 = 1])
Yare both exponentially distributed ran-
dom variables with parameter A = 1, so '(Ja(t2)I[62 = 0] + Jb(t2)I[62 = 1]).
that F(x) = 1 - e- x , G(y) = 1 - e- Y , This expression is of the form n!(a1 +
J(x) = e- x , g(y) = e- Y , P(Wl) = e-te- t = b1)(a2+b2)j multiplying the terms together

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

(It is actually more efficient to start the


outer loop at i=1, with i=O handled as a
After calculating all such terms, we can special case.) The inner loop indexed by
compute j generates as a binary string all possi-
ble patterns of exact and censored values
E[S(t)] = ~ E[S(t) I w] . P(w), (Is and Os) among the i observations that
weO are less than t. The string is generated by

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

quartic and higher-order spectroscopic constants,


Abstract location of rotational instabilities, and characterization
of the "cubic" anisotropies for the spherical top
We have obtained analytic expressions, clusters A4 and Acs which lead to a partial lifting of
parametric in centrifugal displacement coordinates, their rotational energy-level degeneracies. Of
which provide exact classical descriptions of the particular interest is the result that for each of these
rotational energy dispersions, that is, the dependence cluster types the preferred direction of the rotational
of the combined rotational and vibrational energies on angular momentum is parallel to a molecular four-
the rotational angular momenta, for small molecular fold axis, leading to reduced symmetries of D2d for
clusters bound by van der Waals interactions modeled tetrahedral A4 and D4h for octahedral Acs.
by pairwise additive (6-12) Lennard-Jones potentials.
The clusters considered consist of three (equilateral I -Introduction
triangle), four (tetrahedron), and six (octahedron)
units and serve as models for small clusters of rare- The distortion of a rotating molecule from its
gas atoms such as argon. This work represents an equilibrium geometry and its effect upon the
extension of our recently published study of analytic rotational energy levels has been recognized for a
rotational energy dispersions for diatomic molecules long time by molecular spectroscopists. Interest in
bound by harmonic oscillator, Morse, or Lennard- these centrifugal effects, as they are often called, has
Jones potentials [J. Mol. Spectrosc. 155, 205 increased in recent years due to the development of
(1992)]. high-resolution spectroscopic techniques and to major
The Maple V mathematical problem-solving advances in the theoretical description of highly
system has been employed in numerous ways in this excited rotational states of molecules. In a series of
investigation, in obtaining the exact parametric studies (Refs.(1-6» we presented a new approach to
expressions, in obtaining both power series and Pad6 centrifugal distortions and their associated rotational
approximant (rational function) forms useful to energy stabilizations which exploits ab initio
molecular spectroscopists, and in making three- electronic structure computational methods. This
dimensional plots of rotational energy surfaces which approach is direct, bypassing in . its simplest
portray the variations of the combined rotational and applications the explicit calculation of spectroscopic
potential energies with the directions of the rotational constants such as vibrational frequencies as this
angular momenta with respect to the molecular information is implicitly contained in the ab initio
frames. electronic energy hypersurface. Specifically the
The physical properties of the clusters which method is particularly useful at any computational
are addressed using our results include calculation of level for which analytic gradients of potential-energy
hypersurface is available. Results were presented in
our first study (Ref.(1» for H2 +, NH3 , CH4 , BF3 , and

°
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:

pJ2=I44z 2(I-z 3) + 72(Z4/Z 2)(1-Z3) (12)


i
E=pJ2z14 + 4(1-z 3 + 8(1-(3)2 (19)
+ 2(1-(z/2)3l + (I-Z3)2
(13)

Through the parameter interdependencies the energy


Z=z(f(z+() (14)
is a function of a single variable.
How do we use Maple V to solve these sets
of equations? Consider for example the last set, Eqs.
E=pJ2z14 + 6(I-z 3)2 + 6(1-(3)2 (15) (16)-(19), describing ~ with J II C4 • We obtain
+ 3(1-Z3)2 numerical solutions in the following sequence: first,
select a value of Z greater than 112 (the correspond-
ing distance is compressed below 2112ro by the rota-
Note that Eqs. (13) and (14) give the interdependen- tion); second, solve Eq. (17) for t; third, solve Eq.
cies of the structural parameters, so that the energy (18) for z; fourth, solve Eq.(16) for {3P; and fifth,
again is in effect a function of a single parameter: solve Eq. (19) for the energy E. Other sequences are
The effective energy in Eq.(15) has a value of possible as long as we start with an equation in only
(588/257) for J = 0, for which z., = to = (264/257YI3 two variables, taking one of them as independent.
and Zo = zol2. The value Zo = (264/257)113 =
1.00900 describes the compression (x., = -0.00447) v - Results and Discussion
of the 12 edges due to the attractive trans interac-
tions. The energy value (588/257) is relative to that The key results will be presented and
for the unattainable structure with all fifteen interact- discussed here, with many quantitative details to be
ing pairs being at ro (z = t = 1). It is desirable for left for a future publication (Ref.(26». We consider
some purposes to subtract this constant from the first the equilateral triangular complex A3 • Reduced
energy so that the energy is zero for J = o. We energies E as a function of {3J2 were found for three
follow this latter convention in our energy tabulations cases, namely J II C2 OJ, J .1 C2 (Jy ), and J II C3
and all discussion. Alternatively, relative to disso- OJ, as based on the expressions in Table I and on

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

1. L. L. Lohr and J.-M. J. Popa, J. Chem. Phys. Table I


84, 4196 (1986).
2. L. L. Lohr and A. J. Helman, J. Comput. Chem. Energy-Angular Momentwn Expressions
8, 307 (1987). Parametric in Displacements
3. L. L. Lohr, Int. J. Quantum Chem: Quantum for LJO Clusters
Symp. Symp. 21, 407 (1987).
4. A. Taleb-Bendiab and L. L. Lohr, J. Mol. Species Direction (JJ2
Spectrosc. 132, 413 (1988). [Z2( l_r))8.b
5. L. L. Lohr, J. Mol. Struct. (THEOCHEM) 199,
265 (1989). A2 J .1 C... 6d Id
6. L. L. Lohr, J. Mol Spectrosc. 155, 205 (1992). A3 (D3J
7. R. S. Berry, J. Jellinek, and G. Natanson, Chem.
J I ~ 36 3
Phys. Letters 107, 227 (1984). J I C2 6 1
8. R. S. Berry, J. Jellinek, and G. Natanson, Phys. A4 (TJ
Rev. A30, 919 (1984).
9. J. Jellinek, T. L. Beck, and R. S. Berry, J.
J ~ S4 24 2
J C3 36 3
Chem. Phys. 84, 278 (1986). ~ (~ - cis only)
10. R. S. Berry, T. L. Beck" H. L. Davis, and J. 96 4
Jellinek, Adv. Chem. Phys. 70 (part 2), 75 (1988). J
J
II C4
C3 144 6
11. N. Quirke, Mol. Simul. 1,249 (1988).
12. D. M. Leitner, R. M. Whitnell, and R. S. a) z = 1/(1 + X)2 = (rc/r)2
Berry, J. Chem. Phys. 91, 3470 (1989). b) (J = BC<A~/Dc(A~, where De(A~ well
13. D. H. Li and J. Jellinek, Z. Phys. D - Atoms, depth d.
Molecules, and Clusters 12, 177 (1989). c) E = Ee~Q)/De(A~.
14. J. Jellinek and D. H. Li, Phys. Rev. Letters 62, d) The tabulated integers are mUltipliers of the
241 (1989). expressions at the head of each column.
15. J. Jellinek and D. H. Li, Chem. Phys. Letters
169, 380 (1990).

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.

Professor Lohr may be reached at The Department of


Chemistry, The University of Michigan, Ann Arbor,
MI,48109-1055. His e-mail address is:
[email protected].

b)

Carl H. Huben was graduated with a B.S. Chemical


Engineering degree from the University of Michigan,
Ann Arbor, in December, 1992. A recipient of a
National Science Foundation Predoctoral Fellowship,
he plans to pursue graduate studies in physical
chemistry at Stanford University.

Mr. Huben may be reached c/o Professor Lawrence


L. Lohr at The Department of Chemistry, The
University of Michigan, Ann Arbor, MI, 48109-
1055. Mr. Huben's e-mail address is:
[email protected].

143
SYMBOLIC COMPUATION IN COMPUTABLE GENERAL
EQUILIBRIUM MODELING
Trien T. Nguyen
Department of Economics, University of Waterloo, Waterloo ON, Canada

that they are completely left unassisted. They


still have to mainly rely on the traditional "pa-
1 Introduction per and pencil" technology in the specification
of their models. Analytical expressions for spe-
Alongside theoretical developments of mathemat- cific demand and production functional forms such
ical economics in the fifties and sixties, the emerg- as CES (constant elasticity of substitution), YES
ing field of computable general equilibrium (CGE) (variable elasticity of substitution), or LES (lin-
modeling (Scarf and Shoven [1984], Shoven and ear expenditure system), with or without multi-
Whalley [1992]) has been pre-occupied with the level nesting, remain to be worked out manually
problem of numerically solving systems of highly by modelers. Calibration procedures (Mansur and
nonlinear simultaneous equations describing gen- Whalley [1984]), no matter how laborious and te-
eral equilibrium states of a multi-sector model dious, still have to be performed manually so that
of an economy. Path breaking contributions by analytical formulas for key model parameters can
Scarf [1973], Merrill [1972], van der Laan and Tal- be derived before the solver in GAMS can crank
man [1979], and others in the theory of fixed- out their numerical values. If modelers wish to get
point computation have made it now possible to a more realistic representation of the real world,
routinely compute numerical solutions of complex the modeling process will become so complicated
CG E models in various areas such as public fi- that the analytical part can quickly render the
nance, international trade, development, environ- model intractable by hand even before the numer-
ment, and economic history. ical part has a chance to tackle its job.

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)

Consider the following simple illustrative model of


an economy with n commodities indexed by j = (4)
1, ... , nand h households indexed by i = 1, ... , h.
Each household is given fixed amounts of com- n (CES)
modities called initial endowments Wij > 0 and ' " ' J: II. (I-II.)
is allowed to trade in the market for the "right" L...J vik Pk
k=l
amounts of commodities to their own satisfaction.
Satisfaction is described by the so-called utility Clearly, quantities demanded are negatively re-
function Ui (Xi!, ... , Xin) which can be specified lated to prices and positively related to incomes.
by either one of the following two popular func- This is consistent with intuition since, everything
tional forms: else being the same, the lower the prices or the
higher the incomes, the greater quantities people
n
IT X ij

'J (Cobb- Douglas)
will buy. Individual excess demands are defined
as differences between quantities demanded and
j=l
initial endowments:
(1)
Zij (PI,'" ,Pn) = Xij - Wij' (5)
(CES) A positive individual excess demand means that
the household is buying to make up for the gap
Xij - Wij while a negative individual excess de-
with share parameters Oij > 0, elasticity of sub- mand means that the household is selling the ex-
stitution (Ti 2: 0, Pi = 1 - (1/ (Ti), and quantities cess supply Wij - Xij. A zero individual excess
demanded Xij. The value of (Ti indicates how eas- demand means that the household is neither buy-
ily commodities can be substituted for each other ing nor selling since quantity demanded matches
to maintain household satisfaction. For example, exactly with the initial endowment.
(Ti = 00 implies infinite or perfect substitutabil-
Market excess demands are defined as the sum
ity while (Ti = 0 means no substitution at all, for
of all individual excess demands Zij in (5):
example, like right shoes and left shoes.
h
Given any price vector (PI, ... ,Pn), endowment
incomes Yi can be evaluated as the value of initial
Zj (PI,'" ,Pn) = L (Xij - Wij) (6)
i=l
endowments at current market prices:
A positive value for Zj means that the economy
n as a whole is having shortages since households al-
Yi(Pl, ... ,Pn) = L Pj W;j. (2) together demand more than the total amount of
j=l endowments in the economy. On the other hand, a
negative value for Zj implies surpluses since house-
Endowment incomes enable households to buy the
holds demand less than the amount of endowments
maximum quantities of commodities which they
available. The economy is said to be in general
can afford. The economic problem for households equilibrium when quantities demanded match ex-
in this simple framework is therefore to balance actly with quantities supplied for all commodities,
between what they want (satisfaction) and what
they can afford (income constraint). This can be (7)

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).

This section outlines the structure of GAMS pro-


***** GAMS FILE gexparam.inc *****
SETS
grams in the context of the illustrative example
j commodity I C1, C2, C3 I
presented in the previous section. To be specific,
i household I H1, H2 I;
suppose that there are three commodities (n = 3)
named C1, C2, C3 and two households (h = 2)
PARAMETERS
named HI, H2. Model parameters such as elastic-
sigma(i) elasticity of substitution
ities of substitution C1'i, share parameters 6i j, and
I
initial endowments Wij are given in the table be-
H1 1.
low.
H2 2.
I
delta(i,j) share parameters
Elasticity Share Initial I
of Parameters Endowments H1.C1 .2222222222
Substitution H1.C2 .3333333333
H1.C3 .4444444444

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

The Maple program gexparam. mpl listed below


Equilibrium has two parts. The first part specifies model
Prices 1.0000 1.1108 1.2045 parameters selected in the previous section such
as n commodities, h households, elasticities of
Household substitution sigma (all Cobb-Douglas except the
Demands last household), utility share parameters delta,
H1 2.2556 3.0459 3.7454 and initial endowments W. For illustration pur-
H2 2.7444 3.9541 5.2546 poses, these data are purely hypothetical with no
Total 5.0000 7.0000 9.0000 real economic significance. The second part of
the program writes these model parameters back
Initial into a parameter block in the GAMS data file
Endowments gexparam. inc listed in subsection 3.1 above.
H1 2.0000 3.0000 4.0000
H2 3.0000 4.0000 5.0000 ##### Maple file gexparam.mpl #####
Total 5.0000 7.0000 9.0000 ##### included by gexmaple.mpl #####

Market ##### global parameters #####


Excess n := 3;
Demands 0.0000 0.0000 0.0000 h := 2;
sigma := array(1 .. h,[seq(1,i=1 .. h-1),h]);
delta := array(1. .h,1. .n);
W := array(1..h,1..n);
4 Interfacing GAMS with for i from 1 to h do
for j from 1 to n do
Maple delta[i,j] :=
(i+j)/sum(i+jj,jj=1 .. n)
Section 3 shows how the gex model was numer- od;
ically solved using GAMS alone. For this simple for j from 1 to n do
illustrative example, an argument can certainly be W[i,jJ := (i+j)
made that numerical software like GAMS provides od;
modelers with all the tools they need. This is how- od;
ever based on the presumption that the analyti-
cal structure of the model, especially equation (4) ##### parameter block #####
of household demands, has been manually worked interface(quiet=true);

148
econlib.mpl
gexparam.mpl

,.
gexmaple.mpl

,.

Maple

"
gexparam.inc gexparam.inc gexparam.inc
gexmaple.eqn gexmaple.inc
manual
editing

"
gexgams.gms gexmaple.gms

(manually coded) (Maple-ae;e;/e;ted)

Fig. 1. Interfacing GAMS with Maple

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 #####

2/9 1/3 4/9 ##### read included files #####


U[1] : = X[1, 1] X[1, 2] X[1, 3] read('econlib.mpl'): # economic routines
read('gexparam.mpl'): # model parameters
2 p[1] + 3 p[2] + 4 p[3]
X[1, 1] := 2/9 ------------------------ ##### global variables #####
p[1] p := array ( 1 .. n) ; # prices
U := array(1. .h); # utility
2 p[1] + 3 p[2] + 4 p[3] y := array(1. .h); # incomes
X[1, 2] := 1/3 ------------------------ X := array(1 .. h,1 .. n); # demands
p[2] Zij := array(1. .h,1. .n); # excess demands
Z := array(1 .. n): # excess demands
2 p[1] + 3 p[2] + 4 p[3]
X[1, 3] := 4/9 ------------------------ ##### market excess demands #####
p[3] for i from 1 to h do

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

EQ_object .. object =E= GAMS will issue a compiler error message.


sum(j,(p(j) * Z(j» ** 2); This can be fixed by simply manually editing
to remove those "bad" newline characters and
EQ_Zl .. Z("Cl") =E= join the lines together as follows:
-1/9*(-170*p[3]*p[1]*p[2]+656*p[3]*
p[1]**2+1025*p[1]**2*p[2]-378*p[3]* -1/9*(-170*p("C3")*p("Cl")*
p[2] **2-150*p[2] **2*p[1]-477* p("C2")+656*p("C3")*
p[3]**2*p[2]-128*p[3]**2*p[1])/ p("Cl")**2
p[l] / (9*p [3] *p [2] +16*p [3] *p [1] +
25*p [2] *p [1] ) These idiosyncratic differences can be interpreted
as the weakness of either Maple or GAMS (or
EQ_Z2.. Z("C2") =E= both) depending on one's inclination to favor one
2/3* (ll*p [3] *p [1] *p [2] +88*p [3] * software package over the other. Our intention
p[l] **2+25*p[1]**2*p[2]-81*p[3] * here is not to point a finger at whom is to be
p[2]**2-225*p[2]**2*p[1]+18* blamed, but rather to show that these problems
p[3]**2*p[2]+152*p[3]**2*p[1])/ surface only if modelers attempt to integrate both
p[2] /(9*p [3] *p[2] +16*p [3] *p [1] + tools in the modeling process. It is probably not
25*p [2] *p [1] ) too technically difficult for developers of these soft-
ware packages to provide a conversion routine be-
EQ_Z3 .. Z("C3") =E= tween Maple and GAMS outputs.
1/9*(-236*p[3] *p[l] *p [2] +128*p [3] *
p[1]**2+875*p[1]**2*p[2]+108*p[3] * Listing of the output file gexmaple . eqn after man-
p[2] **2+1200*p[2] **2*p[1]-585* ual editing and renaming as gexmaple. inc is as
p [3] **2*p [2] -1040*p [3] **2*p [1] ) / follows:
p[3] / (9*p[3] *p [2] +16*p [3] *p[l] +
25*p [2] *p [1] ) ***** GAMS FILE gexmaple.inc *****
***** originally gexmaple.eqn *****
This "semi-GAMS" file is however is not ready to ***** included by gexmaple.gms *****
be processed by GAMS as it needs at least two EQUATIONS
adjustments to reconcile the following syntactical EQ_Zl market excess demand
differences between GAMS and Maple. EQ_Z2 market excess demand
EQ_Z3 market excess demand
• Firstly, Maple uses square brackets [ ] for EQ_object objective function;
array elements while GAMS uses combina-
tions of parentheses and double quotes (" EQ_object .. object =E=
"). This can be adjusted by either manually sum(j,(p(j) * Z(j» ** 2);
editing or using Unix utilities such as

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.

[4] Debreu, G. (1959) Theory of Value. New


York: Wiley.
These crude statistics however did not reveal the
hidden costs associated with time resource and ef- [5] Kehoe, T. J., and J. Whalley (1985) "Unique-
fort spent by modelers who, if without the help ness of Equilibrium in Large Scale Numeri-
of Maple, would have to perform the tedious and cal General Equilibrium Models," Journal of
error-prone manual process of analytical deriva- Public Economics 28, 247-254.
tion of the equation block required by GAMS.
[6] Mansur, A., and J. Whalley (1984) "Numeri-
Measurements of these costs remain to be esti-
cal Specification of Applied General Equilib-
mated but we would not be surprised if they could
rium Models: Estimation, Calibration, and
be substantial.
Data," chapter 3 in Scarf, H. E. and J. B.
Shoven (eds.), Applying General Equilibrium.
New York: Cambridge University Press.
5 Conclusion
[7] Meeraus, A. (1983) "An Algebraic Approach
to Modeling," Journal of Economic Dynam-
Symbolic computation software such as Maple ics and Control 5:1, 81-108.
can indeed be useful to CG E modelers in the
model-building process. An interface between [8] Merrill, O. H. (1972) "Applications and
Maple and specialized modeling software such as Extension of an Algorithm That Com-
GAMS provides the best of both worlds: mathe- putes Fixed Points of Certain Upper Semi-
matical manipulation from Maple and large-scale Continuous Point to Set Mappings," Ph. D.
numerical computation from GAMS. The paper thesis, Department of Industrial Engineering,
presents a simple illustrative example showing how University of Michigan.
Maple can be successfully used in conjunction with
[9] Murtagh, B. A. and M. A. Saunders (1987)
GAMS.
"MINOS 5.1 User's Guide," Report SOL 83-
A combination of two powerful tools such as 20R, December 1983. revised January 1987,
GAMS and Maple now allows CGE modelers to Stanford University.

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.

[12] Shoven, J. B., and J. Whalley (1992) Apply-


ing General Equilibrium. New York: Cam-
bridge University Press.
[13] van der Laan, G., and A. J. J. Talman (1979)
"A Restart Algorithm for Computing Fixed
Points Without an Extra Dimension," Math-
ematical Programming 17, 74-84.

[14] Weintraub, E. R. (1983) "The Existence of a


Competitive Equilibrium: 1930-1954," Jour-
nal of Economic Literature 21, 1-39.

Trien T. Nguyen is an associate professor of


economics with publications and research inter-
ests in computable general equilibrium model-
ing of economic policy in public finance, interna-
tional trade, and economic development. Con-
tact address: Professor Trien T. Nguyen, De-
partment of Economics, University of Water-
loo, 200 University Avenue West, Waterloo, On-
tario, Canada N2L 3G 1. Telephone: (519) 885-
1211 ext. 2794. Fax: (519) 725-0530. Email:
[email protected].

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

Abstract .. output. The state transition matrix is the unique


solution to

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)

and has the following important properties [1]:

Mathematical Computation with Maple ~ cI>(t, t) = I (4)


Ideas and Applications
10m Lee, Editor "This work was supported under the USAF Graduate Fel-
©1993 Birkhauser Boston lowship Program

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

Stability of the homogeneous system,


In general, a closed form solution for q>(t, to)
x(t) = A(t)x(t), (7) does not exist. In this section, several classes of
systems for which q>(t, to) can be calculated in
whose solution is given by closed form are discussed. Maple routines which
aid in this calculation are discussed. After sum-
x(t) = q>(t, to)xo, (8) marizing classes for which the state transition can
be calculated, two decomposition schemes will be
where Xo = x(to), can be determined from the discussed which expand on these classes.
state transition matrix, according to well known Before examining these classes, it should be
stability theorems [1] (see Appendix). The neces- noted that the procedures to be discussed assume
sary and sufficient conditions on q>(t, to) for sta- that the linalg package has been loaded along
bility are summarized in Table 1. with the procedures listed in Table 2. The eye
It is easy to verify that the solution to the non- and zeros procedures are modeled after the Mat-
homogeneous system (1) is given by lab functions of the same names and return the

x(t) q>(t, to)xo + 1t


to
q>(t, r)B( r)u( r)dr
identity matrix and a matrix of zeros, respectively.
The msubs procedure substitutes expressions into
matrices.
y(t) = C(t)q>(t, to)xo + C(t) (9) The Kronecker product of A = [aij] E ~mxn

1 t
to
q>(t, r)B( r)u( r)dr + D(t)u(t).
and B E ~pxq is defined to be

To guarantee that the system can be driven from


one state Xo to another state Xl with an input
u(t), it is necessary to show that the system is
controllable. The LTV system (1) is said to be where A ® B E lRmpxqn. The vector vec A is de-
controllable if given any Xo there exists an input fined to be
u(t)[to.tt] such that x(h) = O. Controllability of
(1) can be determined from the state transition (11)
matrix according to a well known theorem [2] (see
Appendix).
To guarantee that the system states x( t) can be where A E ~mxn, vec A E lRmn , and the ai are
estimated from the system output y( t), it it nec- the columns of the matrix A. The command in-
essary to show that the system is observable. The vec(vec(A),m,n) will return the matrix A. The
LTV system (1) is said to be observable on [to, t1] procedures kron and vec transform matrix equa-
if the initial state Xo is uniquely determined by tions of the form
the output y(t) for t E [to, t1]' Observability of
AXB=C (12)
(1) can be determined from the state transition
matrix according to a well known theorem [2] (see where A E lRmxn , X E ~nxp, and B E ~pxq and
Appendix). The controllability and observability X is unknown to the equivalent system of equa-
Gramians, W(to, t1) and M(to, t 1), respectively, tions
(see Appendix) can also be used in the design of (BT ® A)vec X = vee C. (13)
controllers and observers for (1).
It is clear that the state transition matrix is im- This equation can be solved for vec X by lin-
portant for studying stability, controllability, and solve(D, vec C) where D = BT ® A. [3]
observability of (1). Calculation of the state tran- With these tools, we can now study the solution
sition matrix for linear, time-invariant systems is of
a straight forward task. Unfortunately, for linear
time varying systems, it is often difficult if not im- <j(t, to) = A(t)q>(t, to), q>(to, to) = I. (14)
possible to calculate the state transition matrix.
While in general there is no closed form solution
to (14), the solution can be expressed in terms of

158
Table 1: Stability Bounds on 4)(t, to)

Stable in the sense of Lyapunov at to 114)(t, to) II < k(to) < 00


Uniformly stable in the sense of Lyapunov 114)(t, to)1I < k < 00
Asymptotically stable at to 114)(t, to)1I ::5 k(to) < 00
114)(t, to)lI- 0 as t - 00
Uniformly asymptotically stable 114)(t, to)1I ::5 k1e- k2 (t-t O)

Table 2: Maple Utility Procedures

eye(·) Computes identity matrix


zeros(.) Computes matrix of zeros
msubs(A, 81, ••. , 8 n ) Substitutes sub expressions into matrix
kron(A,B) Kronecker product A ® B
vec(A) vec A
invec(A,m,n) inverse of vec A

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:

peano:= A(t) A{t1)dt1) = A(t1)dt1) A(t),


proc(A.n.tO) (17)
local vi.v2.i.tp; for all t, to, the state transition matrix is given as
if not type(n.posint) then
ERROR('n must be positive integer') (18)
elif not type(A.matrix) then
ERROR('A must be matrix') Again, Maple can easily calculate 4){t, to) using
elif not type(tO.scalar) then the commandexponential(map(int, msubs(A,
ERROR('tO must be a scalar') t=t1), t1=tO •• t».
fi; Checking (17) is equivalent to checking if
v2 := eye(A);
vi := evalm(v2)i
for i to n-i do
v2:=map(int.multiply(A.v2).t=tO .. tp); is satisfied [4]. A procedure com has been written
v2:=msubs(msubs(v2.t = t.i).tp = t); to check condition (19). The commutative condi-
vi:=add(vi.v2) tion can also be checked by decomposing A(t) into
od; the form
L cr,{t)A,
II
RETURN(") A{t) = (20)
end
'=1

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

A(t) = L A;(t) (29)


end
;=1 If
such that 4>l(t,O) = B(t)(t)<}l(t,O), <}1(0,0) =I (35)
4>;(t,O) = F;(t)<};(t, 0), i =1,2, ... ,m (30) is solvable then
<}i(O, 0) = I,
is solvable where <}(t, to) = (1: <}1( r, to)dr) A(to) + I. (36)

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))

where wet) =wet) - wet) and > check(phi,t,O)j

> A:=matrix([[O,g*w,g*cos(w*g*t)], [1 0 0] [ 0 g w g cos(w g t) ]


[-g*w,O,-g*sin(w*g*t)],[O,O,O]])i [ ] [ ]
[0 1 0], [- g w 0 - g sinew g t»
[ 0 g w g cos(w g t) ] [ ] [ ]
[ ] [0 o 1] [ 0 0 0 ]
A .- [ - g w 0 - g sinew g t) ]
The identity matrix and the matrix A(t) are re-
[ ]
0 0 turned as expected. Note that by examining
[ 0 ]
4>(t,O), we see that the nominal trajectory is un-
The eigenvalues of A(t), given by stable. The elements 4»13(t,0) and 4»23(t,0) of
4>(t,O) are clearly unbounded.
> eigenvals(A)i Example 2
Again consider Euler's equations for a sym-
2 2 1/2 2 2 1/2 metrical body, that is 11 = 12 = I. Setting
U1 = U2 = 0, the equations can be written in the
0, (- g w) - (- g w)
form of a quasi-linear parameter varying system
are time invariant, which suggests that A(t) [14];
may be in the A1 class. The procedure can
0 gz(t)
fal(A,AO,Al,A2,O) returns Al and A2 with Al [ -g .. (t) oo ] [ WI (t) ]
given below as = 0 W2(t)
o o
1
0 z(t)
ts
[ -t4
o
t{
ts
0
1.(cos(w9t)(t4 - gw) + sin(wgt)(ts - t9»
!(sin(wgt)(gW - ti) + cos(wgt)(t.s - t9»
~
+ [k] U3(t) (40)

where t4, t5, and t9 are parameters to be specified. where z(t) =


ws(t). A linear parameter varying
These parameters are chosen such that At and A2 (LPV) system depends on a time varying parame-
are time invariant, ter rather than explicitly on time. This parameter

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

Introduction Spatial decomposition schemes include spatial enu-


This paper describes inplici t_solids which im- meration, cell decomposition, and octree representa-
plements implicit solid modeling (ISM) using Ma- tion. Spatial enumeration represents an object as a
pleV2. Implicit solid modeling refers to the method collection of volume cells. Object representation is rel-
that uses an implicit function to define a composite ob- atively easy to maintain but difficult to create due to
ject. Various primitives are pre-defined and joined us- the simplistic structure of the scheme. Shapes com-
ing Boolean operations to form the resulting implicit posed of large curvature variation are most difficult to
function [Storti et al. 1992]. model since they require more geometry than is pro-
A solid model contains an informationally complete vided by cubic cells. Cell decomposition is a generali-
description of the geometry and topology of a 3-D ob- zation of spatial enumeration and allows the cells to
ject [Requicha and Voelcker 1982]. There are many vary in shape and size. Octree representation permits
applications in which solid modeling can be used to recursive subdivision of partially occupied cells, but
adequately represent the geometry of a solid object be- requires significantly more memory as the size of the
fore the object is manufactured. There are numerous cells becomes smaller. In constructive solid geometry,
advantages of constructing a model, notably models objects are built by moving, joining, and cutting prim-
that have physical properties that are good approxima- itive objects. More specifically, primitive solids such
tions to those of the real object. Mass properties of the as spheres, cuboids, and superellipsoids are combined
object such as its volume and moments of inertia can using Boolean operations which include union, inter-
be computed. Design engineers can develop proto- section, and difference. The resulting object is a tree-
types in a computer to visualize their design and deter- structured representation with the primitive solids at
mine the characteristics of the components. Using the leaves and the Boolean operations at the nodes.
solid modeling not only allows visualization of objects The scope of the representation is determined by the
without having to first manufacture them, it also per- number and types of primitives allowed. Constructive
mits changes to be made to the design with minimal ef- solid geometry is attractive because it resembles man-
fort. ufacturing process and is easy to understand.
There are three traditional categories of solid-mod-
eling systems, namely, boundary representation (B- Implicit Solid Modeling
rep), spatial decomposition, and constructive solid ge- In implicit solid modeling (ISM), a solid object in
ometry (CSG). The implementation of boundary rep- the 3-D Euclidean space £3 is described by a defining
resentation involves the description of the enclosed function of the spatial coordinates. The complete rep-
surfaces, which can include planar polygons, quadrics, resentation of the object is unambiguous and is associ-
spline surfaces, and surface patches. Constraints on the ated with the ability to construct a point membership
type of surfaces used in the scheme affect the level of classification (PMC) which categorizes any point in £3
representation power. Furthennore, the order of the as either belonging to the interior, exterior, or surface
surface function polynomials has to be kept relatively of the object. The defining function divides the space
low to maintain a reasonable level of complexity, into three regions: the interior where F(x,y,z) < f. the
which restricts the effectiveness of the scheme. exterior where F(x,y,z) > f, and the surface where
F(x,y,z) = f[Ricci 1973]. The constantfis referred to
as the threshold value of the function.
Mathematical Computation with Maple ~
Ideas and Applications
Functional definitions of some useful primitives are
10m Lee, Editor readily available. For example, superellipsoids [Barr
©1993 Birkhauser Boston 1981] are defined by the function:

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

where a, h, and c define the geometric extent while el


and e2 specify the shape properties. This function de-
scribes a broad family of easily defined primitives.
Displacement and scaling of the primitives are The resulting equations which give the modified-
achieved by linear coordinate transformations. Em- Ricci intersection, union, and difference of the alge-
ploying the basic primitives and operations, simple ob- braic-Boolean operators of degree n are:
jects are represented with a selection comparable to
existing CSG modelers, and additional primitives can (5)
be added by simply providing the appropriate defining
functions. F lu2 =(F 1-n + F 2-n)-l (6)
While simple primitives are useful in forming a
working basis for the modeling scheme, functional (7)
representations of more complicated objects produced
by Boolean volume set operations are also necessary. computer Algebra System
Consider forming a function describing the intersect- Even though the foundations of ISM have existed
ing region of the two solids defined by Fl and F2. Since for 30 years, practical implementations and availabili-
all the points in the region have to satisfy both the ine- ty to the mass engineering audience were not possible.
qualities Fl </ and F2 <f, the intersection of two solids Before the advent of computer algebra systems, the
is associated with the defining function Maximum usefulness of implicit solid modeling was limited be-
(Fl,F2)· cause the defining functions for even moderately com-
plicated solids became meaningless to the user. Now,
(2) this limitation can be overcome with the help of a com-
puter algebra system such as Maple V2. Handling and
In addition to intersection, other Boolean operations manipulating functions that were once thought of as
such as union and difference can be defined using Min- impossible are now not only feasible, but relatively ef-
imum and Inverse, in addition to Maximum. fortless and error-free. The current implementation of
To approximate the Maximum function with the [n_ Maple V2 on a workstation or PC provides sufficient
=
norm (note that Max(F 1, F2) r(IF11, IF21», Ricci computing power to accomplish basic ISM calcula-
[Ricci 1973] proposed a power law relation tions.
In addition to the function evaluation and manipula-
(3) tion capabilities, MapleV2 also provides commands
such as iIlI>licitplot3d and iI\I>licitplot to visu-
The functions Fl and F2 are required to be non-neg- alize solids and 2-D sections defined by implicit ex-
ative and continuous in £3. Staying within the algebra- pressions. All of the figures in this paper were
ic realm allows the use of additional tools for variable generated using either of the above mentioned com-
elimination. Since the order of the blend, n, determines mands except the ray-traced pictures in Figures 3 and
the accuracy of the approximation to the intersection, 5. One minor limitation of the plotting commands is
a larger n produces blending surfaces that cling more that the grid spacing has to be kept below a relatively
closely to the primitive solids. Note that blending ef- low limit, which sometimes makes the plots appear
fects are primarily noticeable near surface intersec- "rough". An alternative around this problem is to per-
tions. This approximation method automatically form a ray-trace on the defining function of the solid
produces geometrically continuous blended surfaces. when a detailed picture of the solid is needed.
Although the discussion above pertains to two solids, IIII>lici t_solids offers the benefits of compact
the method can be applied simultaneously to any num- code, easy extension or modification, and a simple user
ber of solids. interface, taking advantage of Maple V2's argument
Implicit_solids uses Ricci's formulation with type checking and visualization capabilities. Ma-
the threshold constant / = 1. The consequence of this pleV2's improvements in output display capabilities

170
help ease the strain of examining long and complicated In_on of f1 and f2

equations. The users are now able to choose various


output display options, the most useful one being the
high-resolution print which displays equations in near
text-book form.
The proper usage of all the commands in iIrplic-
it_solids, including the Boolean operators and coor-
...
'1
(]
dinate transformations, can be found in the help pages.
'1.
-J -, -I

The help pages are included to provide the users with


adequate information and guidance when needed and
they were designed to conform to the standard Ma-
ple V2 help format. Some useful examples are also in-
cluded in the help pages so that new users may start
using the package by just duplicating the examples and DiIf.....,.<12·f1) Union of f1 and f2

observing the results.

Algebraic Solid Modeling


Computer algebra systems are most effective when
dealing with algebraic problems, i.e. manipulating and
solving polynomial equations. To adapt ISM to per- "..l.-'::::::=:===:=::::"'~-7
form efficiently on computer algebra systems, minor
restrictions are required, and the resulting scheme is
called Algebraic Solid Modeling (ASM) [Ganter and > read implicit_solids;
Storti 1992]. In this scheme, solids are represented by > f1 :=Circle;

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;

by using a higher degree polynomial to model the r+y2+r


squaroid. As mentioned before, the blending effects (A unit sphere centered about the origin)
> Cubold(4);
are most noticeable near the intersections of the ob-
jects, giving the resulting sections rounded corners at x4+,Y'+z4
the intersections. (A unit cuboid of degree 4 centered about the origin)
> Superellipsold(5.6);
Another aspect of ASM is the use of rational num-
bers to specify all coefficients, such as lengths, dis-
(xlJ3 + yl(3)6!S + r!5
placements, and direction cosines [Canny et al. 1992]. (A superellipsoid with el =5, e2 =6)
All representations and manipulations can then be per-
formed using exact arithmetic. Rational rotation is

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]);

mouse and rotating it. The rotated solid can be re-dis-


played with different options for color schemes, axis
locations, and surface characteristics.

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:

In this case, the path was defined to be a straight line


along the x axis:

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);

FIGURE 4: An Example of a Swept Solid.

To make the final object finite, a range function was


defined as a simple parabola with a value of 1 at t ±1 =
and a minimum value of 0 at t =0:

(11)

To intersect this with the sphere's defining function,


the standard Boolean intersection is used, but the order
is left at one for simplicity.

f =sphere + range - 1 (12)


FIGURE 5: Propeller and Shaft.
A higher order can be used for increased precision at
the ends, though at added computational cost. UtiIiz-
it solids. For example, Figure 5 shows a propeller
ina MapleV2's resultant to remove t from this func-
and shaft. The propeller is a swept solid that was gen-
ti;n, and the function dfldt =
0 yields the desired
erated by rotating an ellipsoid while translating it
implicit representation of the object.
along a straight line. The shaft was generated by the
The swept solid methods just discussed create equa- Extrude command in inplici t_solids. The two
tions that can be efficiently operated on by inplic- were joined together by the Unite function.

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

In[4], we pioneered the use of Maple in proving


the correct implementation of hardware whose
ABSTRACT behaviour is represented as an algorithmic state
machine. Here, we continue that discussion by
There is some reluctance towards presenting a new methodology and several exam-
the use of formal verification methods by ples. Our contribution this time, is the ease by
the design community. One factor contri- which the new methodology helps with represent-
buting to this lack of enthusiasm is the ing and reasoning about certain designs.
degree of user sophistication required in
representing a design and reasoning about 2. Functional Hardware Model
it in most systems, especially those Gate-level, as well as register-transfer-Ievel,
involving theorem provers. To overcome hardware behaviours can be modeled as syntactic
this, we present the use of symbolic pro- extensions of the Lambda calculus. In this section,
gramming languages to prove several we present a brief introduction to this modeling
classes of hardware designs correct. technique. Interested readers are referred to [5] for
We start by defining a functional model a formal, and in-depth, treatment of this topic,
for the specification of synchronous based on denotational semantics.
hardware. Next, we discuss the program-
ming techniques for implementing the 2.1. Combinational modules
model in the symbolic programming We define an m-input, n-output (mxn-put) combi-
language Maple. Given a Maple model (a national device D , by
program) of a design, we execute the pro-
gram to derive its symbolic behaviour. D = A. (Tl1> Tl2, ... , TIm) . (E1> E2 , ... , En)· (1)
The Maple system is also used to compare
The right side of (1) is a short form for
the derived and the reference behaviours.
A. (TIl> Tl2, ... , TIm) . E i , 1~ i~ n , where
We end by presenting several Maple-
based verification examples. Tlj, l~j~ m, is the jth input port's value, and
').., (TIl> Tl2, ... , TIm)· Eb 1 ~ k ~ n, is the kth output
Our contribution to hardware verification
is the development of a modeling method port's value.
within a symbolic programming para-
digm, and the ensuing facility for reason- 2.2. Sequential modules
ing about certain designs. The behavior of an mxn-put sequential machine
B, with q state-variables, is modeled by two com-
1. Introduction binational circuits defmed by
The development of general-purpose symbolic Bcmb (Sl> S2, ... , Sq ) = (2)
computation systems over the last few years[1-3]
suggests their use as a support environment for ').., (Tl1> Tl2, ... , TIm) . (E1> E 2 , ... , En)
developing and testing symbolic hardware verifi-
cation techniques. and

Mathematical Computation with Maple l7


Ideas and Applications
10m Lee, Editor
@1993 Birkhauser Boston

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.

f. Sequential calls propagate down the


design hierarchy, and eventually update the
w X unit-delay elements as the only design primi-
tive with a sequential behaviour (Section
3.2).
j: Rl, R2, R3 Note that combinational modules (such as g
in example) lack state variables and there-
fore do not participate in the sequential
Y Z behaviour of the j module. Furthermore,
combinational calls to sequential circuits
also do not affect their unit-delay elements.
Figure 1: Composition of three sub- Lines 16 and 17, have their usual mean-
modules f, g, and h (top) into a ings.
single composite design j (bottom).
The construct 'h:R2,R3' defines 3.2. The underlying system
module 'h' as having two state vari-
ables: 'R2' and 'R3'; similarly for 'f'. In[8], we have shown that register-transfer designs
Being a combinational element, 'g', can be implemented using only three types of
has no state-variables. design components, namely: multiplexors, unit-
delays, and combinational elements. Although
output list is. initially assigned to a tem- Maple directly supports most of the combinational
porary variable ( T1, T2, and T3 in this elements that one might require, such as 'and',
example), and then individually assigned to 'or', and 'add', we enclose these functions within
the corresponding net names. new functions ( typically called 'And', 'Or', or
'Add' ) that return a list, as required by the Maple
Line 13, corresponding to in (Xo, ... ) in model discussed in Section 3.1.
(5), returns a list of values (in this case
[Y, Z]), indicating j 's output list. Maple functions Del and Sel, shown in Figure
3, realize the unit-delay and multiplexor (or selec-
Lines 14 and 15 are an iterative imple- tor) primitives, respectively. The storage proper-
mentation of the rec~iv~ de~mition implied ties of the unit-delay primitive are realized through
by in ( ... , fC (flei SI)(Xl), l:5:j:5: w» the use of an arrayed global variable, Memo. For
in (5). To update j's state-variables the most part, the operations of the De I and Se I
(R1, R2 , R3) for the next iteration of the functions are clear from their code.
function, sequential calls are made to h and

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)
(&not(Inl) &and In2) &or
(Inl &and &not(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)
[(&not(Inl) &and &not(In2))
&or (Inl &and In2)] end

Inv .- proc(In) [&not(In)] end Figure 8: Two implementations of the


(supposedly) same register-transfer
OddImp := proc(A,B,C,D,E,F,G,H,I) behaviour.
local Tl,T2,T3,T4,TS,T6,T7,T8,T9,
TIO,Tll,T12,Yl,Y2,Y3,Y4,YS,
Y6,Y7,Y8,Y9,YIO,Yll,Y12;
Rec(Tl = Xnor(A,B),Yl = Tl[l], shown in Figure 9.
T2 = Inv(C), Y2 = T2[1],
T7 = Xnor(Yl,Y2), Y7 = T7[1], 4.2. Proof of the correctness of sequential
T3 Xnor(D,E),Y3 = T3[1], circuits
T4 = Inv(F),Y4 = T4[1], Synchronous sequential circuits require one or
T8 = Xnor(Y3,Y4),Y8 = T8[1], more clock pulses (steps) to produce their results.
T5 = Xnor(G,H),Y5 = T5[1], We distinguish between those sequential circuits
T6 = Inv(I), Y6 = T6[1], that complete their task after a fixed number of
T9 = Xnor(YS,Y6),Y9 = T9[1], steps, known a priori, and those that require an
TIO = Xnor(Y7,Y8),YlO = TIO[l], unknown and possibly variable number of steps
TIl = Inv(Y9),Yll = Tll[l], before they produce their results.
T12 Xnor(YlO,Yll),Y12=T12[1]);
This distinction helps us to deterministically unroll
[Y12]
those with a fixed number of steps and to evaluate
end
them as combinational designs. In Section 4.2.1,
while proving the correctness of a design borrowed
> tempImp:=OddImp(a,b,c,d,e,f,g,h,i) ;
from[13], we show the ease with which the Maple
#
model can be used in simulating the unrolling step.
> bequal( t emp Imp [1] , tempSpec ); However, when the proof procedure is applied to
true designs with an unknown number of steps, it
# requires induction and, therefore, the designer's
participation. An example of this form of proof
(also borrowed from[13]) and the techniques by
Figure 7: The Maple-session aimed at which the Maple model may help the designer to
proving the design shown in Figure 5 derive the iteration invariants, is given in Section
as a correct implentation of the odd 4.2.2.
function specified by (6).

181
#
> read RT_Implementation;
#
Add .- proc(In1,In2) [In1+ln2] end

Sub .- proc(In1,In2) [In1-In2] end Xl

Mul .- proc(In1,In2) [In1*In2] end


X2
Mod21 := proc(In1,In2,ln3)
local T1,T2,Y1,Y2;
Rec(T1 = Mul(In1,Y2),Y1 = T1[1], X3
T2 = Add(In2,In3),Y2 = T2[1]);
[Y1]
end X4-

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

Figure 9: A Maple session that proves (b)


the two designs shown in Figure 7
have the same behaviour.
Figure 10: Two different implementa-
tions of the BCD code recognizer. (a)
The combinational implementation;
inputs are expected in parallel. Note
4.2.1. Proof of sequential circuits with a known that the X4 input is not used. (b) The
number of steps sequential implementation; inputs,
including X4, are expected in series.
Figures to.a and to.b show a combinational and a
sequential implementation of a BCD code recog-
nizer, respectively. The combinational design (the
reference design) is a straightforward

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

> with(logic); Memo[l] := [false]


> comb .- true;
> sequ := false; > Memo[2] .- [false] ;
# Memo[2] := [false]
# In the interest of brevity
# definitions of logicr-gates of > Memo [ 3 ] .- [f a 1 s e ] ;
# all types are removed from this Memo[3] := [false]
# and the next page.
#
Bcd_comb := proc(mode, Xl, X2, X3, X4) #
local T1,T2,T3,T4,T5,T6,T7,T8,T9, # Next the design is pulsed for
Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9; # four complete cycles.
Rec( #
T5 Not1(X1) , Y5 T5[1], > Bcd_sequ(comb, 1, 2, 3, X4);
T6 Not1(X2), Y6 T6[1], [true]
T7 Notl(X3), Y7 T7[1],
T8 Andl1(Y6, Y7), Y8 = T8[1], > Bcd_sequ(sequ, 1, 2, 3, X4);
T9 Or11(Y5, Y8), Y9 = T9[1]); [false]
if mode then [Y9]
else []; #
fi; > Bcd_sequ(comb, 1, 2, 3, X3);
end; [true]
#
> Exp1 := Bcd_comb(comb,X1,X2,X3,X4); > Bcd_sequ(sequ, 1, 2, 3, X3);
Expl := [not (Xl and (X2 or X3))] [true]

> F1 := convert( Exp1[1] , toinert); #


F1 := &not (Xl &and (X3 &or X2)) > Bcd_sequ(comb, 1, 2, 3, X2);
# [true]
Bcd_sequ := proc(mode, R1, R2, R3, X)
local T1,T2,T3,T4,T5,T6,T7,T8,T9, > Bcd_sequ(sequ, 1, 2, 3, X2);
T10,T11,T12,Y1,Y2,Y3,Y4,Y5,Y6, [X3 or X2 and not X3]
Y7,Y8,Y9,Y10,Y11,Z;
Rec( #
T4 = And011(X,Y1,Y3), Y4 = T4[1], > Exp2 := Bcd_sequ(comb,1,2,3,X1);
T5 And010(X,Y2,Y3), Y5 = T5[1], Exp2 := [not (Xl and (X2 or X3)
T6 = AndOOO(Y1,Y2,Y3), Y6 = T6[1], and (X3 or X2 and not X3))]
T7 AndlOO(X,Yl,Y3), Y7 = T7[1],
T8 And111(X,Y1,Y3), Y8 = T8[1], > Bcd_sequ(sequ, 1, 2, 3, Xl);
T9 Or11(Y4,Y5), Y9 = T9[1], [Xl and not (X2 or X3) and
T10 = Orl1(Y6,Y7), Y10 = T10[1], (X3 or X2 and not X3)]
T11 = Or11(Y2,Y8), Y11 = T11[1],
T12 = Nand1001(X,Y1,Y2,Y3), > F2 := convert ( Exp2[1], toinert);
Z = T12 [1] , F2 := &not (Xl &and ((X3 &or X2) &and
T1 Del (comb,R1,Y9), Yl=T1 [1] , (X3 &or (X2 &and (&not X3)))))
T2 = Del(comb,R2,Y10), Y2=T2 [1] ,
T3 = Del(comb,R3,Yl1), Y3 =T3 [1] ) ; #
if mode then [Z] # Next the two boolean expressions
else Del (sequ, Rl, Y9); # assigned to F1 and F2 are compared
Del (sequ, R2, Y10); # for equality.
Del (sequ, R3, Yll); #
fi; > bequal(Fl, F2);
end; true
#
> Memo[l] .- [false] > quit;

186
Appendix II

> with(logic); > Multip(sequ, 1, 2, 3, a, b, false);

ztest := proc(In) > Memo[l]; Memo[2]; Memo[3];


if type(eval(In) ,numeric) [a - 2]
then [evalb(eval(In) = 0)] [3 If(a 0, 0, b)]
else '[ In = 0]' fi [Or(a - 3 = 0, b = 0)]
end
# Conjecturing and inputting values.
Multip := proc(mode,Rl,R2,Fl,X,Y,DONE) #
local Tl,T2,TN,T3,TDONE,T4,T5,T6, > Memo[l] := subs(-2=-(k-l),Memo[1]);
T7,T8,T9,TIO,Tll,TOUT,T12,Xl,X2,X3, Memo[l] := [a - k + 1]
X4,X5,X6,X7,X8,X9,XIO,Xll,X12,N,OUT;
Rec(Tl='Sel(N,X,DONE) ',Xl = Tl[l], > Memol := subs ( k k+l, Memo[l]);
T2='Del(comb,Rl,Xl)' ,X2 = T2[1], Memol := [a - k]
TN='Dec(X2)' ,N = TN[l],
T3='Dec(N)' ,X3 = T3 [1], > Memo[2] := subs( 3 k, Memo[2]);
TDONE='Del(comb,Fl,X7)' , Memo[2] := [If(a 0, 0, b) k]
T4='Dec(X) , ,X4 = T4[1],
T5='Sel(X3,X4,DONE)' ,X5 = T5[1], > Memo2 := subs( k = k+l, Memo[2]);
T6='ztest(X5) ',X6 = T6[1], Memo2 : = [ If (a = 0, 0, b) (k + 1)]
T7='Orll(X6,X8) ',X7 = 'T7[1]',
T8='ztest(Y)' ,X8 = T8[1], > Memo[3] .- subs ( -3 = -k, Memo[3]);
T9='ztest(X) , ,X9 = T9[1], Memo[3] . - [ Or (a - k = 0 b = 0)]
I

TIO='Sel(Y,0,X9)' ,XIO = TIO[l],


Tll='Sel(X12,XlO,DONE)' , > Memo3 .- subs ( k k+l, Memo[3]);
Xll=Tll [ 1] , Memo3 := [Or(a - k - 1 = 0, b = 0)]
TOUT='Del(comb,R2,Xll)' ,
OUT=TOUT [ 1] , > Multip(sequ, I, 2, 3, a, b, false);
T12='Add(XIO,OUT) , , [Or(a - k - 1 = 0, b = 0)]
X12=T12 [1]); #
if mode then [OUT,TDONE[l]] # Tesing the conjecutres.
else Del(sequ,Rl,Xl); #
Del(sequ,R2,Xll); Del(sequ,Fl,X7) > Memo[l]; Memol;
fi [a - k]
end [a - k]
#
> comb .- true; sequ := false; #
> Memo [ 1 ] . - [ a]; Memo [ 2 ] . - [0]; > Memo[2]; Memo2;
> Memo[3] .- [true]; [If(a=O,O,b) + If(a=O,O,b) k]
#
[If(a = 0, 0, b) (k + 1)]
> Multip(sequ, I, 2, 3, a, b, true);
> normal (Memo[2] [1] - Memo2[1]);
> Memo[l]; Memo[2]; Memo[3]; o
[a] #
[If(a 0, 0, b)] > Memo[3]; Memo3;
[Or(a - 1 = 0, b = 0)] [Or(a - k - 1 = 0, b 0) ]
[Or(a - k - 1 0, b o) ]
> Multip(sequ, I, 2, 3, a, b, false); #
# Therefore, the conjectured
> Memo[l]; Memo[2]; Memo[3]; # expressions are correct and
[a - 1] # as a result (8) holds.
[2 If(a 0, 0, b)]
[Or(a - 2 = 0, b = 0)]

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

We have designed a working I. Explanation of CSG


2-D Constructive Solid Geometry
(CSG) system in MAPLEV, which In CSG, objects are
is currently comprised of more represented as the applications
than 1600 lines of code. Our of the boolean operations
research in this area is difference, intersection, and
important for several reasons. union to regular sets. Some
To begin with, it is the first examples of regular sets are
user expandable CSG system. We squares and limayons in two
designed the system to allow dimensions or spheres and
the user to add their own cylinders in three dimensions.
definitions of curves and The user performing CSG enters
primitives. It is also the information about obj ects using
first symbolic CSG system. The primitives such as squares,
advantage of this is that the limayons, etc. The user then
user can change the initial indicates how they are to be
values of the parameters to combined into the new object by
obtain different sizes of the taking the difference,
same conc~ptual object. An intersection, or union of these
inequality list, generated by primitives. A more detailed
our program, will ensure that explanation of CSG can be found
the object is conceptually the in [TIL80], [TIL84], and
same. This is important as to [TRIAS93] .
enable shape optimization of
objects. The generated II. The CSG Boundary
inequality list will also Representation and M
eliminate needless computations Algorithms
as parameters are varied by
simply checking whether or not We were able to draw from
the new input values satisfy Robert Tilove's work in [TIL77]
the inequality list. Finally, and [TIL81] to help us design
this method of symbolic our algorithms to convert our
evaluation serves as a paradigm CSG expressions to a boundary
for other areas of science and representation. Table I shows
engineering. the CSG Boundary Representation
algorithm. If given a CSG
expression of the form
CSG EXP:=rectangle(a,b,side1,
Mathematical Computation with Maple ~
Ideas and Applications
- side2) 'intersect
10m Lee, Editor rectangle(c,d,side3,
©1993 Birkhiiuser Boston side4)

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

expression, containing these A B


two rectangles, and place them
in a CSG tree. The first ON OFF OFF
rectangle will be the left-hand ON
son, the second rectangle will
be the right-hand son, and the Fiqure 1 Classifying a segment
intersect operator will be the against primitives
parent of the two. This tree
will then be passed to the
function edqelist. Edqelist Below is a partial listing
will then break each primitive of our procedure combinel to
into segments and pass each perform the difference task.
segment, along with the tree
passed to edqelist to the
function M. Table II shows the
M algorithm. This algorithm 1 if operation = '&difference'
takes a segment and classifies 2 then
it against every primitive 3 if statusl 'on' and =
within the CSG tree. M then 4 status2 'on' then =
computes whether the segment is 5 if bitl =
bit2 then

189
function M (Edge,T);

/*T is a CSG Tree


this procedure returns an edge divided into segments with
on, off, and in
for those segments with the on indication, there is also a
bit that indicates whether the region is above or below the
segment*/
if T is a primitive then
perform a primitive classification
else
Result L = M (left hand son of T);
Result R = M (right hand son of T);
Produce a merged result for this Edge
using Result L and ResultR
Table II CSG Edge Merge Procedure [TILSO]

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

9 map (proc (n) if assiqned(op(2,n) [2]) then


map (para1istqen,op (2,n) [2],op(1,n» fi;
end,op(op(segmentsets»):
10 h:=p10t(para1ist):
11 for i from 4 to nops(h) do
12 h:=subs(op(2,op(i,h»=BLACK,h):
13 od:
14 print(h);

Text Box 1 The code used to qenerate plots

boundary of the obj ect after Lines 4 and 5 of


the eSG algorithm has been run. para1istqen will replace each
para1istqen, which does this var iable in the ft-type with
for us, is shown in Text Box 1. the corresponding value for
this segment. Ft[seqp1ace[1],
The map function, in line vars] will provide the list of
9, processes each element of variables, other than x and y,
segmentsets. The second contained wi thin the def ini tion
element of each table entry of a curve. For example, the
represents the segments that parabola defined above will
are on the obj ect . Thus, have a, b, and c for this.
op(2,n) is the list of segments When this loop is finished,
that require plotting for this eq1ist will contain a list of
segment set. Op(l,n) sUbstitutions that will convert
represents the entry in the an equation of this type to the
hash list. This is a vector specific curve on which these
consisting of a ft-type and the segments lie. seqp1ace[temp+1]
grounded values for each will represent the specific
variable in the definition of value for the temp'th variable
that curve. in the curve definition. Thus,

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

BOT82 Botkin, M.E., Shape TIL80 Tilove, R.B.,


Optimization of Exploiting Spatial
Plate and Shell and Structural
structures, AIAA Locality in
Journal, Vol. 20, G e 0 met r i c
pages 268-273, FEB Intersection
1982. Problems, IEEE
Transactions on
GOS88 Gossard, D.C., Computers, Vol. C-
Zuffante, R.P., and 29, No. 10, pages
Sakurai, H., 874-883, OCT 1980.
Representing
Dim ens ion s , TIL81 Tilove, R.B.,
Tolerances and Exploiting spatial
Features in MCAE and Structural
Systems, IEEE Locality in
Computer Graphics Geometric Modelling,
and Applications, TM-38, Production
Vol. 8, No.2, pages Automation Project,
51-59, MAR 1988. University of
Roc h e s t e r ,
LEFF90 Leff, L. , Symbolic Rochester, New York,
Finite Element OCT 1981.
Analysis and
Constructive Solid TIL84 Tilove, R.B., A
Geometry, Ph.D. Nul I - 0 b j e c t
Thesis Southern Detection Algorithm
Met h o d i s t for Constructive
University, 1990. Solid Geometry,
Communications of
TIL77 Tilove, R.B., A the ACM, Vol. 27,
Study of Geometric No.7, pages 684-
Set-Membership 694, JUL 1984.
Classification, TM-
30, Production TRIAS93 Trias, T.S., Kyaw,
Automation Project, M. , Thompson, D. ,
University of Leff, L., and Malik,
Roc h e s t e r , Z. , Towards a
Rochester, New York, Symbolic Math
NOV 1977. CAD/CAM System,
submitted to
American Society of
Mechanical Engineers
199 3 J 0 i n t
Conference on
Engineering Systems
Design and Analysis.

198
About the Authors

Darren Thompson is currently a


senior at western Illinois
University and is planning to
attend graduate school to earn
his Ph. D. in computer Science.
He has presented papers in this
area of research at The
Illinois state Academy of
Science, 1993 and TIMS/ORSA,
1993.
Tom Trias did the work while an
undergraduate at Western
Illinois University. He
anticipates graduating and
proceeding to a graduate
program shortly.
Laurence L. Leff, Ph.D. is an
Assistant Professor of Computer
Science and is acti ve in
applying symbolic mathematics
techniques to Computer Aided
Design and Finite Element
Analysis for mechanical
engineers.
Please send all correspondence
to: Western Illinois University
% Darren Thompson, 447 Stipes
Hall, Macomb, IL 61455.

199

You might also like