You are on page 1of 238

Maple V:

Mathematics and its Application


OTHER MAPLE WORKSHOP TITLES:

MATHEMATICAL 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
Maple V:
Mathematics and its Application

Proceedings of the Maple Summer


Workshop and Symposium,
Rensselaer Polytechnic Institute,
Troy, New York, August 9-13,1994

Robert J. Lopez
Editor

Springer Science+Business Media, L L C


Robert J. Lopez
Rose-Hulman Institute of Technology
5500 Wabash Avenue
Terre Haute, IN 47803

Library of Congress Cataloging-in-Publication Data

Maple Summer Workshop and Symposium (1994 : Rensselaer Polytechnic


Institute, Troy)
Maple V: Mathematics and its application : proceedings of the Maple
Summer Workshop and Symposium, Rensselaer Polytechnic Institute, Troy,
New York, August 9-13, 1994 / Robert J. Lopez, editor,
p. cm.
Includes bibliographical references.
ISBN 978-0-8176-3791-0 ISBN 978-1-4612-0263-9 (eBook)
DOI 10.1007/978-1-4612-0263-9
1. Maple (Computer file) - Congresses. 2. Mathematics-Data
processing—Congresses. I. Lopez, Robert J., 1941- II. Title.
QA76.95M35 1994 94-21604
sKras'ss-^o CIP

Printed on acid-free paper fffc ®


© Springer Science+Business Media New York 1994 ÄP
Originally published by Birkhäuser Boston in 1994

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


Allrightsreserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted, in any form or by any means, electronic, mechanical, photocopying, 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, L L C ,
for libraries 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, 222 Rosewood Drive, Danvers, MA 01923, U.S.A. Special requests should be
addressed directly to Springer Science+Business Media, L L C .

ISBN 978-0-8176-3791-0

Camera-ready text prepared by the authors.

987654321
Contents
Preface vii

Abstracts of Invited Presentations ix

I A. Maple in Computer Science

"Turtle Graphics" in Maple V .2


Eugenio Roanes Lozano, Eugenio Roanes Macias 3

A Distributed Approach to Problem Solving in Maple


K. C. Chan, A. Dfaz, and E. Kaltofen . . . . . . . . . . . . . . . . . 13

Denotational Semantics Applied to the Typesetting of Maple Expressions


Reid M. Pinchback . . . . . . . 22

I B. Maple in Applied Mathematics 29

A Symbolic Engineering Mechanics System Built on OEM Maple


Philip Todd, Robin McLeod and Marcia Harris . . . . . . . . . . . . . . . . . . . . . 31

Signal Processing Using Maple V


John I. MoUnder . . . . 39

Implementation of a Mapping Procedure for the Domain Decomposition for PDEs in Maple
Peiyuan Li and Richard L Peskin 46

II A. Maple in Education . . . 55

The Influence of Maple on a Linear Algebra Course at the Delft University of Technology
Harry A. W:M. Kneppers 57

Can Maple Help in Teaching Calculus with Limited Time and Staff?
Scott R. Fulton 63

Enlivening the Mathematics Curriculum with Maple


G. F. Fitz-Gerald and w: P. HeaLy 71

II B. Maple in Science 81

Analytical Approaches to Solving Coupled Nonlinear Schrooinger Equations Using Maple V


M. F. Mahmood and T. L Gill 83

Solution of the Solar Cell Transport Equations Using Maple


Randy T. Dorn and R. J. Soukup . . . . . . . . . . . . 90

Kramers and Wannier V-Matrices for the Partition Functions of the Ising Model
P. Frempong-Mireku and K. J. K. Moriarty 97
III A. Maple in Abstract Algebra 105

FRAC: A Maple Package for Computing in the Rational Function Field K (X)
Cesar Alonso, Jaime Gutierrez, and Tomas Recio . . . . . . . . . . . . 107

Group Rings and Hopf-Galois Theory in Maple


Timothy Kohl . . . . . . . . . . . . . . 116

Rational Generating Function Applications in Maple


Robert A. Ravenscroft, Jr. 122

III B. Maple in Science 129

Symbolic-Numeric Computations for Problem-Solving in Physical Chemistry and Biochemistry


J. Grotendorst, J. Dornseifferand S. M. Schoberth 131

Maple V Analytically Calculating Plane Strain FE-Matrices with Rotational Degrees of Freedom
G. Zirwas 141

Chemical Engineering with Maple


Ross Taylor and Katherine Atherley 149

IV A. Maple in Education 157

Maple Labs and Programs for Calculus


William w: Farr and Michael VanGeel 159

Maple at the University of North London


Graham Taylor-Russell . . . . . . . 167

Introducing Maple to First Year Engineering Students Via Project Study


UlfR¢nnow . 173

Another Look at Learning the Techniques of Elementary Integration


Joseph A. Pavelcak . . . . . . . . . . . . . . . . . . . 179

Worksheets: Can We Teach Mathematical Algorithms with Them?


Michael Monagan . 187

IV B. Maple in Science and the Applications 197

Computer Algebra as a Tool for Analyzing Nonlinear Systems


Diana Murray . 199

Maple V and Geometrical Optics: Aberration Coefficients in Arbitrary Optical Systems


Eisso Atzema . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Solution of Banded Linear Systems of Equations in Maple Using LU Factorization


Robert M. Corless and Khaled EI-Sawy . . . . . . . . . . . . . . . . . . 219

Using Maple to Design a Complex Mixture Experiment


Richard A. BUonick . . . . . . . . . . . . . . . 228
Preface

The Maple Summer Workshop and Symposium, MSWS '94, reflects the growing commu-
nity of Maple users around the world. This volume contains the contributed papers. A
careful inspection of author affiliations will reveal that they come from North America,
Europe, and Australia. In fact, fifteen come from the United States, two from Canada,
one from Australia, and nine come from Europe. Of European papers, two are from Ger-
many, two are from the Netherlands, two are from Spain, and one each is from Switzerland,
Denmark, and the United Kingdom.
More important than the geographical diversity is the intellectual range of the contributions.
We begin to see in this collection of works papers in which Maple is used in an increasingly
flexible way. For example, there is an application in computer science that uses Maple as
a tool to create a new utility. There is an application in abstract algebra where Maple has
been used to create new functionalities for computing in a rational function field. There are
applications to geometrical optics, digital signal processing, and experimental design.
We begin, I believe, to see that Maple is understood as more than just a new tool for
accomplishing specific tasks within a world of traditional practice. There are hints that
users have begun to see Maple as a new working environment wherein whole segments of
professional activity are carried out. The paper by Taylor and Atherley suggests that the
chemical engineering student should be functioning in a Maple envelope, and the paper by
Monagan points to a similar direction in mathematics.
The philosopher and theologian Thomas of Aquinas points out that all things are known
according to the mode of the knower. It is entirely possible that as Editor, I am simply finding
evidence of my own perspective on Maple. That is why forums like the Maple Summer
Workshop and Symposium are so essential to the development of change in teaching,
learning, and practice. It is by the sharing and exchanges which characterize a conference
that insights will be appraised, and their implications nurtured. The final judgments are up
to the conference participants, the readers of this volume, and history.
The organization of this volume is programmatic. The sections in the text correspond to
the sessions scheduled on the program. This layout was adopted for the convenience of the
conference attendees. We apologize to readers who would have preferred a stricter thematic
organization.
Finally, we have included brief abstracts of the talks by the invited speakers. For readers
who were not able to attend MSWS '94 these abstracts might help delineate the experience
of those who did attend. And for those who did attend, they might serve as a reminder of
all the good ideas the conference generated.
The only fitting conclusion to this preface is an acknowledgment of the efforts of all those
who helped make the MSWS '94, and this volume, a success. Lest I omit anyone's name, I
will issue a blanket sigh of gratitude for the help from the folks at Waterloo Maple Software,
and at Birkhauser, the publishers, and from the referees whom I cajoled into reviewing the
contributed papers. Finally, I thank the authors themselves for their efforts at writing and
formatting these papers, and for their promptness and patience in meeting all the deadlines.

Robert 1. Lopez
Rose-Hulman Institute of Technology
Terre Haute, Indiana

viii
Abstracts of Invited Presentations

Experimental Mathematics: Prospects and Pitfalls

Jonathan Borwein
Shrum Professor of Science
Centre for Experimental and Constructive Mathematics
Simon Fraser University

The use of sophisticated symbolic, graphic and other packages allows mathematicians (applied or
pure) to do mathematics from an experimental perspective until recently far from the experience of
most of us. I will present case studies (from linear algebra, analysis and combinatorics) that attempt
to illuminate the enormous possibilities and the potential pitfalls of doing empirical mathematics.
I will also discuss some of the related projects being undertaken at the Simon Fraser Centre for
Experimental and Constructive Mathematics.

Dr. Charles E. Campbell Jr.


NASA Goddard Space Flight Center
cec@gryphon.gsfc.nasa.gov

Goddard Space Flight Center has been pursuing robotics to help the next service flight for the Hubble
Space Telescope. To do this requires dexterity of the robot, kinematically and dynamically. A seven
degree of freedom RRC arm provides a model of kinematic dexterity, and the new GSFC-invented
capaciflector sensor provides control systems with the data to gain dynamic dexterity. The talk
will cover the computer architecture at the Intelligent Robotics Laboratory used to support robotics,
some kinematics, and control problems involving use of the capaciflector: virtual force, imaging,
and 6-DOF pre-contact alignment.
Theorist in the Classroom

Dr. Donald Hartig


Mathematics Department
California Polytechnic State University - San Luis Obispo
San Luis Obispo, CA

Theorist is a WYSIWYG computer algebra system featuring a user-friendly interface, incredibly


good graphics, and the seamless integration of equations, tables, matrices, and number crunching.
This presentation will focus on the use of Theorist in the classroom as a demonstration platfonn and
in the computer lab as a resource for the student. Recent student Notebooks will be examined as
well as Notebooks used in calculus, differential equations, and linear algebra. Special attention will
be given to the use of Theorist in conjunction with the development of calculus from the numerical,
graphical, and analytical point of view as advocated in the Harvard Core Curriculum.

Biology, Mathematics, and Maple

James V. Herod
School of Mathematics
Georgia Institute of Technology
Atlanta, GA 30332-0160

Mathematical biology, resource modeling, and population dynamics are rich sources of problems
in mathematics. Undergraduates in biology often finish their studies with only limited exposure to
the richness of these three areas. This happens in part because of a lack of training that biology
students have in mathematics. Their introduction to a tool such as Maple allows them to understand
more deeply some of the issues in these research areas and to examine current work, even with a
limited mathematical background. On the other hand, mathematically sophisticated students may
find a fascination in their introduction to the problems of biology. Mathematical biology may use
mathematics that the students already know, but in ways that they had not imagined. We present
some mathematical models that are accessible to undergraduate biology students.

x
Advanced Control and Engineering Computations Using Maple V

Dr. Ayowale B. Ogunye


Computing and Information Technology-CR & 0
The Dow Chemical Company
Midland, Michigan

In recent years, considerable interest has been generated in the areas of symbolic computation for
advanced control and engineering computations. The driving force for this interest is the poten-
tial for solving complex problems which were hitherto impossible or difficult to undertake. The
analysis and design of control systems for multivariable processes described by polynomial ma-
trices were practically non-existent before the advent of symbolic computation. Manipulation of
polynomial matrices by hand-calculations is very complex and not amenable to computer imple-
mentation. Consequently, the numerical methods developed to perform the necessary manipulations
are computationally intensive and often suffer from numerical instability. The numerical solution
of differential equations modeling physical phenomena such as diffusion, reaction, heat transfer and
fluid flow processes are of paramount importance. One of the established methodologies for this
class of problems involves the use of polynomial approximations using orthogonal collocation, finite
elements, etc. In this talk, we describe the use of Maple V for solving the above mentioned prob-
lems. The advantages of error-free symbolic manipulations and numerically stable results, obtained
quickly and efficiently, with a tremendous gain in time and minimal effort, are demonstrated.

Using Maple To Teach Physics


Glenn Sowell
Department of Physics
University of Nebraska at Omaha
Omaha, NE 68182-0266
USA
(402) 554-3724
sowell@unomaha.edu

Computer algebra software represents a mature technology that has already made significant con-
tributions to physics research. It is only just beginning to impact physics education. And we have
a long way to go before that impact will be significant. I will discuss some of the problems we face
in incorporating this software into the curriculum and suggest some of the solutions.

xi
I A. MAPLE IN COMPUTER SCIENCE
"TURTLE GRAPHICS" IN MAPLE V.2

Eugenio Roanes Lozano, Eugenio Roanes Macias .


Faculty of Education, Universidad Complutense de Madnd

Abstract angles are measured in degrees.

We think the "Turtle Geometry" [1J is a Below there is a list of procedures and accessi-
useful and convenient way of doing graph- ble variables (global variables). We shall classify
ics programming. Recently, we have devel- the procedures according to their purpose.
oped brand new implementations of the ''Tur-
tle Geometry" in Turbo Pascal [12J and in Primitives that change the position of the turtle:
Maple V [14]. Our implementations include the
usual primitives with Turbo-Pascal-like syntax: Forwd(n:algebraic): Moves the turtle forward
Forwd(dist), TurnLeft(ang) , SetPenColor( color), the number of steps given.
SetPosition(xl,x2), etc. We shall begin with a Back(n:algebraic): Moves the turtle forward
brief resume of the implementation developed in (-1)·n.
Maple V. SetPosition(xl :algebraic,x2:algebraic):
Takes the turtle to the specified position.
Further on we shall show how using an imple- SetX(xl:algebraic): As SetPosition, but only
mentation that is based upon floating point arith- changing the x coordinate.
metic , can be unsuitable even for dealing with SetY(x2:algebraic): As SetPosition, but only
problems in elementary Geometry. Details con- changing the y coordinate.
cerning how exact arithmetic is treated in our HomeO: We implement it as a SetHeading(O)
implementation are given. Clarifying examples followed by a SetPosition(O,O).
are also included. ClearScreenO: As Home, plus clearing the pre-
vious drawings.

1 An Introduction to the Primitives that change the orientation of the


turtle:
"Turtle Geometry"
TurnRight(ang:algebraic): It turns the turtle
The "turtle" is a mobile prompt on the graphics
clockwise, by adding the given angle to its orien-
screen. As an animal, it can move forwards or
tation.
backwards and it can turn. By default it leaves
TurnLeft(ang:algebraic): It turns the turtle
a trail behind. See [1J for details.
counterclockwise, by subtracting the given angle
to its orientation.
The "turtle" is connected to Cartesian coordi-
SetHeading(ang:algebraic): The turtle is
nate axes x, y. The x coordinate axis is hori-
turned until the new Heading is "ang".
zontal, the y coordinate axis is vertical, and the
SetHeadingTowards(xl :algebraic, x2:alge-
point (0,0) is the centre of the screen. Headings
braic): The turtle is oriented towards the given
are measured clockwise from the y+ axis. All the
point.

Other primitives:

PenUpO: Upon command, the turtle doesn't


leave a trail behind.

3
· PenDownO: Upon command, the turtle leaves >RIGHT 135
a trail behind. >FORWD 100*SQRT 2
SetPenColor(color): Lets the user choose the >RIGHT 135
pen color. The usual Maple inputs COLOUR- >END
(HUE(a» and COLOUR(RGB,a,b,c) are admit-
ted. The turtle should have returned to the center of
the screen. But, surprisingly, if we ask for the
Dot(x1:algebraic, x2:algebraic): The com-
puter draws the given point. position now, it is not (0,0)
FullScreenO: Changes to the Graphics Screen. ?PRINT POS
The computer makes a "PLOT" of the 0.002 0.002
"CURVES" stored in the list "dib".

Global variables:

i) Current x coordinate: XCor (type: algebraic)


ii) Current y coordinate: YCor (type: algebraic)
iii) Current orientation: Heading (type: alge-
braic)
iv) Current color for the "pen" the turtle carries:
PenColor.

It is clear that the turtle is very close to point


(0,0). But what would have happened if we had
2 Floating Point Arithmetic checked whether the turtle was in the center of
vs. Exact Arithmetic the screen or not?

Observation.- In this section the examples are ?IF AND XCOR = 0 AND YCOR = 0
implemented in IBM LOGO, because of the sim- [PR "YES][PR "NO]
ilarity of syntax. Nevertheless, the kind of prob- NO
lems that we present have nothing to do with The answer would have been completely wrong,
the kind of language or the version. They are a not "approximately" right.
consequence of the assumptions made when rep-
resenting numbers in floating point arithmetic.

Note.- As there is no terminator in LOGO, 2.2 Rediscovering Incommensura-


to distinguish inputs from outputs, we shall rep- bility?
resent by"?" the LOGO prompt in interactive
We could think that the reason for what has hap-
mode and by">" the LOGO prompt inside the
pened is that V2 is an irrational, and as a conse-
body of the procedures.
quence its decimal representation has an infinite
number of non periodic ciphers, so it has been
2.1 Does the Pythagorean theorem truncated. This is the correct explanation.
hold in floating point arith-
metic? However, let's consider the diagonals of a regu-
lar pentagon. According to [3], the observation of
The following program clears the screen and or- this drawing could be what led to the discovery of
ders the turtle to draw a right angled isosceles incommensurability in ancient Greece: the ratio
triangle. of a diagonal to a side in a regular pentagon is an
irrational number (they are incommensurable).
?TO TRI
>CLEARSCREEN
The following procedure
>FORWARD 100
>RIGHT 90 ?TO PENTAG
>FORWD 100 >CS

4
>RIGHT 90 >MAKE "AI HEADING
>REPEAT 5 [FORWARD 80 LEFT >SETH TOWARDS SE :Ql :Q2
72] >MAKE " A2 HEADING
>LEFT 36 >MAKE "A COMPL(ABS(:Al-:A2»
>REPEAT 5 [FORWARD 80* >PRINT :A
(1+2*SIN 18) LEFT 144] >END
>PR POS
>END ?TO ABS :AN
>IF :AN > 0 [OP :AN] [OP -:AN]
draws a regular pentagon with sides 80 steps long >END
and its diagonals. So we could expect that the
same error as in 2.1 would take place. Surpris-
?TO COMPL :AN
ingly, in this case, the turtle returns safely to >IF :AN > 180 [OP 360 - :AN]
point (0,0). As all depends on the "luck" of the [OP :AN]
roundings, the behaviour of the floating point >END
arithmetic is unpredictable. ABS calculates the absolute value and COMPL
calculates, if necessary, (360 - angle).

= =
If the points are P (0,10), Q (10 * y'3, 10)
and R = (0,0), the angle obtained is 60.001 0 . It
is a close approximation.

But what would happened if we wanted to


study whether or not the point R belongs to
the circumference c (whose diameter is PQ)? If,
for instance, P = (-100,0), Q = (100,0) and
R = (0,100), the result is 90 0 and as a con-
sequence, R E c. But if R = (0,100.001) or
R = (0,99.999) the result is also 90 0 . We would
find that there are three points aligned in c !!!.

2.3 Relative position of points and


2.4 The dangers of iteration
circumferences
Let's return to the procedure described in 2.1. If
Let PQ be the diameter of a circumference, c, we type
and R a point. The following is a well known
result in Elementary Geometry: ?REPEAT 1000 [TRI]
instead of drawing the same triangle 1000 times,
i) R E c iff PRQ = 90 0 the turtle draws several very close triangles. The
ii) R is in the interior of c iff PRQ > 90 0 final image is a "thick sided" triangle. And at
iii) R is in the exterior of c iff PRQ < 90 0 the end of the process, the distance to the center
of the screen (the point where the turtle should
Let's consider the following LOGO-program be) is greater than 2.
that draws the triangle PQR and calculates pJiQ
?TO ANG :Rl :R2 :Pl :P2 :Ql :Q2
>CLEARSCREEN
>PENUP
>SETPOS SE :Rl :R2
>PENDOWN
>SETPOS SE :Pl :P2
>SETPOS SE :Ql :Q2
>SETPOS SE :Rl :R2
>SETH TOWARDS SE :Pl :P2

5
2.5 Small numbers and periodic (old.xCor, old_YCor)(new.xCor, new_YCor)
numbers
is also added to the list "dib".
If the turtle moves 1~ of a step forwards 30 times
(in floating point arithmetic) it is not the same For instance, if a Forwd(distance) is typed, the
as moving forward 100 steps. new XCor is the previous one plus the distance
we want the turtle to move multiplied by the co-
?REPEAT 30 [FORWARD (10/3)] sine of the angle (gOO-Heading). The new YCor
?PRINT POS is calculated similarly.
099.999
In this case it is clear that the reason of the in- All the procedures involving changes of the tur-
accuracy is the truncation of 3.3333. tle's position are implemented in a similar way.
Those which involve changes of the turtle's orien-
Very small numbers are not handled correctly tation produce only changes in the value stored
either. in the variable Heading. We have tried to avoid
similar code been written in different places. The
?FORWARD 0.0001 whole file occupies about 5k in its readable form.
?PRINT POS
00
The reason in this case is that very close numbers
4 The arithmetic in our im-
are represented the same way. This also occurs, plementation
for instance, if we type
In the first version "dib" was a list of numbers
?PRINT 30000000001 - 30000000000 in exact arithmetic. The disadvantage is that,
o in exact arithmetic, the length of the expressions
Both numbers have been represented as 3 x 10 10 . grows very quickly (the length of the represen-
And to increase the number of significant digits is tations of the numbers is not fixed and not even
not the right solution. It is clear how, given any related to the size of the numbers). The reason
number of significant digits, a similar example for this growth is that turns generally involv~ir­
can be found such that the result is not correct. rational numbers. Compare, for instance

165 - 3/\ (1/2) * Pi /\ 4 + 23/\ (1/2)


3 The design of our imple-
with its representation in floating point arith-
mentation metic
1.078336623
The idea behind our implementation is that the
turtle draws a sequence of segments. A segment This way "dib" could reach huge sizes. Moreover,
can be described to Maple with the command the change from the text screen to the graphics
"CURVES". This way, all of the orders that re- screen was extremely slow.
quire the computer to draw, are stored in a list of
"CURVES", each member of which includes an Therefore we decided to approach the problem
option where the desired color of the correspon- in a different way. The coordinates of the end-
dent segment is stored (the active color when the points of the segments to be drawn can be stored
segment was drawn). The final drawing is ob- in floating point. The reason is that the screen is
tained as a "PLOT" of this list of "CURVES", a discrete world (the pixels are not points from a
that we have named "dib". This variable is reset mathematical point of view). What is really im-
by ClearScreenO. portant is that the current position of the turtle
is maintained in exact arithmetic. This way both
The current position of the turtle is stored in advantages are obtained:
the variables XCor,YCor. If the "turtle's pen" is
"up", the old values of XCor and YCor are just • At any moment, one can confidently check
substituted by the new ones. And if the "turtle's whether the turtle is at a certain point or not.
pen" is "down", the segment

6
• The speed of the plotting is increased. >XCor;
100 2 1 / 2
>XCor;
4.1 The Pythagorean theorem (in 100 2 1/ 2
Maple) Numbers in floating point arithmetic usually
include a decimal point. Those in exact arith-
We shall represent by">" the Maple prompt. metic never do. It is clear how 100 x 2 1 / 2 has
Let's consider again the example of the right an- been approximated by 141.4213562.
gled isosceles triangle of section 2.1. In Maple we
could type

>Forwd(100); 4.2 Relative position of points and


>'furnRight(90); circumferences (in Maple)
>Forwd(100);
>'furnRight(135); Let's compare 2.3 with the corresponding trans-
>Forwd(100*sqrt(2) ); lation to Maple.
>'furnRight(135); >Ang:=proc(rl,r2,pl,p2,ql,q2)
> fullS creen 0; > ClearScreenO;
> PenUpO;
for the same triangle to be drawn. Now, the ques-
> SetPosition(rl,r2);
tion about the final position of the turtle is an-
> PenDownO;
swered correctly:
> SetPosition(pl,p2);
>XCor; > SetPosition(ql,q2);
o > SetPosition(rl,r2);
>XCor; > SetHeadingTowards(pl,p2);
o > al:= Heading;
> SetHeadingTowards( ql,q2);
The list "dib" is: > a2:= Heading;
> a:= Compl(abs(al-a2»;
{CURVES([[0,0],[0,100.]], > end; #Ang
COLOUR(RGB,O,O,O»,
([[0,100.] ,[100.,100.]], >Compl := proc(an:algebraic)
COLOUR(RGB,O,O,O», > if evalf(an) > 180 then (360 - an)
([[100.,100.] ,[0,0]], > else an;
COLOUR(RGB,O,O,O»} > fi;
> end; #Compl
Let's look at another example. We want to draw
the segment PQ, P = (100 x ..;2/2,100 x ..;2/2), If P = (0,10), Q = (10 * J3, 10) and R = (0,0),
Q = (100 x ..;2,100 X ..;2). the angle obtained is 60°. That is the correct
value.
> 'furnRight (45);
>PenUpO; If, for instance: P = (-100,0), Q = (100,0)
>Forwd(100); and R = (0,100), the result is 90° and as a con-
>PenDownO; sequence, R E c. If R = (0,100.001) the result
>Forwd(100); is 135 - 141.3707694
Pi . Using evalf we can approx-
> FullScreen 0; imate it: 90.0028649 > 90 (observe that this ap-
proximation takes place on the final value, not
The list "dib" is:
throughout the whole process). If R = (0,99.999)
{CURVES([[10.11061810,10.11061810], the result is 135 - 141.3;;5694, that is, approxi-
[141.4213562,141.4213562]], mately: 89.9971354 < 90. Therefore, using exact
COLOUR(RGB,O,O,O»} arithmetic, the position of the point with respect
to the circumference can be successfully deter-
If we ask for the current position, we obtain the mined.
correct answer

7
See [9] for a clear and sensible introduction to
the importance of exact arithmetic.

5 Some recursive advanced


examples
The possibilities of the turtle are definitely
boosted by the use of recursion. As we have
seen, the fact of using an implementation based
upon exact arithmetic is key to working safely
with very small numbers, very big numbers or Example 2: The shell of a nautiloid is a really cu-
very close numbers. This is specially important rious example of growth in animals. A nautiloid
when dealing with recursive procedures. Below lives just outside the shell and uses the different
we shall develop some advanced examples for our chambers, as the depots of a submarine, to ob-
implementation of ''Turtle Graphics" . tain the desired density. From time to time a new
chamber grows. The longitudinal section shows a
Example 1: Given n and I, draw n squares spiral. We can plot an approximate drawing very
8 1 ,82 , ... , 8 n such that: simply:

- The sides of the first one are 1 steps long - Draw an interpolation of a spiral. The first
side is 1 steps long, the ratio of one side to the
- The vertices of 8 n are the midpoints of the next one is inc and the number of sides is numl.
sides of 8n - l We have chosen to turn an angle of 20 degrees
from one side to the next one. Sides 1 to 18 be-
long to the border of the embryonic chamber.
>polycuad:=proc(l:algebraic,niv:integer)j
> PenUpOj - From vertex 18 onwards we draw the segment
that connects the nth vertex to the (n - 18)th.
> Forwd(I/2)j
> TurnRight (90)j
> Forwd(I/2)j To draw a new chamber, all we have to do is
> PenDownOj draw another side of the spiral and the segment
> for i to 4 do whose endpoints are the (n + 1)th vertex and the
> TurnRight(90)j (n + 1 - 18)th vertex.
> Forwd(l)j
> odj >nautiloid:=proc(l:algebraic,
> PenUpOj inc:algebraic,numl:integer)
> TurnRight(IS0)j
> Back(I/2)j
> TurnLeft(90)j > Ipun:=[[evalf(XCor),evalf(YCor)]]j
> nautiloid...recurs(l,inc,numl)j
> Back(I/2)j
> TurnRight (45)j > endj #nautiloid
> PenDownOj
>nautiloid...recurs:=proc(l:algebraic,
> if niv > 1 then
inc:algebraic,numl:integer)
> polycuad(l/sqrt(2),niv-l)j
> local x,yj
> fl.j
> Forwd(l)j
> endj #polycuad
> TurnRight (20) j
A nice example can be obtained, for instance, > Ipun:=[[evalf(XCor),evalf(YCor»),
typing op(lpun»);
> x:=XCorj
>ClearScreenOj > y:=YCorj
>polycuad(300,15 )j > if nops(lpun) > 17 then
>FullScreenOj > SetPosition(op(l,op(IS,lpun»,

8
Example 2: Longitudinal section of a nautiloid

9
o 0 0 0 0 0 000 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0
o 0 0 0 0 0 000 0 0 0 0 0 0 0 0 0 0 0 000 0 000
0 0
00 0 00 00 0 0 00
00 0 0 00 0
o 0 00 0 0 0 0 00 0 0 000 0 0
0 0

000 000 0 0 0 0 0 0 0 0 0 000


00000 0 000 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
o 0 0 0 0 0 000 0 0 000 0 0 0 0
00 0 00 0 DOD 000 00 0 00 0
o 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
0
00 0 00 0 0
o
00 00
0 00 0 0 0 0 000 0 0
0
00000 0 000 000
o 0 0 0 0 0 000 0 0 000 0 0 0 0
00 0 00 0 00 0 00 0 00 0 00 0
o 0 0 0 0 0 000 0 0 0 0 0 0 0 0 0
o 0 0 0 0 0 000 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 D
00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0
o 0 0 0
0 000 0 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
0 0
00 0 00 00 0 0 00 00 0 0
o
00 0
0 00 0 0 0 0 00 0 0 0 0 000 0 0

000 000 0 0 0 0 0 0 0 0 0 000


00000 0 000 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0
00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0
o 0 0 0 0 0 000 0 000 0 0 000 0 0 0 0 0 0 0 0 0

Example 3: Third step in the construction of a 2-D Sierpinski sponge

10
op(2,op(18,Ipun)) ); [4] A. Heck: Introduction to Maple. Springer-
> PenUpO; Verlag, 1993.
> SetPosition(x,y)
> PenDownO; [5] B.W. Char, K.O. Geddes, G.H. Gonnet,
> fl·, B.L. Leong, M.B. Monagan, S.M. Watt:
> if numi > 0 then Maple V Language Reference Manual. Springer-
> nautiloid-recurs(I*inc,inc,numI-1) ; Verlag, 1991.
> fl·,
> end; #nautiloid-recurs [6] B.W. Char, K.O. Geddes, G.H. Gonnet,
B.L. Leong, M.B. Monagan, S.M. Watt:
An example of a realistic nautiloid can be ob- Maple V Library Reference Manual. Springer-
= =
tained for I 1 and ratio inc ~~~. Verlag, 1991.
>CIearScreenO;
>nautiIoid(1,108/100,55 ); [7] B.W. Char, K.O. Geddes, G.H. Gonnet,
>FullScreenO; B.L. Leong, M.B. Monagan, S.M. Watt:
First Leaves: A Tutorial Introduction to Maple.
3) Another typical example of recursion are Springer-Verlag, 1991.
sponges. In this case the program is not as short
as the previous ones, so we shall not include the [8] A. Montes, M. Noguera, A. Grau:
code. The plotting of the third step in the con- Apuntes de Maple V. Universitat Politecnica de
struction of a 2-D Sierpinski sponge is included Catalunya, 1994.
above (side = 300).
[9] R. Pavelle, M. Rothstein, J. Fitch: Alge-
bra por ordenador. Investigaci6n y Ciencia, Feb.
6 Conclusions 1982 (spanish version of the article in Scientific
American num. 245, Die. 1981).
Firstly, our implementation allows us to plot tur-
tle drawings in Maple. Additionally, it permits
[10] E. Roanes Lozano: Automatizacion e im-
us to do the plottings in exact arithmetic, which
plementacion de algunos problemas algebraicos y
can be extremely important when dealing with
geometricos. (Ph.D. Thesis). Univ. Politecnica
many problems.
de Madrid, 1993.

7 Obtaining the code of our [11] E. Roanes Lozano: "Precision Indefinida"


y Matematica Elemental. Boletin de la Sociedad
implementation "Puig Adam" de Profesores de Matematicas,
num. 31, Mayo 1992.
The code is going to be incorporated to the Maple
Share Library. Alternatively, you can contact the
[12] E. Roanes Macias, E. Roanes Lozano:
authors.
Una implementaci6n mejorada y flexible de la
"Turtle-Geometry". II Encuentro de Geometria
Computacional. Zaragoza, 1992.
References
[13] E. Roanes Macias, E. Roanes Lozano:
[1] H. Abelson, A. diSessa: Turtle Geometry. Matematicas con ordenador. Ed. Sintesis, 1988.
The Computer as a Medium for exploring Math-
ematics; M.I.T., 1981. [14] E. Roanes Macias, E. Roanes Lozano:
An Implementation of "Turtle Graphics" in
[2] H. Abelson: Apple Logo. Byte Books / Maple V.2. Computer Algebra Nederland
McGraw-Hill, 1982. (CAN), Nieuwsbrief 12, March 1994.

[3] C.B. Boyer: A History of Mathematics. [15] -: LOGO Reference Manual. IBM/LCSI,
John Wiley, 1968. 1984.

11
[16] -; Manual de Referencia y del Usuario Eugenio Roanes Lozano (eroanes@fi.upm.es)
ACTI-LOGO. Idealogic, 1984. studied Mathematics at the Universidad Com-
plutense de Madrid (UCM), received his Ph.D.
[17] -: Guia de Referencia y Manual del usuario in Mathematics from the Universidad de Sevilla
WIN-LOGO. Idea, Investigaci6n y Desarrollo in 1991 and received a second Ph.D. (in Com-
S.A., 1991. puter Science) from the Universidad Politecnica
de Madrid in 1993. His research interests in-
[18] -; Turbo Pascal v.6.0 User's Guide, Pro- clude Computer Algebra, Computational Geom-
grammer's Guide £3 Library Reference. Borland etry and Algebraic aspects of A.I. He is presently
International, 1990. a Lecturer at the Faculty of Education (Sec. Dep.
Algebra) of the UCM.
[19] -: Turbo Pascal v.3.0 Reference Manual
(Cap. 19 PC-Goodies). Borland International. Eugenio Roanes Macias (roanes@mat.ucm.es),
father of the former author, received his Ph.D.
in Mathematics from the UCM in 1973. His
research interests include Algebraic Geometry,
Computer Algebra and Computation in Math-
ematics Teaching. He is presently a Professor at
the Faculty of Education (Sec. Dep. Algebra) of
the UCM.

We can be reached by the following address;


Eugenio Roanes
Sec. Dep. Algebra (Fac. of Education)
Edificio Pablo Montesino
Universidad Complutense
c/ Santisima Trinidad 37
E-28010-Madrid (SPAIN)

12
A DISTRIBUTED APPROACH TO
PROBLEM SOLVING IN MAPLE

K. C. Chan, A. Draz, and E. Kaltofen


Department of Computer Science, Rensselaer Polytechnic Institute, Troy, NY

Abstract is performed from the Maple environment by


A system is described whereby a Maple computa- a system call to a DSC program which com-
tion can be distributed across a network of com- municates with the concurrent server daemon
puters running Unix. The distribution is based on process. That process, which has established
the DSC system, which can ship source code and IP jTCPjUDP connections to equivalent dae-
input data to carefully selected computers for ex- mon processes on the participating compute
ecution and which can retrieve the produced out- nodes, handles the call and sends the subtask
put data. Our code is fully portable and requires to one of them. Similarly, the control flow of
no changes of the underlying Maple or Unix sys- the application program is synchronized by li-
tems. Speedup over Maple's built-in sequential brary calls that wait for the completion of one
procedure is demonstrated when computing deter- or all subtasks. Participating compute nodes
minants of integer matrices. can be anywhere on the Internet.
- DSC can distribute a Maple source file and
1. Introduction the corresponding input data file. The re-
The paradigm of distributing a compute-intensive mote computer starts a Maple shell and exe-
program over a network of computers is becoming cutes the source file, which is assumed to read
commonplace in today's problem solving by com- from the input data file and produce an output
puter. Several systems are available for support of data file, which is returned to the parent pro-
distributed computation, among them Gelernter's cess. Note that the distribution of source code,
Piranha Linda, PVM (Parallel Virtual Machine) which is not restricted to Maple but can be in
by Geist et al., and the Unix system's remote C or Lisp instead, allows the parent process to
shell command. In 1991, we announced a plat- dynamically construct programs for distribu-
form for distributing symbolic code, called the Dis- tion thus permitting the use of so-called "black
tributed Symbolic Computation tool-DSC (Diaz box" data type~. Furthermore, on a shared file
et al. 1991). The DSC system has been signifi- system file transfer can be performed by path
cantly improved over the past three years (Diaz et name and no physical file movement needs to
al. 1993). This paper describes our new interface take place.
to Maple, which permits the automatic distribu- - The master-slave paradigm for distribution can
tion of a Maple computation over a network of be relaxed by making use of a co-routine-like
computers. distribution mechanism. In that case, the par-
The following important DSC features are avail- allel subtask can exchange information with
able to Maple users through the new interface. the parent task in the middle of a computa-
tion.
- The distribution of so-called parallel subtasks
- The interface from Maple to DSC consists of
10 library functions. Processor allocation and
interprocess communication is completely hid-
den from the Maple programmer. Indeed, DSC
has a fairly sophisticated scheduler that tries to
match the subtask's resource demands, which
are given in rough estimates as (optional) ar-
guments to the DSC call, with a suitable com-

13
puter on the network. CPU and memory usage tries are computed faster by distribution. We note
of participating compute nodes is estimated by that all of the needed computer algebra technol-
having a resident daemon process probe them ogy, such as finding prime numbers, computing
in 10 minute intervals and communicate the matrix determinants modulo prime numbers, and
CPU and memory load to the DSC server dae- the Chinese remainder algorithm, is provided by
mons. If no computer meets certain threshold Maple. There are more sophisticated coarse grain
requirements, the parallel subtask gets queued parallel algorithms, such as root finding or sparse
for later distribution under presumably better interpolation (Char 1990), which would require
load conditions on the network. The scheduler more custom-made Maple programming. In our
makes DSC a truly heterogeneous parallel sys- opinion, an important application of the DSC in-
tem. terface is the parallelization of our Maple code for
- The progress of a distributed computation can the solution of sparse linear systems. This code
be monitored by an independently run con- was developed as a prototype for our superfast
troller program. This controller also initializes C++ implementation (Kaltofen and Lobo 1994).
the DSC environment by establishing server Nonetheless, the distributed version of our proto-
daemons on the participating computers. type code would make parallel sparse linear system
solving available to the entire Maple world.
- It is possible to run several distributing Maple
We hope to add several new features to DSC
programs simultaneously by specifying distinct
and the Maple interface in the future. First, we are
UDP port numbers on start-up. DSC and the
planning to build a graphical user interface to the
Maple interface do not require any changes
control program which monitors all DSC processes
to existing Unix or Maple setups. Security
and computers. Second, we are planning to imple-
is guaranteed because DSC tags the messages
ment some form of process migration. Although
which it sends through unprotected ports with
our scheduler attempts to find the best compute
a secret key.
node for a given parallel subtask, often the choice
Note that the design of the features discussed is not optimal because unexpected load levels ap-
above has been extensively tested in our sym- pear later at the selected computer. In that case, it
bolic applications, which are: the parallel Can- would be very helpful if a partially completed task
torjZassenhaus polynomial factorization algorithm could be moved to another node. And finally, the
(Diaz et al. 1991), the Goldwasser-KilianjAtkin Maple interface could be enhanced by high level
primality prover for titanic primes, i.e., prime data types that hide the actual explicit DSC calls,
numbers with more than 1000 decimal digits (Va- such as the "bags of incomplete futures" that we
lente 1992), and the block Wiedemann algorithm have implemented in our Lisp interface (Diaz et
for the solution of sparse linear systems over finite al. 1991).
fields (Diaz et al. 1993).
The main design goal for the DSCjMapie in- 2. System Layers
terface was that it had to be completely portable. In Diaz et al. 1991 we described how concep-
Therefore, we chose a mechanism by which the tually the DSC system itself is organized in a
DSC library functions are called through a system multi-layered fashion, each layer drawing from
call. That call executes an interface program that its predecessor. Referring to Figure 1, the bot-
sends a signal to a concurrent daemon process. It tom layer consists of the interprocess communi-
is that single daemon process which calls the C cation using DARPA Internet standard protocols
language DSC user library function which in turn IPJTCP jUDP. Built on this layer lies the first
communicates with the server process via a user DSC level which includes the internal DSC rou-
datagram. Thus we avoid any dependence on calls tines, the daemons, and the C library functions.
to functions written in C from within Maple, a fea- The second layer consists of the LispjC interface,
ture that is lacking in older Maple installations. the controller program, the new MaplejC inter-
We demonstrate the usage of our interface by face and C user programs that use only the seven
a standard example, namely the computation of basic C library functions. The third layer draws
the determinant of an integer matrix by homo- on the LispjC interface and the MaplejC inter-
morphic imaging and Chinese remaindering (Mc- face. This layer contains the Lisp library, basic
Clellan 1973). We can report that determinants Lisp functions and basic Maple functions. At the
of 100 x 100 integer matrices with single digit en- topmost layer lies the implementation of high level

14
4
High level
L1spuserpgm

3
Basic Maple User pgm Basic Lisp User pgm Lisp library

2
ControllerlSetup
Basic C usr pgm MlplelC library LlspiC library
Utilities

Internel DSC routlnes, deemons, and library functions

DARPA IPfTCP/UDP Protocol Functions

Figure 1: System Layers

Lisp functions which utilize the support routines and DSC server daemons have to be started. The
contained in the Lisp library. Such a Library is DSC Controller program supports the user in con-
being developed for Maple. figuring the network and in the monitoring of com-
putational tasks (Diaz et al. 1991).
3. Maple Interface
Figure 2 portrays the Scenario of a distributed
The Maple User Interface Library contains ten Maple determinant computation. After starting
functions that can be invoked from a user's Maple the controller program on compute node 1, and
program or session. The standard example of com- DSC servers on compute nodes 1, 2, and 3, the
puting the determinant of an integer matrix in main Maple task distdet. mpl is initiated. It
parallel (by homomorphic imaging and Chinese first reads in an integer matrix from distdet. i
remaindering) illustrates the interaction between and selects appropriate moduli. For each modu-
DSC and Maple. lar image, distdet .mpl calls the DSC Maple li-
brary function dscpr _sub, passing Maple code in
a file det 1. mpl and the residue matrix in det 1. i
to DSC for distribution. The function dscpr _sub
communicates the distribution request to the lo-
cal server running on compute node 1. The lo-
diatdet . mpl
cal server locates a suitable processor, in this case
diatdet.i compute node 3, and sends both files to the cor-
responding remote server. The server on com-
pute node 3 starts a Maple session for det 1 . mpl.
That program then reads its data from the remote
copy of det 1. i and writes its output to the re-
mote file det 1. d. When the parallel subtask com-
pletes the file, det 1. d is copied back to compute
node 1. In the meantime, the application pro-
gram has initiated distribution of another parallel
subtask, det2, for which the local server selected
compute node 2. A call to the DSC Maple library
detl.mpl
det1.i---
function dscpr_wait or dscpr_next can be used
detl.d--- to block the main task distdet .mpl on the com-
Figure 2: Simple Distribution Scenario pletion of its children.
Before a Maple application can distribute par- The source code of distdet . mpl found in Fig-
allel subtasks over the network, the database of ures 3 through 9 illustrates the usage of the DSC
available compute nodes needs to be initialized Maple library functions.

15
with(linalg) ;
#################################################
## distdet(subprobsf,solfile,A,iprod)
## input -
## subprobsf - source file (without path information)
## of the subproblems
## solfile - the file name that will contain the determinant
## of the matrix A
## A - square matrix
## iprob - starting point for prime moduli
## description -
## compute the determinant of the integer matrix A by
## homomorphic imaging and Chinese remaindering
distdet := proc(subprobsf,solfile,A,iprod)
local LOW_CPU, MEM, PWD, SOURCE_FILE,INDEX,fid,build,exec,y,
NUMPROBS ,moduli ,residue ,tmod,ubound,prod,inc,u;
## LOW_CPU - estimated CPU usage
## MEM - estimated memory usage in megabytes
## PWD - real path
## SOURCE_FILE - source file with real path information
## INDEX - subproblem index file
## NUMPROBS - the number of primes needed given the initial value
## fid - temporary file id
## build - Maple build command
## exec - Maple execute command
## y - loop counter
## moduli - the array of moduli
## residue - the array of determinant residues
## tmod - moduli for each subroblem (save can only save names)
## ubound - the upper bound for the product of the moduli
## prod - the product of the moduli
## inc - the next starting point for the moduli search
## u - determinant
# Read in DSC Maple User Functions
read('dsc_maple.mpl');
# Set problem parameters
sUbprobsf:= subprobsf;
LOW_CPU:= 240;
MEM:= 5;
# Start dsc_maple daemon
system('dsc_maple commandfile messagepid dscmaplepid t');
# Wait a while for startup
system('sleep 2');
# Get real path information
PWD := dscpr_pwd('commandfile','messagepid','dscmaplepid','answerfile');
SOURCE_FILE:= cat(PWD,'/' ,subprobsf);
# Log problem in local server problem database
INDEX := dscdbg_start('commandfile' ,'messagepid','dscmaplepid',PWD,
, answerf ile' ) ;
Figure 3: Interface Start-Up

Figure 3 displays the initialization steps that the dsc_maple .mpl interface library has been load-
are needed when distributing Maple code. Once ed, a dsc_maple daemon can be started via a

16
system call to the host operating system from # Prepare corresponding input files
the Maple environment. After startup of the for y from 1 to NUMPROBS do
dscmaple daemon, calls to the functions in the fid:=cat(SOURCE_FILE,y,'. ',lie);
Maple User Interface Library can be made. In or- tmod := moduli[y];
der to assure distinct file names when running mul- save A , tmod, fid;
tiple distributed Maple applications, the dsc_maple od;
daemon program must receive three command line
arguments, which are file names representing a # Make copies of the subproblem
dsc_maple command file, a dscmaple_message copyfiles(NUMPROBS,SOURCE_FILE,'mpl');
temporary daemon process id file, and a dsc_maple
Figure 5: Prepare Parallel Subtasks
daemon process id file. These files, along with a
fourth string denoting the dsc_maple_message an- After the moduli have been computed, the par-
swer file, are passed as parameters to all ofthe sub- allel subtasks can be prepared for distribution.
sequent Maple User Interface Library functions. Figure 5 details how the parallel subtask input
These four files are only used by the different lay- files and copies of the parallel subtasks are created.
ers of the Maple Interface and are never accessed The copyfiles function is provided in the Maple
directly from the user's Maple application. The User Functions Library. Eventually, we hope to
function dscpr_pwd is used to determine the cur- provide additional high level library functions.
rent path of the local Maple session. This informa- Figure 6 demonstrates the use of the function
tion is used later as a parameter to all remaining dscpr_sub to start a parallel subtask within the
Maple User Interface Library functions. The func- DSC environment. Additional arguments to this
tion dscdbg_start in Figure 3 is the first maple function are four strings denoting, respectively,
interface call that communicates a request to the the path to the local files, the types of the local
local DSC server. This function can be used to files to be sent, the build (compile, for instance)
track a problem and is useful when one wishes to command, and the exec (load and run) command
debug distributed tasks using Maple interactively. required for the parallel subtasks; two additional
Arguments to this function include the four inter- integer arguments represent the CPU and memory
face specific file names and the current path of the requirements of the parallel subtasks. It is possible
local Maple session. to use default build/exec commands by supplying
ubound := evalf(2*hadamard(A»j null strings for the corresponding arguments. It is
also possible to bypass C and L.isp compilation by
# Compute the Moduli supplying dsc_c. build or dsc_lisp. build as the
print('Compute_the_Moduli')j build command. The shell script dsc_maple. int
prod := 1j NUMPROBS:= 0; applies the source and input files to a Maple ses-
inc :=iprod; SIon.
After the determinant parallel subtasks have
while prod < ubound do been spawned Figure 7, shows the Maple code
NUMPROBS := NUMPROBS+1; necessary for blocking the execution of the main
moduli[NUMPROBS] := nextprime(inc); task and after synchonization the code required for
inc := moduli[NUMPROBS]+1j performing the shutdown of the DSC Maple inter-
prod := prod * moduli[NUMPROBS]j face. The functions dscpr_wait and dscpr_kill
odj are used, respectively, to wait on and to kill spe-
cific subtasks. In both cases, the additional ar-
Figure 4: Compute Necessary Moduli gument is the index of the subtask in question.
One way of computing the determinant of a The dscpr_wait function is also used to wait on
matrix in a distributed fashion is to first com- the completion of all outstanding subtasks when a
pute the determinant of the input matrix modulo value of -1 is supplied for the index. The function
n relatively prime numbers in parallel and then to dscpr_next is used to wait for the completion of
construct the corresponding true integer value by the next parallel subtask. Its additional argument
Chinese remaindering. Figure 4 shows the com- is filled with the name of the solution file corre-
putation of the moduli by using the Hadamard sponding to the completed subtask. The function
inequality to get an upper bound for the determi- dscpr_maple_kill, will terminate the dsc_maple
nant. daemon in an orderly fashion.

17
for y from 1 to NUMPROBS do
# Prepare arguments
fid:= cat(SOURCE_FILE,y);
build:= cat('dsc_maple.build');
exec:= cat('dsc_maple.int ',subprobsf,y,'.mpl ',subprobsf,y,'.d',
, ',subprobsf,y,'.i');
print('one_Ievel_driver: fid = '.fid);
print('one_Ievel_driver: build = '.build);
print('one_Ievel_driver: exec = '.exec);
print('one_Ievel_driver: cpu requirement = '.LOW_CPU);
print('one_Ievel_driver: mem requirement = '.MEM);

# Spawn subproblems
rval:= dscpr_sub('commandfile' ,'messagepid','dscmaplepid',
PWD,fid,'pi' ,build,exec,LOW_CPU,MEM,
'answerfile');
od;
Figure 6: Distribute Parallel Subtasks
# Wait on all subproblems
rval := dscpr_wait('commandfile' ,'messagepid','dscmaplepid',
PWD,-l,'answerfile');
dscpr_maple_kill('commandfile' ,'messagepid','dscmaplepid' ,PWD);
Figure 7: Wait On All Parallel Subtasks

# get residues from .d files lmagmg.


for y from 1 to NUMPROBS do The input file and output file specified by the
fid:= cat(SOURCE_FILE,y,'.d'); call to dscpr_sub in the main task are put in
read(fid) ; the variables DSC_IFILE and DSC_OFILE by the
residue[y] := ddet; Maple interface.
od; The control program allows the user to inspect
u := chrem(convert(residue,list) , the progress of an application program and its par-
convert(moduli,list»; allel subtasks. This will include the main applica-
save u • prod ,solfile; tion program and the parallel subtasks that have
RETURN(u) ; been spawned in the current DSC environment.
end;
Figure 11 is an example of the parallel sub-
Figure 8: Compute Determinant task database. The main Maple program prefixed
The code in Figure 8 computes the integer de- as distdet (running on troi. cs. rpi. edu) reg-
terminant of A from the n residues of the deter- istered with the DSC server via dscdbg_start,
minants by Chinese remaindering. was given the task name DSC40eO_1. This task
read('IM_l0_l0_l'); distributed Maple code (and an input file) to
pleiades. cs. rpi. edu. This is indicated by both
answer := distdet('det','distdet.d',
maple: 1 and input: 1 being set. The shell
A,10000000);
script dsc_maple. int is in the exec argument of
quit;
the call to dscpr_sub. The parallel subtask has
Figure 9: Initial Startup Mechanism not spawned children. All processes run on Sun
Since the file is executed in a interpreted man- compute nodes, as CPU 3 indicates.
ner the call to distdet is made after the function For 100 x 100 integer matrices with single digit
definition and the reading of the matrix. Finally entries the computation of the the distributed
the session is terminated via a quit command as version of the determinant computation program
seen in Figure 9. on 22 processors was 1.5 times faster than the
Figure 10 is the subproblem file copied and dis- standard Maple determinant function (det). For
tributed by distdet. mpl which computes the de- 200 x 200 matrices on 18 processors the speed up
terminant of the integer matrix by homomorphic was a factor of 1.9. The speed up becomes more

18
with(linalg) ;
#################################################
## ddet(one_input,one_output)
## input -
## one_input - input file for subproblem
## one_output - output file for subproblem
ddet .- proc(one_input,one_output)
local commandfile,messagepid,dscmaplepid,answerfile,msgstr,PWD;
## commandfile _ dsc_maple DSC command file
## messagepid - dsc_maple_message process id file
## dscmaplepid - dsc_maple process id file
## answerfile - subtask solution file
## msgstr - temporary string
## PWD - real path
# Read in DSC Maple User Functions
read('dsc_maple.mpl');
# Start dsc_maple daemon
commandfile cat (one_input , '.cmd');
messagepid .- cat (one_input , '.mpid');
dscmaplepid cat(one_input,'.ppid');
answerfile .- cat (one_input , '.ans');
msgstr := cat('dsc_maple ',commandfile,' ',messagepid,' ',dscmaplepid,' &');
print(msgstr);
system(msgstr) ;
# Wait a while for startup
system('sleep 2');
# Get real path information
PWD := dscpr_pwd(commandfile,messagepid,dscmaplepid,answerfile);
# Kill dsc_maple_daemon
dscpr_maple_kill(commandfile,messagepid,dscmaplepid,PWD);
# Wait a while for shut down
system('sleep 2');
# Remove files
msgstr 'rm -f '; msgstr .- cat(msgstr,commandfile); system(msgstr);
msgstr .- 'rm -f '; msgstr .- cat(msgstr,messagepid); system(msgstr);
msgstr 'rm -f '; msgstr .- cat(msgstr,dscmaplepid); system(msgstr);
msgstr .- 'rm -f '; msgstr cat(msgstr,answerfile); system(msgstr);
# Read in matrix and modulo
msgstr PWD;
msgstr .- cat(msgstr,'I' ,one_input);
read(msgstr);
# compute the determinant of A modulo tmod
ddet := Det(A) mod tmod;
save ddet , one_output;
end;
ddet(DSC_IFILE,DSC_OFILE);
quit;
Figure 10: Parallel Subtask

significant with larger problems. must be called at the beginning of any parallel
The Maple interface library also allows the user subtask that is to be treated as a co-routine. Its
to implement co-routines. To distribute Maple co- only arguments are the four interface specific file
routine applications, the function dscpr_cosetup names and the current path of the local Maple ses-

19
PRO B L E M D A TAB A S E

problem name: distdet


problem PID: 16S96 node: troi.cs.rpi.edu index 0 CPU 3
parent PID: 16477 naddr: 128.213.2.43 index-1
source name: /fsS/misc1/ugrads/chank/dsc/source/distdet
c: o lisp: 0 math: 0 maple: 1 obj: 0 input:O
build command: dsc_maple.build
exec command: dsc_maple.int /fsS/miscl/ugrads/chank/dsc/source/distdet.mpl
/fsS/miscl/ugrads/chank/dsc/source/distdet.d
blocked sock: -1 block condition -1
completion 0 status: 00000000 build: 1
peer link -1 child list: -1 # subprob: o
state 0
estimated cpu use estimated mem need (megs) : S
MORE
problem name: DSC40eO_1
problem PID: 16608 node: troi.cs.rpi.edu index 1 CPU 3
parent PID: -1 naddr: 128.213.2.43 index-1
source name: dsc_prob_debug
c: o lisp: 0 math: 0 maple: 0 obj: 0 input:O
build command:
exec command:
blocked sock: 6 block condition -1
completion 0 status: 00000000 build: 1
peer link -1 child list: 2 # subprob: 2
state 0
estimated cpu use : -1 (UNKOWN VALUE)
estimated mem need (megs) : -1
MORE
problem name: DSC40e02
problem PID: -1 node: pleiades.cs.rpi.edu index 2 CPU 3
parent PID: 16608 naddr: 128.213.2.43 index 1
source name: /fsS/misc1/ugrads/chank/dsc/source/det1
c: 0 lisp: 0 math: 0 maple: 1 obj: 0 input: 1
build command: dsc_maple.build
exec command: dsc_maple.int detl.mpl det1.d det1.i
blocked sock: -1 block condition -1
completion 1 status: 00000000 build: o
peer link 3 child list: -1 # subprob: o
state 0
estimated cpu use HIGH_CPU estimated mem need (megs) S
MORE
Figure 11: Problem Data Base

sion. When the Maple parallel subtask calls the turned from the spawning call to dscpr_sub) and
dscpr30wait function with an additional integer a string identifying which input file, if any, should
argument, it enters a sleep state and optionally be sent to the co-routine before the parallel sub-
transmits a data file back to its parent. A parent task is to be resumed.
task can send a wake up call to a sleeping parallel
subtask via the dscpr_coresume function. Addi- This material is based on work supported in
tional arguments to this function are an integer part by the National Science Foundation under
which uniquely identifies a parallel subtask (re- Grant No. CCR-90-06077 and Grant No. CCR-93-

20
19776, Research Experiences for an Undergradu- King Choi Chan currently is an undergradu-
ate supplement (first author), and by GTE under ate student in Computer Systems Engineering at
a Graduate Computer Science Fellowship (second Rensselaer Polytechnic Institute.
author).
The software described in this paper is freely Angel Diaz received both his B.S. degree in
available by anonymous ftp from ftp.cs.rpi.edu in Computer in 1991 and his M.S. degree in Com-
directory dsc. puter Science in 1993 from Rensselaer Polytechnic
Institute. He is currently pursuing the Ph.D. de-
Literature Cited gree at Rensselaer under the direction of Professor
Erich Kaltofen. His special fields of interest in-
Char, B. W., "Progress report on a system for general- clude parallel methods in symbolic computation.
purpose parallel symbolic algebraic computation," He was a Rensselaer Polytechnic Institute Gradu-
in PlOC. 1990 Internat. Symp. Symbolic Algebraic ate Fellow from 1991-1992, received support from
Comput., edited by S. Watanabe and M. Nagata; the National Science Foundation Fellowship Pro-
ACM Press, pp. 96-103, 1990. gram in 1992, and is currently the recipient of the
Diaz, A., "DSC Users Manual (2nd ed.)," Tech. Rep. GTE Fellowship Program. He is also a member
93-11, Dept. Comput. Sci., Rensselaer Polytech. of Upsilon Pi Epsilon national computer science
Inst., Troy, New York, May 1993. 197 pp. honor society.
Diaz, A., Hitz, M., Kaltofen, E., Lobo, A., and Va-
lente, T., "Process scheduling in DSC and the Erich Kaltofen received both his M.S. degree
large sparse linear systems challenge," in Proc.
in Computer Science in 1979 and his Ph.D. de-
DISCO '93, Springer Lect. Notes Comput. Sci.
gree in Computer Science in 1982 from Rensse-
722, edited by A. Miola; pp. 66-80, 1993. Avail-
able from anonymousGftp. cs. rpi. edu in directory
laer Polytechnic Institute. He was an Assistant
kaltofen. Professor of Computer Science at the University
of Toronto and an Assistant and Associate Pro-
Diaz, A., Kaltofen, E., Schmitz, K., and Valente, T.,
"DSC A System for Distributed Symbolic Compu- fessor at Rensselaer Polytechnic Institute, where
tation," in PlOC. 1991 Internat. Symp. Symbolic he is now a Professor. His current interests are
Algebraic Comput., edited by S. M. Watt; ACM in computational algebra and number theory, de-
Press, pp. 323-332, 1991. Available from anony- sign and analysis of sequential and parallel algo-
mousGftp.cs.rpLedu in directory kaltofen. rithms, and symbolic manipulation systems and
Kaltofen, E. and Lobo, A., "Factoring high-degree languages. Professor Kaltofen currently is the
polynomials by the black box Berlekamp algo- Chair of ACM's Special Interest Group on Sym-
rithm," Manuscript, January 1994. Available from bolic & Algebraic Manipulation and serves as as-
anonymousGftp. cs. rpi. edu in directory kaltof- sociate editor on several journals on symbolic com-
en. putation. From 1985-87 he held an IBM Faculty
McClellan, M. T., "The exact solution of systems of Development Award. From 1990-91 he was an
linear equations with polynomial coefficients," J. ACM National Lecturer.
ACM 20, pp. 563-588 (1973).
Valente, T., "A distributed approach to proving large Department of Computer Science
numbers prime," Ph.D. Thesis, Dept. Comput. Rensselaer Polytechnic Institute
Sci., Rensselaer Polytech. Instit., Troy, New York, Troy, New York 12180-3590
December 1992. Available from anonymousGftp.
cs. rpL edu in directory valente. Internet: {diaza,kaltofen }lllcs. rpi. edu

21
DENOTATIONAL SEMANTICS APPLIED TO THE
TYPESETTING OF MAPLE EXPRESSIONS

Reid M. Pinchback
Academic Computing Services, MIT, Cambridge, MA

Introduction meaning. Our objective is to 'operationalize' the


semantics in terms of a Maple implementation.
Using your favourite document preparation pack-
age for typesetting mathematical expressions - to Perhaps the most useful property of denotational
include in papers and theses, for example - can be semantics is its compositional nature[l], by which we
tedious at the best of times. It is particularly frustrat- mean:
ing when the desired expressions already exist some- The meaning ofa phrase is determined by
where else, such as in an active Maple session, but are its denotation and the meaning of its
not in any kind of format that is both transferable and direct subphrases.
typographically useful. Here, the concepts of denota-
tional semantics are applied to the problem of export- For example, given a grammatical product A ::= B C,
ing Maple expressions to FrameMaker via MIF the meaning of A is a function of the meanings of B
(Maker Interchange Format) files. and C. The kind of notation typically used for denota-
tional specifications looks like:
The approach shown here involves the following
steps: A[A] ::= ... B[B] ... C[C] ."

1. Specify an abstract syntax capable of representing where A, B, and C are semantic functions defined over
a useful subset of Maple expressions. the appropriate syntactic constructs.

2. Specify the meaning of each grammatical produc- While generally denotations are specified in terms
tion in terms of Maple-coded 'denotations'. of a lambda calculus, such is by no means a require-
ment of the method. We will specify our denotations
3. Use the grammatical and denotational design in terms of Maple constructs.
information to implement a meta-evaluator in
Maple. The resulting program will behave as a
Abstract versus Concrete Syntax
transducer for converting Maple expressions into a
MIF document. Since likely more people are familiar with gram-
mars for concrete syntax than ones for abstract syntax,
Denotational Semantics and since at a glance they are similar in appearance, to
avoid later confusion we will briefly contrast the two
This is a method useful for specifying the meaning kinds[2]:
of formal languages in an abstract way, using mathe-
matical constructs called 'denotations'. The theoreti- 1. Concrete syntaxes are those typically encountered
cal underpinnings of the method are in domain theory, in introductory compiler courses. Their grammars
which we will not need to explore here. This is in part contain many productions useful for resolving pre-
because of relative simplicity of our application, and in cedence relationships and for specifying important
part because we are not attempting to create a fully syntactic keywords like 'if and 'then'. All of this is
abstract implementation-independent specification of necessary for parsing languages with sentences
that are written as character strings.
2. Abstract syntaxes have grammars that are compact
and represent the inherent structure of sentences in
the language, as represented by tree structures
(such as parse trees) instead of character strings.
With neither the need to resolve precedence nor to

22
indicate the syntactic keywords that parsers use for operands, which are themselves Maple expressions. In
pattern recognition in matching productions, the final implementation we will be using the Maple
abstract syntax grammars have much simpler and commands 'whattype' and 'op' to parse expressions,
many fewer productions than is the case for con- instead of using something like the 'hackware' pack-
crete syntax grammars. age. This relatively indirect access to the structure of
Maple expressions will make the implementation
A particularly useful property of abstract syntax 1 is
more readable at the cost of having to deal with some
that it allows us to collapse operator productions. For
special-case situations where 'op' and 'whattype' don't
example, contrast the following concrete and abstract
provide us exactly the information we need.
syntaxes for specifying simple arithmetic expressions:
We will restrict consideration to Maple expressions
and ignore command constructs like 'iLthen', and thus
Concrete Syntax Abstract Syntax
will also ignore the Maple 'procedure' and 'uneval' types.
E ::=E+T IT E ::=EOE For simplicity of the discussion we will also not include
the more complicated aggregate expression types
T ::=T *pIp 0::=+ 1* 'series', 'array', and 'table', but by the end of this paper it
should become apparent how they can be incorporated. 2
P ::= (E)
We first present an over-simplified abstract syntax
Table 1: Example of Concrete vs. Abstract Syntax just to get us started, allowing us discuss some impor-
tant features before we present a more complete ver-
The reduced complexity of abstract syntax makes sion. The start symbol for this syntax is 'P', and a
it even easier to utilize compositional approaches for description of the intended interpretation is included
dealing with the meaning of a language. Here is an beneath each production:
example of a semantic specification for the above syn-
P::=Q
tax, where the first production indicates that we apply
P (a Maple program) is an expression sequence.
the meaning of the binary operator to the meanings of
its two operands: Q::=E*
Q (an expression sequence) is a sequence of
E[E 0 E) ::= 0[0]( E[E], E[E] ) expressions.
0[+] ::= integer addition E ::= I I N I T(X*)
O[*] ::= integer multiplication E (an expression) is either an integer, a name, or a
To use this approach all you need to have (or be type construction over a sequt!nce of operands.
able to simulate) is a tree-oriented representation of the X ::=Q E N I I
language structure for a sentence. When the nodes of X (an operand) is either an expression sequence or
the tree contain tag information to indicate the type of an expression or a name.
each component phrase, it becomes a simple process I I
N ::= S function N(Q) indexed N[Q]
when traversing the tree to find matching productions N (a name) is either a string, a function, or an
of the abstract syntax. Since Maple expressions have indexed reference.
this kind of structure[3] and the structure is relatively
T ::= + I * I 1\ I list I set I ...
accessible to us, this is an approach that we can use.
T is a Maple aggregate type specifier.

An Abstract Syntax for Maple Expressions One important distinction to make in how Maple
represents expressions internally is the difference
There are very few productions in an abstract syn- between an expression sequence (an expression of sur-
tax describing Maple expressions. We will focus on face type 'exprseq') versus the sequence of operands
creating a syntax that does reasonable justice to how for a type. An 'exprseq' internally is a single object,
Maple types are represented internally. This will allow tagged with type EXPSEQ, having a sequence of com-
us to view surface types as different as "+" and 'list' as ponent objects, each of which in turn is some kind of
type construction operators over their component an expression. Some types (like 'function' and 'array')

I From this point on we will simply use the term 2 The results of adding support for these types,
·syntax'. and cease to make the distinction between syn· excluding indexfcn semantics, can be viewed in the
tax and gram mar. 'm aple2m if' code subm illed to the Maple share library.

23
have a sequence of operands, some of which may be 06 ::= fraction I float
expression sequences, but the sequence of operands 07 ::= integer
for the particular type is not itself an 'exprseq'. Such 08 ::= string
distinctions are important both syntactically and 09 ::= function I indexed
semantically - for parsing expressions properly, for
implementing the design cleanly, and for generating Semantic Functions for Maple Expressions
the MIF output code correctly.
Now that we have a relatively complete and use-
Another feature of the syntax to notice is the provi- able syntax for Maple expressions, we need some
sion for names. These are not quite the same types for semantic functions for mapping the syntax into deno-
which 'type(expr,name)' is true. Maple internal data tations that will represent the MIF code to be gener-
structures have a different internal concept for a name ated[4]. These semantic functions, when implemented
that has more in common with the concept of Lvalues in Maple, will have the following general structure:
found in other languages like 'C'. Since 'name' is not
P : maple programs -t MIF programs
actually a surface type in Maple, this is not really a
point of confusion for creating an expression parser, P[Q] ::= ... Q[Q] ...
but can be confusing to the reader. Q : expression sequences -t a comma-separated
As we have stated, the above syntax is over-simpli- sequence of MIF MathFullForm components
fied. Some of the types encompased by the T produc- Q[E*] ::= ... map(E,E*) ...
tions (for example "=" and "N') are binary operators E : expressions -t meaning of expressions
over expressions. Others (such as "+" and "*") are E[N] ::= N[N]
n-ary operators. In other words, we need to deal with E[T] ::= T[T]
the fact that different types have different signatures
describing their operands. The solution used here is to T : non-name expressions -t meaning of non-
add productions to the syntax to deal with grouping name expressions
operators according to their signature. From the view- T[OI(E,E)) ::= 0[01] ( E[E], E[E] )
point of later specifying the semantics, we would be T[02(E)] ::= 0[02] ( E[E] )
partitioning the types into equivalence classes of sig- T[03(E*)] ::= 0[03] ( map(E,E*) )
natures, determine the meaning of the operands based T[04(Q)] ::= 0[04] ( Q[Q] )
on the signature for the class, and then passing the T[05(N,E)] ::= 0[05] (N[N], E[E] )
result to the function that denotes the meaning of the T[06(1,1)] ::= 0[06] ( 1[1], 1[1] )
particular type. In fact, for consistency, we will do this T[07(1)] ::= 0[07] ( 1[1] )
with the N productions for names as well, since these N : name expressions -t meaning of name expressions
are also expressions constructed from Maple types and N[08(S)] ::= 0[08] ( 8[5] )
thus generalize to the same treatment. The reason for
N[09(N,Q)) ::= 0[09] (N[N],Q[Q])
the N productions is that we use names in circum-
stances where we don't use non-name expressions, but o : type operators -t meaning of type operators as
the productions still describe Maple internal expres- a MIF MathFullForm component
sion types. Integers and strings will also be treated in 0[+] ::= function to map the denotation of the
this type-operator expressive way: operand sequence to a MIF 'plus[...]' code fragment
(etc.)
P ::=Q
Q ::=E* I : integers -t meaning of integers (implemented as
E ::=T N I the identity operator)
T I I
::= 01 (E,E) 02(E) 03(E*) 04(Q) I 8 : strings -t meaning of strings (implemented as
I I
05(N,E) 06(1,1) 07(1) I the identity operator)
I
N ::= 08(S) 09(N,Q) In the above specifications, '.. .' indicates surrounding
01 ::=" = I I .. I I I
<> < <= and or I I denotational information. Most of the added material
02 ::= not in the denotations comes in dealing with programs,
03 ::= + * I expression sequences, and type operators. For this
04 ::= set listI application the other productions add negligible deno-
05::=. tational information beyond retrieval of the denota-
tions of their subphrases.

24
Implementing the Meta-Evaluator Figure I shows a portion of the actual implementa-
tion code for 'maple2mif, to give readers a sense of the
Four objectives were set for the Maple implemen-
final result. The routine is easily used by invoking it to
tation of the semantics of the meta-evaluator3:
construct a procedure to do the conversion, converting
1. It must work (obviously!). an expression to a string, and then writing the results
to a file:
2. It must closely follow the notation of the design.
> read 'maple2mif. txt' :
3. It must be easy to modify when implementing sim- >M := maple2mif():
ple and obvious extensions. >X := sin(a+b)Af(pi):
> interface (echo=O) ;writeto(foo);
4. It must be possible to have different instantiations > print (printf (' %s' ,M(X) ) ) ;
of the meta-evaluator without global naming con- > writeto (terminal) ; interface (echo=l) ;
flicts.
Objective I needs no discussion. Objectives 2 and Limitations
3 go hand-in-hand. The desired way to modify the pro- The 'maple2mif converter works quite well when
gram will be by first determining changes to the considered purely as a typesetting tool, with only a few
abstract syntax, following with changes to the denota- minor caveats:
tional specifications, and then finally by making (pre-
sumably manageable) changes to the implementation. • Since Maple is an 'eager evaluator' of arguments,
the expression you pass to the evaluator may not be
Objective 4 is important if we want to have differ- the expression that gets typeset. For example,
ent MIF converters available to us at the same time. 'maple2mifOO +2)' would generate MIF code for
For example we might want different converters for typesetting '3' in FrameMaker, while for commuta-
different font sizes, or different converters that typeset tive situtations like 'x+y', 'maple2mifO(x+Y), may
rational numbers (type 'fraction') either vertically or typeset either 'x+y' or 'y+x', varying between
horizontally, ie: Maple sessions. No good solution to this is known

(D versus (112)
at this time, other than perhaps to allow support for
some kind of neutralized expression form like that
returned by 'procbody'.
To allow for these situations the meta-evaluators can-
not share, by name, a single global object (like a sub- While some support for mapping special symbol
routine) that might need to be modified for differing names (like 'aleph' and 'pi') to their typeset sym-
semantics. The solution is implemented by giving bolic has been provided, there is no support for
each meta-evaluator its own protected environment of mapping special function names (like 'int') to their
local variable names for internal subroutines. The typeset equivalent. This should be addressed in the
entire collection of local names is in turn given to the future by modifying the syntax and semantics of
subroutines by such tricky methods as: 4 the 'function' type, handling it in a method similar
to how type operator syntax is treated now.
>M := proc ()
> local f,g; There are some Maple expressions that do not have
> env: = {' G ' =g, ' F' =f } ; close FrameMaker equation equivalents. The solu-
> g:= subs (env, x -> F(x+l»;
tion used here is to provide MIF code for some-
> f:= subs (env, y -> sin(y)+G(2));
> thing that is similar in appearance, for example by
> end; using the 'times' specification and character
This way the functions 'f and 'g' are only accessible to strings. This is not a limitation in 'maple2mif, but
other subroutines contained within the procedure 'M'. in the FrameMaker equation format. It does not
have a convenient method for formatting an
expression with an arbitrary binary operator.
3Terms like 'meta-evaluator' and 'meta-interpreter' When we view 'maple2mif as an exposition of denota-
may sound esoteric, but simply signify language evalua- tional methods, there are real limitations that need
tors implemented in lerms of an exisling inlerpreter,
addressing:
oflen used to modify the defaull interprelive behaviour.
4 This technique was found in - and gratefully bor- • While the use of 'whattype' and 'op' allows us rea-
rowed from - Michael M onagan's implemenlation of lhe sonable access to the internal structure of Maple
Gauss package.

25
expressions, they are not the perfect tools for the I. Support domain-oriented structuring of denota-
job. The result is a slight proliferation of special- tions. This is important as a structural design
case code, for example to distinguish between tool, as it serves in the role of a data-type for
'exprseq' and sequences of operands, or to retrieve denotational methods.
the occasional zero-th operand that 'op' doesn't
2. Support specification of states and environ-
return unless specifically asked for. The situation
ments. This is important for modelling mem-
is even less satisfactory for eventually supporting
ory and I/O. For example, this could be used to
the 'procedure' type, where we would need to use
handle treatment of last-name evaluation and
'procbody' and manipulate neutralized procedure
'assume' properties in Maple.
statements. The 'hackware' package provides bet-
ter access to the internal structures, but at the cost 3. Implementation of continuations. This is
of increased visual complexity, combined with the important for dealing with flow-of-control and
need to distinguish continually between objects error-handling issues, both of which become
and pointers to objects. What is really needed is a important when moving beyond evaluation of
front-end to hackware that would make it more Maple expressions to include Maple command
convenient for implementing traversals of arbitrary structures and the 'procedure' type.
Maple expressions.
The methods of denotational semantics have a
Conclusion
great deal more muscle than has been explored The methodology of denotational semantics can be
here[5]. For constructing more complicated meta- useful for designing programs. For structured pro-
evaluators, such methods are necessary for gener- gramming approaches to problems that can be charac-
alizing the implementation to encompass a broader terized in terms of formal languages, the composition-
range of possible meanings. The three most impor- ality property of denotational semantics allows us to
tant steps to take in the future are: create concise top-down solution methods. We hope

>maple2mif := proc()
> local env,sfP,sfQ,sfE,sfN,sfT,sfO,sfS,sfI,MIFargs,MIFsymbol;
>
> env:= {'P'=sfP, 'Q'=sfQ, 'E'=sfE, 'N'=sfN, 'T'=sfT, 'O'=sfO, 'S'=sfS, 'I'=sfI,
> 'MIFARGS'=MIFargs, 'MIFSYMBOL'=MIFsymbol};
>
> # semantic function P
> # defined over the syntactic domain of programs
> sfP:= subs (env, proc()
> cat('<MIFFile 3.00> # generated by maple2mif\n',
> '<Math\n',
> '<MathFullForm " ' , Q(args) , '\' >\n' ,
> '<MathOrigin 2.0" 2.0">\n',
> '<MathSize MathMedium>\n',
> '>\n' ) ;
> end); # proc sfP
>
> # semantic function Q
> # defined over the syntactic domain of expression sequences
> sfQ:= subs (env, proc()
> if nargs=O then
> # NULL exprseq
> E(");
> elif nargs=l then
> # single expression
> E(args[lj);
> else # nargs > 1
> # multiple expressions
> cat ( , comma [ , , MI FARGS (op (map (E, [args I ) ) ) , ' I ' ) ;
> fi;
> end); # proc sfQ
Figure 1

26
> # semantic function N
> # defined over the syntactic domain of typed name expressions
> # where allowable name operators={string,function,indexed}
> sfN: = subs (env, proc ()
> local 0;
> 0 :=whattype(args[1]);
> i f member (0, ( , s tr ing' }) then
> 0(0) (S(args[1]));
> elif member (0, ('function', 'indexed'}) then
> 0 (0) (N (op ( 0 , a rgs [ 1 ] ) ) , Q ( op (arg s [1] ) ) ) ;
> else
> ERROR (cat ('unsupported expression type, ,0,', detected'));
> fi
> end); # proc sfN

> # semantic function 0


> # defined over the syntactic domain of type operators
> # where type operators=list+set+'+'+'*'+ (etc).
> sf 0 ( , string') : = proc ()
> local found;
> if length(args[1] )=1 then
> cat ( , char [ , , args [l] , '] ') ;
> elif MIFSYMBOL(args[l], 'found') then # to deal with symbol names like
> cat('char[',found,']'); # aleph, pi, Pi, PI, ...
> else
> cat ( , string [" , , args [l] , , "] , ) ;
> fi;
> end;

> # return meta-evaluator


> eval (sfP) ;
>
>end: # proc maple2mif
Figure 1, cont.

that here we have provided a realistic example of such Biography


an approach that will motivate others to consider sim-
Reid M. Pinchback (reidmp@mit.edu) received his
ilar methods for solving problems that require the tra-
B.Math degree from the University of Waterloo in
versal and interpretation of Maple expressions.
1991. In that year he joined the Academic Computing
Services department of MIT as a Faculty Liaison,
References where he currently maintains and supports Unix and
[1] Tennent, R.D., Semantics of Programming Lan- Macintosh installations of Maple and other software
guages, Prentice Hall International, UK (1991). packages intended for educational use. He has also
been serving as Assistant Editor for the Maple Techni-
[2] Allison, L., A Practical Introduction to Denota-
cal Newsletter since July of 1993.
tional Semantics, Cambridge University Press,
UK (1986).
[3] Char, B.W., et aI., Maple V Language Reference
Manual, Springer-Verlag, New York (1991).
[4] MIF Reference, Frame Technology Corporation
(1991).
[5] Gordon, J.c.G, The Denotational Description of
Programming Languages, Springer-Verlag, New
York (1991).

27
I B. MAPLE IN APPLIED MATHEMATICS
A SYMBOLIC ENGINEERING MECHANICS SYSTEM
BUILT ON OEM MAPLE

Philip Todd, Robin McLeod and Marcia Harris


Saltire Software, Beaverton, Oregon

Abstract A Constructive Variational Geometry System


represents engineering geometry as a sketch with
In this paper, we present a system which converts constraints (also called "dimensions") given as labels
graphical descriptions of engineering mechanics on the sketch. "Constructive" refers to the classical
problems into closed form equations. We describe constructions of Euclid's geometry, for example, the
the functions we provide for simplifying and construction of a point of intersection, given two
manipulating the resulting mathematical equations. known lines. "Variational" means that numerical
information resides in the dimensions, such as
distance between points or measure of an angle,
which are labeled on the diagram, rather than
1. Introduction
residing in the coordinates of points; therefore
change or motion in the figure can be simply
A major limitation of the use of symbolic represented as change or variation in a constraint
mathematics packages, such as Maple, by value.
mechanical engineers is the difficulty of accurately
converting a geometry based mechanical engineering In this paper, we present a system which converts an
problem into a set of algebraic equations which can engineering mechanics problem, expressed as an
then be manipulated, solved or visualized by the Analytix model, into a symbolic mathematical
symbolic mathematics package. representation within Maple. We discuss the
functions which were developed to allow the user to
In the last eight years, Variational Geometry has manipulate and display this mathematical model.
emerged as a natural and powerful language for the We present several examples to show the process .J
expression of mechanical engineering problems using the hybrid system.
[1,2,6], particularly problems in the realm of
engineering mechanics. Problems involving the Our approach allows the engineering mechanics
kinematic behavior of mechanisms may be succinctly problem to be expressed in the natural graphical
expressed in the form of a constraint-based terms of a dimensioned sketch, while automatically
variational model of the geometry along with first performing the error prone process of converting the
and second derivatives of the constraints. With an geometrically expressed problem into mathematics.
additional capability for handling forces and masses,
we add the ability to express problems in the statics
and dynamics of mechanisms. The commercial 2. System Architecture
package Analytix uses a variational geometry user
interface as the means of specifying problems in the
dynamic analysis of mechanisms [3-6]. These There are three components to the symbolic
problems are then solved numerically in the package. mechanics package: (i) the front end is a modified
Figure 1 shows an Analytix model of a four-bar version of the Analytix variational geometry
linkage. package; (ii) a layer of code converts from the
Analytix representation of the mechanics problem to
a symbolic representation; (iii) a set of Maple
functions facilitates user interaction with the
symbolic representation.

31
Component (i) is written in C, component (ii) To perform a kinematic analysis, the user specifies
contains C code and Maple code, component (iii) is the velocities and accelerations of any constraints
entirely Maple code. which are in motion. (In the example of the four bar
linkage (figure 1), all constraints would have 0
velocity and acceleration except the driving angle.
(i) Analytix If the crank is being driven at constant angular
velocity v the angle would be given a velocity v and
an acceleration 0.) The user also must specify a
To create a model of a mechanism in the Analytix fixed point and a fixed line.
package, the user first sketches the mechanism.
Typically the sketch contains a simplified With the constraint velocities and accelerations
representation of the mechanism's geometry. Links given, the model is able to output on demand the
are usually represented by straight lines between position, velocity, and acceleration of any point of
joints or points of force application. Centers of the mechanism and the angular velocity and angular
gravity of any links with non-negligible mass are acceleration of any line.
explicitly sketched.
Static analysis of a mechanism may be performed in
The user then specifies the exact geometry by a very natural way in a Variational Geometry system
adding constraints to the drawing. The constraints by assuming that constraints carry reactions. Hence
specify angles or distances on the drawing. For a not only the motion, but also the statics of the model
kinematic analysis, the constraints should represent are defined by the constraints. If loads are applied
quantities whose motion is known. In practice, for a to a mechanism in Analytix, reaction forces are
single degree of freedom mechanism, all the generated in the constraints. The system will sum
constraints but one represent quantities which stay the constraint forces which impinge on a point to
fixed throughout the motion of the mechanism. The give the reaction force at that point. The system will
final constraint represents the driver, whose motion integrate the forces on a single line segment to give
is known. The Analytix system aids the constraint shear force and bending moment.
specification process by giving continuous feedback
on whether the model is underconstrained, Analytix allows external forces to be applied to any
overconstrained, or consistently constrained. The point on a mechanism and external torques to be
constraint values may be numbers or expressions. applied to any line. These forces may be constant or
Figure 1 shows an Analytix model for a four bar they may vary with geometry, time or some other
linkage. parameter. Analytix also provides conformal force
elements: translational and rotational spring-damper-
actuators.

To perform inverse dynamics in Analytix, the user


specifies the instantaneous motion of the mechanism
in the same way as for kinematics, but also applies
forces and specifies the mass of points representing
mass centers. The user also specifies the moment of
inertia of lines which represent rigid links. The user
can now generate the same reaction force outputs as
for the static analysis, except the inertial forces
generated by the accelerating masses will be taken
into consideration.

In a dynamic analysis, some constraints represent


Figure 1: Afour bar linkage specified by the quantities whose behavior is known in advance -
lengths of three sides and one angle. either quantities which remain fixed or drivers,
whose motion is given. Other constraints are free to
accelerate in response to unbalanced forces present
in the model. To sel up a dynamic model, the user

32
specifies the fixed constraints and the input drivers problems of arbitrary complexity, it was necessary
in the same way as for kinematic analysis. Free to maintain a symbolic representation as a nested
constraints are given initial values and initial sequence of expressions with intermediate variables
velocities and marked as being free to accelerate. introduced by the system. This eliminated the
exponential growth in individual expression
complexity. However, as Maple is designed to
(ii) Creating Symbolic Analytix Models manipulate single expressions rather than sequences
of expressions with collective meaning, this
necessitated a layer of code to allow the
In a previous paper [4] a method was described for manipulation of our symbolic representations.
performing a symbolic analysis of dimensioned
engineering drawings. Analysis of the constraint Table I shows the system output for the location of
graph associated with the drawing led to its point P9. For comparison, table 2 shows the same
description as a sequence of elementary Euclidean expressions without intermediate variables.
constructions, each of which was responsible for
constructing a single point or line from its specified
relation to known (already constructed) points and
lines.

For example, a construction sequence for the four


bar linkage of figure I is given below.
Construct a point (point P2) at the origin.
Construct a line (line L3) through point P2
in the direction of the x-axis.
Construct a point (point P4) on line L5 P6 _P6casin(e) P6e(acos(e)-b)
distance a from point n. !)'- P6d P6d

Construct a line (line L5) through point P2


angle e degrees to line L3.
Construct a point (point PI) on line L3
distance b from point n. -b P6c(acos(e)-b) P6easin(e)
Construct a point (point P6) distance c from P6x - + P6d + P6d
point PI and distance d from point P4.
Construct a line (line L8) through points PI
and P6.
Construct a line (line L7) through points P4
and P6. Table 1: Equations for the curve traced by point P9
Construct a point (point P9) on line L7 on the four bar linkage shown in Figure 1.
distance d/2 from point P4.
Each individual construction which is part of the
sequence described above has a corresponding set of
equations which may be solved to determine the
unknown geometrical entity. These are described in
[4].

In [4], expressions for the coordinates of the


drawing's points and the coefficients of the
drawing's lines were established in terms of the
independent constraint values alone. With this
approach, the system suffered from substantial
intermediate expression expansion, and was able to
deal only with rather simple drawings. In order to
deal with drawings and engineering mechanics

33
FullySubstitute(P9x);

I ()+lb+1 (acos(e)-b)2+a2sin(e)2+c2-d2)(acos(e)-b) I(
2 a cos 41 2 4 2 2 +
a cos(e) -2acos(e)b+b 2 +a 2 sin(4?)2 4
2c 2 a 2 cos(e)2- 4 c2 a cos(e)b+2c 2 b 2 +2c 2 a 2 sin(e)2 _a 4 cos(e)4
+ 4 a 3 cos(e)3 b - 6 a 2 cos(e)2 b 2 - 2 a 4 cos(e)2 sin(e)2 + 4 a cos(e) b 3
+ 4 a 3 cos(e) b sin(e)2 - b 4 - 2 b 2 a 2 sin(e)2 - a 4 sin(e)4 + 2 d 2 a 2 cos(e)2
112
- 4 d 2 a cos(e) b + 2 d 2 b 2 + 2 d 2 a 2 sin(e)2 - c 4 + 2 c 2 d 2 - d 4 ) a sin(e)j(
a 2 cos(e)2 - 2 a cos(e) b + b 2 + a 2 sin(e)2)

Table 2: Equation for P9x with all the intermediate variables eliminated.

Two different engineering mechanics functions are InstallDerivative(var.dvar) - installs an expression


available to the user. Reaction(x) gives the for the derivative of var with respect to dvar.
pseudoforce in parameter x.
InstallDiffEq([xQ•...•xnD creates new variables
A_xQ•...,A_x n representing the accelerations of (b) Extracting Expressions from the IVT
xQ,...•xn . In the process of assigning expressions to
these accelerations, a number of new intermediate
Evaluate(expr) - returns expr with the equation from
variables will be introduced (many representing
derivatives of existing variables). Velocity variables the IVT substituted for each variable in expr which
VJQ,...,V_x n will also be introduced and treated as is in the IVT. This is not done recursively
independent input variables. The methods used in
FullyEvaluate(expr) - A recursive version of the
these functions are described in [6].
above.

EvaluateF(expr,assgn) - performs a floating point


(iii) Interacting With Symbolic Analytix
evaluation with numerical assignments given in
Models assgn.

The Intermediate Variable Table (IVT) and the Equations(expr,style) - for each variable v in expr
routines to support and manipulate this structure which is in the Intermediate Variable Table, returns
were written in the Maple symbolic programming the equation defining v. Style specifies whether
language and coexist as a package running within implicit or explicit equations are desired.
Maple. We describe in the following the functions
which constitute this library. grouped according to FullEquations(expr.style) - A recursive version of
their use. the above

CFunction(fname.varlist) - creates a C function with


(a) Adding variables to the IVT name fname to evaluate the variables contained in
the varlist. Inputs to the function are all the
constants in the recursive definition of the variables
Install(vamame.eqn) - Installs a new variable with in varlist.
defining (implicit or explicit) equation eqn.

InstallAreaMoments(name.pointlist) - installs a (c) Displaying the IVT


number of new variables corresponding to area
moments of the polygon defined by the points in
pointlist. Show(expr.style) - displays expr and the definitions
(recursively) of all the table symbols involved in
expr.

34
(d) Geometric and mechanics functions 2, one angle is given a value t, while a second angle
is given a value r*t+s, where r is the gear ratio and s
represents the offset between the gear angles in an
Angle(line1,line2) - returns the angle between two
initial configuration.
lines

Area(pointlist) - returns the signed area of the closed


polygon formed by the pointlist.

Distance(entityl,entity2) - returns the distance


between the two entities.

InstallDifffiq(parlist) - for each parameter p in


parlist, installs equations for the acceleration of p,
A_p.

Reaction(var) - returns the reaction pseudoforce in


variable Var'

Figure 2: An Analytix model ofa geared 5-bar


(e) Applying Maple functions to individual linkage.
expressions
Table 3 gives the expressions derived by the system
Apply(expr,fcn,arg2, ... ,argn) - for each variable v for the coupler curve drawn in figure 2.
in expr which is in the Intermediate Variable Table,
applies the function fcn to the expression defining v. Show(P6);

P8y=dsin(rt+s)
(0 Eliminating Intermediate Variables
L10B=cos(rt+s)

Substitute(expr,varlist) - substitutes the definition of PB" = e - d LiOS


each of the variables in varlist into the definition of
each of the variables in expr. If no second
parameter is given, substitutes all intermediate
variables explicitly found in the definition of each
variable in expr.

FullySubstitute(expr) - a recursive version of the


above which eliminates all intermediate variables
from expr.

. (t) + P6c (POY - a sinO»


P6!Y-_ a S10 P6e (PBx - a cos(t»
P6d + P6d
3. Example Problems

P6 = (t) + P6c (PB" - a cos(t» P6e (poy- a sin(t)


" a cos P6d P6d
(i) Coupler Curve for a Geared 5-bar linkage

In this example, we derive equations for the curve


Table 3: Coordinates of the coupler curve for the
traced by one point on a geared five bar linkage. A
geared five-bar linkage
gear pair is modeled in Analytix by creating a
formula linking the values of two angles. In Figure

35
(ii) Torque in a Crank / Piston to the reaction in parameter a. The system returns
an expression for the torque which involves the
intermediate variable P8a and its derivative with
In our second example, we derive an equation for respect to a. To express torque as a single equation
the torque generated by piston force F in a in the input parameters, we can apply the function
piston/crank mechanism. The Analytix model is FullySubstituteO.
parametrized by the crank length c, the length of the
connecting rod L, and the crank angle a. Assuming
a force of F (depicted as 1 in figure 3) applied at the
(iii) Dynamics of a Double Pendulum
piston, we require the torque in the crank.

In our third example, we use the system to derive the


equations of motion for a double pendulum with unit
~l.~
~1
/'; masses at the end of each link. Figure 4 is the
-(c a Analytix model of a double pendulum. The
Variational Geometry model of dynamics assumes
- - - - - .. _-_.':.
that one or more of the model's parameters is free to
accelerate in response to unbalanced forces. In this
case, we wish the angle parameters a and b to be
free to accelerate.
Figure 3: An Analytix model ofa Piston Crank
Mechanism

The Variational Geometry statics model assumes


reaction forces in constraints balance any externally
applied forces. Thus a statics question should be
translated into a question regarding reaction forces
in constraints. In this case, we require the reaction
pseudoforce (actually a torque) in parameter a.

Install(torque,torque=Reaction(a»;

Show(torque); Figure 4: An Analytix model ofa double pendulum.

The command to create the differential equations is:


2 PBa (~ PBa) = -2 c 2 sin(a) cos(a) InstallDiftEq([a,b]);

The system introduces new variables A_a and A_b


torque = ( -c sin(a) + (~ P8a)) F
for the accelerations of a and b, and new parameters
V_a and V_b for the velocities of a and b. It then
FullySubstitute(torque); derives the equations of motion as expressions for
A_a and A_b in terms of the input parameters along
with V_a and V_b.

The initial expressions for the accelerations in this


example involved a large number of intermediate
Table 4: Equationsfor the torque in the crank
variables. Application of the function
generated by an input force F at crank angle a.
SimplifyTableO resulted in the equations shown in
Figure 5. The parameter g seen in Table 5 is the
In Table 4, a new variable, torque, is introduced into acceleration due to gravity.
the Intermediate Variable Table with a value equal

36
A_a:: - G V_a 2 sin(2 b)- 4 cos(b) cos(a +b)g- V_a 2 sin(b) +8 cos(a)g

- 2 V_a V_b sin(e) - V_b sin(b)) / ( - ~ + ~ cos(2 b))


2

A_b:: - (3 V_a 2 sin(b)- 8 cos(a +b) g- V_a 2 sin(2b)+4 cos(b)g cos(a +b)

+ 8 cos(b) cos(a) g - V_a V_b sin(2 b) - ! V_b 2 sin(2 b) - 8 cos(a) g

+ 2 V_a V_b sin(b) + Sin(b))j( -~+!


V_b 2 cos(2 b))
Table 5: Equationsfor the accelerations A_a and A_b of the angles a and b. Parameters V_a and V_b are
introduced by the system and represent the velocities ofa and b, g is the acceleration due to gravity

Table 6 shows the use of CFunction() to create code CFunction(CalcAcc,[A_a,A_b]);


for evaluating these accelerations. CFunction()
automatically derives which variables are inputs and
which (any intermediate variables) are locals. The void CalcAcc(
function may be called with the 'optimized' option, double b,
in which case, further local variables are introduced double a,
for any common sub-expressions in the evaluation. double g,
double V_b,
Code generation in CFunction() uses the Maple double V_a,
function C(). In more complex dynamics problems,
with dozens of intermediate variables introduced by double *A_a_,
the mechanics system and dozens more introduced double *A_b_)
by the use of the 'optimized' option, the capability
of automatically generating the wrapper code for a C double A_a;
function was essential. double A_b;
A_b = -(3.0*V_a*V_a*sin(b)-8.0*cos(a+b)*g-
V_a*V_a*sin(2.0*l?)+4.0\
CFunctionO Implementation Note *cos(b)*g
*cos(a+b)+8.0*cos(b)*cos(a)*g-
V_a*V_b*sin(2.0*b)-V_b*V_b*sin(2.0*b)/2-\
In the case shown above, we desire code for a 8.0*cos(a
sequence of equations, namely for an equation )*g+2.0*V_a*V_b*sin(b)+V_b*V_b*sin(b»/(-
representing A_a and an equation representing A_b. 3.0/2.O+cos(2.0*b)/2);
The Maple function optimize() will accept a A_a = -(V_a*V_a*sin(2.0*b)/2-
sequence of equations as input, however it is 4.0*cos(b)*g*cos(a+b)-V_a*V_a*sin(b\
assumed that the last in the sequence of equations is )+8.0*cos
the only one we actually care about. Hence any of (a)*g-2.0*V_a*V_b*sin(b)-V_b*V_b*sin(b»/(-
the prior equations may be discarded if it is not 3.0/2.0+cos(2.0*b)/2);
deemed necessary in computing the final answer. *A_a_ = A_a;
For example, let's assume we want to generate code *A_b_= A_b;
for x and y from the sequence of equations: [r=2*a,
x=r, y=r*sin(t)].
Table 6: CFunction() can be used to create a C
optimize([r=2*a,x=r,y=r*sin(t)]); function to evaluate these accelerations.

y = 2 a sin(t)
In order to ensure that all the equations in our output
sequence are preserved we use the undocumented
Maple function 'optimize/statseq()' with as its first

37
parameter the list of equations to be optimized and Authors
as its second parameter the list of output variables.
This ensures these outputs are preserved.
Philip Todd has an M.A. in Mathematics from
'optimize/statseq' ([r=2*a,x=r,y=r*sin(t)],[x,y]); Cambridge University, an M.S. in Applied
Mathematics from Georgia Tech and a Ph.D. in
Mathematical Biology from Dundee University. He
[r = 2 a, x = r, y = r sine t ) ] is the founder and V.P. of Research and
Development of Saltire Software. He is currently
the principal investigator of an NSF SBIR grant
4. Conclusions researching automatic mathematical modelling of
geometric and mechanical problems.
We have presented a system which allows
engineering mechanics problems to be specified in Robin McLeod received his Ph.D. in Mathematics
an extremely intuitive and graphical manner through from Dundee University in 1972. His research
the medium of a variational geometry system while interests lie in numerical analysis and applied
a mathematical formulation of the problem within geometry. He is a Senior Scientist at Saltire
Maple is made available to the user. We have thus, Software. His current research involves human
for this problem domain, automated the error prone readability of symbolic mathematics, and
process of mathematical modeling which generally readability-directed simplification.
precedes mathematical analysis. The maintenance
of an intermediate variable table enabled us to keep Marcia Harris received her B.S. in Mathematics
the complexity of this mathematical model under from UCLA, and her M.S. in Computer Science
control. from Oregon State University. Her research
interests include the symbolic representation of
robot paths.
5. References
Todd & McLeod can be contacted at SaItire
Software, PO Box 1565, Beaverton OR 97075, tel.
1. Light R., Gossard D., (1982) "Modification of 503-622-4055
geometric models through variational geometry",
CAD 14:209:214 Harris can be contacted at 1334 SE 52nd Street,
Portland, OR
2. Fuller N. & Prusinkiewicz P. (1989) "Applications
of Euclidean constructions to computer graphics",
Visual Computer 5:53-67 Acknowledgement
3. Todd P. (1986) "An algorithm for determining
consistency and manufacturability of dimensioned This research was partially funded by the National
drawings" CAD86 pp 36 - 41, Butterworths, London Science Foundation under grant number ISI-
9223482
4. Todd P. and Cherry G., (1989) "Symbolic
Analysis of Planar Drawings", Lecture Notes in
Computer Science Vol 358 (p. Gianni ed.) 344-355

5. Todd P. (1989) "A k-tree generalisation that


characterises consistency of dimensioned
engineering drawings", SIAM Journal of Discrete
Mathematics 2:255-261.
6. Todd P. (1992) "A Constructive Variational
Geometry Based Mechanism Design Software
Package" ASME DE-Vol 46, Mechanism Design &
Synthesis, pp 267 - 273

38
SIGNAL PROCESSING USING MAPLE V

John I. Molinder
Department of Engineering, Harvey Mudd College, Claremont, California

Introduction continuous-time and discrete-time systems to a


pulse input. Listings of the command procedures
It is common practice to use frequency domain are given in the appendix. Additional commands
techniques to determine the characteristics of are under development and listings are available
signals and systems. Signals are often from the author.
characterized by their frequency spectrum and a
great deal of insight into the behavior of a linear Underlying Concepts
time-invariant (LTI) system can be gained by
examining its frequency response. As a result of Sampled continuous-time signals and
the dramatic increase in the speed and discrete-time signals can be thought of as
decrease in the cost of digital hardware, vectors with each component representing the
discrete-time signal processing techniques value of the signal at a particular time instant.
based on the discrete Fourier transform (OFT) Since it is more natural to represent a
have become more and more prevalent. This continuous-time signal as an expression, the
paper describes a number of special commands first step is to construct a vector with
that exploit both the symbolic and numeric components equal to the values of the
computational capabilities of MapleV to provide expression at uniformly spaced time instants.
a signal processing environment that is both Maple's Fast Fourier Transform (FFT) command
flexible and easy to use. Using these can then be used to compute the spectrum of
commands, the results of processing the sampled signal. The effect of processing the
continuous-time signals with continuous-time signal with a LTI system (either continuous-time
systems described by their s-plane transfer or discrete-time) can now be determined by
functions or discrete-time systems described by computing the spectrum of the output. This
their z-plane transfer functions are easily requires multiplying the spectrum of the input
determined. Important concepts such as aliasing signal by the frequency response of the system.
and causality can be explored. Although Finally, the output of the system in the time
designed for a class in systems engineering, the domain can be determined by taking the inverse
procedures should be of use to practicing Fourier transform of the output spectrum using
professionals as well. First, some of the special Maple's iFFT command. While all of these
commands will be described followed by an operations can be accomplished using the
example of shOWing the response of both standard Maple command set, the special
commands described in this paper greatly
reduce the time and tedium involved (not to
mention the probability of error) and allow the
user to concentrate on the important principles
rather than the details. A short description of
each of these commands is given below.

39
spectrum is ploffed and the result is stored in
Special Commands
vectors xrf and xif.

Initialization
zfilter(dtf)
Before using the special commands listed below
their files must be read and numerical values Analogous to the previous command, the effect
must be assigned to the variables sf (sampling of processing the signal with a discrete-time
frequency) and p2 (length of the FFT as a power system specified by its z-plane transfer function
of 2). In the example that follows sf is set to 64 is determined by using this command. Again,
samples per second and p2 to a value of 8 the magnitude of the output spectrum is ploffed
(corresponding to a FFT of length n=28=256 and the result is stored in vectors xrf and xif.
points).
FourierO
ffourier(et)
This command uses Maple's iFFT command to
This command computes a vector of length n compute the inverse Fourier transform of the
whose components are the values of the output spectrum and plots the output in the time
samples of a continuous-time signal domain. It accesses xrf and xif for its input.
(represented by the expression et), determines
vecprod(n,x,y,z)
its spectrum (using Maple's FFT command) and
plots the magnitude of the spectrum as a
This command computes a vector z of length n
function of frequency in Hertz (corresponding to
with components that are the products of the
the sampling frequency). The result is stored in
corresponding components of vectors x and y.
vectors xr and xi (the real and imaginary parts of
It is used as part of the Ipfilter(fh) command.
the spectrum) where it can be accessed by the
filtering commands listed below. Thus this
Example
command must be executed before using any of
the filtering commands.
Consider the response of a system to a pulse.
The first step is to create an expression xt that
Ipfilter(fh)
represents the pulse:

The effect of an ideal low-pass filter with cutoff


xt:=u(t-1.5)-u(t-2.5);
frequency fh is simulated by this command
which also plots the magnitude spectrum of the
where u is the alias of the Heaviside function. A
output. As with all the filter commands, the result
plot is shown in Figure 1. To compute the
is stored in vectors xrf and xif (the real and
spectrum and display its magnitude the following
imaginary parts of the output spectrum) where it
commands are issued.
is available for the inverse Fourier command.

p2:=8;
afilter(ff)

sf:=64;
This command determines the effect of
processing the signal with a continuous-time
ffourier(xt);
system specified by its s-plane transfer function
tf (ff must be an expression with independent
This will compute the DFT (using Maple's FFT
variable s). The magnitude of the output
command) with n=2 8=256 points and a sampling

40
frequency of 64 samples per second (covering a This will set all the components of the OFT
total time duration of 256/64=4 seconds. The corresponding to frequencies higher than 10Hz
resulting plot of the magnitude spectrum is equal to zero. The resulting spectrum is shown
shown in Figure 2. Note that the points of the in Figure 3. A plot of the waveform in the time
OFT have been connected for clarity but the domain is shown in Figure 4 and is obtained by
actual frequency resolution is 64/256=0.25 Hz. giving the following command.

iffourierO;

".'e Plo~

'.8
..
'.6

.. ..
'.2
,.
.
Figure 1 " '" " ...
Figure 3

M.aplePlo1

5ll

...
PI Ie Plot

'"
'"
" "

"
Figure 2 .
e.;:

If this waveform is the input to an ideal low-pass


filter the spectrum of the output can be Figure 4
determined by giving the command below.

Ipfilter(10);

41
Now suppose we want to determine the I1ipl9 Ptct

response of a second-order system with transfer


function H1(s) given below. "
"
H1(s) =
S2
900
+ 6s + 900
..
This corresponds to a second-order system with
a natural frequency of 30 rad/sec and a per unit
"
damping of 0.1 (highly underdamped). Since
the spectrum of the pulse is available it need not "
be computed again. First the transfer function is "
entered as an expression as shown below. Figure 5
H1 s:=900/(sI\2+6*s+900);

Next the magnitude spectrum of the output


"*,19 Plot
(shown in Figure 5) and the output waveform
(shown in Figure 6) are computed and plotted by 15

issuing the following commands.

afilter(H1 s);
,.,
iffourierO;

Now consider the transfer function H2 (s) given


-0,
below.

H2 (s) = 900 Figure 6


S2- 6s + 900

Issuing the commands below produces the


output waveform shown in Figure 7.

H2s:=900/(sI\2-6*s+900);

afilter(H2s); "

iffourierO;

05
Notice that the output is not causal (response
starts prior to the input). This is to be expected
since use of the Fourier transform forces the
region of convergence to be to the left of the
poles in the right half of the s-plane (to include
the imaginary axis) resulting in an anticausal
response. The magnitude spectrum is the same Figure 7
as that shown in Figure 5.

42
Similar sequences of commands produce the Finally, consider a first-order discrete-time
outputs shown in Figures 8 and 9 corresponding system with the transfer function given below.
to the transfer functions listed below.
H1(z) = __1 __
1-0.875 Z·1

H3 (s) = 10
s + 10 Issuing the commands below produces the
output waveform shown in Figure 10.
H4 (s) = 10
s - 10
H1 z:=1/(1-.875/z);

These represent the output of first-order


zfilter(H1 z);
systems with causal and anticausal responses.

iffourierO;

As expected, the result is similar to the output of


the first-order continuous-time system shown in
Figure 8.
"
••

"
(
Figure 8

Figure 10
t1aptePlot

-0.2 Conclusions

-0.'
The special commands described in this paper
provide a convenient method for determining the
properties of signals and systems using MapleV.
-0.6

Combined with Maple's symbolic manipulation


-0.8
capabilities these procedures allow the student
-, or professional to design and simulate a variety
of signal processing systems. Similar commands
Figure 9 are under development for areas such as
modulation and communication link analysis.

43
Appendix # NOTE: REQUIRES THAT FOURIER.MPL BE
# READ BEFORE USING

Ipfilter:=proc(fh)
Listings tor several of the special commands are
npts:=2Ap2;
given below.
mx: =vector(npts, 1);
np:=nptsl2;
for k from 2 to np+1 do
fourier.mpl
if xax[k) > fh then
mx[k):=O;
# Set up MapleV to handle FFT and unit step
mx[npts+2-k):=0;
# functions
fi;
cd;
readlib(FFT):
vecprod(npts,xr,mx,xrf);
readlib(Heaviside):
vecprod(npts,xi,mx,xif);
alias(u=Heaviside):
mf:=vector(npts,O);
# Load vector manipulation routine for k to npts do
mf[k]:=sqrt(xrt[k)1\2+xif[k]1\2) ;
# read ·vecprod.mpr; od;

# Routine to compute and graph FFT of a p:=concat(xax,mf);


# sampled time waveform p1 :=convert(p,listlist);
# npts=2Ap2=number of points plot(p1 );
# sf=sampling frequency end:
# et=time waveform expression (variable must
# be t) afilter.mpl

ffourier:=proc(et) # Arbitrary filter routine


npts:=2Ap2; # npts=2Ap2=number of points in FFT
en :=subs(t=(n-1 )/sf,et); # sf=sampling frequency
fcn:=unapply(en,n); # tf=transfer function (variable must be s)
xr:=vector(npts,fcn);
xi:=vector(npts,O); afilter:=proc(tf)
FFT(p2,xr,xi); npts:=2I\p2;
m:=vector(npts,O); np:=npts/2;
for k to npts do pi:=evalf(Pi);
m[k):=sqrt(xr[k)1\2+xi[k)1\2); dw:=evalf(2*pi*sf/npts);
cd', ffd :=subs(s=I*(n-1 )*dw,tt);
df: =sf/npts; ffdf:=unapply(ffd,n);
g:=n->df*(n-1 ); mx:=vector(np+1,ffdf);
xax:=vector(npts,g); x:=vector(np+1,0);
xf:=vecfor(npts,O);
p:=concat(xax,m); xrf:=vector(npts,O);
p1 :=convert(p,listlist); xif:=vecfor(npts,0);
plot(p1); mf:=vector(npts,O);
end: for k to np+1 do
x[k):=xr[k]+I*xi[k];
cd',
Ipfilter.mpl xf[1 ]:=evalc(x[1 ]*mx[1]);
for k from 2 to np+1 do
# Ideal low-pass filter routine xf[k]:=evalc(x[k]*mx[k]);
# npts=2Ap2=number of points in FFT xf[npts+2-k]:=evalc(conjugate(xf[k]));
# fh=high frequency cutoff cd;

44
for k to npts do # sf=sampling frequency
xrf[k]:=evalc(Re(xf[k]));
xif[k]:=evalc(lm(xf[k])); iffourier:=procO
mf[k]:=sqrt(xrf[k]"2+xif[k]"2) ; npts:=2"p2;
00', iFFT(p2,xrf,xif);
dt:=1/sf;
p:=eoncat(xax,mf); gt:=n->dt*(n-1 );
p1 :=convert(p,listlist); xaxt:=vector(npts,gt);
plot(p1);
end: p:=concat(xaxt,xrf);
p1 :=convert(p,listlist);
plot(p1);
zfilter.mpl end:

# Arbitrary discrete filter routine


vecprod.mpl
# npts=2Ap2=number of points to be computed
# sf=sampling frequency # Read in linear algebra routines for vector ma-
# dtf=transfer function (variable must be z) nipulation

zfilter:=proc(dtf) with(linalg):
npts:=2"p2;
pi:=evalf(Pi); # Compute the product of real vectors x and y
dw:=evalf(2*pi/npts); ferm by term
ffd:=subs(z=exp(I*(n-1 )*dw),dtf); # n=vector length
ffdf: =unapply(ffd, n); # z=resulting vector
mx:=vector(npts,ffdf);
x:=vector(npts,O); vecprOO :=proc(n,x,y, z)
xf:=vector(npts,O); z:=vector(n,1 );
xrf:=vector(npts,0); for i to n do
xif:=vector(npts,O); z[i]:=x[i]*y[i];
mdf:=vector(npts,O); 00',
for k to npts do end:
x[k]:=xr[k]+I*xi[k];
xf[k]:=evalc(x[k]*mx[k]);
xrf[k]:=evalc(Re(xf[k]));
xif[k]:=evalc(lm(xf[k])); Reference
mdf[k]:=sqrt(xrf[k]"2+xif[k]"2);
00; A. V. Oppenheim, A. S. Willsky, and I. T. Young,
sf1 :=5f; Signals and Systems, Prentice-Hall, Inc., New
g:=n->(n-1 )*sf1 /npts; Jersey, 1983.
xax:=vector(npts,g);

p:=concat(xax,mdf);
p1 :=convert(p,listlist); John I. MoUnder Oohn_molinder@hmc.edu)
plot(p1); received his B.S. degree from the University of
end: Nebraska, his M.S. degree from the Air Force
Institute of Technology, and his Ph.D. degree
from Caltech, all in Electrical Engineering. Since
ifourier.mpl
1970 he has been a member of the faculty at
# Computes and plots real part of inverse FFT Harvey Mudd College where he is Professor and
# npts=2Ap2=number of points Harvey S. Mudd Fellow of Engineering.

45
IMPLEMENTATION OF A MAPPING PROCEDURE FOR THE
DOMAIN DECOMPOSITION FOR PDEs IN MAPLE

Peiyuan Li and Richard L. Peskin


CAIP Center, Rutgers University, Piscataway, NJ

Abstract the asymptotic analysis and an artificial intelli-


gence technique, plan generating system, to de-
Domain decomposition for partial differential equa- compose the domains of second order nonlinear
tions(PDEs) is implemented using singular pertur- ODEs and generate parallel programs for finite dif-
bation analysis. The programming work is accom- ference method for solving the problems. Hed-
plished in a symbolic programming environment, strom and Howes[IJ used asymptotic analysis to
namely Maple. determine a domain decomposition method for a
First we establish the definitions of a domain and singular perturbation convection-diffusion equation
boundary conditions in the symbolic programming with turning points, and also suggested the basis
environment, Maple, then apply the characteristic functions to be used in a finite element method.
curve method to transform the reduced equation A numerical algorithm based on asymptotic anal-
to a first order system. After a series of transfor- ysis for a 2-dimentional boundary value problem
mations, the first order system can be transformed has been implemented by Rodrigue and Reiter[9J.
to a third order ODE. If the third order ODE can The authors[5J have successfully applied singular
be solved in Maple, the solutions of the reduced perturbation analysis[2, 3, 4J to domain decompo-
equation are obtained. Thus, an approximate solu- sition for partial differential equation(PDEs). In
tion of the equation is constructed from a solution our previous paper[5J the presentation is focused
of the reduced equation and correction terms corre- on mathematical analysis and mathematical meth-
sponding to boundary layers and interior layers. By ods used for the domain decomposition. In this
applying the above methods a set of criteria to de- paper we present the implementation of domain
termine a stable partition of a domain can be built. decomposition in a symbolic computation environ-
Based on the set of criteria, the search for all pos- ment(Maple).
sible stable partitions is implemented by traversing General elliptic partial differential equations
on the graph of a given domain. Using the similar (PDEs) can be specified as follows,
traversing method on the partitioned domain, each
individual subdomain is selected automatically so A(x, u)· Vu + h(x, u) = €V 2
U, x in n, (1)
that it can be distributed to a processor for fur-
ther processing. The structure of the system im-
u(x, €) = <j;(x) x on r = an.
plemented in Maple is described in a pseudo-code. where
In this paper only elliptic equations are discussed. x= (Xl, ... ,XN),

a a
v = (-a
Xl
'''''-a
XN
)
1 Introduction and
A(x, u) = (al(x, u), ... , aN(x, u)).
The analysis for singular perturbation problem has
been successfully used for domain decomposition by o is a bounded region in n Nwhose boundary r is
several researchers. Russo and Peskin[8] combined a smooth (N - I)-dimensional manifold.
The associated reduced equation is,

A(x, u)· Vu + h(x, u) = 0, x in 0, (2)

46
which is a quasilinear first order PDE. The solution
of the reduced equation will be denoted as Uo, u
being the solution of the elliptic problem (1).
As a result of singular perturbation analysis,
the solution of an elliptic problem can be approx-
imated, under certain conditions, by the solution
of the associated reduced equation and correction
terms. That is, in a large portion of the domain of
the elliptic problem the solution of the problem can
be replaced by the solution of the reduced equation;
however there exist subdomains, boundary and in-
terior layers, in which the solution of the problem
is a combination of the reduced solution and corre-
sponding correction terms. Some conditions, called
Figure 1: The domain expressed in Maple
stable conditions, are required for admissible solu-
tions. These stable conditions are described in de-
tail as theorems in [5] and a set of rules are built list, expressing the domain, is as follows:
from the stable condition requirements. The aim
of our system is to search for stable partitions from [[Xl, Yl, eq 1],
all possible partitions using previously mentioned [xz, Yz, eq2],
rules and traversing on a graph of the domain. Af- [X3' Y3, eq3],
ter stable partitioning, the domain is divided into
[X4' Y4, eq4],
a set of subdomains. Finally the system selects
each subdomain individually so that each subdo- [xs, Ys, eq5]],
main can be distributed across different processors
in which every element is a sublist, corresponding
for parallel computation. During the selecting pro-
to a side of the domain. The order of elements in
cess the size of the subdomain has to be adjusted
properly in order to satisfy requirements from the a list is the clockwise order of sides of a domain.
The first and second elements in a sublist are the
Schwarz method[10].
x and Y coordinates of the start location of a side,
and the third element is the equation of curve of
the side. Here we do not limit the equation for a
2 Representations of Domain side; however implementation requires restriction
and BCs to equations recognizable by Maple. Both convex
and concave domains are permissible in our defini-
The first step for implementing, in Maple, domain tion.
decomposition for 2-D PDEs is the representation The boundary conditions in 2-D are expressed as
of domain and boundary conditions. Here we do a list also. For the domain in Figure 1, we have a
not distinguish the concepts, domain and region following list as boundary conditions,
rigorously. The strict definitions of domain and
region are given in [5]. We use lists to express do- [[1,5], 1, h(x, y), fz(x, y), h(x, y), f4(X, y),
mains and boundary conditions because lists are fs(x, y), h(Xl, Yl) = fs(xll yd]·
accessible data structures in Maple. In Maple, a
list can be easily tranformed into a set or an ex- The first element of the above list is a sublist,
pression sequence. This transformation allows dif- which contains the indices of incoming sides. By
ferent type manipulations to be applicable to the incoming side, we mean that the characteristic
same object. For instance, for a domain, set op- curves for the reduced equation (2) are incoming
erations(union, minus and intersect), and list op- through this side. The detail description of in-
eration(concatenation) can be used. More impor- coming side can be found in [5]. The first and
tantly, the list, representing a domain, can be re- fifth sides are incoming side in the above list. The
garded as a graph, so tha~ algorithms for graphs second element is the number of the additional
can be directly applied to the list(domain). boundary conditions. The third to seventh el-
For a general domain in 2-D, as shown in Fig- ements, h(x, y), fz(x, y), h(x, y), f4(X, y), fs(x, y),
ure 1, its boundary consists of several sides. The are given boundary conditions for the first to fifth

47
smooth and do not all vanish at the same point.
The first order system has a parametric form solu-
= =
tion, x x(s), y y(s), and u(s). Also the initial
condition is referred to as the initial curve C in
(x, y, u) space. To solve this initial value problem
we pass a characteristic curve through each point
of the initial curve C. If these curves generate a
surface, this integral surface is the solution of the
initial value problem. The conditions, under which
a unique solution of the initial value problem for
(3) can be obtained, are expressed as,

Figure 2: A general domain


(4)
sides respectively. The last element, h(xll yI)
fS(Xl, Yl), is the additional boundary condition, on C. The initial conditions are obtained from the
which means the values of h(x, y) and fs(x, y) are boundary conditions along incoming side F_ .
equal at the point (Xl, Yl). (There is one additional
condition, so the second element is the number, 1.) 3.1 Obtaining the Initial conditions
from Boundary Conditions
3 Solving the Redueed Equa- If the reduced equation (2) satisfies the following
tion boundary condition along the incoming side F_ ,

The solution of the associated reduced equation(2) uo(x, y) = ¢(x, y), for (x, y) in f(x, y) = O.
is the main part of the approximated solution of
For the boundary, f(x, y) = 0 we change the form
PDE(l). Solving the reduced equation is one of
to, y = g(x). Then for the first order system (3),
the principal parts of our system implemented in
the initial condition can be rewritten as,
Maple.
Suppose a general domain for PDE is depicted s = 0, x = 1", Y = g(1"), U = ¢(1",g(1")).
as in Figure 2. The boundary of domain, r, con-
sists of three parts, F_, the incoming side, Fo , the As a special case, if the boundary is x = k, where
tangent side, F+, the outgoing side. For the re- k is a constant, the initial condition then is,
duced equation, we cannot have a solution satisfy-
ing the complete boundary conditions, only a solu- s = 0, x = k, y = 1", = ¢(k, 1").
U

tion which satisfies the given boundary conditions


Similarly, for the boundary y = k, we have the
along a part of the boundary, say, the incoming
initial condition for the first order system (3),
side, F_. Using the method of characteristics [11]
for solving the first order PDE (2), we obtain the s=O, X=1", y=k, u=¢(1",k).
first order system,
dx 3.2 Solving the First Order System
al(x, Y, u)
ds in Maple
dy
a2(x, y, u) (3) The initial value problem may not have a solution
ds
du at all or it may have infinitely many solutions; these
-h(x, y, u) cases are not treated in the current paper. We only
ds
treat the case in which the condition (4) is satisfied,
with initial conditions at s = 0 given as X = x( 1"), that is, the initial value problem has a unique so-
Y = y( 1") and u = u( 1") with 1" as a parameter. The lution. This first order system is solved in Maple.
solution of (3) are called the characteristic curves Using the method of elimination, a third order or-
of the equation (2). Here we have assumed that dinary differential equation(ODE) is derived from
al(x, y, u), a2(x, y, u) and h(x, y, u) are sufficiently the first order system.

48
Differentiating the first equations of (3) we ob- I lsi Onlor ~tom I
I
tain the equation,
13M~DE I
d2x dx dy du
ds2 = F(ds' ds' ds'x,y,u), (5) F

Upon the substitution of (3) into (5), the equation


(5) becomes,

(6)

Differentiating the equation (6) and substituting


(3) into it, we find
solve

(7)
.olved unsolved
Coupling the first equation of (3) and the equation
(6) and solving for y, u, Figure 3: Flowchart for solving the first order sys-
tem

we use the transformation

q,
Finally, substituting the above equations into the
equation (7) we obtain the third order ODE (12)

(8) where q is the function of p, to reduce the second


order ODE(11) to the first order ODE
If resulting equation (8) is linear, it can be solved dq
directly. However if it is nonlinear, it may not be F(dp,q,P) =.0, (13)
directly solved using Maple. Fortunately there is
no explicit variable s in the equation (8), so we can which can be solved using Maple. Another limited
introduce the transformation, form of the second order ODE we consider is,

dx
p, (14)
ds
d2 x Similarly to the above case, we apply the transform
(9)
ds 2
d3 x dp
r,
ds 3 dx
d2 p dr
in which p is a function of x. The equation (8) is , (15)
dx 2 dx
transformed into the second order ODE
and obtain the first order ODE
(10) dr
F(dx' r, x) = 0, (16)
Attempts to solve the second order ODE symboli-
which can be solved using Maple. The flowchart
cally are limited by current capabilities of systems
expressing the above procedure is depicted in Fig-
like Maple. If the nonlinear second ODE has the
ure 3.
form
The ODEs for which the above special cases ap-
(11 ) ply can be solved using Maple. However we cannot

49
guarantee that we will obtain a symbolic solution correctors, Wi(X, c), give the nature of layers in de-
to the general ODE like (7). It may be necessary tail. The layer effect exponentially decays along the
to resort to a numerical solution. Using numerical inner normal direction of the corresponding bound-
methods in the singular perturbation analysis will ary or interior singular curve. And the width of
be discussed in a future paper. layer is of order c or of order c l / Z depending on the
nature of the boundary or singular curve [5].
Based on the stability conditions, Theorem 1 -
4 Conditions for Stable Parti- 5[5], we build a production system [7], which uses
tioning and Searching the stability conditions as rules to search for all sta-
ble partitions of the given domain. In the produc-
Using uo, the solutions of the reduced equation, we tion system, the global database consists of sym-
can partition the domain into a set of subdomains. bolic functions, symbolic equations and lists which,
Among all possible partitions we are only interested as defined in Section 2, express the given domain
in the stable partitions with which u, the solution and subdomains as well as boundary conditions.
of the elliptic PDE is approximated in every sub- The search process is implemented by traversing
domains by Uo and is convergent to Uo as c --t O. on the graph which includes the given domain and
Certain stability conditions required by conver- all singular curves in the domain. Moreover, the
gence have to be imposed on such solutions. In search process is controlled by the following steps.
[5], three theorems, Theorem 1, 2, 3, for boundary
1. Along whole boundary every side is distin-
layer and two theorems, Theorem 4, 5, for interior
guished as F+, Fo and F_.
layer are described in detail. Each theorem includes
certain stability conditions as assumptions. When 2. On every side of boundary it is verified that
all assumptions in one of these thorems are satis- there is a theorem among Theorem 1, Theorem
fied, there exists a positive constant co such that 2 and Theorem 3, which is satisfied.
for 0 < c S co the equation (1) has a solution
u = u(x, c) of class c(Z,O')(n i ), which is defined as 3. The reduced solution Uo is tested to determine
the smoothness of a function in [4]. Moreover, for if it is smooth.
x in n i we have that 4. If the Uo is nonsmooth, the singular curves
must be found.

5. Along the singular curves it is verified if there


where is a theorem between Theorem 4 and Theorem
5 which is satisfied.
Wl(x, c) K l exp[-klc-lEl(x)] + ...
6. The widths of boundary layers and interior lay-
+ K P1 exp[-klc-lEp , (x)],
ers are determined.
Wz(x, c) L l exp[-(mlC- l )l/Z'1J l (x)] + ...
+ L , exp[-(mlc- l )l/Z'1J , (x)],
r r
Once the traversing on a given domain is com-
pleted, the domain has been stably partitioned into
W3 WI + Wz, a set of subdomains which include boundary and in-
and the Ci are known positive constants. Here terior layers and the other subdomains. The next
step is to "select" each subdomain individually for
max I¢(x) - uo(x)l, further computation.
~;'(o)

max I¢(x) - uo(x)l,


>Ii;::' (0) 5 Selecting
o< k l < k, and 0 < ml < m. The parameters Selecting subdomains means, that based on a par-
k and m are constants defined in assumptions of titioned domain, each individual subdomain is au-
theorems[5] . tomatically tagged so that it can be distributed to
The formula (17) indicates that the solution of a processor for further numerical processing. The
(1), u, is approximated by the reduced solution of selecting process is implemented by traversing on a
(2) with the layer corrector Wi(x, c). Wi(x, c) is domain, similar to that used for searching. Dur-
the summation of several terms each of which cor- ing the selecting process, the size of the subdo-
responds to a boundary or interior layer. The layer main has to be adjusted properly in order to assure

50
satisfaction with requirements from the Schwarz pertur
method [10, 9], that is, the subdomain has to over- {
lap with adjacent subdomains. The overlapping of _solve the reduced equation(sReduequ)
subdomains can accelerate the convergence of it- _determine the singUlar curve with the
erations in computation for PDEs. The following solution of reduced equation(sicurve)
rules are applied in the selecting process: _verify the first assumption of the stable
conditions for boundary layers(criteBl)
1. The selecting starts from the incoming side. _verify the second assumption of the
stable conditions for boundary
2. When the traversal moves from an incoming layers(criteB2)
side to a boundary side which has a bound- _verify the third assumption of the
ary layer, we have to select a birth-boundary stable conditions for boundary
layer subdomain. This subdomain is defined layers(criteB3)
to be the region located at the corner between _determine the widths of boundary layers
incoming side and boundary layer side. for all sides of domain(Wid, boundco)
_form the set of sides of all boundary
3. When the traversal moves along a boundary layers(formlyr)
side which has a layer, we can select a bound- _determine the kind of interior layers
ary layer subdomain. for interior lines(tyinter)
_verify the stable conditions for interior
4. When the traversal moves from a boundary layers (cri tel)
side to another boundary side, both of which _determine the width of interior layers(widI)
have boundary layers, a corner-boundary layer _form the set of sides of all interior
subdomain can be selected. This subdomain layers (formiyr)
is located at the corner between two boundary if no interior layer(sicu=NULL)
sides.
_select subdomains in turn, obtain a set
of sudomains(wsosubs)
5. When traversal moves from an incoming side
elif
to a singular curve, an birth-interior layer sub-
_select subdomains in turn, inclUding
domain can be selected. This subdomain is
interior layers, obtain a set of
defined to be the region located at the corner
subdomains(obtsubs)
between singular curve and incoming side.
fi
}
6. When the traversal moves along a singular
curve, we can select an interior layer subdo-
Following is an example which illustrates the pro-
mam. cess.
7. When the traversal moves from a singular
curve to a boundary side which has a boundary 7 Example
layer, a corner-interior layer subdomain can be
selected. This subdomain is located at the cor- Consider an elliptic problem.
ner between singular curve and boundary side.
au
=--
8. When the traversal is finished on a domain,
[f!.u
ax + u,
after removing the subdomains created in the in the square region n.
above steps, the remaining part, that is the
main subdomain, is selected. s = (x, y) : F(x. y) < 0 for F(x, y) = (1 - x 2)(y2 - 1),
and
6 Structure of Program o side =
l:x 1,0 S y S 1
1 side =
2:x 1. -1 S y S 0
The whole package of domain decomposition in exp\x - 1) 3:-1 S x S 1,y=-1
Maple consists of 78 functions. The structure of the ¢(x, y) = exp( -2)
siue
side =
4:x -1, -1 S y S 0
package can be represented in the following pseudo- o side 5:x= -1,0 S y S 1
code. o side 6:-1 S x S Ly= 1

51
The parameters are y
~ (x, 1) = 0

here TJ is the decay ratio of layers defined ill [5].


~(-l,y)=O <P (1, y) = 0
The reduced equation is (0 <= Y<= 1) (0<= Y<= 1)
au
- - +u = o.
ax x.
The reduced solutions satisfying the boundary con-
ditions along side 1 and 2 is
<P (-1. Y) = eXp(-2) <p (1, Y) = 1
0 O::;y
uo = { exp(x - 1) y::;O (-1 <= Y<= 0) (-1 <= Y<= 0)

y = 0 is a singular curve for the reduced solution.


The system travels the region and automatically (x,-l)=ex x-1
applies stability criteria, Theorem 3 and 5, to the
graph, finally get the stable partition of domain, de-
picted in Figure 4, and the widths of layers. Width
of boundary layer: Figure 4: The stable partitioned domain

0,0, .07963856349, .002378981685, [-.9964315275, -.8805421548, -x-.9964315275 = 0]],

[[.9203614365, -.8805421548, x-.9203614365 = 0],


.0009210340374, .09210340372 [.9203614365, -1., Y = -1],
Width of interior layer:
[-.9976210183, -1., -x-.9976210183 =0],
[-.9976210183, -.8805421548, -y-.8805421548 = 0]],

.04291932052. [[-.9964315275, -.9203614365, -y-.9203614365 = 0],


[-1., -.9203614365, x = -1],
[-1., -4291932051.0E-ll, y+4291932051.0E-ll = 0],
The set of subdomains selected is shown in Fig- [-.9964315275, -4291932051.0E-ll, -x-.9964315275 = 0]],
ure 5. The corresponding list of subdomains se-
lected is as follows. [[1., -.9203614365, -y-.9203614365 = 0],
[-.9976210183, -.9203614365, -x-.9976210183 = 0],
The list of sub domains selected: [-.9976210183, -4291932051.0E-ll, y+4291932051.0E-ll = 0],
[[[.8618448944, 1., Y = 1],
[1., -4291932051.0E-ll, x = 1]],
[1, 1, x = 1],
[[1., -6437898077.0E-ll, y+6437898077.0E-ll = 0],
[1., .8618448944, y-.8618448944 = 0],
[.8618448944, .8618448944, x-.8618448944 =0]], [.9356210192, -6437898077.0E-ll, x-.9356210192 = 0],
[.9356210192, 6437898077.0E-ll, -y+6437898077.0E-ll = 0],
[[-1., .8618448944, x = -1],
[1., 6437898077.0E-ll, x =1]],
[-1, 1, Y = 1], [[-1., 6437898077.0E-ll, -y+6437898077.0E-ll = 0],
[-.9986184489, 1., -x-.9986184489 = 0],
[-.9964315275, 6437898077.0E-ll, -x-.9964315275 = 0],
[-.9986184489, .8618448944, y-.8618448944 = 0]],
[-.9964315275, -6437898077.0E-ll, y+6437898077.0E-ll = 0],
[-1., -6437898077.0E-ll, x = -1]],
[[-.9990789660, .8618448944, -x-.9990789660 = 0],
[-.9990789660, 1., Y = 1],
[.9078965963, 1., x-.9078965963 = 0],
[[.9570806795, -6437898077.0E-ll, y+6437898077.0E-ll = 0],
[-.9976210183, -6437898077.0E-ll, -x-.9976210183 = 0],
[.9078965963, .8618448944, y-.8618448944 = 0]],
[-.9976210183, 6437898077.0E-ll, -y+6437898077.0E-ll = 0],
[.9570806795, 6437898077.0E-ll, x-.9570806795 = 0]]]
[[-.9986184489, 4291932051.0E-ll, -y+4291932051.0E-ll = 0],
[-1., 4291932051.0E-ll, x = -1],
[-1., .9078965963, y-.9078965963 = 0],
[-.9986184489, .9078965963, -x-.9986184489 = 0]],

[[1., 4291932051.0E-ll, -y+4291932051.0E-ll = 0], 8 Conclusions


[-.9990789660, 4291932051.0E-ll, -x-.9990789660 0], =
[-.9990789660, .9078965963, y-.9078965963 = 0],
[1., .9078965963, x= 1]], In our present symbolic-numeric system we only
handle the partition of simple domains. By includ-
[[1., -.8805421548, x = 1],
[1, -1, Y = -1], ing advanced computational geometry functions,
[.8805421548, -1., x-.8805421548 = 0], the partition of complicated domains can be imple-
[.8805421548, -.8805421548, -y-.8805421548 = 0]],
mented. Based on the partitioned domain, we iden-
[[-.9964315275, -1., Y = -1], tify the data dependency among the set of subdo-
[-1, -1, x = -1],
[-1., -.8805421548, -y-.8805421548 = 0], mains. Thus we can create a synchronous parallel

52
Partial Differential Equations, Vol.4( 1), pp1-
39, 1979.

[4] F.A. Howes, "Some Singular Perturbed Non-


linear Boundary Value Problems of Elliptic
Type", proceedings of Conference on Nonlin-
ear Partial Differential Equations in Engineer-
ing and Applied Science, University of Rhode
Island, pp151-166, 1979.

[5] P. Li and R.L. Peskin, "Domain Decomposi-


tion for Singular Perturbation PDEs", Mathe-
matics and Computers in Simulation, Vol. 36,
1994.

[6] P. Li and R.L. Peskin, "A New Method in Do-


L.- .Q....::.6_ _----J1 ~
main Decomposition for ODEs", Mathematics
and Computers in Simulation, Vol. 36, 1994.
Figure 5: The selected subdomains
[7] N.J. Nilsson, Principles of Artificial Intelli-
gence, Morgan Kaufmann Publishers, Inc.,
algorithm employing the intrinsic data dependency 1980.
among the set subdomains. Using the set of sub-
domains, the synchronous parallel algorithm and [8] M.F. Russo, and R.L. Peskin, "Automatically
the proper mapping of communication among the Identifying the Asymptotic Behavior of Non-
processors we can expect to complete the parallel linear Singularly Perturbed Boundary Value
distributed computation for PDEs with good par- Problems", Journal of Automated Reasoning,
allel computing time, speedup and efficiency. Thus, Vol.8, pp395-419, 1992.
symboic systems like Maple are useful, not only for
analysis of singular perturbation PDEs, but also for [9] G. Rodrigue, and E. Reiter, "A Domain
domain decomposition for parallel computation. Decomposition Method for Boundary Layer
Problems", Proceedings of the Second Interna-
tional Symposium on Domain Decomposition
9 Acknowledgment Methods, California, pp226~234, 1988.

This study has been supported by the National Sci- [10] H.A. Schwarz, Gesammelte Mathematische
ence Foundation under grant ECS-9110424 at Rut- Abhandlungen, Springer, Berlin, 2, pp133-134,
gers University. 1890.

[11] E. Zauderer, Partial Differential Equations of


Applied Mathematics, John Wiley & Sons,
References Inc., pp35-77, 1983.
[1] G.W. Hedstrom and F.A. Howes, "A Domain
Peiyuan Li
Decomposition Method for a Convection Dif-
(pli@yinayng.rutges.edu, pli@caip.rutgers.edu,
fusion Equation with Turning Point", Proceed-
Tel:908-445-3304) received the Ph.D. degree in
ings of the Second International Symposium
aerospace engineering from Rutgers University in
on Domain Decomposition Methods, Califor-
1994, the M.S. degree in computer science from
nia, pp38-46, 1988.
Rutgers University in 1992 and the M.S. degree in
[2] F.A. Howes, "Perturbed Boundary Value computational mechanics from Shanghai Jiao Tong
Problems Whose Reduced Solutions Are Non- University in 1982. His current research interests
smooth", Indianna University Mathematics include parallel algorithm, parallel computing and
Journal, Vol.30, No.2, pp267-280, 1981. high performance computing as well as applied soft-
ware in symbolic and object oriented environments.
[3] F .A. Howes, "Singular Perturbed Semilinear Richard L. Peskin
Elliptic Boundary Value Problems", Comm. (peskin@caip.rutgers.edu, Tel:908-445-3685)

53
is Professor of Mechanical and Aerospace Engineer-
ing at Rutgers University, and is Director of the
CAIP Computational Engineering Systems Lab.
His research interests include the interface between
symbolic and numeric computing, as well as the de-
velopment of scientific user data management and
interface systems. He has published numerous pa-
pers related to computer software and applications,
as well as in the fields of computational fluid dy-
namics, nonlinear dynamics, and combustion.

54
IIA. MAPLE IN EDUCATION
THE INFLUENCE OF MAPLE ON A LINEAR ALGEBRA COURSE
AT THE DELFT UNIVERSITY OF TECHNOLOGY

Harry A.W.M. Kneppers


Department of Pure Mathematics, Delft University of Technology, The Netherlands

1. Introduction 2. The use of Maple


For the past two academic years, we have been We shall now look at some ways in which Maple
using Maple in the linear algebra course for first- has proved to be useful in our course.
year students in the faculty of Systems Engineer-
ing, Policy Analysis and Management at the Delft 2.1 Elementary computations
University of Technology. The course consists of When students are practising linear algebra, a lot
three components: four hours per week for lectures, of time is needed for elementary computations. By
two hours per week for tutorials and another two "elementary" we mean: the type of computations
hours per week for computer laboratory. that have already been practised before, either in
primary school or in secondary school or in an ear-
In the lectures, no computers are used. Defini- lier part of our course.
tions and theorems are illustrated by small exam- Example 2.1.1
ples, which do not require too many computations, After teaching the students how to multiply ma-
so that students can see it "with their own eyes." trices, we show them some ways in which matrix
Premature use of a computer would give an unde- algebra differs from the algebra of real numbers.
sired magic touch to the subject. We ask them to compute AB and BA, we ask
The tutorials are there to help students digest the them to multiply [ 1-2]
-3 6 with [4 -2]
2 -1 '
things they have learned. To this end, they get
etcetera. All this can easily be done by hand, pro-
small exercises so that they can do it "with their
vided the matrices are small. Working with matrix
own hands." For example, to get some idea of what
powers, however, is different. The following exer-
a row operation does to a matrix, students should
cise is given to the students in the computer lab
first do it by hand a couple of times, before using
class during the second week of the course.
addrow, swaprow and mulrow.

The purpose of the computer laboratory is to prac- Exercise


tise linear algebra. During the lab classes, each
student has a PC with Maple at his or her dis-
posal. The lecturer is there to answer questions. (a) Let A = [~ ~ ~]. Compute
789
A 2
, A 3
, A4, A 5 and A 25 .
(b) Sometimes, the powers An of a ma-
trix A behave according to a cer-
tain pattern. Compute A 2 , A 3 ,
A 4 and A 5 and give a formula for

-q
An if:
-6
[ -1
(i) A = -4 4
7 -9 -3
-1
(ii) A =
[ -3
: 7
3
-1~
-3
]

57
2 2
[ -2 -5 ]
(iii) A = 1~ -7 20 o
-4 11 with basis (b],b 2 ), where b] 3
-10 o
(iv) A =
[-1 11
-6 ]
-8 -5
7 1
o
o

J]
14
(v) A = [ -2
-1 10
and b2 = 1 . f is the linear map
1 -13 o
o
0 1 1 1 1 from V to W defined by
0 0 1 1 1
(vi) A = 0 o 0 1 1 2v] - V2 - 6V3 - 3V4
0 000 1 o
0 000 0 3v] - V2 - 8V3 - 4V4

Un
1
o
(vii) A = 1
o
0 (in Maple: f:=v->vector([
2*v[1]-v[2]-6*v[3]-3*v[4],O,

-n
Of course, students are not surprised with the out- 3*v[1]-v[2]-8*v[3]-4*v[4],O,O]);)
come of question (a). But when they answer (b),
they usually become enthusiastic. (Without a com-
puter, they would not have been so enthusiastic (aJ Let v =[ Write vasa lin-
about this exercise.)
ear combination of (a], a2, a3) and
Example 2.1.2
put the coefficients of this linear
We teach our students how to find the matrix of a
combination in the column vector
linear map relative to certain bases, and we prove
x. This x is called the column of
that the matrix of f times the matrix of 9 is equal
co-ordinates of v relative to the
to the matrix of the composite map fog. They
see a lot of I:'s but most of them don't know what basis (a], a2, a3)'
it is all about. Students now have the opportu- (b) Compute f( v) through the Maple
nity to practise this within a reasonable time. For command f (v) ; . Find the col-
the following exercise, all they need to know is the umn of co-ordinates y of f( v) rel-
definition of the matrix of a linear map. ative to (h, &2)'
(c) Find the matrix F of f relative to
Exercise (a],a2,a3) and (b],b 2).

n", [!]
V is the vector space with basis (d) Verify that Fx = y.
(a],a2,a3), where (e) 9 is the linear map from W to R2
defined by

"I =[_ = and "3 =


9

[ :::~ ], and W " the vedm 'pace


In R 2 we choose the basis (c], C2),

where c] = [ ~ ] and C2 = [ ~ ].
Find the matrix G of 9 relative to
(b],b 2) and (C],C2).

58
(f) h is the linear map defined by h( v) = the definition, students can get an impression of
g(f(v)) (so h is the composite map what the condition number is trying to tell them.
of g and f). Find the matrix H of
h relative to (aI, a2, a3) and (Cl, C2)'
Exercise
(g) Verify that H = G F. A is the matrix ~ [-1 ~]. The
unit circle in the x, y-plane is trans-
Example 2.1.3
formed by A into the curve
Suppose the students have learned and practised
solving systems of linear equations, and we now
C = {A [ cos(t)sin(t) ] (O:S t:s 27f)}
have come to the issue of finding eigenspaces. Again,
lots of systems must be solved. There is no need A picture of this curve is obtained by
to do this by hand any longer, so the students may the Maple commands
use Maple here. This will save a lot of time which
they can use for practising the things we want them
to practise, like determining the algebraic and ge- b:=evalrn(A&*vector([cos(t),sin(t)]»;
ometric multiplicity and diagonalizing matrices.
plot([b[1],b[2],t=O .. 2*Pi]);
Exercise Find the determinant and the condition
Given the matrices number of A and make a picture of the
83 80 -60] curve C. Do the same in each of the
A = -20 3 30 and

:]
[ following cases:
o 0 43
7 -20 -5 (a) A = [~ ~]
5 -13 -5
B = [
-5 10 7 :
(b) A= [ 100 100]
5 -10 -5 -3 -100 100
(a) Use only det and solve to find 100 200]
the eigenvalues of A and B. Check (c) A =[ 300 400
your answer with eigenvals.
It appears that the determinant tells us
(b) Use only nullspace to find a ba- something about the measure by which
sis of each of the eigenspaces of the area of the unit circle is enlarged,
A and of B. Check your answer whereas the condition number tells us
with eigenvects (The output of something about the measure by which
eigenvects(A); consists of " lists" the shape of the unit circle is "flattened."
of the form [a, b, S], in which a is
an eigenvalue, b is the algebraic
Example 2.2.2
multiplicity of a and S is a basis
One ofthe most important applications of linear al-
of the corresponding eigenspace).
gebra is solving systems of linear differential equa-
(c) Is there a basis of R 3 that consists tions. We would like the students to make phase
of eigenvectors of A? portraits, but since we are not teaching them cal-
(d) Is there a basis of R 4 that consists culus, we don't want them to spend too much time
of eigenvectors of B? on it.

2.2 Making pictures Exercise


The solution of an initial value problem
Example 2.2.1
is regarded as the parametric equation
Pictures may help to understand the condition num-
of a curve. In this exercise, we are go-
ber of a matrix. With Maple, it does not take much
ing to make pictures of such curves. In
time to draw those pictures. So immediately after

59
each of the questions, we are dealing would be rather discouraging without a computer,
with the initial value problem but in a computerlab class, they are manageable
for the students.
u' Au = Example 2.3.1
{ u(O) = Uo
Exercise

l", ~
V is the vector space spanned by (a1' a2)
(a)A= [ -11 -1]-1 anduo= [ 11 ] .
and W is the vector space spanned by
Find the solution u and give the
commands
curvel:=[u[1].u[2].t=0 .. 10]; (b" b" b3 ), wh", ", ~ -~ [

[-il ~ Ul ~ -j]
and
plot(curvel);
to make a picture of u.
Repeat this question, but this time
b, b, [
with Uo = [ ~ ]. Assign the name
curve2 to this curve. In the same
way, make a curve3 with Uo
[ ; ] and a curve4 with Uo
and b3 ~ [ -!H
(a) Verify that both a1 and a2 are per-
[ ~ ]. Draw the four curves III pendicular to each of bl , b2 and b3 ·
one picture with the command (The dotproduct of two vectors v
plot({curvel.curve2.curve3.curve4});. and w is computed by Maple through
the command dotprod (v. w) ; ).
(b) The same question, but now with
(b) Verify that each vector from V is
A=[~ -b]' perpendicular to each vector from
W. Hint: Take v = C1al + C2a2
(c) Again the same question, with A =
and w = d1 bl +d2 b2 +d3 b3 (don't
[~ _ ~ ] and for the initial con- assign values to Cl, C2, d l , d2 and
d3 ! If necessary, give the com-
ditions we take respectively Uo =
mands cl:='cl'; etc.) and show
[ to ],
1
UQ = [ 1
5], UQ = [ 19 ] that v is perpendicular to w.

and Uo = [ ~l5 ]. This time, the (c) Now the general statement. V is
the vector space spanned by
interval from 0 to 1 is a better (al,a2, ... ,a n ) and W the vector
range for t. Why was this change space spanned by (b l ,b 2 , ... ,bm ).
not needed in questions (a) and It is given that ai is perpendicu-
(b)? lar to bj for i = 1, ... ,n and j =
1, ... , m. Prove that each vector
from V is perpendicular to each
2.3 Proving abstract statements vector from W.
If we give our students an abstract statement and
ask them for a proof, they usually have two prob- Example 2.3.2
lems. Firstly, "abstract" means" difficult" or" mys-
terious" to them. They often don't see what an Exercise
abstract proof has to do with down-to-earth com-
putations. Secondly, they don't know how to start.
The following two exercises are examples of how
to help them with both problems. Both of them
(a) A is the matrix [1 6
94
-~~ =i~]
-4 -5

60
17 -49 70] we did not want them to use eigenvals immedi-
and B = 6 -20 34 . ately, since this exercise was meant to practise the
[ o -2 7 computing of eigenvalues. So we often had to in-
(i) Find a matrix 5 and a matrix dicate which Maple functions they were allowed to
Tsuch that 5- 1 AS T- 1 BT = = use.
A, where A is a diagonal ma-
Third, we did not want to spend too much time on
trix.
teaching them Maple. So we decided to introduce
(ii) Compute M =
5T- 1 .
each function at the moment it was needed. Fur-
(iii) Verify that B = M- 1 AM. thermore, we provided a list of all the Maple func-
(b) A is an n x n matrix with n dis- tions that are used in our course. This turned out
tinct eigenvalues and B is an n x n to be a good policy: there was hardly any need to
matrix with the same eigenvalues give the students an introduction to Maple. They
as A. Prove that B is similar to just used it.
A.
4. The results
Comparing the experience of the past two years
3. Teaching materials with the teaching of linear algebra without a lab
In our view, most books with titles such as" Linear
class, we make the following observations.
Algebra with a Computer" make too much use of a
computer (see, for example, "Experiments in Com- 4.1 Students' motivation
putational Matrix Algebra" by D. R. Hill (Random On the average, the motivation of the students is
House,1988) or "Linear Algebra with Maple V" by better. Of course, there always is the usual group
E. Johnson (Wadsworth, 1993)). Definitions are of students who are motivated anyway, and also
often surrounded by lots of computer commands there are those who just want to pass their exams
and sometimes the reader is expected to type com- with minimal efforts. But talking about students
plete programs. This approach focuses too much who are somewhere between these extremes (which
on the computer. So we decided to use a textbook is the largest group) we noticed that they do much
on Linear Algebra without a computer. We have better than the norm for this group of students.
chosen G. Strang's book" Linear Algebra and its
Applications" (third edition, Harcourt Brace Jo- 4.2 Understanding the theory
vanovich, San Diego 1988). Then we wrote a sup- We teach definitions, we give examples and we
plement for the lab classes. The exercises in the prove theorems, and our students sit and listen
above examples are from this supplement. Writing (and, hopefully, make notes). But a great deal
the supplement, we faced the following three diffi- of our theory cannot be practised by the students
culties. themselves, for the simple reason that there is not
enough time. With computer algebra, we can over-
First, we were tempted to make the matrices too come this problem. For example, observing the
big. For example, we asked for the rank of the way students handle the exercise in example 2.1.2,
matrix it turns out that the recipe for finding the matrix
1- t -4 7-t -6 of a linear map is not as straightforward as we ex-
2 tz-2t+l -4 t2 - 2t + 3 pected it to be for the students. After completing
t-6 -6 t+3 -9 this exercise in the computer lab class, they have
1 2t - 4 7 - 3t 3t - 6 a much better understanding of what this matrix
3t - 12 2t - 12 6 3t - 18 is all about.

for each value of t. It turned out that the students 4.3 Tests
needed more time than expected to type all the Every other week, at the end of a lab class, we
entries and to detect typing errors. give the students a 20-minute test. With Maple
available, we can ask them the things we want to
Second, we did not want the students to use all ask. A typical example is a test in which several
the available Maple functions. In example 2.1.3, 3 by 3 matrices are presented, and students are

61
asked to diagonalize them, if possible. Thus we
can see if they have learned how to handle eigen-
values and eigenvectors, without going through the
time-consuming process of solving lots of systems
of linear equations.

5. Conclusion
It hardly takes time to teach Maple to the students,
whereas using Maple saves a lot of time. With the
assistance of Maple, we observe an improvement in
the motivation of the students. Furthermore, they
get a better understanding of the theory and we
can test them more effectively.

Harry Kneppers studied Mathematics at the Lei-


den State University (The Netherlands) and re-
cieved his Ph.D. in Mathematics from the Free Uni-
versity (Amsterdam, The Netherlands) in 1982. At
present, he is a lecturer at the Delft University of
Technology. His address is as follows:

Harry A.W.M. Kneppers


Department of Mathematics
Faculty of Technical Mathematics and
Informatics
Delft University of Technology
P.O. Box 5031
2600 GA Delft
The Netherlands

E-mail: H.A.W.M.Kneppers@twi.tudelft.nl

62
CAN MAPLE HELP IN TEACHING CALCULUS
WITH LIMITED TIME AND STAFF?

Scott R. Fulton
Department of Mathematics and Computer Science, Clarkson University,
Potsdam, NY

Abstract 2 Background
This paper describes our experiences incorportat- In the 1993-94 academic year we introduced a
ing Maple into a calculus course with limited time significant component of Maple into the standard
and staff. Our approach to teaching the basics Calculus course at Clarkson University. This sec-
of Maple and its use in lectures and take-home tion describes the background for this experiment:
projects are described. Student reactions are sum- the facilities, time and staffing constraints, and
marized and compared to those at another insti- prior uses of Maple at the University.
tution. We conclude that our low-key approach
can have a positive impact on the course without
radical changes in the course format or substantial
2.1 Facilities
increases in contact hours or staffing. Clarkson University has a wide range of computer
facilities available for students. A generous site
license from Waterloo Maple Software allows the
1 Introduction full Academic version of Maple (currently Maple
V release 2) to be available on all machines which
Computer algebra systems such as Maple have
are capable of running it. This includes:
enormous potential for transforming the teaching
and learning of Calculus. Well-established pro-
• Student PCs: Each student entering the Uni-
grams, such as that at Rensselaer Polytechnic In-
versity is issued a personal computer. For
stitute [11 have made it clear that Maple can be
1993-94, this computer was an IBM PS/2
used effectively if the necessary commitment, fa-
Model 25SX (20MHz 80386SX processor)
cilities, time, and personnel are there. But what
with 4MB RAM, an 80MB hard disk, and a
if any of these factors are lacking? Can Maple
color VGA montior. Maple was pre-installed
still be used effectively? This paper describes our
on each student PC.
experiences incorporating Maple into a calculus
course with adequate facilities but a distinct lack • Networked PCs: Various PCs in dorm com-
of time and personnel. We hope this informa- mon areas, computer labs, classrooms, and
tion will prove useful to others interested in using lecture halls are available to students (when
Maple under less than ideal conditions. not in use ill classes). Many of these are capa-
The paper is organized as follows. Section 2 ble of running Maple, accessed from a central
describes the institutional setting and constraints. file server.
The format of the calculus course and the ways in
which Maple were used are described in section 3. • Workstations: Over 125 IBM RS/6000 color
Section 4 presents results from a survey of student workstations are available for student use.
reactions to using Maple. Our conclusions and Many of these are concentrated in three com-
thoughts for the future appear in section 5. puter classroom/labs with 20-30 worksta-
tions each; all run Maple.

2.2 Constraints
The standard freshman calculus course at Clark-
son (taken primarily by engineering and science

63
majors) meets for two hours of lecture and one 3 Implementation
hour of recitation per week. This austere schedule
poses a challenge for teaching and learning calcu- Maple (or any other computer algebra system) can
lus, even with a conventional approach. Adding serve at least two distinct purposes in a calculus
a new aspect to the course (such as using Maple) course:
must be balanced against the prospect of having
to cut something else out due to lack of time. In • As a learning tool: Maple has the potential to
Fall 1993, there were three lecture sections (150- help students better understand the concepts
160 students each) and 12 recitations (about 38- of calculus by making it easy to explore an
40 students each), with a total of about 460 stu- idea graphically and numerically as well as
dents. Total staffing was one professor and three analytically.
and a half Teaching Assistants. In Spring 1994
• As a problem-solving tool: Maple allows stu-
there were about 15% fewer students, the same
dents to solve problems more difficult and/or
number of sections, one professor, and four TAs.
realistic than the standard "textbook" prob-
Undergraduate tutors were available for scheduled
lems, allowing students to focus on the con-
group and drop-in tutoring and help sessions. Stu-
cepts involved rather than the details of the
dent consultants were available in the computer
calculations.
labs in the evenings and on weekends.
While we have tried to incorporate both of these
aspects of Maple into the course, our focus is on
the first: using Maple to help teach and learn cal-
culus.

2.3 History
3.1 Recitations
The efforts to incorporate Maple into calculus de- Our first goal was to teach the students enough
scribed in this paper build on the efforts of others about Maple to allow them to use it effectively
in previous years. In Fall 1991, an experimen- on their own. To do so, the first three weeks of
tal section of Calculus II (for students with ad- recitations were held in a workstation-equipped
vanced placement credit) met regularly in a PC- classroom/lab. Experience from the previous year
equipped classroom/lab. Also, an experimental showed that standing in front and writing on the
course combining calculus and physics used Maple board was a poor way to explain Maple (the stu-
regularly. Anecdotal evidence suggests that stu- dents cannot see the board well from behind the
dents were not completely satisfied with either ap- computer monitors), so we prepared tutorial hand-
proach; however, the experience gained by the in- outs to lead students through the basics of Maple.
structors helped guide later experiments. The tutorial handout for the first week led stu-
dents through starting Maple, getting help, using
In Fall 1992, all recitations of Calculus I were Maple as a calculator, basic Maple commands and
held in a workstation-equipped classroom/lab. syntax, and some basic commands for algebra. All
The Teaching Assistants showed students how to algebra was limited to expressions (not functions)
use Maple to solve problems related to their home- for this first week. For this first week only, we had
work. Although it did not generate a student two TAs in each recitation to help deal with the
revolt like at the University of Pennsylvania [2J, initial confusion of logging in, lost account names
this experiment was not a complete success. Sur- and passwords, etc.
vey results indicated that many students felt that The tutorial handout for the second week ex-
they did not learn enough about Maple to use it plained more commands for algebra, introduced
effectively on their own, and that the recitation lists (which arise in solving equations) and the
time would be better spent going over homework Maple notation for functions, and showed how to
and answering questions, rather than dealing with generate simple plots. Most students appeared to
Maple. Some compared this approach to a typing be able to work through these tutorials during the
class: "The TA wrote a command on the board recitation; some optional exercises were included
and we typed it in but didn't understand any- for working at home, but were ignored by most
thing." students. Having students work in pairs worked

64
well: this appeared to help overcome the typing were intended as learning exercises, grading was
problems and general confusion experienced the intentionally lenient: anyone making an honest ef-
previous year. It was also inevitable, since there fort would get a majority of the credit available.
were more students per recitation than worksta- Each project counted 5% of the course grade, and
tions in the lab. included an optional extra credit section.
The third week of recitation (still in the com- The three projects for the Fall consisted of:
puter lab) was devoted to working through a
"Practice Project" intended to give students an • Project 1: The Derivative.
idea of what to expect in the Maple Projects they This led students through the concept of the
would later do on their own (see below). This derivative as the slope of the line tangent to
project led students through some simple transfor- a curve, using both graphics and numerical
mations of functions (translations and dilations) calculations in an attempt to beat the con-
and then used these ideas in solving a simple ap- cept to death. An application section consid-
plied problem (finding the equation of a curve de- ered a problem involving a rocket under con-
scribing the shape of a tunnel). Most students did stant thrust, using the derivative to compute
the first part without trouble, while many were the acceleration from the velocity. Maple was
not able to complete the last part. This work was used to estimate the time at which an astro-
not handed in. naut would black out due to the effects of ac-
All remaining recitations were held in a regu- celeration. An extra credit section pointed
lar classroom and devoted to reviewing material out that the acceleration increases rapidly as
from lecture, going over homework problems, and the fuel runs low. and asked students how to
answering questions. Thus, after the third week, adjust the assumptions to avoid crushing the
students were on their own as far as using Maple. astronaut.
The book Maple V Flight Manual [3] was recom-
• Project 2: Optim·ization.
mended as a useful supplement, but it appears
An initial section had the students use Maple
that few students bought it.
to find the derivative of a function. set it
equal to zero, and solve for the critical points.
3.2 Maple Projects Graphs were used to see what was happen-
ing, and Maple's fsol ve command was in-
Students completed three take-home Maple troduced. An application section usell Maple
Projects during each semester. The goals of the to solve the classic textbook min-max prob-
projects were two-fold: to reinforce the calculus lem of moving a beam around a rectangular
concepts being learned through lecture and home- corner in a hallway. and then illustrated the
work, and to show how Maple can be used as a power of Maple by considering the case where
tool to solve "real-life" problems. Each project the thickness of the beam was not negligible
consisted of a handout with explanation and in- (i.e., a 4 x 4). An extra credit section gener-
structions and an answer sheet to be completed alized the problem by allowing the beam to
and turned in. Some of the projects were entirely be tipped in the vertical.
new, while others were based on ideas from other
sources, notably [4]. Students had one week to • Project S: The Definite Integral.
complete each project, and were allowed to work This used \.Olllmands from Maple's student
in pairs if desired (less than half did so). Most stu- package to illustrate areas under a curve
dents used Maple on their own PCs, rather than (graphically and mUllerically). Students then
go to one of the networked workstations or PCs. used an integral to solve an applied probabil-
Given the large enrollment and limited staff, ity problem (what percentage of sheet steel
we tried to design the projects so the instruc- can be expected not to meet the specifica-
tions would be crystal clear (to avoid unnecessary tions?); this integral could not be evaluated
confusion) and to make the grading possible in a using antiderivatives. An extra credit sec-
reasonable amount of time. Initially, most of the tion explored the accmacy of answers given
commands needed were given explicitly in the in- by various numerical approximations (left-
structions (with explanation); later, students were sum, right sum, middlesum. trapezoid, and
expected to figure out how to accomplish a given simpson).
task in Maple on their own. Since the projects

65
The three projects for the Spring consisted of: • On the first day of class, simple animations
of secant lines approaching a tangent line and
• Project 1: Volumes of Solids of Revolution. boxes filling up the area under a curve were
An initial section led the students through used to illustrate the dynamic nature f)f the
defining and plotting a solid of revolution fundamental ideas of calculus.
(like a football), and computing its volume
by the disk method. In the next section, • In discussing limits (e.g., lim:z:~o sin(x)/x =
students repeated this for a doughnut using 1), it proved useful to have Maple generate
the washer method, and then worked out the tables of numerical values and graphs (these
Maple commands for the shell method on seem more believable when produced on the
their own. An extra credit section had stu- spot, rather than copied from the instructor's
dents compute the volume of frosting needed notes).
to cover the top of the doughnut (maple frost- • Using Maple helped bring Newton's method
ing, of course). to life.
• Project 2: Numerical Integration. • Using Maple for graphs was especially helpful,
After defining the "exact" expression for the since it allows one to draw accurate graphs
period of a pendulum as an integral, this that everyone can see.
project used Maple to investigate the accu-
• In discussing infinite series, the fact that the
racy of the linear approximation to the pen-
harmonic series diverges was made more be-
dulum and the accuracy of the trapezoidal
lievable by using Maple to comute partial
approximation to the integral. Students also
sums of a large number of terms (e.g., 10 10 ,000
found the length required for a given period.
terms).
• Project 3: Convergence of Infinite Series. In addition to helping communicate the concepts
After introducing the Maple commands to being taught, using Maple in lecture helped the
generate (and plot) partial sums of a series, students take the program seriously, and provided
students used Maple to investigate whether a them with examples of its use. Also, it helped
given series would converge, and estimated its break up the monotony of the lecture format,
sum. They then computed approximations to which may have helped enhance learning and im-
7r using four different series and compared the prove students' perceptions of the course.
number of terms required to give three deci- We started the year using the DOS version of
mal place accuracy. Maple on a 386 PC. This arrangement proved frus-
trating, since the characters produced were barely
Grades on the Maple Projects were uniformly readable from most of the lecture hall. Several stu-
high, which is not suprising given the simple na- dents suggested trying the PC-windows version;
ture of the projects and the intentionally lenient this proved to be great, and was used the rest of
grading policy. It appears that most students the year. With the larger fonts available, text was
were able to complete most of each project with- clearly visible from everywhere in the room, and
out trouble. While few students expressed great the black-on-white format was much clearer. Also,
enthusiasm for the projects, few complaints were the ability to point and click on a graph to find
heard. Finally, despite the opportunity given to coordinates of a point was helpful.
work with a partner, it is likely that some cheat-
ing also occurred (this was suggested by several
students); given the current lack of staff for the 3.4 Homework
course, it is difficult to see what could be done to Students turned in homework to be graded ap-
prevent or even detect it. proximately once per week. None of the problems
specified using Maple (with the exception of the
3.3 Lectures Maple projects). However, students were encour-
aged to use Maple to check their answers (not to
Maple was used every day in lecture, typically for do the work!), and they were shown how to do so
5-10 minutes of a 50 minute lecture. The pri- in many cases in lecture. It appears that about
mary use was to help illustrate the concepts being 30-40% of the students did use Maple this way
taught. Some examples include: (see section 4 below).

66
3.5 Exams 4 Evaluation
During the fall semester, each of the three hour ex- There was relatively little negative feedback about
ams contained questions which involved Maple, in Maple during the year. In six opportunities for
each case worth a total of 10% of the exam. The written feedback about the course, few students
purpose of these questions was two-fold: to en- expressed an opinion about Maple (although those
courage students to learn Maple, and to evaluate who did were often negative). In talkiug with stu-
whether or not they had. The first exam had two dents and TAs, it appeared that student reactions
questions testing basic Maple syntax, the second to Maple were generally favorable.
had two questions about how to express certain A survey about Maple conducted in lecture dur-
operations in Maple, and the third asked which ing the last week of class each semester provided
of five sequences of Maple commands would solve more quantitative feedback. The respOIlses are
a given max-min problem. With only one excep- shown in Table I for the Fall semester (299 of 444
tion, average scores on the Maple questions were students responding) and Table II for the Spring
substantially higher than on the non-Maple ques- semester (177 of 361 students responding). Note
tions; nevertheless, many students were upset that that questions 1 and 10 were changed between
Maple appeared on the exams, and there was great semesters. For comparison, many of the state-
relief when it was announced that the final exam ments on the survey were taken directly from a
would not involve Maple. similar survey used at Rensselaer Polytechnic In-
During the spring semester, no Maple appeared stitute (RPI) and reported in [1]. The columns
on the exams. In retrospect, this was a mistake. labeled "RPI" give the percentages of students at
as several students pointed out: it allowed stu- RPI who agreed with the statement in Fall 1992
dents who "worked with a partner" on the Maple (Table I) and Spring 1993 (Table II). It should
projects to avoid any real involvement (and learn- be noted that the calculus course at RPI has sub-
ing) with Maple. stantially more time (3 or 4 lectures. 1 recitation, 1
computer lab per week) and resources (31 TAs for
about 1000 students) than at Clarkson (2 lectures,
1 recitation, no computer lab, with 3.5-4 TAs
3.6 Notes
for about 400 students). Finally, a simple survey
To keep our focus on learning calculus-rather about Maple was done at Clarkson ill Fall 1992;
than struggling with computers-we intentionally only one of the questions was repeated here (#17),
stuck to the basics of Maple. In particular, we did as the others did not seem applicable. In 1992 the
not teach or use: responses for #17 were 1%, 10%, 28%, 28%, and
31 % (strongly agree to strongly disagree), showing
that students in the present year feel significantly
• programming constructs (if/then, loops, pro-
more comfortable with using Maple on their own.
cedures, etc.)
Students were also given the opportunity to
write their own comments on the surveys. While
• advanced graphics their written comments were few. many of these
were negative. A common thread was the re-
• printing Maple sessions or graphics quest for more help in learning Maple: either a
handbook, a separate computer lab, or a separate
Implicit plots and animation were used a few times course in Maple. Indeed, in the Spring--when
in lecture, but the students were not asked to use many students were enrolled in the engineering
them. computing course---several students wrote that we
During the Spring semester, no additional in- should "make Maple a separate course" and have
the calculus course "stick to learning calculus".
struction in Maple was given (except for optional
review sessions and help for the few students who
were not enrolled in the course in the Fall). How-
ever, most of the students (the engineering ma-
jors) were also enrolled in an introductory engi-
neering course in computers which used Maple for
30-60% of the time.

67
strongly uncertain or strongly
agree agree no opinion disagree disagree BPI
1. The first three weeks of recitation in the computer 5 25 9 44 15
lab taught me enough about Maple to be able to use
it effectively in this course.
2. The use of Maple in lectures helped me to better 11 39 21 20 8
understand the concepts of calculus.
3. The Maple projects were interesting. 6 31 26 25 12 50
4. The Maple projects were reasonable in length and 12 52 20 12 4 54
difficulty.
5. Working on the Maple projects with a partner was 37 38 17 3 3 86
helpful and worthwhile.
6. Working the Maple projects helped me to better 7 29 27 26 10
understand the concepts of calculus.
7. Attending weekly computer labs (in addition to 25 23 18 23 10
recitations) would have been better than take-home
Maple projects.
8. I used Maple often to check my homework or to 10 26 12 24 27
help understand material from class.
9. I prefer to use Maple on my personal com- 31 30 26 6 5
puter rather than on one of the networked computers
(workstation or PC) in the computer lab rooms.
10. The exam questions involving Maple were rea- 10 33 18 24 14
sonable and fair.
11. Maple enables me to solve some problems that 32 46 11 6 4 87
would be almost impossible by hand calculations.
12. By using Maple I am able to see new approaches 5 29 31 25 8 57
for solving some problems.
13. Maple was easy to apply to problems of various 6 23 25 34 10 41
kinds.
14. The use of Maple in this course has improved my 2 14 31 35 16 42
problem-solving skills.
15. The use of Maple revealed aspects of calculus 3 21 35 29 11 49
that I hadn't thought about before.
16. The use of Maple was satisfactorily interwoven 11 46 20 17 6 71
with the rest of the course.
17. I have learned Maple well enough to feel confident 6 30 19 29 15
using it on my own.
18. My knowledge of Maple will probably help me in 12 32 26 17 11 70
other science and engineering courses.
19. I enjoyed the course. 14 36 23 16 9 76
20. I would rather have had a calculus course that 21 15 23 23 16 46
did not use Maple.

Table I: Responses (percent) to Maple Survey (Calculus I, Fall 1993)

68
strongly uncertain or strongly
agree agree no opinion disagree disagree RPI
1. I learned enough about Maple last fall in Calculus 13 44 10 26 6
I to be able to use it effectively in this course.
2. The use of Maple in lectures helped me to better 12 38 23 19 7
understand the concepts of calculus.
3. The Maple projects were interesting. 4 30 31 25 10 64
4. The Maple projects were reasonable in length and 8 54 15 16 6 64
difficulty.
5. Working on the Maple projects with a partner was 42 36 15 3 2 89
helpful and worthwhile.
6. Working the Maple projects helped me to better 4 37 23 23 12
understand the concepts of calculus.
7. Attending weekly computer labs (in addition to 15 20 19 23 23
recitations) would have been better than take-home
Maple projects.
8. I used Maple often to check my homework or to 12 33 14 24 17
help understand material from class.
9. I prefer to use Maple on my personal com- 20 28 23 13 15
puter rather than on one of the networked computers
(workstation or PC) in the computer lab rooms.
10. I sometimes use Maple now for learning or solving 6 30 21 22 20
problems, even when it is not required for a course.
11. Maple enables me to solve some problems that 38 47 10 2 2 91
would be almost impossible by hand calculations.
12. By using Maple I am able to see new approaches 4 29 39 21 6 69
for solving some problems.
13. Maple was easy to apply to problems of various 3 41 26 22 7 59
kinds.
14. The use of Maple in this course has improved my 2 21 37 31 7 57
problem-solving skills.
15. The use of Maple revealed aspects of calculus 5 28 35 25 6 62
that I hadn't thought about before.
16. The use of Maple was satisfactorily interwoven 14 53 13 15 5 82
with the rest of the course.
17. I have learned Maple well enough to feel confident 14 49 12 14 9
using it on my own.
18. My knowledge of Maple will probably help me in 28 41 12 10 7 74
other science and engineering courses.
19. I enjoyed the course. 12 44 25 10 8 80
20. I would rather have had a calculus course that 10 10 24 32 22 36
did not use Maple.

Table II: Responses (percent) to Maple Survey (Calculus II, Spring 1994)

69
5 Conclusions and Thoughts Professor A. S. Fokas continued that effort. The
suggestions of Professor Michael Felland were also
for the Future of great help. The TAs for the course (Ben-
Overall, our experience with introducing Maple in jamin Brown, Joel Helms, Taras Lakoba. Frank
our calculus course was positive. The student re- Michielsen, and Anwar Saleh) did much of the
actions, while not overwhelmingly positive, indi- front-line work with the students. The Educa-
cate that many students found the use of Maple at tional Resource Center staff (especially Thomas
least acceptable, and in some cases helpful. On the Wright and Robert Barringer) provided invaluable
other hand, some students appear to view Maple technical support. Finally, the people at Waterloo
as an add-on to the course, and as such it provides Maple Software made this work possible by their
a convenient focal point for complaints. Some pos- generous license which allowed us to put Maple on
itive aspects: all student computers.

• Providing tutorial handouts allowed recita-


tions in the computer lab to function well. References
• Allowing students to work together on Maple [1] W. E. Boyce and J. G. Ecker, "The Computer-
proved to be a good idea. Oriented Calculus Course at Rensselaer Poly-
technic Institute," presented at the Maple
• Using Maple in lectures opened up new ways
Summer Workshop and Symposium, Ann Ar-
to illustrate concepts, made numerical results
bor, ML August 1993: accepted for publication
more believable, and contributed to a more
in The College Mathematics Journal.
interesting style of presentation.

• Having Maple on the student PCs (rather [2] T. J. DeLoughry, T. J., "A Revolt Over
than in a computer lab to which students Software," Chronicle of Higher Education,
must make a separate trip) made it much 11/24/93, p. AI?
more palatable. [3] W. Ellis, E. Johnson. E. Lodi, and D.
Some possible improvements for the future: Schwalbe. Maple V Flight Manual. Pacific
Grove, California: Brooks/Cole, 1992.
• Identify a specific subset of Maple commands
to be learned and used in the course, and pro- [4] M. H. Holmes, J. G. Ecker, W. E. Boyce.
vide a handout listing and describing them. and W. L. Siegmann, Exploring Calculus with
Maple. Reading, Massachusetts: Addison-
• Require students to purchase an appropriate Wesley, 1993.
printed manual for Maple, such [3].

• Find more realistic applications to include in


the Maple projects. Scott Fulton earned a B.A. degree from Kala-
mazoo College and M.S. and Ph.D. degrees from
Has using Maple increased students' under- Colorado State University. Since 1986 he has been
standing of calculus? It may be impossible to an- at Clarkson University, where he is currently Asso-
swer this question. Nevertheless, it appears that ciate Professor in the Department of Mathemat-
even when used in the relatively low-key way de- ics and Computer Science. Besides teaching, he
scribed here, Maple can have a positive effect on conducts research in computational mathematics,
the course. Students have been exposed to an- including spectral, multigrid, and semi-implicit
other way of approaching calculus and have seen methods, and applications to atmospheric mod-
the power of a modern tool for doing mathemat- eling and numerical weather prediction. He may
ics; this should help equip them for subsequent be contacted at:
courses and careers.
Dept. of Mathematics and Computer Science
Acknowledgements: If this work has been success- Clarkson University
ful, it is in part due to the efforts of those who Box 5815
came before me and those who helped. Profes- Potsdam, NY 13699-5815
sor A. George Davis helped bring Maple to Clark- email: fulton<Q)sun.mcs.clarkson.edu
son and was the first to use it in calculus here;

70
ENLIVENING THE MATHEMATICS CURRICULUM WITH MAPLE

G. F. Fitz-Gerald and W. P. Healy


Department of Mathematics, Royal Melbourne Institute of Technology, Melbourne,
Victoria, Australia

Abstract The availability of such a small number of machines


meant that any experiment in the use of Maple
We describe the use of Maple in the undergraduate
would involve only small-enrollment subjects. For
mathematics curriculum at a large Australian Uni-
this reason the introduction of Maple to the teach-
versity, the Royal Melbourne Institute of Technology
ing programme was at first restricted to our math-
(RMIT). Maple has been integrated into (a) the first- ematics degree course. The first-year quota for
year programme of a specialized Mathematics Degree
this course is approximately sixty students. (In
Course for mathematics majors and (b) some higher- contrast, the first-year service calculus subject has
year service mathematics subjects for Engineering and
an enrollment of approximately eight hundred stu-
Applied Science students. Maple sessions are sup-
dents.) Four classes of fifteen first-year mathemat-
ported by high-quality teaching materials published as
ics degree students became the "guinea pigs" for
part of the RMIT Lecture Notes in Mathematics Se-
our introduction of Maple to enliven the teaching
ries. We believe the introduction of Maple has en-
of a traditional mathematics programme at RMIT.
livened the teaching and learning of mathematics at
RMIT. Some discussion is given of the changes in both Our perception of the effect of introducing Maple-
teaching methods and subject content brought about based material into this level of the degree pro-
by the use of Maple. The results of a student question- gramme is that traditional topics that had become
naire and an analysis of student performance in one of unpopular with students were now approached in
the higher-year engineering mathematics subjects are a more understanding way. The topic of Riemann
also presented. sums in integration theory is a case in point. En-
couraged by student response to' the use of Maple in
the first-year mathematics degree programme, we
1 Introduction have begun to introduce similar material into some
of the larger-enrollment service subjects. Over
The mathematics department at RMIT introduced the past few years the content of some subjects
Maple into the teaching programme in 1992. A
had to be modified because of the lack of alge-
subsidised licence was obtained on the adoption braic manipulation skills and trigonometrical and
of the textbook [1] in the large-enrollment first- geometrical knowledge on the part of many stu-
year service calculus subject. This provided the dents entering tertiary education. This has meant
opportunity to install Maple (Version 4.2) on a that some of the more interesting, but more ana-
centralised computer network supporting 17 Mac-
lytically demanding, aspects of the subjects could
intosh SE computers. Subsequently we upgraded only be touched upon. Maple now provides the
to Version 5 and more recently to Version 5 Release opportunity to include varied and realistic exam-
2. ples on these more difficult topics. Students can
concentrate on the parameters of any particular
model rather than on the intricacies of the meth-
ods involved. (We remark parenthetically that this
may force the mathematical community to confront
the possibility that an education in mathematics
should provide more than simply a kit bag of tools
applied to a range of contrived problems.)

71
In Section 2 below we give details of the integra- 2.2 Maple Laboratory Sheets
tion of Maple into the first year of the mathematics
degree course and discuss the educational philos- The introduction of Maple was implemented by
ophy that motivated this teaching initiative. In an interested and enthusiastic team of writers who
Section 3 we describe the use of Maple in higher- were familiar with the entire course and developed
year service mathematics subjects and present an material that would support the overall aims of the
evaluation based on a student questionnaire and programme. Initially it required the weekly prepa-
an analysis of student performance in one of these ration of a hand-out, in the form of a laboratory
subjects. Planned new developments are outlined sheet along the lines suggested in [2], on some topic
in Section 4 and our conclusions are summarised in of the course. As the Maple sessions ran in parallel
Section 5. with the traditional laboratory sessions, each week
students were solving similar problems using both
pen and paper calculations and Maple. The oppor-
2 Mathematics Degree tunity to explore algebraically more difficult prob-
lems than a typical modern student could handle
without recourse to a symbolic manipulation pack-
2.1 Structure of the Programme age was not lost on the developers of the Maple
laboratory material. In Table 2, a list of all the
As was mentioned in Section 1, Maple was intro-
duced into the teaching of the first-year mathemat- first-year topics, grouped by subject area, for which
Maple laboratory sessions have been developed is
ics degree programme in 1992. This was achieved
by developing a set of Laboratory Sheets structured presented.
around a pre-existing mathematics laboratory sub- A handbook of laboratory sheets for use by stu-
ject in which students performed "pen and paper" dents in the Maple sessions has now been prepared
calculations. The first year of the mathematics de- in two parts with one part for each semester. The
gree programme is a traditional one that covers the handbook has been published by the Department
areas of analysis, linear algebra and applied mathe- of Mathematics as part of the RMIT Lecture Notes
matics (mathematical modelling). Presentation of in Mathematics Series [3,4]. (These handbooks re-
the material has always been in the form of small flect the high quality of the lecture note series in
classes that are typically a combination of lecture general and provide excellent resources to the stu-
and tutorial. However, in support of the theoreti- dent at a modest cost.) Each laboratory sheet in-
cal presentations, a formal component of the course cludes:
involves students attending the mathematics labo-
ratory sessions. In these, staff assistance can be
obtained while the students attempt problems re- • a statement of the aims of the session;
lated to work recently covered in lectures.
• a review of the mathematical background for
The five core subjects and one laboratory subject the session;
in the first year of the mathematics degree course
are given in Table 1. All of these are year-long • worked examples;
subjects taken over two 13-week semesters. In
addition to the core subjects, there are also four • student exercises;
hours per week of non-mathematics elective sub-
• the syntax of the Maple commands to be
jects. The mathematics laboratory subject MA192
used;
was designed to develop the students' problem-
solving skills with problems being drawn from the
• a report sheet.
four core mathematics subjects (MAlll, MA212,
MA532 and MA533). Only one of the two contact
hours for MA192 is now devoted to solving prob- A shortened version of the laboratory sheet for the
lems by the traditional pen and paper methods. session on Polar Coordinates is given as an exam-
The other contact hour is taken up by a weekly ple in Appendix A. (The Maple command syntax
Maple Laboratory Session. and report sheet are omitted in this version.)

72
Table 1: Core subjects in first year.

Subject Code Subject Name Hours/Week


MA1l1 Analysis 1 3
MA212 Linear Algebra 2
MA532 Mathematical Methods
and Models A 3
MA533 Mathematical Methods
and Models B 2
CS600 Digital Programming 1 4
MA192 Mathematics Laboratory 1 2

2.3 Maple Laboratory Sessions 2.4 Educational Philosophy


The four weekly one-hour Maple classes, each with The aims for student learning or educational 'phi-
about fifteen students, are supervised by an aca- losophy' behind the introduction of Maple to the
demic staff member. The staff member is either a first-year mathematics degree course are as follows.
lecturer or tutor in the first year of the mathemat-
ics degree programme. The role of the supervisor 1. The Maple sessions are intended to support
is to: (rather than completely replace) the tradi-
tional pen and paper laboratory sessions.
• explain the aim of the session to students;
2. The use of Maple promotes students' under-
• respond to difficulties that students may have standing by engaging them actively with the
on the use of Maple, the Macintosh SE sys- subject. In each Maple session, the students
tem or the mathematics underlying the lab- review and use mathematics that they have
oratory session; met at least twice before in the preceding two
or three weeks - once in lectures and once in
• observe student progress and offer assistance
to individual students. the pen and paper laboratory sessions. The
mathematical content is therefore reinforced
by being dealt with again in a different con-
In order to prepare for the laboratory sessions, stu-
text.
dents are encouraged to read the laboratory sheets
beforehand and, if necessary, to review the rele- 3. Maple's graphics capabilities enable the stu-
vant mathematical topics. They are expected to dents to plot graphs of functions and to visu-
go through the worked examples using Maple dur- alise solutions of differential equations very
ing the session and to submit their solutions to the easily. In the past, although most students
exercises on the report sheet at the end of the ses- were capable of deriving the formal solutions
sion. The report sheets are marked and returned to of differential equations, for example, they
the students at the beginning of the next session. often had a poor understanding of the be-
haviour of the solutions and their physical
The Maple laboratory sessions contribute to the
implications.
assessment of the subject MA192, for which the
only grades available are pass and fail. In order to 4. Maple's computational power and algebra
obtain a pass in MA192 students are first of all re- 'engine' enable students to solve problems
quired to attend classes in the subject. They must more efficiently and to tackle problems that
then obtain a passing grade in at least 75% of the are more difficult algebraically than those
traditional pen and paper problem-solving sessions that modern students are capable of dealing
and at least 75% of the Maple laboratory sessions with otherwise. This allows the possibility of
taken over the whole academic year. dealing with more realistic problems.

73
Table 2: List of first-year topics available as Maple laboratories.

Subject Topics
Maple Introduction
Variables and functions
Analysis Inequalities
Composition of functions
Limits
Differentiation
Riemann sums
Non-linear equations
Integration
Polar coordinates
Functions of two real variables
Sequences and series
Linear Algebra Spanning sets
Vectors
Matrices
Linear transformations
Inner product spaces
Eigenvalues and eigenvectors;
diagonalization
Applications of diagonalization
of matrices
Mathematical Methods Differential equations
and Models Particle motion
Phase plots
Resonance

5. It is easy to create individual Maple assign- 3 Service Subjects


ments for students, although the need for do-
ing this has not actually arisen in MA192. 3.1 Comparison with Mathematics
Degree
Based on the success of the Maple material with the
6. The students are taught how to use a sym- mathematics degree students, a similar programme
bolic manipulation package. That mathe- is being developed for some of the large-enrollment
matics students should be aware of and fa- service subjects. Material has already been pre-
miliar with mathematical software packages pared for courses in MA003 Differential Equa-
is a desirable educational end in itself, quite tions A, MA004 Differential Equations B, MA015
apart from the use of such packages as teach- Residues and Integral Transforms and MA019 Fi-
ing aids or as tools for the students during nite Element Methods. We will discuss here only
their degree programmes. the subjects MA003 and MA004. These courses
have no time allowance for the formal presenta-
tion of Maple material and the large numbers pre-
clude the formal laboratory sessions adopted in the

74
mathematics degree course. The same style of lab- Macintosh SE Laboratory when it is not being used
oratory session is nevertheless followed. The cur- for classes. As these students are in the third year
rent availability of Maple on only a small number of of an engineering or physics degree course, they
machines for a large number of students is clearly have much more experience in computer program-
a problem from the point of view of conducting ming and the use of computer software packages
supervised laboratory sessions. than first-year mathematics students.
Maple laboratory sessions for MA004 cover the fol-
3.2 Differential Equations A lowing topics:

Maple laboratory sessions have been developed for


the four main topics in the subject MA003 Differ- • Introduction to Maple;
ential Equations A. These cover the areas of • Generalized Fourier series;

• Laplace transforms; • Partial differential equations;

• Series solutions of differential equations; • Application of Bessel functions;


• Fourier series; • Phase plots.
• Partial differential equations.
For each session, laboratory sheets are provided for
MA003 is taken by the majority of students in student use. These have the same format as the
the Faculty of Engineering and the Department of sheets used in MA192. The students are expected
Applied Physics at RMIT. The enrollment is 550 to go through the worked examples in the labora-
students taught by several staff in classes rang- tory in their own time and are required to submit
ing in size from 40 to 120. Because of the num- their solutions to the exercises on the report sheet.
bers involved, no attempt has been made so far to Students are required to submit three assignments
make the Maple sessions a compulsory part of the which, together, contribute 20% of the total assess-
MA003 programme. Once a wider access to Maple ment for the subject. All three assignments require
is achieved this situation will be redressed. the use of Maple.

3.3 Differential Equations B 3.3.1 Evaluation


Maple laboratory sessions have been developed for Student Questionnaire
several topics in the subject MA004 Differential
Equations B. The aim of MA004 is to extend A questionnaire was handed out to the MA004
the basic techniques required in the solution of class near the end of the course in 1993. The stu-
dents were encouraged to complete the question-
boundary-value problems in mathematical physics
and engineering. MA004 also includes a brief intro- naire but were told that doing so was voluntary.
duction to systems of non-linear differential equa- Eleven students answered the questionnaire. Even
tions and stability. though this represents only about one sixth of the
class, there was nevertheless a spectrum of opinion
MA004 is a compulsory subject in the third year expressed in the answers.
of the Bachelor of Engineering course in Electrical
Engineering at RMIT and is taught as one single The questionnaire consisted of the following three
class. The class normally has an enrollment of 60 items. (Note that DEB stands for Differential
students with a majority of these being Electrical Equations B.)
Engineering students. The remaining are usually
Applied Physics students who take MA004 as an 1. What aspects of the use of Maple have helped
elective subject in their final year. your understanding of topics in DEB?
The lecturer demonstrates the use of Maple during 2. Please comment on what aspects of the use
class using a portable computer and a screen pro- of Maple you feel have hampered your devel-
jector. MA004 students are given free access to the opment of understanding of topics in DEB.

75
3. What, in your opinion, are the three most way in which this enabled them to visualize solu-
important things you have learned from tions of differential equations. This is illustrated in
using Maple in DEB? the answer to Question 1 by Student A and in the
comment by another student that 'seeing in three
A broad categorization of the respondents is that dimensions the graphical output of heat equations'
nine were 'positive', i.e. they found Maple useful was one of the three most important things learned
in helping to learn the subject, and the remaining from using Maple. Seven of the eleven respon-
two were 'negative', i.e. they did not find Maple dents to the questionnaire mentioned this aspect
useful. The answers of a typical 'positive' respon- of Maple as a positive feature. Four of the respon-
dent (Student A) and of a 'negative' respondent dents did not answer Question 2 and two others
(Student B) to the three questions are reproduced made only brief comments to the effect that the
in full below. package was not very 'user friendly' (see also the
response of Student B given above). Others, how-
Student A
ever I had deeper specific criticisms in response to
1. Visualizing the series and graphical solution Question 2. For example,
of the boundary-value problems; understand-
ing the steps used in deriving the Fourier co- Perhaps try to tie the Maple commands
efficients. more in with the lectures, but keep the
assignments and examples.
2. The process of producing the program output
is not necessarily time consuming. However,
getting these printed (when many people are and
on the system) can be. One suggestion-
someone from the Mathematics Department Sometimes the Maple exercises are so
needs to assist the computer staff with Maple easy to do because you just had to copy
printing. the worked examples (maybe change a
few things), so at times like that we
3. (a) Using another or alternative computer weren't really thinking about the prob-
package to 'Mathematica'. lem on our own.
(b) To visualize particular senes expan-
sions. Both of these students were positive about using
(c) Being able to solve 'long-winded' Maple, however. Their answers to Question 1 were
boundary-value problems.

Student B Being able to verify theorems from lec-


tures; also being able to change vari-
1. I found that Maple was unable to enlighten ables and compute new answers quickly
me in the understanding of topics in DEB. I and easily.
believe it is a waste of our time using it.
2. The friendliness towards the user was awful. and
3. (a) Familiarization with the keyboard,
monitor and disk drives. The preparation for the assignments
where we had to look through the
(b) Ergonomics in my study environment. lecture notes to understand the solu-
(c) One more program that I can write on tion process of the assignment. The
my resume. explanation-type questions were good
because they tested our knowledge and
The single most common aspect of Maple men- understanding of DEB concepts.
tioned by the students was its two- and three-
dimensional graph-plotting capabilities and the respectively.

76
Analysis of Student Performance ment. Its effectiveness in terms of students' perfor-
The assignment requirements were not only to pro- mance and understanding needs to be further eval-
duce numerical answers or graphical output but uated. It will be useful to carry out evaluations of
also to give a physical interpretation or commen- other subjects along the lines of that already dis-
tary on the results obtained. Most students did the cussed for the subject MA004.
assignments very well. Approximately 84% of the
students achieved a total mark of 15 or greater out
of 20 for the three assignments combined. Only 4.2 New Laboratory
5% of students achieved a mark of less than 10 The large numbers enrolled in service courses is
out of 20. Many students sought advice from the a major difficulty with attempting to introduce
lecturer, particularly for Assignment 1. The chief Maple. However the department has recently ac-
request was for clarification of technical details of quired new accommodation that includes a labo-
Maple commands. Many students obtained their ratory with approximately fifty 486 machines each
own copy of Maple for use on their own comput- running Maple under the Windows environment.
ers. A few students went to extraordinary lengths This should also have an impact on perceptions
in producing graphical output for the assignments of "user friendliness" of Maple. We look forward
and this was accompanied by commentaries and to the opportunity to exploit this in introducing
interpretations that indicated an excellent under- Maple in service mathematics where the provision
standing of the subject matter. These students of more realistic examples has always been a prob-
were also among the top performers in the exami- lem. Furthermore, we intend to schedule super-
nation. vised classes in this new laboratory for all students.
The pass rate for MA004 in 1993 was 80%. This
The fact that some students have their own copy
compares with pass rates of 74% and 70% in 1992 also assists the introduction of Maple to these
and 1991 respectively. Of course not too much can
courses. We are happier suggesting students con-
be read into one year's figures but it is at least
sider such a purchase once a full version is readily
clear that the introduction of Maple has not had a available on the RMIT campus.
detrimental effect on student learning in this sub-
ject. On the contrary, there is evidence from the
answers to the examination questions that some 5 Conclusion
common misconceptions held by students in the
past have to a large extent been eliminated by the Maple has been successfully introduced into a va-
use of Maple. For example, egregious errors in the riety of mathematics programmes covering a wide
manipulation of infinite series solutions of partial range of topics offered at RMIT. Supporting ma-
differential equations were almost entirely absent. terial in the form of laboratory sheets provides a
It is significant that an understanding of such ma- useful student resource in understanding the math-
nipulations was necessary in all three assignments ematics and the implementation of the Maple ma-
in order to be able to use Maple to produce the terial.
required solutions and graphs. This argument is The introduction of Maple to the mathematics
supported by the comment of one student, already teaching programme has helped to put into fo-
quoted above, that 'the preparation for the assign- cus the mathematically important elements of the
ments where we had to look through the lecture mathematics curriculum. There is an opportunity
notes to understand the solution process of the as- to delineate precisely the core mathematical ideas
signment' was an aspect of the use of Maple that needed to be presented in a course without the
helped the understanding of topics in this subject. added distractions of routine methods getting in
the way of understanding any new material be-
4 Planned Developments ing presented. Too often students are labouring
in their grasp of new topics simply because of their
4.1 Evaluation lack of technical expertise in material covered at
The integration of Maple into our undergraduate an earlier stage (often before they arrive at the ter-
programmes is still in its early stages of develop- tiary level).

77
Students participating in the programme have en- (a) if the equation is invariant under the sub-
joyed the experience and have responded in posi- stitution (r,O) --+ (r, -0), then the curve is
tive ways. Many use Maple to solve problems in symmetric about the initial line;
other subjects they are currently studying. This
(b) if the equation is invariant under the substi-
develops further the use of Maple in the entire
tution (r,O) --+ (r,7I'- 0), then the curve is
mathematics curriculum at RMIT.
symmetric about the straight line 0 = ~71' -
this is the straight line through the origin and
References perpendicular to the initial line;

[1] Stewart, J. Calculus, 2nd ed., Belmont Califor- (c) if the equation is invariant under the sub-
nia, Brookes/Cole, 1991. stitution (r, 0) --+ (-r, 0) or the substitution
(r,O) --+ (r, 0+ 71'), then the curve is symmet-
[2] Bauldry, W. C., & Fielder, J. R. Calculus ric about the origin.
Laboratories with Maple, Belmont California,
Brookes/Cole, 1991. Points of intersection of two curves defined by po-
[3] Connell, H. J., Fitz-Gerald, G. F., Healy, W. P. lar equations are obtained by solving the equations
and Luo, Y. S. Maple Laboratory Sessions Part simultaneously for rand O. However, this method
1, RMIT Lecture Note in Mathematics, Mel- may not give all points of intersection, since some
bourne, Mathematics Department RMIT, 1993. points of intersection may have to be represented
by two different sets of polar coordinates in order
[4] Connell, H. J., Fitz-Gerald, G. F., Healy, W. P. to satisfy the two equations. In these cases, it is
and Luo, Y. S. Maple Laboratory Sessions Part often necessary to transform the polar equation of
2, RMIT Lecture Note in Mathematics, Mel- one of the curves. In general, it is useful to sketch
bourne, Mathematics Department RMIT, 1993. the two curves on the same diagram to ensure that
all points of intersection have been located.

Appendix A - Example Labo- 3 Graphs of Polar Equations


ratory Session
When Maple's plot command is used to obtain the
1 Aim graph of a polar equation, the curve must be given
parametrically in the form [r(t), O(t), t = t 1 .. t2]
In this laboratory session you will use the com-
where t is a real parameter and t 1 :::; t :::; t 2. The
mands
option coords = polar must also be specified. In
this laboratory session, we will a/ways take the pa-
plot and fsolve
rameter t to be the coordinate 0 itself. The polar
equation will therefore be passed to the plot rou-
to plot curves defined by polar equations and to
find points of intersection of such curves.
=
tine as [r(t), t, t t1 .. t2]'

Example 1 Use the plot command to sketch the


2 Background curve defined by the polar equation r = 2cos 0
where 0 :::; 0 :::; 71'.
If rand 0 are polar coordinates in the plane, a curve
is defined by the equation r = 1(0), where 1 is a
We obtain the plot by following the procedure out-
given function, or, more generally, by g(r,O) = 0
lined above with
where g is a given function. The curve consists of
all points that have at least one set of polar coor-
r(t) = 2* cos(t).
dinates (r,O) that satisfy the equation. [Note that
(r,O), (-r, 0 + 71') and (r,O + 2n7l'), where n is any
integer, all represent the same point.] Certain sym-
metries of a curve may be inferred from its polar • plot([2*cos(t), t, t = 0 .. Pi], coords = polar);
equation. In particular,

78
We know from lectures that the equation r = intersection of the cardioid and the parabola are
2a cos B represents a circle that passes through the (1, ±t1l") and that the two curves touch at these
origin, has radius a and has a diameter along the points.
initial line. (Note also that since cos B is even in
(), the graph must be symmetric about the initial 4 Exercises 1
line.) The curve produced by Maple, however, is
distorted and does not look like a circle. To rectify 1. For each of the following polar equations,
this, we can specify horizontal and vertical ranges
(for the Cartesian coordinates x and y) to ensure (i) use the plot command to sketch the
that the aspect ratio of the graph is the same as curve;
that of the screen. The aspect ratio is the ratio of (ii) state the symmetries, if any, the curve
the width to the height and for Macintosh screen possesses;
this is about 1.5. In the following plot command,
(iii) explain how the symmetries can be in-
the horizontal and vertical ranges are -3 .. 3 and
ferred from the polar equation.
-2 .. 2 respectively. This gives an aspect ratio of
6/4 or 1.5 and the curve obtained does look like (a) r = 3 - 2 cos B (lima<;on without a
a circle when the plot window is 'maximized' to loop)
occupy the entire screen. We also use the 'title'
option to give the graph a name that will appear (b) r = 1 + 2sin B (lima<;on with a loop)
in the plot window.
2. (a) Sketch the 4-leaved rose r = 4 sin 2B and
the circle r = 4 in the same window.
• plot([2*cos(t), t, t = 0 .. Pi], -3 .. 3, -2 .. 2,
coords = polar, (b) Find all points of intersection of the two
title = 'Example 1- Circle'); curves.

We can plot more than one curve in the same win-


dow by passing a set of polar equations to the plot 5 Points of Intersection
command, as in the next example.
Although sketching the graphs of two polar equa-
tions sometimes enables us to find the points of
Example 2 Sketch the cardioid intersection of the two curves, it is often necessary
to solve the polar equations simultaneously to find
r=l-cosB
such points. Maple's fsolve command allows us to
and the parabola solve the equations numerically. This is illustrated
in the following example.
r = 1/(1 + cos())
Example 3 Find all points of intersection of the
in the same window. spiral r = 0.28 and the ellipse r = 1/(2 - cos ())
where 0 :S () :S 211".
We use the same horizontal and vertical ranges
as in Example 1 and take the domain of () to be We first plot the two curves.
(-11",11"). Note that on the parabola, r -+ 00 as
()-+±11". • plot( ([0.2*t, t, t = 0 .. 2*Pi], [1/(2 - cos(t)),
t, t = O.. 2*Pi]} ,
• plot(([I - cos(t), t, t = -Pi .. Pi], -1.5 .. 1.5, -1 .. 1, coords = polar,
[1/(1 + cos(t)) , t, t = -Pi .. Pin, title = 'Example 3 - Spiral and
-3 .. 3, -2 .. 2, coords = polar, Ellipse' );
title = 'Example 2 - Cardioid
and Parabola'); It is evident from the graphs that there is just one
point of intersection. This occurs in the second
It appears from the plots that the only points of quadrant, in which ~11" < B < 11". We use fsolve to

79
obtain the solution of 0.28 = 1/(2 - cos 8) in this (ii) Note that the four-leaved rose is sym-
intprval metric about the origin and can also be
represented by the polar equation -r =
• fsolve(0.2*t = 1/(2 - cos(t)) ,t, Pi/2 .. Pi); cos 28, although its petals will now be
2.039428915 traced out in a different order as 8 in-
creases from 0 to 21T. Plot r = - cos 28
The corresponding value of r is then obtained by and r = 1 - cos 8 for ~1T < 8 < ~1T
substitution. The right-hand side of either equa- only and then use fsolve to find polar
tion can be used but here it is easier to use r = 0.28. coordinates for this point of intersection
correct to 3 decimal places.

.4078857830
G. F. Fitz-Gerald (rmag{@minyos.xx.rmit.edu.au)
is a Senior Lecturer in the Mathematics Depart-
Polar coordinates for the point of intersection are
ment at RMIT. He holds a B. Sc.(Hons.) and Ph.
therefore (0.408,2.039) correct to 3 decimal places.
D. degrees in Applied Mathematics from the Uni-
versity of Western Australia. His main research
6 Exercises 2 interests include water gravity waves and the use
(a) Sketch the 4-leaved rose r = cos 28 and the of mathematical methods to solve applied problems
cardioid r = 1 - cos 8 in the same window. arising in applications. Such applications have re-
cently included bluff-body aerodynamic flows, elec-
(b) Your graphs should show that there are seven tromagnetic wave propagation and aero-acoustics.
points of intersection. Polar coordinates for He has been particularly interested in the teaching
three of these points can be read directly from of service mathematics and is the coordinator of all
the graphs. What are they? higher year service mathematics at RMIT. The in-
(c) Of the other four points of intersection, two troduction and use of symbolic computation pack-
are in the first quadrant and the other two ages (such as Maple) into the teaching programme
are reflections of these in the initial line. It at RMIT is another of his interests.
is therefore sufficient to determine the polar
coordinates of the two points of intersection W. P. Healy (rmalh@minyos.xx.rmit.edu.au) is a
in the first quadrant. One of these two points Senior Lecturer in the Department of Mathemat-
appears to have a 8 coordinate in the interval ics at RMIT. He received a B. Sc.(Hons.) degree
(0, ~1T). in Applied Mathematics from North-East London
Polytechnic in 1972, a Ph. D. from University Col-
(i) Plot r =. cos 28 and r = 1 - cos () for lege London in 1975 and a Graduate Diploma in
o < 8 < ~1T only. Computing Studies from the University of Mel-
(ii) Using fsolve, find polar coordinates for bourne in 1991. Prior to joining RMIT as a Lec-
this point of intersection correct to 3 turer in 1982 he was a Postdoctoral Research Fel-
decimal places. low for four years and a Lecturer for four years
and a Lecturer for two years at the Australian Na-
(d) The other point of intersection in the first
tional University, Canberra. His research interests
quadrant appears to have a 8 coordinate in
are chiefly in Quantum Electrodynamics. He is the
the interval (~1T, ~1T). However, using fsolve
author of a book "Non-Relativistic Quantum Elec-
to try to find a solution of cos 28 = 1 - cos 8
trodynamics" (Academic Press, London, 1982) and
in this interval produces a null result.
has published more than twenty research papers.
(i) Explain this null result by plotting r = His teaching interests are in undergraduate Pure
cos 28 and r = I-cos 8 for ~1T < 8 < ~1T and Applied Mathematics, Engineering Mathemat-
only. (Note that cos 28 is negative on ics and pedagogical uses of symbolic manipulation
this interval.) packages.

80
lIB. MAPLE IN SCIENCE
ANALYTICAL APPROACHES TO SOLVING COUPLED
NONLINEAR SCHROEDINGER EQUATIONS USING MAPLE V

M.F. Mahmood and T. L. Gill


Computational Science and Engineering Research Center, Howard University,
Washington, DC

Abstract shown experimentally that they can


3
The coupled nonlinear Schroedinger propagate in single-mode optical fibers.

(CNLS) equations involving highly oscillatory Solitons are nonlinear pulses that

terms attracts great current interest owing to propagate without dispersion in the

both its fundamental meaning and potential anomalous dispersion regime of single-mode

applications in optical logic devices. We optical fibers. The combined effects of

have used Maple V in solving the problem of group-velocity dispersion and self-phase

coupled nonlinear Schroedinger equations. A modulation lead to the formation of optical

paper describing the main features of this solitons in these fibers and can be described

work will soon be published. by a nonlinear Schroedinger (NLS)


1
equation. Single-mode optical fibers
4
Introduction support two distinct modes of polarization

A significant amount of work has because of linear birefringence with weak

been done in the past in the investigation of intermodal dispersion and can be coupled
1
nonlinear processes in optical fibers. ,2 together through the Kerr effect. The

Propagation of soliton pulses as information coupling between the two polarization modes

bits in optical communication systems has in a birefringent single-mode optical fiber

attracted a great deal of interest since it was can be regarded as an important effect, since

the coupling between the modefields is

possible over long propagation distances.

83
The interaction between the two Variational analysis of eNLS equations

optical modes in a birefringent single-mode The pulse propagation in a nonlinear

fiber may be described by a system of birefringent optical fiber with two distinct

coupled nonlinear Schroedinger (CNLS) modes operating in the anomalous group-

equations and it gives rise to a large number velocity dispersion regime is governed by a
6
of schemes for making all-optical switches. system of CNLS equations

In this paper, we present a general

formalism for the study of soliton

propagation in birefringent single-mode

optical fibers in the framework of a system of


2
+~v u* exp(-iROz) = 0, (la)
CNLS equations with highly oscillatory terms

due to nonlinear polarization and used Maple

V specially in evaluating integrals wherever

it was possible. We follow an adiabatic

approach using a time-averaged variational


5
formulation to describe nonlinear intermode

interactions of soliton pulses in the two + ~ u2v* exp(iROz) = 0, (lb)

polarizations. In our analysis, the CNLS

equations are reduced to a Lagrangian u(z,t) = v(z,t) and v = v(z,t) are the slowly

problem when solitons are considered as varying wave envelopes of the slow and fast

effective particles. Using NLS solitons as polarized modes, respectively, and 0 is

trial functions in an averaged Lagrangian one-half the difference in the group

formulation, a set of ordinary differential velocities of the two modes. We assume that

equations (ODE's) for various soliton the fiber is lossless. The highly oscillatory

parameters are derived. terms in equations (la) - (lb) cannot be

neglected for weakly birefringent fibers since

84
K
this leads to polarization instability [6] - [7]. ---secht, (4)
V1 + f
These equations without the highly

oscillatory terms were studied earlier with


the soliton
the initial conditions

I
u(z,t) = v(z,t) = 'I/J(z,t)
u(O,t) = -
A
secht, (2a) VI + f

.fi
2( /"2
-""-- exp(2i,> z)sech(2(t) (5)
v(O,t) = -
A secht. (2b) V1 + f

.fi

evolves for ~ < K < ~ with an amplitude (


Equations (Ia) and (Ib), when solved with
related to the pulse intensity K by the
8= 0 and the oscillatory terms neglected,
relation
give an exact solution, u = v, which is the

solution of the NLS equation:


(6)

(3)
We assume that the above results are also

valid in the case of coupled NLS equations

where 'I/J = VI + f u = VI + f v. for the symmetric two-<:omponent input

Equation (3) is exactly integrable by the pulse.

inverse scattering transform (1ST) method We reformulate the problem of

and, when applied to the Cauchy problem coupled NLS equations (Ia) - (Ib) using a

with the initial condition variational principle in Lagrangian form,

1"(1)
u(O,t) = v(O,t)
f J
[l)

8 Ldzdt = o. (7)
-m -m

_ 1 _ 'I/J(O,t)
VI + f

85
The Lagrangian, L is given by soliton-form ansatz for the polarization

components:

. Ov* Ov
+ ':'(v::r
2 uz
- v* ::r)
uz

Inserting the unperturbed solitonic

components (10) into equation (8) and using

(9) in conjunction with Maple V software, we

obtain

exp(iROz) - ~ u*2v2 exp(-iROz), (8)

where * represents complex conjugation. A

time-averaged Lagrangian may be defined as 4(1 OV 1 8(2Jl2 O~2


+ (1 + t) 0;- - (l""+ t) a;:-

<L> = f Ldt. (9)


4(2 OV 2 80( 1 Jl 1
+ (1 + t) 0;- + (1 + t)

We apply a reduced variational principle in


2
2 2 80(2 Jl 2 8(1 Jl 1
which t I u 1 Iv1 is treated as a
+---
perturbation and consider the following
(1 + t) (1 + t)

86
and x
r
= 2(r (t - e),r r = 1,2.
1 Using the Euler-Lagrange equations,
(1 + t)
a coupled system of eight ODE's for the

evolution of u and v soliton parameters

(r,er ,j.Lr, and 1/


r
(r = 1,2) are obtained.

(ll) de r
(r -dz r + (-1) 8(r - 2j.L (
r r
where

1 iR8z
+ 8" e
a
7Jji: <
L2
uv>
r

1 -iRbz
+-e ~<
a L3
>= 0' (12)
8 Uj.L uv
r

d
+ ;rr-
a 1
- 8 Dd j.L ( )
z r r u"-_ <Luv >r

+e
iR8z a
;rr-<
£2
>
U"-_r uv

8 £3
+ e -iRCz ;rr-
u"-_ < uv > = 0, (13)
r

87
a <£3 > =
+ -41 e-iROz "!r.:- 0, (14) and is calculated from soliton
ull uv
r
phenomenology. The formula for the

threshold amplitude, A , is obtained as a


thr
function of birefringence and is given by

-1/2 ,
+0 • 26£ u. (16)

J1-r -iROz a £3
- 4[ e (Jjj: < uv>
r r
Our calculated values of the threshold

1 a £1
+ -;:v-<
1 iR&
>+-e ;:v-
a amplitude by formula (16) was found to
4 v~_ uv 4 v~_
r r depend nonlinearly on birefringence.

In conclusion, we found Ma.ple V to


2
< £ uv >
1 -iROz
+ -4 e
a£3
;:v- <
uv >,
(15)
v~_ be quite useful, making our lives easier by
r

evaluating most of the integrals in our

In equation (12), the birefringence parameter analytical approach to solving coupled

oappears in a symmetrical way, and this nonlinear Schroedinger equations.

suggests the study of the perturbation-

induced dynamics of the soliton solution. REFERENCES

These ODE's give a criterion for the two 1. V.E. Zakharov and A.B. Shabat, Sov.

pulses to form a bound state. The Phys. JETP 34, 62(1972).

nonlinearity of the medium makes it possible 2. A. Hasegawa and F. Tappert, Appl. Phys.

to lock the u and v polarization components Lett. 23, 142(1973).

together above threshold amplitude through 3. L.F. Mollenauer, R.H. Stolen and J.P.

their effective interaction. This threshold Gordon, Phys. Rev. Lett. 45, 1095(1980).

varies with the birefringence parameter, 0 4. D. Glage, Appl. Opt. 10, 2252(1971).

88
5. D. Anderson, M. Lisak, and T. Reichel,

Phys. Rev. A 38, 1618(1988).

6. C.R. Menyuk, J. Opt. Soc. Am. BQ,

392(1988).

7. K.J. Blow, N.J. Doran, and D. Wood,

Opt. Lett. 12, 202(1986).

8. S. Trillo, S. Wabnitz, R.H. Stolen, G.

Assanto, C.T. Seaton and G.!. Stegeman,

Appl. Phys. Lett. 49, 1224(1986).

Dr. Mohammad F. Mahmood received


his Ph.D. degree from Howard
University, Washington, D.C. in 1988.
His current research interests include
nonlinear wave propagation in optical
fibers, applications to all~ptical
switching devices and lasers, soliton
theory and computer architecture. He
is currently a Senior Research Scientist
at Computational Science and
Engineering Research Center, Howard
University, Washington, D.C.

Dr. Tepper L. Gill received his Ph.D.


degree from Wayne State University in
1974. His current research interests
include simulation modeling of
nonlinear systems, relativistic quantum
theory, high speed networking and
computing, and soliton theory. He is
currently Professor of Electrical
Engineering & Mathematics and
Director of Computational Science and
Engineering Research Center, Howard
University, Washington, D.C.

89
SOLUTION OF THE SOLAR CELL TRANSPORT EQUATIONS
USING MAPLE

Randy T. Dorn and R. J. Soukup


Department of Electrical Engineering, University of Nebraska-Lincoln, Lincoln, NE

Abstract obvious. Often it may seem easier to abandon Maple


and find the solution by hand than to spend the time
The solar cell transport equations and the necessary to discover a command sequence that gives
associated boundary conditions can cause many the desired results.
symbolic algebra computer programs difficulties.
However, it is shown in this paper that Maple can be This paper will show how to make Maple find the
used to find the transport equation solutions for both a transport equation solutions for both a dark and an
dark and an illuminated solar cell. The correct illuminated solar cell without resorting to hand
procedures must be used and some precautions taken calculations. Several common boundary conditions
but once learned, these techniques will be useful in are explored and the precautions necessary to get
many applications. intelligible answers are explained. The tricks and
techniques used to solve these problems should be
useful in many other applications.
Introduction
Symbolic math packages such as Maple are of great Solar Cell Model
interest to the scientist or engineer because of the
potential to free them from the drudgery of tedious A solar cell is a pn junction that has been optimized
algebraic manipulations. Often equations can be very to convert light into electricity. The most general
long and complicated and it becomes a chore just to models begin with the carrier concentration continuity
keep track of the negative signs. One particular area equations and these are usually simplified further into
where Maple has been used to great advantage is the the minority carrier diffusion equations. These
solution of the transport equation for a solar cell. equations have closed form symbolic solutions and

*
can be considered the starting point in most device
In its simplest form the transport equation is a analysis.'
second order linear ordinary differential equation with
well known general solutions. Maple can easily solve Light
this equation and even apply simple boundary
conditions. However, solar cells can have unusual -W n - - - - - - - - - - -
boundary conditions that often cannot be easily n type
applied. In either case, once a solution is found, it -Xn - - - -
may be several pages in length and difficult to put
into an intelligible form. 0---------

The commands required to solve a differential


equation, apply the boundary conditions, and arrange xp - - - - - - - - - -
the solution in the simplest form are not always
p type

Wp - - - - - - - - - -
x
Figure 1. Solar Cell configuration

90
The configuration is shown in figure 1. Light is Dark Cell Solution
incident on the surface at -Wnon a cell that is Wp +
Wn thick. The pn junction is at x =
0 and the p region
depletion region is Xp + Xn thick. The steady state
minority carrier diffusion equations and associated The equations for a dark cell are identical to those
boundary conditions are: of a regular pn junction. Since there is no light, G =0
and the minority diffusion equation in the p region
p region (xp < x < Wp) reduces to:
2
d ~ np(x) ~ np(x) Goe·ClX f1 :=diff(dnp(x),x$2)-dnp(x)/Ln"2=0;
d x2 • -Ln-2- = Dn

dn,,( JJ,t J
fl :=(l..dnp(X»)- dnp(x) =0
~ np(xp) =
ax 2 Ln 2

Since it is inconvenient to use a "~" in Maple, a


lim
x~oo
~np(x) =0 "d" will be used in its place. The boundary condition
at the edge of the depletion region (xp) is given by:
n region (oWn < x < oxn)
bc1 :=dnp(xp)=dnpo * (exp(VNt)-1 );

~) J
d 2A£.1pn(x) _ A
~ _ Goe -ClX
d X2 Lp2 - Dp
bel :=dnp(XPl=dnpo(.(

The most reliable way to handle an infinite


boundary in Maple is to assume first it is finite and
then take the limit after the differential equation is
d ~pn(x) I = ~
D £.1A pn(.Wn) solved.
dx x=.Wn P
bc2:=dnp(Wp)=0;
Ln is the diffusion length and Dn is the diffusion
coefficient for a minority electron and both are bc2:= dnp(Wp) = 0
assumed constant. ~np denotes the number of excess
electrons and Go e- Cl x is the generation due to light. To solve f1 with the listed boundary conditions we
The boundary condition at xp is common for device use the dsolve command. The simplify command
analysis and is often referred to as the law of the reduces the result to a common denominator and
junction. For the boundary condition at Wp we will combines the exponentials.
assume that the p side of the solar cell is much thicker
than the average electron diffusion length so that Wp f2:=simplify(dsolve({f1 ,bc1 ,bc2},dnp(x)));
is effectively at infinity. Therefore the number of
excess electrons at infinity should be zero. This is the f2 := dnp(x) =
long base diode approximation and simplifies the
solution. 2

The minority carrier diffusion equation for the n


region is identical to that in the p region except that
we deal with minority holes and ~np ~ ~pn, Ln ~ Lp,
and Dn ~ Dp. The boundary condition at -xn is
comparable to that at xp. The boundary condition at
oWn relates ~pn and its derivative by Sp, the surface Before the limit can be taken we must have a single
recombination velocity.3 Note that the depletion expression with no = sign. To do this we take the
region ( -xn < x < xp) is not discussed here. right hand side of f2 and give it the name dnpx.

91
dnpx:=rhs(f2): n region

In addition the assume command must be used to The minority carrier diffusion equation for the n
inform Maple of the sign of Ln. This is necessary so region of a dark cell (G =0) is:
that Maple can determine if exp(-Wp/Ln) is 0 or
undefined. The limit will return unevaluated if f3:=diff(dpn(x),x$2)-dpn(x)lLpA2=O;
assume is not included.
a2
f3:= -dpn(x) -
J dpn(x)
0
assume(Ln>O): ( ax 2 Lp2
dnpx:=simplify(limit(dnpx,Wp=infinity);
The boundary condition at the edge of the depletion
~) J (-
( ( Vt
P region (-xn) is comparable to bel. However, there is
X-X )
Ln- little sense in inserting such a long constant so soon in
dnpx := dnpo e - I e the calculations. We can use Cdpn for now and
substitute the actual expression {dpno*[exp(VNt)-
Ln- is Maple's notation that this result was I]} later. Another advantage is that this constant will
computed using an assumption on Ln. It is now a not be converted into trig form in later manipulations
simple matter to compute the current density due to so that the final expression will be simpler.
electrons and evaluate it at x =xp:
bc3:= dpn(-xn)=Cdpn;
Jnx:=q*Dn*diff(dnpx,x):

Jnxp:=simplify(subs(x=xp,Jnx»;
bc3 := dpn( -xn ) =Cdpn

The boundary condition at oWn is given by:

bc4:=D(dpn)(-Wn)=Sp/Dp*dpn(-Wn);

bc4 := D(dpn)( -Wn) =Sp db~-Wn)

Maple cannot completely evaluate this boundary condition in one step and additional commands will be
necessary.

f4:=dsolve({f3,bc3,bc4},dpn(x));

(
( Wn ) ( ) ~ J (~)
f4 '= dpn(x) = Cdpn e Lp Dp + Sp dpn( -Wn) e Lp Lp e Lp

. ((- ~;) (~;) (- ~;) (~;)J


e e +e e
D
'P

+ (Jii) SPd£n(-Wn)LP+CdPnDPJ~ )JJip)


((- ~;) (~;) (-~;) (~;)J
e e +e e Dp

Note that dpn(x) contains a dpn(-Wn). We can evaluate dpn(-Wn) by substituting oWn for x and solving for
dpn(-Wn). If dpn(-Wn) is then defined to be that expression, further references to f4 will include the evaluated
dpn(-Wn).

dpn(-Wn):=solve(subs(x=-Wn,f4),dpn(-Wn»:

92
In its present fonn f4 is a very long and complicated expression and will not be shown here. To simplify f4
we use convert to put it into trig fonn and then we can use combine to gather the trig tenns. It is also necessary
to use simplify after each of these commands to get the simplest expression.

f4a:=simplify(convert(f4,trig)):

f4b:=simplify(combine(f4a,trig)):

dpnx:=rhs(f4b);

Jwn+x) . (wn+x))
d nx'- Cdpn ( Dp cos,\ Lp + Sp Lp smh Lp
p.- Jwn-xn) .nJwn-xn)
Dp cos'\ Lp + Sp Lp ShU\ Lp

If we had not taken the precaution of substituting Cdpn for dpno*[exp(VNt)-l] Maple would have also
converted it to trig fonn and created a very long expression.

Now we can compute the current density due to holes and evaluate it at -xn.

Jpx:=-q*Dp*diff(dpnx,x):

Jpxn:=simplify(subs(x=-xn,Jpx));

Jpxn := _ q Dp Cdpn (Dp SUU\


;nJ WnLp- xn ) + Sp cos''\.
J Wn - xn ) )
Lp Lp
Jwn-xn)
Lp ( Dp cos,'\. Lp . (wn-xn))
+ Sp Lp smh Lp

Now it is a simple matter to substitute the mathematical expression for Cdpn.

Jpxn:=subs(Cdpn=dpno*(exp(VNt)-1 ),Jpxn);

Jpxn :=-
q Dp dpno el((~) ]( - 1
Wn -xn
{ )
.nJwn-xn)
Dp ShU\ Lp
.
JWn-xn))
+ Sp cos,'\. Lp Lp
n{UT))
nn -xn
Lp ( Dp cos Lp + Sp Lp S1 Lp

Jp(-xn) is more complicated than In(xp) because of the different boundary conditions. However, it is easy to
show that the expressions are comparable if we make the comparable assumption that Wn is essentially at
infinity.

assume(Lp>O):

Iimit(Jpxn,Wn=infinity):

This simpler fonn of Jp(-xn) added to In(xp) is known as the ideal diode equation. 2

93
Illuminated Cell Solution

The equations for an illuminated cell include a


generation term which makes the solutions more
The first boundary condition is evaluated as follows:
complicated. Maple can still find the solution using
the same procedure as for the dark cell but it will be
simplify(subs(x=xp,dnpx)=Cdnp);
very long and difficult to comprehend. This does not
mean that Maple is no longer useful, only that some
experience and intuition are necessary. (-a xp)
C2+C3 e =Cdnp
p region C2a:=solve(",C2);

The minority diffusion equation in the p region for (-a xp)


the illuminated cell is: C2a := -C3 e + Cdnp

f5:=diff(dnp(x),x$2)-dnp(x)/Ln"2= For the second boundary condition:


-Go*exp(-a*x)/Dp;
simplify(subs(x=Wp,dnpx)=O);

f5 := (a 22 dnp( X)] _ dnp( x} = __Go--::-e(_-a_X_) xP xP


ax Ln2 Dp CI Sin{ WPL: )+C2 cos{ WPL: )

The boundary conditions are the same as for the dark + C3 e(-a Wp) =0
cell and will not be repeated here.

From our experience with the dark cell we can C1 a:=simplify(solve(",C1 ));
guess that the solution is of the form:
P
CIa:= _ C2 cos{ WpL:x )+C3 e (-a Wp)
dnpx:=C1 *sinh((x-xp)/Ln)+C2*cosh((x-xp)/Ln)+
C3*exp(-a*x); P
sm{W1£:x )
dnpx:=
CIa is the only term with a Wp. Since we are
interested in the solution when Wp is infinite it is
Cl sm{ x ~:p ) + C2 cos{ x ~:p ) + C3 e( -a x) enough to evaluate CIa at Wp = infinity. This time it
is necessary to make an assumption about both Ln
and a.
If this is actually a solution it should solve the
original differential equation. assume(Ln>O): assume(a>O):

simplify(subs(dnp(x)=dnpx,f5)); limit(C1 a,Wp=infinity);

C3 e(-a x) (a 2 Ln 2 _ I) _ Go e(-a x) -C2

Ln2 Dp Clearly CI = -C2 = -C2a, C2 = C2a, and C3 = C3a.


Although dnpx is long it is still understandable
It is a good idea to give the constants a different because it is in separate parts. If we had let Maple
name at this time. This will keep the other constants find the solution using dsolve it would not be so clear.
a manageable size. dnpx is a solution of f5 if C3 =
C3ais: The current density due to electrons evaluated at x =
xp is:
C3a:=simplify(solve(",C3));
Jnx:=q*Dn*diff(dnpx,x):

94
a:='a': Ln:='Ln': If this is actually a solution it should solve the
original differential equation.
Jnxp:=expand(subs(x=xp,Jnx));
subs(dpn(x)=dpnx,f6):
qDn C3a
(a xp) C6a:=simplify(solve(",C6));
e

We can substitute for the constants, but the result is


an expression that simplify is unable to put in the
shortest form. Instead of using simplify, collect is
used to gather Go, and then the op command is used The first boundary condition is evaluated as follows:
to split the expression into separate parts. These parts
are simplified individually and then the equation is subs(x=-xn,dpnx=Cdpn): C5a:=solve(",C5);
reassembled.
(a xn)
C1 :=-C2a: C3:=C3a: Cdnp:=dnpo*(exp(VNt)-1): C5a := -C6 e + Cdpn

J1 :=eollect(Jnxp,Go): For the second boundary condition:

Jnxp:=simplify(op(1,J1 ))+J1-op(1,J1); subs(x=-Wn,diff(dpnx,x))=


Sp/Dp*subs(x=-Wn,dpnx):
Jnxp:=
C4a:=simplify(solve(",C4));

Go q D n L ne
(-axp)
qDndnpoU~)J C4a:=
(Ln a+ l)Dp Ln
C5 Sin{ W~;xn )DP + C6 a e(a Wn) Lp Dp
D region
cos{ wn ; xn ) Dp + Sp Sinh( Wn ; xn ) Lp
L L
The minority carrier diffusion equation for the n
region of an illuminated cell is: wn-xn) (aWn)
+ Sp C5 cosh( Lp Lp + Sp C6 e Lp
f6:=diff(dpn(x),x$2)-dpn(x)/LpI'2=
-Go*exp(-a*x)/Dp;
cos{ Wn ; xn ) Dp + Sp Sin{
L
W~; xn ) Lp

f6 .-(:i.d
.-
( )] dpn(x)
po x -
Go e(-a x)
------
Often Sp is not known and we are interested in the
solution when Sp =0 and Sp =infinity.
ax
2 Lp2 Dp
C4SpO:=limit(C4a,Sp=O);
The boundary conditions are the same as for the dark
cell. We can guess that the solution is of the form:
. C5Sm{w~;xn)+C6a/awn)Lp
dpnx:=C4*sinh«x+xn)/Lp)+C5*cosh«x+xn)/Lp)+
C4SpO .= { DT
"n-xn )
C6*exp(-a*x);
cos Lp
dpnx:=
C4Spi:=limit(C4a,Sp=infinity);
_J -r;- J x + xn )
C4 situ'\.
x + xn )
+ C5 cos,'\. -r;- + C6 e
( -a x)
. C5 cos{ WnL;xn )+ C6 e(a Wn)

C4SPl := n{ DT
"n-xn )

The procedure is the same as for the p region so not si Lp


as many details will be shown.

95
The current density due to holes evaluated at x = -xn Very few commands were needed to find these
is: solutions. However, many commands are useless
unless they are combined with others. A good
Jpx:=-q*Dp*diff(dpnx,x): example of this is the necessity of using "assume"
before taking a limit. Other commands that work
Jpxn:=expand(subs(x=-xn,Jpx)); together are convert and combine. In turn these
commands should be followed with simplify, expand
C4 D C6 (a xn) or collect in some sequence. Often it is necessary to
Jpxn := • q Dp
Lp + q 'P ae try several possibilities before the simplest form is
reached.
For the special case of Sp =0, Jp(-xn) can be found
as follows: References
C4:=C4SpO: C5:=C5a: Jpa:=collect(Jpxn,C6): 1. Pierret, Robert F., Semiconductor Fundamentals
2nd edition, Addison-Wesley Publishing Co.
C6:=C6a: Cdpn:=dpno*(exp(VNt)-1): 1988 88-92

'Jp(-xn,Sp=Or =Jpa; 2. Neudeck, Gerold W., The PN Junction Diode 2nd


edition. Addison-Wesley Publishing Co. 1988
The result will not be displayed here because of the 54-65
length but it is in an intelligible form because of the
precautions we have taken. A similar procedure can 3. Fonash, Stephen 1., Solar Cell Device Physics.
be used to find Jp when Sp is still unevaluated or the Academic Press 1981 154-166
other special case of Sp = infinity.

Conclusion Biographies
Two differential equations were solved with three Randy T. Dorn received his B.S. in Electrical
different boundary conditions. We used Maple's Engineering from the University of Nebraska-Lincoln
"dsolve" to find the solution to the homogenous in 1992. He is currently a graduate student at the
differential equations fl and n. However, additional same institution. Interests include solar cells,
commands were required to complete the application electronic devices and computer assisted symbolic
of the boundary conditions. We were able to insert computations. Email: rrnrtd@engvms.unl.edu
the mathematical form of the boundary condition for
be I at the very beginning because of the simplicity of Dr. R. J. Soukup received his B.S., M.S., and Ph.D.
bc2. If we had tried to do the same with be3 Maple degrees all in Electrical Engineering, all from the
would have converted the exponential term into trig University of Minnesota. He worked for Sperry
form and the solution would have become very RandlUnivac (now Unisys) for three years before
complicated. Since we took special precautions the joining the faculty of the University of Iowa as an
final solution contained both exponential and Assistant Professor in 1972. In 1976 he moved to the
trigonometric functions. University of Nebraska as an Associate Professor.
He became Chairman of the Department of Electrical
Maple's dsolve could also have been used to find a Engineering there in 1978, a position he still holds,
solution for the nonhomogeneous differential and was promoted to Professor in 1980. He is a
equations f5 and f6. However, dsolve typically uses Fellow of the IEEE, a member of ASEE, a member of
exponentials exclusively and the solution would not the AVS, a member of and a past President of
have contained the mixed trig and exponential forms NEEDHA and President of CSEEDHA. His research
that we desire. This would cause the solution to be is in solar cells. Email: eerdrjs@engvms.unl.edu
very long and complicated. By making an
appropriate guess of the solution and then solving for
the constants we were able to keep the mathematics
manageable.

96
KRAMERS AND WANNIER V-MATRICES FOR THE
PARTITION FUNCTIONS OF THE ISING MODEL

P. Frempong-Mireku and K.J.K. Moriarty


Department of Mathematics, Statistics and Computing Science,
Dalhousie University, Halifax, Nova Scotia, Canada

Abstract trix approach is that. it provides a solution to the


In t.his paper we show how to use maple to long range order and also t.he propagation of or-
construct the two dimensional (2-d) and the der throughout. the lat.tice. The theoretical back-
t.hree dimensional (3-d) Kramers and Wannier ground is present.ed in the next section.
V-matrices which are used t.o comput.e the par-
t.it.ion funct.ion (PF) of t.he Ising model by the
perturbation method. The Maple functions 2 2-D Kramers and Wan-
which we have built. t.o deal wit.h these prob- nier V-matrix.
lems are d2clImat, d2Inllm.at, d2'U]Jvmat, d2stm.at,
d3cvmat, d3lnvmat, and d3·u]Jvmat. The screw-like construction introduced by
Kramers and Wannier [I] is adopt.ed here in con-
sidering the theory of a 2-d Ising model on a
1 Introduction square lattice. Assume that the lattice sites
are regularly distributed along a continuous line,
We report. on symbolic const.ruction of the V-
t.wisting its way in a screw-wise fashion over the
matrices of Kramers and Wannier [I] in both 2-d
surface of a torus. Suppose that it consists of
and 3-d. These mat.rices are used in statistical
m pitches of n spins. Let the configuration on
physics t.o comput.e the PF of t.he Ising model
each pitch be denot.ed by ((1\,(12, ... ,(1,,). The co-
by t.he perturbation method. In 1925 Ising car-
ordinates (1\, (12, ... , (1",,, take values +1 or -l.
ried out. an exact calculation of the PF in a one-
Since t.he interaction energies between neighbor-
dimensional latt.ice. His work showed t.hat t.here
ing pairs t.ake the form F( ++).= V( --) = -tJ
was no phase transition t.o a ferromagnet.ic or-
dered st.ate at any temperature. He also failed
and V(+-) = tJ, the total energy can be writ-
ten a<;
to predict phase transition in 2-d and 3-d as well.
However, later works by Onsager [2], Mont.roll [3],
Kramers and Wannier and others have revealed
phase transition in the 2-d and 3-d models. In The sum is over all pairs (i, j) which are nearest
this paper, we follow the steps of I\ramer:'i and neighbors aud J is t.he coupling constant. Let n
Wannier, Askin and Lamb [5] and Oguchi [61 to be the number of spins that make up one pitch
create t.he V-matrices that are used to compute of the screw. By adding the nth spin, one notices
t.he PF of the Ising model on square and cubic that the nth spin interacts with the Oth and the
lat.t.ice. Each of t.he two V-mat.rices has the ad- (n - 1) th spins only, because we are considering
vantage of reducing the size of the original ma- only nearest neighboring interaction. Thus the
trix by half, yet it produces a PF equal to the two interaction energies are as follows:
original matrix. Another advantage of the ma-

where [( = J /2kT and I.: is Boltzmann's con-


stant. Let the probability of the arrangement
(1,,-1,(1,,-2, ... ,(10 be

97
and the one including Un at the next position be reversing all the signs of one, the other can be
given by obtained. Define the parameters

Now according to Boltzmann's theorem, the


probability for any particular arrangement is pro-
portional to the exp( -EfkT), where E is the to- Now we are in the position to construct our pro-
tal energy of the system. If this theorem is ap- gram to compute the matrix M. The name is
plied, one may obtain taken from 2-d complete V-matrix abbreviated
d2cvmat. The matrix M is therefore constructed
'xP(Un, ...,UO) = A(Un-h ...,uO)exp[I<O"n thus:
(U n -l + 0"0)1. (1) d2cvmat:= proc(n) local cl,c2, a, b,
ul, u2,fO,f2,nl uO;
Summing P( 0" n, ... , uo) over 0"0 produces
if nargs=l then
a:=exp(2*K): b:=exp(-2*K):
LP(O"""",O"O) = 'xA(O"n,···,O"d· else
<Yo
a: =args (2) ; b:=args(3);
The resulting situation is identical to the one fi;
described by A(U n-l,O"n-2, ... ,0"0), provided the nl:=2~n/2;

screw is very long. The difference being that 0"1 uO:=matrix(nl,nl,[):


takes the place of 0"0 and U2 of Ul and so forth. for i to nl do
Hence one gets for j to nl do
if j=2*i-l then uO[i,j):=a
elif j=2*i then uO[i,j):=l
else uO[i,j):=O
fi;
od;
where ,X is the PF per individual spin regardless od;
of the order of the matrix in a zero magnetic field. u2:=matrix(nl,nl,[):
For the proof of the latter statement see [II. The for i to nl do
equation (2) can be written compactly as for j to nl do
if j=2*(nl-i)+1 then u2[i,j) :=b
elif j=2*(nl-i)+2 then u2[i,j):=1
else u2[i,j):=O
The matrix M is of dimension 2n x 2" and is not fi;
symmetrical. Thus it is necessary to write the od;
left-handed matrix equation as od;
cvm:=augment(stack(uO,u2) ,
stack(u2,uO»;
The matrix M can be written as a square array end;
by writing the 2n configurations a: = (0"" ...0"1) in Testing our program for n = 2, the matrix M
some definite order. For example, for any con- has the form
figuration + + + - - + ++, replace + by 0 and
- by 1. This example gives 00011000 as a base >H:=d2cvmat(2);
two number. Thus the example just given has
an order of 24. .Also it is convenient to sepa-
1 0
rate the configurations into two classes. Those o e- 2K
with 0"" = 1 are the ones with orders numbers
0,1, ... , 2n - 1 - 1, and those with 0"" = -1 have
the order numbers 2" - 1,2 n - 2, ... , 2"-1. The
o
1
e 2K
0 I]
reason for this arrangement is that if a: and Ci Overriding the default arguments defined
belong to corresponding places in the two classes above with w, t; one obtains
then their order numbers add up to 2"-1 and
are conjugate to each other in the sense that by > Hl:=d2cvmat(3,w,t);

98
A clearer picture of a typical 2-d V-matrix in the
'tV 1 000 o 0 0 =
class (J /I 1 has t IH' followill!!, 1'01'111 for /I 4. =
o 0 w 1 0 000
o 0 000 o t 1 > uV:=d2upvmat(4,s,t);

Ml:=
o 0 o 0 t 100
o 0 o 0 Ii' 100 s 1 0 0 0 0 0 0
o 0 000 Owl 0 0 s 1 0 0 0 0
o 0 t 1 0 000 0 () 0 0 s 1 0 0
t 1 000 000 () 0 0 0 0 0 s 1
uF:=
The V-mat.rix is t.he one used in t.he PF com- 0 0 0 0 0 0 t 1
put.at.ion not the matrix .'\-1, One can build t.he 0 0 0 0 t 1 0 0
V-mat.rix direct.ly or apply a transformation to 0 0 t 1 0 0 0 0
accomplish it., The latter case is adopted, The t 1 0 0 0 0 0 0
transformation is defined as
Three const.ants are ext.ract.ed from the V-matrix
(3) t.o compute the PF. FOl' n = 3, these const.ants
are:
where I is the identity matrix of order 2" -I, It.
is given by the program below. > uO:=evalm(U_O);

d2stmat:=proc(n) local Hl,H2,H,nl;

"o~ [ !
#the order of the matrix 0

~1
nl:=2~n; 0
Hl:=array(identity,l, .nl/2,1 .. nl/2); 0 1
H2:=evalm(-array(identity,1, ,nl/2, 0 0
1. . n1/2» ; 0 0 0
H:=copyinto(H2,stack(augment(Hl,Hl),
augment(Hl,Hl»,nl/2+1,nl/2+1); > ul:=evalm(U_l);
end:
For n = 3,
"l~ ~
the transformation looks like this: 1 0

~]
> H:=d2stmat(3); 0 0
[ 0 0
10001000 1 0
01000100
00100010 > u2:=evalm(U_2);
,- 00010001
H .-
1 0 0 0 -1 0 0 0
o 1 0 0 0 -1 0 0
,) ,_
0000]
0 0 0 0
o 0 1 0 0 0 -1 0 Ii_.- 0 0 1 0
o 0 0 1 0 0 0 -1 [
1 000
Then performing the following operations t.he
two matrices in the upper left and in the lower The lIext. section discusses t.he 3-d computation
right are defined to be t.he V-mat.rices in t.he two of t.he V-mat.rix.
classes, (J" = 1 and (J" = -1.
> V:=evalm(d2stmat(3)&*d2cvmat(3,r,s) 3 3-D Kramers and Wan-
&*inverse(d2stmat(3»);
nier V-matrix.
l' 1 0 0 o 0 o 0
o o ./. 1 o 0 o 0 The 3-el V-mat.rix is much 1Il0re complex than
o o s 1 o 0 o 0 t.he 2-d '·-lIlatrix. To build t.lle 3-d ferromag-
\/.- s 1 0 0 o 0 o 0 Ilet. 011(' lIlay hav!' to 1'011011" tlH' advice of Oguchi
o o 0 0 /. 1 o 0 [2]. He shOlw'<! thar rl1(' sal Ill' approach of t.he
o o 0 0 o 0 l' 1 screw Illet hod ("all 1)(' applied t.o evaluat.e t.he PF
o 000 o 0 -s -1 of t.he Ising modd 011 a cubic lat.t.ice. This ap-
o o 0 0 -s -1 o 0 proach adds spillS one by aile. For t.he simple

99
cubic lattice, it can be divided into many lay- fi;
ers. Then starting from an arbitrary first posi- nl:=2"n/2; k:=round«n-3)/2);
tion, add a spin beyond the one just placed pre- if n<3 then
viously. This construction is continued until a full ERRORC'n must be 3 or greater');
line is arranged. The next line is then arranged in fi;
the same sequence until the whole arrangement if n >=3 then
is completed. Then moving to the first position jl:=n-2-k;
in the next layer the same process is repeated. nb:=2"k;
Consider the 1Hth layer, if the kth spin is added fi;
next, then since the interactions are restricted to #compute the needed matrices.
only nearest neighbors, only the (k - 1) th, the P:=matrixC2"Cjl-l) ,2"jl, []):
jth placed immediately beside it in a preceding #the constant matrix UO
line and Oth spin placed just under the kth spin for i to 2"Cjl-l) do
in the (11), - 1)th layer interact with it. Assume for j to 2"jl do
that each spin has two orientations 17; = ±1. The if j=2*i-l then P[i,j] :=a"3:
t
interaction energies are =f J for parallel and an- elif j=2*i then P[i,j] :=a:
tiparallel spins respectively. Thus the three in- else P[i,j] :=0:
teractions stated above are: fi:
od:
od:
Q:=matrixC2"Cjl-l),2"jl,[]):
Again I .... is defined as l\' = J InT. Let the ar- for i to 2"Cjl-l) do
rangement 17k-I, ... ,l7j-I, ... ,170 have the proba- for j to 2"jl do
bility A(17k_I, ... ,l7j_I, ... ,I70). The probability if j=2*i-l then Q[i,j] :=a:
A( 17k, ... , 17 j, ... , 171 ) is the one in which 171 occupies elif j=2*i then Q[i ,j] :=b:
the place of 170, 172 takes the place of 171 etc. Then else Q[i,j] :=0:
by Boltzmann's theorem, the probability of any fi:
particular arrangement of spins is proportional od:
to exp( - E I kT) because every arrangement has od:
weight 1. Hence one obtains R:=matrixC2-Cjl-l),2"jl,[]):

L exp[KI7k( 17 k-1 + I7j + 17o)]A(17k-l,


for i to 2-Cjl-l) do
for j to 2"jl do
lTo=±1 if j=2"jl-1-2*Ci-l) then R[i,j] :=b"3:
elif j=2"jl-2*Ci-l) then R[i,j] :=b:
else R[i,j] :=0:
The>' in the above equation is the result of Boltz- fi:
mann's exponential being proportional to prob- od:
abilities. It becomes the eigenvalue of the equa- od:
tion. The construction of the matrix J\It ill 3-d is S:=matrixC2"Cjl-l) ,2"jl,[]):
different from that of 2-d. The 3-d matrix gives for i to 2"Cjl-l) do
block matrices instead of the single elements in for j to 2"jl do
the 2-d. The 3-d V-matrix is constructed using if j=2"jl-1-2*Ci-l) then
the equation (4). The order follows the same pat- S[i,j] :=b:
tern as shown for the 2-d. There are two parts elif j=2"jl-2*Ci-l) then
of the matrix M, as noted in the 2-d case. The S[i,j] :=a:
Maple construction of the upper V-matrix ill 3-d else
is shown below. The construction of the lower S[i,j] :=0:
V-matrix in 3-d is done similarly. fi:
d3upvmat:= procCn) local P,Q,a,b,R, od:
S, j 1, nb, k, V; od:
if nargs=l then V:=matrixCnl,nl,O);
a:=exp(K); b;=exp(-K): for i from 1 to nb do
else V;=copyintoCP,V,C2"Cjl-l»*2*Ci-l)+
a:=args[2]; b:=args[3]; 1, 2"jl*2*Ci-l)+1);

100
V:=copyinto(Q,V,2~(jl-l)*(2*i-l)+1, The proof, using matrix theory, consists of
2"jl*(2*i-l)+1) ; proving the fact that for sufficiently high temper-
V:=copyinto(R,V,nl/2+2"(jl-l)*2*(i-l)+ ature. the maximum characteristic value of the
1,nl-2"jl*(2*i-l)+1) ; matrix /\;1(K) uo louger degenerates. For suffi-
V:=copyinto(S,V,nl/2+2~(jl-1)*(2*i-l)+ ciently high temperature, we have
1,nl-2"jl*2*i+l) ;
od; .J
JiUI -- -t ().
I-IX 2I.'T
end; Heucl' k = .JJUT -t O. so

(:'/, =0 = 1 =;3=(:'-/'.
Set. a = =
e /, and I) e -/,'; t.hese are used as de-
fault paramet.ers for the 3-d V-matrices. Again Now usiug our funct.ion d2'1/.]nrmat and for n = 3,
as in 2-d case, one can override these elements one can generate the matrix
by substituting any suitable elements. For con- > V+(O):= d2upvrnat(3,1,1);
venience we have used the symbols (/. and b. Let
P. Q, R. S, be the block matrices in the example

(~~(°1~0
below each of dimension 1 x 2. Then a typical
member of the upper V-matrix iu 3-d is shown F + (0):= 0011 011]
below as [

>d3upvrnat(4,a,b);
In the same way Ilsiug our function d2lnllTnat,
=
and for 11 3, the mat.rix
(13 0 0 0 0 0
(/. 0 > V-(O) :=d21nvrnat(3,1,1);
0 0 (I b 0 0 0 0
0 0 0 0 (13 0
(l 0 o
~
1
0 0 0 0 0 0 a b o 1
0 0 0 0 0 0 b3 b 11 - (0):= [
o -1
0 0 0 0 0
b:J b
b (/ 0 -1 -1 o
0 0 0 () 0 0
b (l 0 0 0 0 () () nUl })(' g('lIerat('(1. H('IT. WI' an' dealiug with a
fiuitl' probieul for which the Imit.rices are of order
A typical member of the lower 3-d V-matrix is 21' wherl' ,. is a Jlositive iutegeL Thus raisiug the
also shown below as matrices \ . + (0) allll \. - (0) to tht' second power
one obtaius
>d31nvrnat(4,a,b);
> evalrn(V+(O) "2) ;

i]
(13 0
(I 0 0 0 0 0 1 1
0 0 a b 0 0 0 0 1 1
0 0 0 0 (13 a 0 0 IV + (O)'= [ ; 1 1
0 0 0 0 0 0 a b 1 1
0 0 0 0 0 0 _b 3 -b
0 0 0 0 -b -(/ 0 0 aud
0 0 _b:J -b 0 0 0 ()
> evalrn(V-(O)-2);
-b -a 0 0 0 0 0 0
1 1
As in the 2-d case, the constant matrices
needed for one t.o compute the PF can be eas-
ily extracted.
11 _ (0)2 := [ ~ 1 -1
1
-1
1 ~1 ]
-1 -1 - 1 -1
As an application in t.his paper, we demon-
strate that an order-disorder transition takes This shows that the matrices are of order 22 .
place between states of tiuite long range order Comput.ing the characterist.ic values of F + (0)2
and those with no long rauge [5]. Due t.o space with t.he help of :\Iap1<'-s eigeuvals fuuct.iou oue
limits matrices of small size are used. gets

101
for j to n1 do end;
if j=2*i-1 then uO[i,j] :=a #Program computes the complete
elif j=2*i then uO[i,j] :=1 #V matrix of Kramers and Wannier
else uO[i,j] :=0 d3lnvmat:= proc(n) local P,Q,a,b
fi; ,R,S,j1,nb,k,V;
od; if nargs=l then
od; a:=exp(K): b:=exp(-K):
u2:=matrix(n1,n1,[]): else
for i to n1 do a:=args[2]; b:=args[3];
for j to n1 do fi;
if j=2*(n1-i)+1 then n1:=2"n/2; k:=round«n-3)/2);
u2[i,j] :=-b if n<3 then
elif j=2*(n1-i)+2 then ERROR('n must be 3 or greater');
u2[i,j] :=-1 fi;
else u2[i,j] :=0 if n >=3 then
fi; j1:=n-2-k;
od; nb:=rk;
od; fi;
fO:=delrows(uO,n1/2+1 .. n1); #compute needed matrices P,Q,R,S.
f2:=delrows(u2,1 .. n1/2); P:=matrix(2~(j1-1),2~j1,[]):
stack(fO,f2); #the constant matrix UO
end; for i to 2-(j1-1) do
#Program computes the the upper for j to 2-jl do
#V matrix of Kramers and Wannier. if j=2*i-1 then P[i,j] :=a~3:
d2upvmat:= proc(n) local c1,c2, elif j=2*i then P[i,j] :=a:
#a,b,fO,f2,uO,u1,u2,n1; else P[i,j] :=0:
if nargs=l then fi:
a:=exp(2*K): b:=exp(-2*K): od:
else od:
a:=args[2]; b:=args[3]; Q:=matrix(2~(j1-1),2-jl,[]):
fi; for i to 2~(j1-1) do
n1:=2~n/2; for j to 2~jl do
uO:=matrix(n1,n1,[]): if j=2*i-1 then Q[i,j] :=a:
for i to n1 do elif j=2*i then Q[i,j] :=b:
for j to n1 do else Q[i,j] :=0:
if j=2*i-1 then uO[i,j] :=a fi:
elif j=2*i then uO[i,j] :=1 od:
else uO[i,j] :=0 od:
fi; R:=matrix(2~(jl-l),2-jl,[]):
od; for i to 2-(jl-l) do
od; for j to 2-jl do
u2:=matrix(n1,n1,[]): if j=2-jl-1-2*(i-l) then
for i to n1 do R[i,j] :=b~3:
for j to n1 do elif j=2~jl-2*(i-1) then
if j=2*(n1-i)+1 then R[i,j] :=b:
u2[i,j] :=b; else
elif j=2*(n1-i)+2 then R[i, j] : =0:
u2[i,j]:=1; fi:
else u2[i,j] :=0; od:
fi; od:
od;od; S:=matrix(2~(j1-1) ,2-jl, []):
fO:=delrows(uO,nl/2+1 .. nl); for i to 2-(jl-l) do
f2:=delrows(u2,1 .. nl/2); for j to 2-jl do
stack(fO,f2); if j=2-jl-1-2*(i-l) then

102
eigenvals(V+(O)-2); reading through the paper and for his important
comments.
0,0,0,4
Similarly the characteristic values of F - (0)2 are Biographies
> eigenvals(V-(O)-2)
Peter Frempong-Mireku is a Doctoral stu-
0,0,0,0 dent at Dalhousie University, Halifax, Nova Sco-
tia, Carmda. He is working on Symbolic Solution
One observes that the maximum characteristic
of the Potts-Ising model. He obtained his MSc in
value of V + (0) is 2 and the rest vanish, while
Mathematics at the University of Saskatchewan.
the characteristic values of V - (0) are all zero.
He also holds MSc degree from Kaluga Pedagog-
This is because the trace of (V + (0)2) is 22 and
ical Institute in Russia, where he had his BSc
that of (V - (0)2) vanishes. From these computa-
degee in },flathematics. He has taught in the Uni-
tions, one gets the following generalization. For
versity of Ghana for three years. His e-mail ad-
any upper V-matrix TV + (0) and lower V-matrix
dress is pfmIQlcs.dal.ca.
TV -(0) of an arbitrary size, there exists a positive
Kevin J. M. Moriarty, graduated from Im-
integer,. such that, since the rank of (HO + (0))"
perial College of Science and Technology, Univer-
and (W - (0)" are one. the characteristic equa-
sity of London, in England. He has taught and
tions reduce to
done research at IlIlperial College, the Deutsches
Elektrollen Synchrotron (DESY) in Hamburg,
Germany. the Interuat.ional Center for Theoret-
The trace of (lV + (0))" is 2", hence the charac- ical Physics (ICTP), in Trieste Italy, CERN in
teristic values of (TV + (0))" are 2", ... ,0, giving Geneva, the Technion-Israel Institute of Tech. in
the maximun characteristic value of HI + (0) to Haifa, Israel. Brookhaven National Laboratory
be 2, and all the rest are 0. However, the trace (BHL) in Long Island. NY., Colorado State Uni-
of (Hl - (0))" is 0. Hence all the characteristic versity in Fort Collins. the Institute of Advanced
values vanish and so are the characteristic values Study in Princeton. He was first Lecturer and
of l'F - (0). This shows that for sufficiently high then reader in Applied Maths. at Royal Holloway
temperature the maximum characteristic value of College of the University of London. In 1983, he
.'\It is non-degenerate. hence it has no long range joined Dalhousie l:niversity. where he is professor
order. The programs are not many so they are of computing Science. In 1990. he was appointed
given in the appendix below. director of the computing sGience at Dalhousie
University. In 1988 he started the Scotia High
End Computing Ltd.. which signed a partnership
4 Conclusion with Alliance Computer Systems of Littlton Mas-
sachusetts, to develop the Scotia Programming
Taking advantage of Maple's built-in functions
Environment and Facility (SPEFY). He is on the
in the linear algebra package it has enabled us to
editorial board of Sc/'entijic Computing.
describe the V-matrix which is used in statisti-
cal physics to comput.e the PF of the Isillg model
by the perturbation method. The V-lllatrix de-
Appendix
scribed here is interesting in its own right. It can
be used in the classroom as a tool in teaching the #Program computes the
screw-like formulation of the Ising 1ll0del prob- #lower negative V matrix
lem forlllulated by Kralllers and Wannier. The d2lnvmat:= proc(n) local cl,c2,a,
computation of the PF is in progress and it may b,uO,ul,u2,fO,f2,nl;
be given in another paper. We are confident that if nargs=l then
in the future we look to a major role for Maple a:=exp(2*K): b:=exp(-2*K):
in statistical physics. else
a:=args[2]; b:=args[3];
Acknowledgements fi;
n1:=2-n/2;
We like to express our appreciation to Dr. uO:=matrix(nl,nl,[]) :
Thomas Trappenberg of Dalhousie University, for for i to nl do

103
S[i,j]:=b:
elif j=2~jl-2*(i-l) then
S[i,j] :=a:
else
S[i,j] :=0:
fi:
od:
od:
V:=matrix(nl,nl,O);
for i from 1 to nb do
V:=copyinto(p,V,(2~(jl-l))*2*
(i-l)+1,2~jl*2*(i-l)+1);
V:=copyinto(Q,V,2~(jl-l)*(2*i-l)+
1,2~jl*(2*i-l)+1);
V:=copyinto(evalm(-R) ,V,nl/2+2~
(jl-l)*2*(i-l)+1,nl-2"jl*(2*i-l)+1);
V:=copyinto(evalm(-S),V,nl/2+2"
(jl-l)*(2*i-l)+1,nl-2"jl*2*i+l);
od;
end;

References
[I] Kramers, R. A. and Wannier, G. R.o Phys.
Rev. 60,252 (1941).

[2] Onsager,1., Phy. Rev. 65.117 (1944).

[3] Mont-roll, E. W., J. Chelll. Phys. 9 706


(1941).

[4] Mont-roll, E. W., J. Chem. Phys. 9 711


(1941 ).

[5] Ashin, J. and Lamb W. E., Phy. Rev. 64,


252(1941).
[6] Oguchi, T., J. Physo Soc. Japan, 5 75 (1950).

104
IlIA. MAPLE IN ABSTRACT ALGEBRA
FRAC: A MAPLE PACKAGE FOR COMPUTING IN THE
RATIONAL FUNCTION FIELD K(X)

Cesar Alonso 1, Jaime Gutierrez2 and Tomas Recio 2


Departamento de MatemcHicas, Universidad de Oviedo, Asturias, Spain 1
Departamento de Matematicas, Universidad de Cantabria, Santander, Spain 2

Abstract:
field IK. We want to start motivating this problem
In this paper we present the programs package FRAC (=
through some applications:
Funciones RACionales) which is designed for perform-

ing computations in the rational function field. The main


1.1 Evaluating
objects in FRAC are rational functions over the field of ra- Suppose that we want to evaluate a function f
tional numbers, but extensions to other computable fields at some points. If f can be decomposed, then
can be done in a "natural" way. The key tool is using func- its value at different points can be computed with
tiona I decomposition algorithms. We motivate the interest O( y'n) multiplications rather than O( n) multipli-
to work with rational function decomposition by presenting cations as is required in the general case. In the
applications to computer science, engineering (CAD), pure particular case when the function f is a rational
mathematics or robotics. We also present some simple ex- function, we can check that it decomposes using
amples in order to illustrate the use of FRA C. Finally, we the FRAC procedure decomposition. Suppose
include the synopsis of the main procedures of FRA C. that we want to evaluate the rational function f =:
X ± 5X 28 ± 10X 21 r'210x14 ± 5x 7 ± 1- 3X 19 _ 3X 12
35
1 Introd uction x (x 7 ±1±x3 )

The problem of determining algorithmically if an Applying our FRAC code decomposition to the
element f of a class of functions can be represented function f, we get:
as a composition of two "simpler" functions 9 and decomposition(J)=
h in the same class, i.e., such that f =g(h), has
3 x4 - 1 _x 3
attracted interest for a long time, see Ritt(1922)
[x 4 (x - 1)' 1 ± x7 J
from a theoretical point of view or Zippel(1991)
from the computational one. This general problem time 60.35 words 1726942.
f = g(h), where h = 1_x
3
is called the Functional Decomposition Problem. Then, ± x7 and 9 =
Although not every function can be decomposed in 3x 4 - 1
this manner, when such a decomposition does exits x 4 (x - 1)"
many problems become significantly simpler. We 1.2 Polynomial Solving
present the particular case when the class of the
The equation f(x) = 0 can be numerically solved
functions are rational functions over an arbitrary
more efficiently if f is decomposable. In the partic-
ular case when f is a polynomial, it is easier then
to determine if the zeroes of f can be expressed in
terms of radicals. The polynomial decomposition
algorithms (see Kozen and Landau(1989)) are now
supported by all major symbolic algebra systems.

107
For instance, Maple uses the procedure compoly, In order to construct symbolically this lattice, we
which is based on an algorithm by Gutierrez et use the FRAC procedure interm. Moreover, if
al. (1989), in order to compute symbolically the we want to order the subfields, we must use the
roots of a polynomial. The following polynomial procedure intermorden. In the particular case
is irreducible over the rational number field: when the field IK (G) contains a non-constant poly-
I=x 12
- 4x 8
- 5x 6
+ 4x + lOx + 3,
4 2
nomial, we can use the procedure interpol (see
but the polynomial is decomposable, as can be Alonso (1994)). Of course, this code is much faster
seen using the compoly Maple comand: than the one above, as can be checked in the last
compoly(f, x) = section of this paper. In this example, we want to
[x 6
- 4x 4
- 5x 3
+ 4x + lOx + 3,x =x
2 2
] compute all intermediate order subfields IF, with
time 5.05 word$111084. <Q(f) c IF C <Q(x), where I is a rational function
On the other hand, applying our procedures de- with rational number coefficients I= 4-l.
x
We
composition or decompol to the polynomial I, apply the procedure intermorden to I:
we get a complete decomposition of I, i.e all given intermorden(f) =
components of I are now indecomposable: 2 _x 2 x2 4 X _x 2
[
x, 1+x4'~'x], [1-x2' 1+x 4],
decompol(f' x) =
2 2 [X2
. [x 2 - 5x + 3, x3 - 2x, x 2]
4
[1:+xx2' l~xx4], [1~xx4], l-x4], [x ]

time 1.16 words 23137. time 13.28 words 21346.

1.3 Computing Subfields ofIK(x) So, we can note that there exist six proper sub-
fields; see in the next section for details about the
Given two rational functions G(x) and H(x), we
inclusion order relation.
are interested in finding explicitly the lattice of all
subfields related to IK(G(x)) and IK(H(x)), i.e.
the union field, the intersection field and all inter- 1.4 Simplifying Inverse Kinematics
mediate subfields IF , with K (G) C IF C lK (x). As
it is mentioned in Helmke (1990), this is a classical The symbolic solution of the inverse kinematic prob-
issue in Algebra. The following diagram illustrates lem requires solving a set of joint determining equa-
this: tions for the correpondingjoint variables. Univari-
lK(x) ate determining equations (after triangulations)
for a revolute joint variable-angle 8, is a kind of
polynomial equation 1(0) == O. The particular
K(G(x), H(x)) type of function 1(8) is called a sine-cosine poly-
nomial or sc-polynomial (see Kovacs &Hommel
/ \ (1992)):

K(G(x)) H«H(x))

\ / where sand c stand for sin(O), cos(O) and m E IN.


We can see 1(0) as a bivariate polynomial mod-
IK(G(x) n IK(H(x)) ulo the ideal s2 + c2 - 1. The most familiar con-
version method for sc-polynomial is the so-called
tangent half angle substitution. By suitable ap-
]I{ plication of this substitution, every sc-polynomial

108
can be converted into a rational function F( x) 1.5 Integrating
in a new variable x = tan(~), with denominator
(1 + x 2 )m. If this rational function is decompos- Assume we want to integrate an indefinite integral
able as F = G(H) such that G is a polynomial of the form (see Zippel (1991), (1992)):
and H is a rational function with denominator of
the form (1 +x 2 y then, the equation /(0) == 0 can J F(x)H(x)t dx,
be numerically and symbolically solved more effi-
where F(x) and H(x) are rational functions. If the
ciently (see also Gathen&Weiss (1993)). To solve
rational function H(X) is a suitable leftcomponent
this problem, first of all, we use the procedure in-
term and then the procedure equals that checks
of F(x), i.e. if there exists G(X) such that F =
G(H), then
when two fields are equal and finally the procedure
leftcomponent.
We consider the se-polynomial /(0) == 0 as III

Kovacs& Hommel(1992), If such a G(y) exists satisfying some added easy


/(0) == 9 + 20e + 10 2 + lOs + 16es - 2s 2 condition, then the above integral can be reduced
By applying the half angle subtitution to /(0), we to the integral of a rational function, which is sim-
have the rational function F( x): pier. We can do that using the procedure left-
component.

F _ -10x 2 + 39 - x4 + 52x -12x 3


- (1+x 2)2 1.6 Manipulating Parametric Curves

A parametrization (G(t), H(t)) of an algebraic pla-


Using the FRAC procedure interm on the ratio-
ne curve F(x, y) = 0 is called simpler or faithful
nal function F:
if every point (x, y) of the curve (except a finite
interm(F) = number of them) corresponds to a unique value of
[x(2x - 21)] the parameter t, i.e. given a point (xo,Yo) there
1+x
exists a unique to such that
time 2.66 wordl 612373.

There exits only an intermediate subfield gener-


Xo = G(to), Yo = H(to)
ate by the rational function h = x(;x -/); now
+x
applying the FRAC procedure leftcomponent to Not every algebraic curve has a parametrization,
this h we get: but if it has one then there exists a faithful one.
The natural question arising fromm the above def-
lefcomponent(h, F, x) =
inition is: given a parametrization of a curve, how
39 - 52 x + 16 x 2 to check if it is simpler or not, and in the negative
time 0.65 wordl 1254.
case to determine a simpler one. This is a very im-
Recoverting the rational function h to a se-polyno- portant topic in computer aided design (CAD); see
mial by applying the inverse of the half angle sub- for example Sederberg (1986), Farin (1988) and
stitution, we get: Alonso (1994). We use the procedures netto or
/(0) == g(h(O)) sederberg for solving that problem.
where 9 =
39 - 52 x + 16 x 2 and h = 1 - c + ~. A parametrization (G(t), H(t)) is quasi-polynomial
This last equation is simpler. if the union field ]I( (G, H) contains a non-constant

109
polynomial (the procedure quasipolynomial checks polynomial r(x)s(y)-r(y)s(x) (see Alonso (1994),
that). In this particular case, we can use the faster Gutierrez and Recio (1992-11). Finding near-sepa-
procedure maxcompol to test simplicity. rated polynomial factors of the bivariate polyno-
Finally, these procedures can be understood as mial r(x)s(y)-r(y)s(x) is equivalent to decompos-
tests of birationallity, i.e. checking if ing the associated rational function F( x) = ~.
S(X)
lK(F1(t), ..., Fm(t)) = K(t). This fact is the basic idea of some of the proce-
See Ollivier (1989), Gutierrez&Recio (1992-1). dures that we are presenting.
In order to illustrate the use of the FRAC pack- Other applications of the functional decomposi-
age for solving the above problem, we consider the tion problem are: the n-partition problem (see
parameterization of the unit circle x2 + y2 - 1: Lenstra&Lenstra &Lovasz (1982)), the problem
of characterizing the class of automorphisms of
lK[Xl, ... ,x m ] and computing their inverses (see
Dickerson (1989), Gutierrez (1991)) and the prob-
lem of finding public key ciphers in algebraic cryp-
First of all, we check if the given parameterization tographY'(see Cade (1985)).
is quasipolynomial, via: Finally, assumimg that we want to know if the
q uasipolynomial( F1 , F2 ) bivariate polynomial:
false f = 3x 2 y - 2x 2 - X +Y - 3y 2 x + 2y2
time 2.18 word8 49298.
over the rational number field is a near-separated
Then, we must apply the procedures netto (see one, we will use the procedure nearseparated,
the last section ):
given an upper bound of the degree:
netto(F1 , F2 ) = nearseparated(j, 3, x, y) =
2x 2 + x
time 3.25 word8 89268. 1 + 3x 2
time 0.21 word8 2222.
So, the parameterization is no simpler and the new
parameter
.
IS S
t2
= (T+t). The polynomial is near-separated and the associ-
ated rational function is the output of the proce-
dure.

1.6 Near-separated polynomials and other


applications
2 Description of implemented
Decomposition of a polynomial F( x) is strongly re-
lated to the separated bivariate polynomial F( x)- procedures
F(y) (see Fried and MacRae (1969)). This fact
together with fast polynomial decomposition algo-
rithms is used by Gathen (1990) in order to find In this section we succinctly describe most of the
efficiently separated polynomial factors of the bi- procedures contained in the FRAC package, giv-
variate polynomial F(x) - F(y). In the same way, ing the arguments, calling sequence and a brief
a decomposition of a rational function F( x) = comment about the procedures. The package also
:f~~ such that gcd(r(x), s(x)) = 1 is strongly re- contains a help: Help(FRAC). The binary code
lated to the associated near-separated bivariate FRAC.m is about 150K.

110
PROCEDURE: left component PROCEDURE: decomposition

Arguments: Two univariate rational functions Arguments: A rational function F(x)


F1(x), F2(x) and the variable x
Calling sequence: decomposition( F( x))
Calling sequence: Synopsis:
leftcomponent(F1(x), F2(X), x)
• The procedure decomposition computes a
Synopsis: complete decomposition of F( x). During such com-
putation the factorization of a bivariate polyno-
• The procedure leftcomponent computes, solv-
mial is required, plus the procedures leftcompo-
ing a linear system of equations, a rational func-
nent and nearseparated described above. If the
tion G(x) such that G(F1(x)) equals F2(x). If such
input is a polynomial, the decomposition pro-
a function G(x) does not exists, the procedure re-
gram uses instead the procedure decompol. A
turns an error message.
typical performance of decomposition computes
a complete decomposition of a rational function of
PROCEDURE: nearseparated degree 40 in 145s.

Arguments: A bivariate polynomial f(x, y), a


PROCEDURE: maxcompol
positive integer s and the variables x, y.
Arguments: List of polynomials
Calling sequence:
nearseparated(f(x,y),s,x,y) Calling sequence:
maxcompol([pol.1, . .. ,pol.n])
Synopsis:
Synopsis:
• The procedure nearseparated decides if the
polynomial f( x, t) is a near-separated polynomial. • The procedure maxcompol computes the great-
In the affirmative case it returns the associated ra- est right common polynomial component of a list
tional function ~ and otherwise returns O. The of polynomials, using techniques of polynomial de-
argument s must be an upper bound of the degree composition.
of a posible associated rational function.
PROCEDURE: netto

PROCEDURE: decompol Arguments: List of rational functions

Arguments: A polynomial f(x) Calling sequence:


netto([rat.func.l, . .. ,ratJunc.n])
Calling sequence: decompol(f(x))
Synopsis:
Synopsis:
• The procedure netto computes the greatest
• The procedure decompol computes a com- right common component of a list of rational func-
plete decomposition of f( x) following the algo- tions following the proof of Luroth's theorem by
rithm of Gutierrez et al.(1989). This procedure Netto (Schinzel (1982), Alonso (1994)). This pro-
decomposes polynomials of degree 120 on a Mac- cedure requires computing the G.C.D. of bivariate
intosh Powerbook 180 in 50 seconds. polynomials.

111
PROCEDURE: sederberg Synopsis:

Arguments: List of rational functions • The procedure intermorden computes the


ordered intermediate subfields according to the in-
Calling sequence:
clusion relation. This procedure returns a list of
sederberg([rat.func.l ,... ,rat.func.n]) lists , with a sublist for each intermediate field be-
Synopsis: tween K(F(x)) and lK(x). In each sublist the first
element is the generator of this intermediate sub-
• The procedure sederberg computes the great-
field, and the other elements are the generators
est right common component of a list of rational
of the intermediate fields that are contained in
functions, this time using theoretical results ap-
the first one. No intermediate fields are between
pearing in Sederberg (1986). This procedure uses
the first and the others. So, we can describe the
only G.C.D. computations of univariate polynomi-
lattice graph and we also can determine all non-
als. It's faster, but random.
equivalent complete decompositions of a rational
function.
PROCEDURE: interpol

Arguments: A polynomial f(x) PROCEDURE: interm2

Calling sequence: interpol(J(x))


Arguments: Two rational functions F 1 (x) and
Synopsis: F2 (x)

• The procedure interpol computes all interme-


Calling sequence: interm(F1(x), F2 (x))
diate subfields between lK(J(x)) and K(x). This
procedure uses some subroutines of the procedure Synopsis:
decompol.
• The procedure interm2 returns all ordered
intermediate subfields between J( (F1 (x)) and
PROCEDURE: interm
lK(F2 (x)). Note that the degree of F1(x) must be
Arguments: A rational function F(x) greater than or equal to the degree of F2 (x).

Calling sequence: interm(F(x))

Synopsis: PROCEDURE: intersectionpol

• The procedure interm computes all interme- Arguments: Two polynomials fl(X) and f2(x)
diate subfields between lK(F(x)) and lK(x). Uses
leftcomponent and nearseparated described a- Calling sequence:
bove. If the input is a polynomial, then the in-
intersectionpol(ft (x), f2(x))
term uses instead the procedure interpol.
Synopsis:
PROCEDURE: intermorden
• The procedure interseetionpol computes, if
Arguments: A rational function F(x) it exists, the polynomial generator of the intersec-
tion field ]I( (ft (x)) n lK (J2( x))
Calling sequence: intermorden(F(x))

112
PROCEDURE: intersection PROCEDURE: TRfaithful

Arguments: Two rational functions FI(x) Arguments: Two rational functions FI (x) and
F2 (x)
F2 (x) and a positive integer s
Calling sequence: TR!aith!ul(F I(x),F2(X))
Calling sequence: intersection(FI(x), F2(x))
Synopsis:
Synopsis:
• The procedure TRfaithful decides if a pa-
• The procedure intersection computes, if it rameterization of a plane curve given by FI (x)
exists, the rational function G( x) of degree least and F2 ( x) is faithful or not. This procedure uses
than the positive integer s and generator of the a Taylor resultant computation of two bivariate
intersection field lK(FI(x)) n lK(F2(x)). If such a polynomials. (see Abhyankar and Bajaj (1989),
function G( x) does not exits, the procedure re- Abhyankar (1990), Alonso (1994)).
turns the message "may be the ground field".

PROCEDURE: quasipolynomial
PROCEDURE: SSfaithful
Arguments: A list of univariate rational func-
Arguments: A list of multivariate rational func- tions
tions and the list of the variables, Xl, ... ,X n , in-
volved. Calling sequence:
quasipolynomial([rat.func.l, . .. ,ratJunc.n])
Calling sequence:
55! aith!ul([ratJunc.l ,... ,rat.func.n], [Xl, ... ,X n ]) Synopsis:

Synopsis: • The procedure quasipolynomial decides if


the
• The procedure SSfaithful decides if a parame- parametrization of a curve given by the list of the
trization of a curve given by the rational functions
rational functions is quasipolynomial or not.
of the input is faithful or not, following results
of Shannon and Sweedler (1988). This procedure
PROCEDURE: equals
uses computation of Grobner basis.
Arguments: Two rational functions F} (x) and
PROCEDURE: Ollifaithful F 2 (x)

Arguments: Same of the precedent function Calling sequence: equals(FI(x), F2(x))

Calling sequence: Synopsis:


Olli!aith!ul([ratJunc.l, ... ,rat.func.n], [Xl,"" Xn ]) •
This useful procedure decides, by solving a
Synopsis: system of linear equations, when two rational func-
tions generate the same field. It returns "false"
• The procedure Ollifaithful computes the same
if lK(FI(x)) is different from lK(F2(x)); and oth-
things SSfaithful, but now using results of 01-
erwise returns a linear fraction U (x) such that
livier appearing in Ollivier (1989). It also com-
putes some Grobner basis.

113
PROCEDURE: Implicit Dickerson,M.: Functional Decomposition of Poly-
nomials . Tech. Rep. 89-1023, Dep. of Computer
Arguments: A list of multivariate rational func-
Science, Cornell University, Ithaca NY (1989).
tions and the list of the variables, t l , ... , t m , in-
volved. Farin, G.:Curves and Surfaces for Computer Aided
Geometric Design. Academic Press, Boston 1988.
Calling sequence:
Implicit([ratJunc.l, ... ,ratJunc.n],[t l , ... , t m ])
Fried, M., MacRae, R.:On curves with separated
variables. Math. Ann., 180, pp. 220-226, 1969.
Synopsis:
Gathen, J. von zur.: Functional decomposition of
• This procedure computes the implicitization
polynomials: the tame case. J. of Symbolic Com-
ideal of the rational funcions following the algo-
putation 9, pp. 281-299 (1990).
rithm of Alonso& Gutierrez&Recio (1994). This
procedure uses computations of some quotient ide- Gathen, J.&Weiss, J.:Homogeneus bivariate de-
als. compositions. Preprint, Dep. of Computer Sci-
ence, University of Toronto, 1993.

Acknowledgment Gutierrez,J.: A polynomial decomposition algorithm


over factorial domains. Compt. Rendues Math.
The authors are indebted to Prof. Carlos Ruiz de
Acad. Science Canada, Vo!. xIII-2, pp. 437-452
Velasco for his suuggestions regarding the imple-
(1991).
mentation on Maple.
Gutierrez,J .&Recio,T.&Ruiz de Velasco.: A poly-
This work is partially supported by CICyT PB
nomial decomposition algorithm of almost quadratic
92/0498 /C02/01 and Esprit Bra-POSSO. 6846.
complexity. Proc. AAECC-6/88. L. N. Computer
Science 357, pp. 471-476 (1989).
References.
Gutierrez,J .&Recio, T.: Rational function decom-
Abhyankar, S., Bajaj, C.:Computations with Al-
position and Groebner Bases in the parameteriza-
gebraic Curves. ISSAC-89. L.N.C.S. No. 358,
tion of plane curves. Proc. of LATIN'92. L. N.
pp.274-284, Springer-Verlag, 1989.
Computer Science 583, pp. 231-245 (1992-1).
Abhyankar, S.:Algebraic Geometry for scientists
Gutierrez,J .&Recio,T.: A Practical Implementa-
and engineers. Math. Surveys and Monographs
tion of two rational function decomposition Algo-
N.35. American Math. Society 1990.
rithms . Proc. ofISSAC'92. ACM (1992-11).
Alonso, C.,Gutierrez, J., Recio, T.:An Implicitiza-
tion Algorithm with fewer variables. To appear Helmke, U. The variety ofsubfields ofIK(x). Comm.
in Computer Aided Geometric Design, 1994. in Algebra, 18(11) pp. 3775-3789, 1990.

Alonso, C.: Desarrollo Analisis e implementaci6n Kovacs, P.&Hommel, G.:Simplification of Symbolic


de algoritmos para la manipulaci6n de variedades Inverse Kinematic Transformations through Func-
parametricas. Ph. dissertation, Dep. Math. and tional Decomposition. Adv. in Robotics. Ferrara
Computing, Universidad de Cantabria, Mayo 1994. Sept. 1992.

Cade, J. J .:A new public-key cipher which allows Kozen,D.&Landau,S.: Polynomial decomposition
signatures. Proc. 2nd SIAM Conf. on App!. Lin- algorithms. J. of Symbolic Computation 7, pp.
ear Algebra, Raleigh NC, 1985. 445-456 (1989).

114
Lenstra. A. K., Lenstra, H. W., Lovasz, L.:Factoring pure mathematics, symbolic computation, solid mod-
Polynomials with Rational Coefficients. Math. Ann. eling and applications to robotic. His e-mail ad-
261, pp.515-534, 1982. dress is:
gutierrez@ccucvx.unican.es
Ollivier,F. Inversibility of rational mappings and
structural ide .:.iifiability in Automatics. Proc. IS-
Tomas Recio is a full Professor of Mathematics
SAC'89, pp. 43-53, ACM; 1989.
at the Universidad de Cantabria. He received his
Ritt,F.: Prime and Composite polynomials. Trans. Ph.D. in Mathematics from Universidad Complut-
Amer. Math. Society 23, pp. 51-66 (1922). ense de Madrid in the area of Real Algebraic Ge-
ometry. He has published extensively in the fields
Schinzel, A.:Selected topics on polynomials. Ann
of real algebraic geometry, computational geome-
Arbor, University of Michigan press, 1982.
try, symbolic computation, robotics and complex-
Sederberg, T. W.:lmproperly parametrized ratio- ity theory. He can be reached by electronic mail
nal cur- ves. Computer Aided Geometric Design, sent to:
3, pp. 67-75, 1986. recio@ccucvx.unican.es

Shannon, D., Sweedler, M.: Using Grabner bases to


determine algebra membership, split surjective al-
gebra homomorphisms, determine birational equiv-
alence. J. Symbolic Computation, 6, pp. 267-273;
1988.

Zippel,R.:Rational Function Decomposition. Proc.


of ISSAC-91. ACM press, 1991. Technical report,
Cornell University, 1992.

About the Authors

Cesar Alonso is currently an Assistant Professor of


Computer Science at the Universidad de Oviedo.
He received his Ph.D in Mathematics from Univer-
sidad de Cantabria in the area of Algebraic Sym-
bolic Computation. His primary interest are in the
area of Algebraic Algorithms. He can be reached
by electronic mail sent to:
calonso@aicvax.aic.uniovi.es

Jaime Gutierrez is an Associate Professor of Ap-


plied Mathematics at the Universidad de Cantabria.
After receiving a Ph.D in theoretical and applied
mathematics from the Universidad de Cantabria,
he has continued to pursue research interest in

115
GROUP RINGS AND HOPF·GALOIS THEORY IN MAPLE

Timothy Kohl
Department of Mathematics and Statistics, SUNY at Albany, Albany, NY

Abstract Multiplication of elements in AG is similar to


polynomial multiplication (as will be important in
Maple) but not quite. Specifically,
As the title implies, the subject is known as
Hopf-Galois theory which attempts to expand the n n
notions of classical Galois theory to more general -- ~~Ct·bg·g·
L....JL....J Z J Z J
settings. While the particulars of the subject are i=1 j=I
not the main focus of this discussion, the principal n
objects under study, namely group rings and cer-
tain subrings of these group rings are of interest.
=LCk9k
k=]
The computational demands involved in describing
for some CI, C2, ... , Cn EA. Since the gi's are ele-
them and performing computations in them, are
what motivated the development, in Maple, of a ments of the group G then gigj E G and Ctibj E A
collection of tools to accomplish this task. Before so the product of two elements in AG is again an
going further, some background would be appro- element of AG. One defines the additive identity el-
priate and will help frame the discussion to follow. ement of AG to be Li OAgi and the multiplicative
identity to be lAC where OA and I A are respectively
I. GROUP RINGS the additive and multiplicative identities of A and
e is the identity element of G. It is easy (although
Definition: Given a ring A with identity and a tedious) to verify that AG satisfies all the condi-
finite group G the group ring AG is defined as the tions, such as the associative law cy (fJy) = (cyf3)"
set of all elements of the form: in the definition of a ring and we shall assume this
n
since it is well known.
~Ct'(7' Now the particular group rings under investiga-
L....J t~ t
i=1
tion are those of the form Q((n)Cn where n is an
integer greater than I and:
where G = { g], g2, ... , gn } and Cti EA. Addition • Q( (n) - extension field of the rationals Q,
is defined by the rule: generated by all n-th roots of unity e.g.
(n = e2rri / n .
n n n
LCti9i + Lbi9i = L (ai + bi)gi • e" - the cyclic group of order n,
i=] i=1 i=1 Cn = (a-) = {1,u,u 2, ... ,U"-I} with
(i.e. The group elements act like a vector space ba-
uiu j = u[i+j] where [i+j] denotes the class
of i+j modulo n.
sis or more precisely as a basis for a free A-algebra
of rank n, since A need not be a field.)
Representing this group ring and determining how
to do calculations within it were accomplished by
using the following three observations:
(I) By default, Maple works with expressions
in as many indeterminates as desired and
treats them as polynomials over the ratio-
nals.

116
(2) Any finite algebraic extension of the ratio- with( numtheory);
nal numbers f{ /Q can be viewed as the
quotient ring Q[z]/ (f(z)) where f(z) is an simp := proc(expr,n)
irreducible polynomial In Q[z]. local e,ee,temp,ne,c,i,j ,degx,degz:
e.g. Q( J3) '= Q[z]/(z2 - :3) e := d + dd + expand(expr):
IH' := nops(e):
(:3) if (.'" denotes the cyclic group of order n ee := 0:
then we can represent the group ring [{ ('" for i from 1 to ne do
as the quotient ring J([:z:J/ (:z:" - 1). Since temp := op(i,e):
in this quotient ring, :z:" = I, every element degx := degree(temp,x):
is a polynornial expression of degree < n, degz.
:= degree(ternp,z):
.

with coefficients in K, and rnultiplication of temp := subs(xAdegx = xA(degx mod n),t.emp):


two such expressions is carried out in the ternp := subs(zAdegz = zA(degz mod n),temp):
usual way except that the relation x" = 1 ee := ee + temp:
is irnposed to give us another 'polynomial' od:
of degree < n. That is, we identify x with ee := ee - d - dd:
(T and reduce all exponents rnodulo n. e := collect.(ee,x):
Of course the first two observations are what lie for j from 0 to n-l do
at the heart of RootOf() and other related com- cli] := coeff(e,xj):
mands, but it is the third observation which yields cli] := cyclosimp( cli],n):
the following represent.ation of Q( (")C,, od:
e :=c[O]:
for j from 1 to n-l do
e := e + cli]*(xA j):
where ~,,(z) is the n-th cyclotomic polynomial, the od:
minimal polynomial of (". e := sort(e,x);
RETURN(e):
Since end:

cyclosimp := proc(expr,n)
local dj,e,cyp:
d := phi(n):
cyp := zAd-cyclotornic(n,z):
where (tij E Q, then {C:, (Tj Ii = 0, ... , ¢( 11) - 1, j = e := expr:
0, ... ,11- I} is a Q-basis for Q((")C,,. Hence, ele- for j from d to n-l do
ment.s of Q(Cn)Cn can be represented in Maple as e := subs(zAj=zA(j-d)*cyp,e):
follows: od:
n-10(n)-1
e := collect(e,z):
(*) 2::= 2::= aij zi:zj RETURN(e):
end:
j =0 i=O

where addition is just ordinary polynomial addi- rnu := proc(exprl,expr2,n)


tion. Multiplication oftwo elements ofthe form (*) RETURN(simp(expr 1*expr2,n));
is carried out like polynomial multiplication except end;
that we make the formal substitutions, ~,,(z) = 0
ad := proc(exprl,expr2,n)
(since we identify z wit.h e,,) and x" - 1 = 0, so
RETU RN (sirnp(expr 1+expr2,n));
that the result is another expression of the form
end;
(*) .
With this in mind all that was needed was to The main procedure is simp() which reduces a
code the routines for performing the 'arithmetic' in given expression to one of the correct form to rep-
CO! ( C")C,,. Although the subsequent package even- resent an element of the group ring. The only pa-
tually grew in size, the code for these operations rameters that are passed are an expression to be
resides in these routines which are given here: simplified and the particular choice of 'n'. The

117
procedure cyclosimp() is used so that all powers II. HOPF ALGEBRAS
of z (think (n) that appear in an expression are
of exponent less t.hat. ¢(n). For example, ¢(9) = 6
In t.his section we shall describe how Maple was
and <l>a(z) = z6 + z3 + I hence + (~+ 1= 0 so (g used t,o comput.e bases for cert.ain Hopf algebra.s
over CQ which are given as subrings of group rings
({; = -(~ - 1 and thus (J, for instance, may be
-3 - I) = - (49 - ~9 of t.he form Q( (pk )C> where p is an odd prime .
WI'I.t,t,en as (-6
9~~) = (9( -~9 -
An init.ial example of a calculat.ion t.hat can be These Hopf algebras act analgously to a Calois
done is t.o det.ermine a set. of orthogonal idernpo- group on the field ext.ension, CQ(a1/pk)/Q where
tent.s in CQ((n)C", that is n element.s C 1, ... , Cn such a E <01 but. a t- bP for any b E <Q!. This ext.ension
t.hat c; = Ci and cici = 0 for i j. For exam- t- is not. C;alois in the usual sense, but is an exarnple
ple, if n=:3 we may define Cl = HO'2 + 0' + I), of what is called a Hopf-Calois ext.ension. (See t.he
C2 = ~((2O'2 + (0' + 1), C3 = ~((O'2 + (20' + I) and references for furt.her information).
Without. going int.o excessive det.ail, the problern
readily verify t.hat. t.hese sat.isfy t.he above proper-
ties. Keep in mind t.hat. ( is a primitive cube root of is this. Civen the group ring Q((pk)Cpk, there is a
uni ty and as such 1+( +(2 = 0 so that. (2 = -( - I. group 6. k = (8) cyclic of order ¢(pk) = pk _ pk-l
which acts" on Q((pk)Cpk as follows:
>el := In*(xA2+x+1);

I I I
el := _;/:2
:3
+ -3:
:3
+ -
:3 where 7r is t.he least. primitive root of pk which in
>e2 := 1n*(zA2*xA2+z*x+1); Maple is given by t.he primroot() function in t.he
numtheory package. This in mind, we can ask
I 2 2 I
e2 := -z x + -Z3: + -1 for a det.ermination of (CQ( (pk )C:pk ) Cl.pk , that is the
:3 :3 :3 subring of elements fixed by all of 6. p k. Specif-
>e:3 := In*(z*xA2+zA2*x+ I); ically, (Q((pk)Cpk)Cl.pk = {cr E CQ((pk)CpkIVct =
cr VS r E 6. p k} which is a Hopf algerbra over Q of
rank pk (as a vector space) and shall be denoted
by pk H. The problem is how to compute a basis for
>rnu(el,el,:3); pk Hover CQ. Now the initial approach was to take
I I I each element of the set of ¢(pk)pk ba.sis elements
-3,2+- 3,+-
:3' :3' :3 =
{(; kO'i Ii 0, ... , ¢ (pk) - I, j =
0, ... , pk - I} an d
compute t.he 'trace' of it under the action of 6. k.
> mu(e2 ,e2,:3);
That is, given (~k O'i define: "
I I I I
( --z - _)3: 2 + -Z3: +-
:3 :3 :~ ;~ cP(pk)-1
(*) t1'((;kO'i) = L V ((;kO'i)
r=O
I 2 I I I cP(pk)-1
3"n: +(-3"Z-3")3:+3"
L (;( O'i"r
> rn u(e l,e2,:3) ;mu(e I ,e:3 ,:3) ;rnu(e2,e:3 ,:3); r=O

It is easy to see that t 1'( (;k O'i) is fixed by every


o
element of 6. 1,k and some basic theory tells us that
o this set spans pk H. However, this set is not linearly
independant (over Q) so we must throw out enough
o elements to yield a basis. It was easy to define, 'in
Maple, the action of 6. p k on the basis elements by
Calculat.ions such as t.hese are interesting, but. it. defining how each power of the generator S acts on
was a more complex problem which spurred t.he de- a basis element and sum these together as in (*) to
velopment. of a larger package which included t.hese define the trace function. The two procedures are
rout.ines. delta(expr',n,r) which returns V (expr) for sr E 6.",
and tr(expr,n) which returns tr(expr).

118
Note the following sample calculations where we
take the image (under the trace map) of a generic
basis element of Q((9)C9 and demonstrate that 89 :={1, z4 x 8 + (_z5 - z2) x 7 + (_z4 - z) x 5
this image is invariant under the action of L\g.
+ Z2 X4 + Zx 2 + Z5 X, (_Z5 _ Z2) x 8
>simp( tr(z:;'x,9),9); + (_z4 - z) x 7 + z5 x 5 + Z4 x 4 + z2 x 2 + ZX,
z3 x 8 + (_z3 _ 1) x 7 + z3 X5
+ (_z3 - 1) x 4 + z3 X2 + (_z3 -1) X,
(_Z5 _ z2) x 8 + (_Z4 _ z) x 7 + Z5;1: 5 + z4 x 4
(_z4 _ z) ;1: 8 + z5 X7 + zx 5 + (_z5 _ z2) x 4
+z2 x 2+ zx
+ z4 x 2 + z2 x , z5 x 8 + zx 7 + z2 x 5
+ (_Z4 _.::) x 4 + (_z5 _ z2) x 2 + z4 x ,
>simp(delta(" ,9,1),9);
(_z3 -1) x 6 + z3;c 3,z3 X6 + (_z3 -1) x 3,
zx 8 + z2 X7 + z4 X5 + z5 x 4 + (_z4 _ z) x 2
(_Z5 _ z2) x 8 + (_z4 _ z) x 7 + z5 x 5 + z4 x 4
+ (_z5 - z2) x, z2 x 8 + z4 x 7
+z2 x 2+ zx
+ (_Z5 _ z2) x 5 + zx 4 + Z5 X2

So we combine the above observations to get a pro- +(-Z4- z )x,x 6 +x 3,


7
cedure gen8pan(n) , where n = pk, of course, which X8 +X +X 5 +X 4 +X 2 +X,
will generate the aforementioned spanning set and 1) x 8 + z 3 x 7 + ( -z 3 - 1) x 5
( -z 3 -
another procedure linearize() to reduce this span-
ning set to a basis. For example, in the following + Z3 X4 + (_z3 _ 1) x 2 + Z3 X}
sample calculations we generate a spanning set 83
(resp. 89) and pass it to the linearize routine which >nops(s9);
outputs a basis b3 (resp. b9) for 3H (resp. 9H).
The use of nop8() is to compare the cardinality of 13
each spanning set as compared with that of the >b9 := linearize(s9,9);
basis derived from it.

>s3:=genspan(3);
b9 :={1, .:;4 x8 + (_z5 - z2) x 7 + (_z4 - z) x 5
+ z2 X4 + zx 2 + z5 x , (_z5 _ z2) x 8
+ (_z4 _ z) x 7 + z5 x 5 + Z4 x 4 + z2;1:2
+ zx, z3 x 8 + (_z3 - 1) x 7

>nops(s3); + z3 x 5 + (_z3 -1) x 4 + z3 x 2


+ ( -z 3 - 1) x, (_4
-<. - Z) X 8 + z5 x7
4 + zx a + (_Z5 _ Z2) X4 + Z4 X2
+ Z2 X, Z5 X8 + ZX 7 + Z2 X5 + (_Z4 - Z) X4
>b3 := linearize(s3,3);
+ (_Z5 _ Z2) X2 + Z4 X, (_z3 -1) x 6 + Z3 X3,
Z3 X6 + (_z3 -1) x 3,
b3:= {1,x 2 +x,(-z-1)x 2 +zx}
x8 + X 7 + x 5 + x 4 + x 2 + x}
>nops(b3); >nops(b9);

3 9
Although not immediately obvious, distinct (ip k (Tj 's
>s9:=genspan(9); can have identical traces and since the output. of

119
genspan() is a set, in the theoretical sense and as only 27 H but also 81 H, with none of the overhead
the Maple data type, duplicate traces do not ap- induced by looking at spanning sets. The culmina-
pear in the spanning set. Furthermore, some ad- tion of this is the procedure jastbasis(b,p,k) which
ditional conditioning is performed so that, among recursively generates a basis for pk+l H given a basis
other things, the constant 1 always appears in the b of pk H. If we make the convention pO H = 1 H =
basis and if tr (~l1'j) is any other rational num- Q and let b1 = {I} then applying jastbasis() to b1
ber, it is not added to the spanning set. Hence the yields a basis bp of pH and applying jastbasis() to
spanning set in general has fewer than ¢(pk)pk el- bp yields a basis bp 2 of p2H and so on.
ements yet more than pk elements, hence the need We illustrate this process with p=3 as before:
for the linearize() routine. Consider the following
example where we generate a basis for 27 H. Again
note the size of the spanning set as compared to >bl := {I}
the basis. bl := {I}

>s27 := genspan(27): >b3 := fastbasis(bI,3,0);


>nops(s27);
b3 := {I, (-z - 1) x 2 + zx, zx 2 + (-z - 1) x}
40

>b27 := linearize(s27,27); >b9 := fastbasis(b3,3,I);

b9 :={I, z4 x 8 + (_z5 - z2) x 7 + (_z4 - z) x 5


b27 := {I, z6 x 24 + z12 x 21 + (_z15 _ z6) x 15
+ z3 x 12 + z15 x 6 + (_z12 _ z3) x 3, ... + z2 x4 + zx 2 + z5 X, ...

Z13 X 26 + (_z17 _ z8) x 25 + (_z16 _ Z7) x 23


+ zl1 x 22 + z10 x 20 + (_z14 _ Z5) x 19
>b27 := fastbasis(b9,3,2);
+ (_z13 _ z4) x 17 + z8 x 16
+ z7 X 14 + (_zl1 _ z2) x 13 b27 := {I, z6 X 24 + z12 X 21 + (_Z15 _ z6) X 15
+ (_z10 _ z) x 11 + z5 x 10 + z4 x 8 + z17 x 7 + Z3 X 12 + z15 x 6 + (_z12 _ z3) x 3, ...
+ Z16 x 5 + z2 X 4 + zx 2 + z14 x }
>nops(b27); Z13 X 26 + (_z17 _ z8) x 25 + (_z16 _ Z7) x 23
27 + zl1 x 22 + z10 x 20 + (_z14_ z5) x 19

By hand, even computing b9 was rather difficult


+ (_z13 _ Z4) x 17 + z8 x 16 + z7 X 14
(let alone b27), so this program had already proved + (_zll _ z2) x 13 + (_z10 _ z) x 11
its value. Now when computing the basis for 27H, + z5 x 10 + z4 x 8 + z17 x 7 + z16 x 5
the excess elements that this algorithm generated
caused not only genspan() to take a long time to + z2 X 4 + zx 2 + z14 X }
work but linearize() as well. With this method,
computing a basis for 81H was prohibitively slow, >b81 := fastbasis(b27,3,3):
but with the results this initial setup yielded, pat-
terns began to emerge which indicated that a much We need not display all of b81, but we can show
more efficient algorithm was possible. Using a vari- some typical basis elements and some calculations
ation of a result that appears in [1] together with to demonstrate that these are indeed elements of
a number of unpublished results of the author, a 81 H. Specifically, 0' E pk H means or (0') = 0' (i.e.
r
much improved algorithm was implemented which r
6 (0') _ 0' = 0) for a1l8 E D.pk, and since D.pk IS
yielded a very rapid calculation of the bases for not cyclic, it suffices to check this for r=1.

120
>b81[13]; a framework in which the complex expressions t.hat
arise are no longer difficult to manipulate. In do-
(_Z39 _ Z12) X 78 + Z51 X 75 + Z21 X 69 + Z6 X 66 ing so, we have freed ourselves to go after the main
+ (_Z30 _ Z3) X 60 + Z42 X 57 + Z12 X 51
problem and deal with it within this same environ-
ment without having to worry about tedious inter-
+ (_Z51 _ Z24) X 48 + Z48 X 42
mediate calculations. Furthermore, as mentioned
+ Z33 X 39 + Z3 X 33 + (_Z42 _ Z15) X 30 earlier, preliminary calculations led to preliminary
results which in turn led to not only increased in-
+ Z39 X 24 + Z24 X 21 + (_Z48 _ Z21) X 15 sight into the problem itself, but an improved com-
+ (_Z33 _ Z6) X 12 + Z30 X 6 + Zl5 X 3 putational scheme. It is in this respect that Maple
stands out, not just as a computational tool but
>simp( delta(b81 [13] ,81,1 )-b81 [13],81); as a conduit of empirical information from which
observant users may derive deeper understanding
o of their subject.

>b81[59]; REFERENCES

Z43 X 80+ Z5 X 79 + zlO x 77 + Z53 x 76 [1] Lindsay N. Childs, On the Hopj Galois Theory jor Sep-
arable Field Extensions, Communications in Algebra
+ (_z31 _ z4) x 74 + z20 X 73 + z25 x 71 17(4) (1989),809-825.
[2] C. Greither and B. Pareigis, Hopj Galois Theory jor
+ (_z41 _ z14) X 70 + (_z46 _ z19) x 68 Separable Field Extensions, Journal of Algebra 106

+ z35 x 67 + z40 x 65 + z2 x 64 + z7 x 62 [3]


(1987),239-258.
Thomas W. Hungerford, Algebra, Springer-Verlag,
+ z50 x 61 + (_z28 _ z) x 59 + z17 x 58 Berlin, 1974.

+ z22 x 56 + (_z38 _ zll) x 55


The author Timothy Kohl is currently working
+ (_z43 _ z16) x 53 + z32 x 52 + z37 x 50 on his Ph.D in mathematics at the State University
+ (_z53 _ z26) X 49 + z4 x 47 + z47 x 46 of New York at Albany. He can be reached at the
+ z52 x 44 + Z14 x 43 + z19 x 41 following address:

+ (_z35 _ z8) x 40 + (_Z40 _ z13) x 38 Timothy Kohl


+ z29 X 37 + z34 X 35 + (_z50 _ z23) X 34 Department of Mathematics and Statistics
+ zx 32 + z44 x 31 + z49 x 29 + zllx 28 State University of New York at Albany
+ z16 x 26 + (_z32 _ z5) x 25 1400 Washington Avenue
+ (_z37 _ z10) x 23 + Z26 x 22 + z31 x 20 Earth Science 110
+ (_Z47 _ z20) x 19 + (_z52 _ z25) X 17 Albany, New York 12222

+ z41 x 16 + z6 x 14 + z8 x 13 + z13 x ll
+ (_z29 _ z2) x lO + (_z34 _ z7) x 8
+ z23 x 7 + z28 x 5 + (_z44 _ Z17) x 4

+ (_z49 _ z22) x 2 + z38 x


>simp(delta(b81 [59] ,81,1 )-b81 [59] ,81);

Conclusion

With Maple and a polynomial-based description


of these group rings, we have been able to construct

121
RATIONAL GENERATING FUNCTION
APPLICATIONS IN MAPLE

Robert A. Ravenscroft, Jr.


Department of Computer Science and Statistics, University of Rhode Island,
Kingston, RI

1. Introduction 2. Basic Maneuvers

Generating function techniques have been used To use generating functions, we must first be
throughout the literature to evaluate summations able to map between closed forms and generat-
and recurrences. Rational generating functions ing functions and between recurrences and gener-
are a particularly effective computation tool, as ating functions. The genfunc package functions
they encode all linear recurrence sequences. These rgLencode, rgLexpand, and rgf....sequence and
are sequences defined by homogeneous linear re- the Maple library function rsolve perform these
currences with constant coefficients. There are tasks.
known generating function techniques for evalu-
To encode a generating function we use the
ating summations and convolutions that involve rgLencode function. As with most of the func-
linear recurrence sequences. Unfortunately, these tions in the genfunc package, rgf _encode re-
methods do not lend themselves well to hand cal- quires that the index variable of the sequence and
culation.
the generating function variable be passed as ar-
The Maple genfunc package provides tools for guments. In the examples in this paper, we use
manipulating rational generating functions and n as the index variable and z as the generating
the sequences that they encode. This paper illus- function variable.
Consider the sequence (n 2 + 2n + 3). We em-
trates how Maple is used for quick and easy eval-
uation of sums and convolutions of linear recur- ploy rgLencode to find its generating function
rence sequences. Section 2 looks at encoding and
G(z).
decoding generating functions. Summations and
convolutions are considered in Section 3. Tech-
niques for hybrid terms and linear indexing are
presented in Section 4. Hybrid terms are terms
defined by the term-wise product of two or more 3 z
----- + 2 --------
sequences. Linear indexing defines a new sequence
1 - z 2
by using a linear polynomial to index a known
linear recurrence sequence. To illustrate these ap-
o - z)
plications of Maple, we consider several summa- / 1 z \
tions and convolutions, including some well known + z 1-------- + 2 --------1
problems involving the Fibonacci numbers. 1 2 31
\O-z) O-z)/

> Gz := rgf_norm(It, z);

2
- 3 + 3 z - 2 z
Gz := - -------------------
2 3
1 - 3 z + 3 z - z
The function rgf-norm puts a rational gener-
ating function into a "normal" form with respect

122
to the generating function variable z. The func- z
tion rgf _expand reverses the process to find the Fz .= - ------------
2
closed form of a sequence defined by a rational
- 1 + z + z
generating function. Consider the expansion of
G(z). To find the recurrence and boundary condi-
tions for the Fibonacci numbers from their gener-
> rgf_expand(Gz, z, n); ating function we use the rgf -sequence function.
This function answers a number of queries about
2 (n + 1) (1/2 n + 1) - n + 1 the sequence encoded by a rational generating
function. We use the 'recur' and 'boundary'
> expand(II); queries here.

2
n + 2 n + 3
> rgf_sequence('recur', Fz, z, F, n);

To determine if an expression is a valid closed F(n) = F(n - 1) + F(n - 2)


form for a linear recurrence sequence, the type
rgf -seq is defined by the genfunc package. The > rgf_sequence('boundary', Fz, z, F, n);
index variable must be passed as an argument
to rgf -seq in the type expression. Consider the
F(l) = 1, F(2) =
sequences (n 2 + 2n ) and (lIn). With the few tools considered here, we are
ready to evaluate summations and convolutions
of linear recurrence sequences. A well known
result states that the generating function of the
true sequence (sn) defined by Sn = L~=o ak, is S(z) =
A(z)/(I-z), where A(z) is the generating function
> type(l/n, rgf_seq(n)); of (ak). To evaluate this summation, we find
the generating function of the solution, S( z) =
false A(z)/(1 - z), and then expand S(z) to find Sn'
The sequence (n 2 + 2n ) is a linear recurrence Consider the summation Sn =
L~=o 2k . To
sequence. The sequence (lin) has generating compute Sn, we use rgLencode to find the gen-
function - In( 1 - z), thus it is not a linear re- erating function of (2 n ), divide this generating
currence sequence. function by 1 - z, and expand the result using
Since all linear recurrence sequences are de- rgf _expand.
fined by homogeneous linear recurrences with con-
stant coefficients, we often need to map a recur- > Az := rgf_encode(2-n, n, z);
rence to a generating function. Maple's library
function rsolve provides a 'genfunc' option that
allows us to find a generating function from a Az .= -------
recurrence. Consider the sequence (Fn ) of Fi- 1 - 2 z
bonacci numbers which is defined by the recur-
rence F n =
F n - 1 + Fn - 2 , with boundary condi-
> rgf_expand(Az/(l-z), z, n);
tions F I = F2 = 1. We can use rsolve to find the
n
generating function F(z) of the Fibonacci num- 22-
bers.
A similar technique applies to convolutions of
linear recurrence sequences. The convolution is
> Fn := F(n) = F(n-l) + F(n-2);
defined by Sn = L~=o akbn-k. Summation is
Fn := F(n) = F(n - 1) + F(n - 2) the special case where bk =
1. The sequence
(Sn) is encoded by the generating function S(z) =
> Fz := rsolve({Fn, F(l)=l, F(2)=1}, F(n), A(z)B(z), where A(z) and B(z) are the generat-
'genfunc' (z)) ; ing functions of (ak) and (b k ). Expanding S(z)
gives Sn'

123
Consider the convolution Sn = 2:;=0 k2 n- k . linear recurrence Sn = Sn-1 + an, for boundary
To evaluate Sn, we use rgf _encode to find the gen- condition So = ao. For the sum of the Fibonacci
erating functions of (n) and (2 n ), multiply them to numbers, we noted that the indefinite sum can be
find the generating function of Sn , and expand the expressed using the symbolic name Fn . In gen-
resulting generating function with rgf .expand. eral, the indefinite sum of any linear recurrence
sequence (an) can be expressed in finite terms us-
ing the symbolic function name an [2, 3].
> Az := rgf_encode(n, n, z);
We use the function rgf...relate to evalu-
z ate indefinite summations that involve symbolic
Az := -------- names of linear recurrence sequences. This func-
2 tion is a general purpose routine that relates
(1 - z) two sequences that have common factors in the
denominator of their generating functions. Let
> Bz := rgf_encode(2-n, n, z); the sequence (an) be encoded by the generat-
ing function A( z). Let B( z) be a generating
1
function whose denominator has factors in com-
Bz := -------
1 - 2 z mon with the denominator of A(z). The func-
tion rgf...relate expresses the sequence encoded
by B( z) in terms of the symbolic sequence name
an. The first four arguments of rgf ...relate de-
n scribe the generating function A( z) and the se-
- n - 2 + 2 2 quence (an), The last two arguments describe the
generating function B(z) of the sequence that is
to be expressed in terms of an,
3. Summations and Convolutions Involv-
Consider Sn = 2:;=1 Fk, the summation of
ing Symbolic Function Names
the first n Fibonacci numbers. We found the
generating function F(z) of (Fn ) in Section 2. To
Often, a summation involves a symbolic function find an expression for the indefinite summation
name instead of a closed form expression. For Sn, we divide F( z) by 1 - z and relate Sn to the
example, the problem might be to evaluate the symbolic name Fn .
summation Sn = 2:;=1 Fk, where (Fk ) is the se-
quence of Fibonacci numbers. If a recurrence or
generating function is given for the named func- > rgf_relate(Fz, z, F(n), n, Fz/(1-z), z);
tion, we can use the functions in Section 2 to
find a generating function for the solution and
2 F(n) + F(n - 1) - 1
then expand it. However, this may not be de- The expression for Sn can be left in this form,
sirable or feasible. The solution might be more or the Fibonacci recurrence can be applied twice
understandable if it can be expressed in terms to express this in the simpler form F n +2 - 1. The
of the named function. For example, the sum function rgf....simp does this simplification for us.
of the first n Fibonacci numbers is known to The function has 5 arguments and an optional
be Fn +2 - 1. The corresponding closed form is sixth argument. It simplifies an expression with
(((1 + J5)/2)n+2 - ((1- J5)/2)n+2)/J5 - 1. It respect to a symbolic sequence name. The first
is not unreasonable to regard Fn +2 - 1 as a more argument is the expression to be simplified. The
informative solution. In other cases, a named second and third arguments define the generating
function used in a problem may have a generating function of the sequence being simplified. The
function that cannot be expanded by rgLexpand. fourth and fifth arguments describe the sequence
Thus, we cannot find a closed form solution for the name. If the sixth argument is omitted, the ex-
problem. pression is simplified relative to the nth term of
The sum Sn = 2:;=0 Fk is the indefinite sum- the sequence. If the sixth argument is present,
mation of the sequence (Fk)' Evaluating the in- it provides the target index, and the sequence is
definite summation Sn = 2:;=0 ak of a linear re- simplified relative to that index.
currence sequence (an) is equivalent to solving the

124
> rgf_simp(Sn, Fz, z, F(n), n, n+2); result, we first expand S(z) using partial fractions
with respect to z.
F(n + 2) - 1

This technique works for all linear recurrence


sequences. We examine one other example here.
Consider the sum sn = L~=o tk, where the se- 1
quence (tk) is defined by the recurrence t n = Tz := --------------
t n- 1 + 2t n -2 + 3t n-3 with boundary conditions 2
to = =
0, tl =
1, and t2 2. Following the steps 1 - 2 z + 3 z
above, we can express Sn in finite terms using the
> Sz := convert(Fz*Tz, 'parfrac', z);
symbolic name tn.
5 + 4 z
> Tn := T(n)=T(n-l)+2*T(n-2)+3*T(n-3); Sz := - 1/11 ------------
2
Tn := T(n) = T(n - 1) + 2 T(n - 2) - 1 + z + z

+ 3 T(n - 3) - 5 + 12 z
+ 1/11
> Tz := rsolve({Tn, T(i=O .. 2)=i}, T(n), 2
'genfunc'(z»; 1 - 2 z + 3 z

The left hand term can be related to Fn and


2
the right hand term can be related to tn'
z + z
Tz := - ---------------------
2 3 > rgf_relate(Fz, z, F(n), n, op(l, Sz), z);
- 1+ z + 2 z + 3 z
9/11 F(n) + 5/11 F(n - 1)
> rgf_relate(Tz, z, T(n), n, Tz/(l-z), z);
> rgf_relate(Tz, z, T(n), n, op(2, Sz), z);
6/5 T(n) + T(n - 1) + 3/5 T(n - 2) - 2/5
12
Convolutions involving symbolic names of lin- - 5/11 T(n) + ---- T(n - 1)
ear recurrence sequences can also be expressed in 11
finite terms using those symbolic function names.
In some cases, rgf .relate can be applied imme- Adding the two expressions gives Sn'
diately to evaluate the convolution. Consider the In general, all convolutions involving symbolic
convolution of the Fibonacci sequence with itself, names of linear recurrence sequences can be ex-
Sn = L~=l FkFn-k· The generating function of pressed in finite terms using the symbolic names
Sn is F2(z) = z2/(1 - z - z2)2. We can relate Sn of the sequences involved in the convolution [2, 3].
to Fn . We can evaluate such convolutions by applying
partial fractions and then relating each term of
the partial fraction expansion to the appropriate
sequence.
(1/5 n - 1/5) F(n) + 2/5 F(n - 1) n

For other convolutions, this approach does not 4. Hybrid Terms and Linear Indexing
give satisfactory results. Consider the convolution
Sn = L~=o tkFn-k, where (tk) is encoded by the Hybrid terms are sequences defined by the term-
=
generating function T(z) 1/(1- 2z + 3z 2). The wise product of two or more parent sequences.
generating function of Sn is T(z)F(z) = z/(l-z- For example, Fn 2n is a hybrid term derived from
z2)/(1- 2z + 3z 2). We can relate Sn to either the the sequences (Fn) and (2 n ). If (an) and (b n )
symbolic name Fn or the name tn' However, the are linear recurrence sequences, then the hybrid
most desirable result relates Sn to both function sequence (anb n ) is a linear recurrence sequence
names, which rgf .relate cannot do. To find this and has a rational generating function [1, 2, 3].

125
The function rgf...hybrid computes the gen- that sequence will require at most m consecutive
erating function of a hybrid sequence. The first terms from the symbolic sequence name (2].
argument to rgf...hybrid is the generating func-
The techniques for hybrid sums work for all hy-
tion variable. The remaining arguments are the
brid sequences defined by the term-wise product
generating functions of the hybrid term's parent
of two or more linear recurrence sequences. We
sequences. Once the generating function of a hy-
examine one other example here. Consider the
brid term is found, we can employ the techniques
of Section 3 to evaluate summations and convolu-
hybrid sum Sn = L~=o akbk, where the sequence
(ak) is encoded by the generating function A(z) =
tions involving that hybrid term.
1/(I-z+4z 2 ) and the sequence (b k ) is encoded by
Consider the summation Sn = L~=l F'{ The the generating function B(z) = 1/(1- 5z - 2z 2 ).
sequence (F;) is a hybrid sequence defined by Following the steps above, we can express Sn in
the term-wise product of two Fibonacci sequences. finite terms using the symbolic function names an
We employ rgf ...hybrid to find its generating func- and bn .
tion.

> F2z := rgf_hybrid(z, Fz, Fz);

2
- z + z Az .= ------------
2
F2z .= - -------------------
1 - z + 4 z
2 3
1 - 2 z - 2 z + z

Dividing this generating function by l-z gives


the generating function for Sn. The value of 5 n can 1
then be related to the summand F;. Bz := --------------
2
1 - 5 z - 2 z
> rgf_relate(F2z, z, F(n)-2, n,
F2z/(1-z), z); > ABz := rgf_hybrid(z, Az, Bz);

2 2 2 2
3/2 F(n) + 1/2 F(n - 1) - 1/2 F(n - 2) 1 + 8 z
ABz := --------------------------------
This result expresses Sn in terms of the squares 234
of the Fibonacci numbers. We can leave the result - 5 z + 114 z + 40 z + 64 z
as is, or "simplify" it to involve just Fn and Fn - 1 .
> Sn:= rgf_relate(ABz, z, AB(n), n,
ABz/(1-z), z);
> rgf_simp(", Fz, z, F(n), n);
213 52
2
Sn .= --- AB(n) + --- AB(n - 2)
F(n) + F(n) F(n - 1)
214 107
A further "simplification" can be obtained if
we simplify with respect to Fn +1 . 109 32
+ --- AB(n - 1) + --- AB(n - 3) + 9/214
107 107
> rgf_simp(", Fz, z, F(n), n, n+1);

F(n) F(n + 1) > Sn ,= subs({seq(AB(n-i)=A(n-i)*B(n-i),


i=O .. 3)}, Sn);
We note that while these simplifications work
out well for summations involving Fibonacci num- 213 52
bers, results for other sequences are not so com- Sn := --- A(n) B(n) + --- A(n - 2) B(n - 2)
pact. In general, if a sequence is defined by an or- 214 107
der m recurrence, simplified expressions involving

126
109 recurrence sequence, then the sequence (aan+iJ),
+ --- A(n - 1) B(n - 1) for integer constants Q' > 0 and (3, is a linear re-
107 currence sequence and has a rational generating
function [2, 3].
32
+ --- A(n - 3) B(n - 3) + 9/214 We need one other piece of information before
107 we can compute the generating function of a se-
quence defined by linear indexing. If a sequence
We can leave the expression in this form, or (an) is defined by an order m recurrence, then the
"simplify" it relative to an and bn . sequence (aan+iJ)' for integer Q' > 0 and (3, is de-
fined by an order m recurrence [3]. Knowing this,
> Sn := rgf_simp(Sn, Az, z, A(n), n); we can use the function rgLfindrecur to com-
pute the order m recurrence defining (aan+iJ)'
The function rgLfindrecur computes the or-
Sn := 9/214
der m recurrence that defines a sequence from 2m
consecutive values of the sequence. Once the re-
/213 13 currence is found, rsolve is used to find the gen-
+ 1--- B(n) - --- B(n - 2) erating function for the sequence. The techniques
\214 107 of Section 3 can then be used to evaluate summa-
tions and convolutions that involve the linearly
\ indexed sequence.
- 2/107 B(n - 3) I A(n)
Consider the summation Sn = I:~=o tk, where
/
tk = F2k+l' The sequence (Fk) is defined by
/109 an order 2 recurrence, therefore (tk) is defined
+ 1--- B(n - 1) - 6/107 B(n - 3) by an order 2 recurrence. The first four terms
\107 of the sequence (tk) are (1,2,5, 13). The func-
tion rgf...findrecur computes its recurrence and
13 \ rsolve computes its generating function T(z).
+ --- B(n - 2)1 A(n - 1)
107 /
> rgf_findrecur(2, [1,2, 5, 13], T, n);
> Sn := rgf_simp(Sn, Bz, z, B(n), n);
T(n) = 3 T(n - 1) - T(n - 2)
/205 14 \
Sn := 9/214 + 1--- A(n) + --- A(n - 1)1 B(n) > rsolve({", T(O)=l, T(1)=3}, T(n),
\214 107 / 'genfunc' (z)) ;

/ 19 36 \
+ 1--- A(n) + --- A(n - 1) 1 B(n - 1) Tz := ------------
\107 107 / 2
z - 3 z + 1
> expand(");
The generating function of Sn is T(z)j(l- z).
205 19 The value of Sn can be related to F 2n +1 and the
9/214 + --- A(n) B(n) + --- A(n) B(n - 1) resulting expression simplified relative to F 2n .
214 107

14 36 > rgf_relate(Tz, z, F(2*n+l), n,


+ --- A(n - 1) B(n - 1) + --- A(n - 1) B(n) Tz/(l-z), z);
107 107
2 F(2 n + 1) - F(2 n - 1) - 1
Linear indexing uses a linear polynomial to in-
dex a linear recurrence sequence. The sequence > rgf_simp(", Fz, z, F(n), n, 2*n);
(F2n +1 ) uses the linear polynomial 2n + 1 to in-
dex the Fibonacci numbers. If (an) is a linear 2 F(2 n) + F(2 n - 1) - 1

127
Not surprisingly, this can be further simplified Robert A. Ravenscroft, Jr. received his Ph.D.
to yield a more compact result. in computer science from Brown University. His
research interests include the analysis of algo-
rithms and symbolic computation. In 1991-92,
> rgf_simp(Il, Fz, z, F(n), n, 2*n+2);
he was a visiting post-doctoral fellow with the
F(2 n + 2) - 1 Symbolic Computation Group at the University
of Waterloo. While there, he implemented the
genfunc package in Maple and redesigned and
5. Conclusion reimplemented much of the rsolve library func-
tion. He was most recently employed as a lecturer
This paper considered the use of rational gen- in computer science at the University of Rhode
erating functions in Maple to find finite expres- Island.
sions for summations and convolutions of linear Robert Ravenscroft
recurrence sequences. Techniques were presented Department of Computer Science and Statistics
that handled hybrid terms and linear indexing. Tyler Hall, University of Rhode Island
The techniques presented in this paper are gen- Kingston, RI 02881, USA
eral enough to solve quickly and conveniently any
summation or convolution involving linear recur-
rence sequences.
The author would like to thank Edmund La-
magna, John Savage, and Keith Geddes for their
useful feedback on this work.

REFERENCES

[1] Robert A. Ravenscroft, Jr. and Edmund A.


Lamagna, "Symbolic Summation with Gen-
erating Functions," Proceedings of the ACM-
SIGSAM 1989 International Symposium on
Symbolic and Algebraic Computation, ACM
Press, 1989.

[2] Robert A. Ravenscroft, Jr., "Generating


Function Algorithms for Symbolic Computa-
tion," Ph. D. Thesis, Department of Com-
puter Science, Brown University, 1991.

[3] Robert A. Ravenscroft, Jr., "Symbolic Com-


putation with Generating Functions," sub-
mitted to Journal of Symbolic Computa-
tion special issue Symbolic Computation
in Combinatorics AI, the Proceedings of
the ACSyAM Workshop September 21-24,
1993, Mathematical Sciences Institute, Cor-
nell University.

128
IIIB. MAPLE IN SCIENCE
SYMBOLIC-NUMERIC COMPUTATIONS FOR PROBLEM-
SOLVING IN PHYSICAL CHEMISTRY AND BIOCHEMISTRY

J. Grotendorst 1, J. Dornseiffer2 and S. M. Schoberth3


Central Institute for Applied Mathematics1, Institute for Applied Physical Chemistrl,
Institute for Biotechnology3, Research Center JOlich, JOlich, Germany

ply using a general ODE solver. It is also an in-


dependent method compared to the solution tech-
1 Introduction niques found in the literature [1-3J. In addition,
methods of mixed symbolic-numeric type for the
This article presents two illustrative examples, determination of the formal parameters involved
from Physical Chemistry and Biochemistry, show- in the analytical solutions are described.
ing how the use of modern computing tools such

I
as Maple changes the approach to solving mathe-
matical problems in science. The concept of scien-
tific computation has evolved from a field encom-
symbolic
passing primarily numerical methods to a much
broader field that includes algebraic and analytical
methods, numerical methods, and graphics. The
combination of all these computing techniques fa-
cilitates efficient and accurate problem-solving. It
allows the development of software systems for the
automatic solution of problems in ways that are
not possible with conventional computing systems. Figure 1: Computing steps in a scientific problem-
Figure 1 displays typical steps in a computerized solving process.
solution process.
First, we study the thermodynamic behavior of
steam reforming reactions. The product compo- 2 Physical Chemistry
sition at equilibrium is calculated by solving a
system of nonlinear equations which itself is de- The catalytic reaction between steam and hydro-
rived by reformulating the equilibrium condition carbon into mixtures of hydrogen, carbon monox-
for each separate reaction. The Newton-Raphson ide, carbon dioxide and methane forms the ba-
method and symbolic computation techniques are sic feedstock (synthesis gas) to produce ammo-
used to solve this system of nonlinear equations. nia, methanol and other chemicals. To find the
most economic reaction conditions, especially car-
In our second example we demonstrate how the
bon boundaries, it is necessary to study theoret-
McConnell equations in Biochemistry, a linear in-
ically the reaction behavior with respect to the
homogeneous system of differential equations with
operating parameters. In the present thermody-
constant coefficients, can be solved elegantly by
namic study we examine the temperature and
using symbolic linear algebra alone. This method
pressure dependence of chemical compositions at
utilizes the special structure of the ODE system
equilibrium. We consider the following simple sys-
and therefore is faster and more direct than sim-
tem of steam reforming reactions to demonstrate
the mathematical model and the computation
techniques involved:

131
1. The methane-steam equality

2. The water-gas shift [nl - ~l - 6, n2 - 6 - 6, n3 + ~l - 6,


n4 +3~1 +6 +26,n5 +6]
3. The carbon-methanation equality The equilibrium constants of the reactions in
terms of the partial pressures
> p:=vector([P[CH4],P[H20] ,P[CO] ,P[H2],
P[C02]]);
To set up a practical computation model the equi-
librium condition for each separate reaction is for-
mulated in terms of the reaction extents ~i,
i= 1..3. If nej, j =
1..5, is the number of moles
of chemical species Sj present at equilibrium and are calculated by
nj is the initial number of moles of that species,
then we have > eqn[i] :=K[i]=
Product(p[j]A al pha[j,i],j=1 .. 5);
3 print(");
nej = nj + L>~ji~i'
5
i=l

where Q,ji are the stoichiometric coefficients of


Ki = II Pj
j=l
Qji

species Sj in each of the reaction equations (i)


[4]. The matrix of stoichiometric coefficients for > for i from 1 to 3 do
these molecular mass balance equations is given print(value(eqn['i']»
od:
by (Maple commands will occur on lines begin-
ning with" > "):
K 1 -- PCOPk2
> with(linalg): PCH4 Pmo
alpha:=matrix([[-l,O,-l],[-l,-l,O],
[1,-1,0],[3,1,2], K
2
= Pm PC02
[0,1,0]]); PH20 PCO

-1 0 -1 K3 = PlI2
PCH4
-1 -1 0
Now, if we insert the relation Pj = XjP, where Pj
Q, := 1 -1 0 denotes the partial pressure, P the total pressure
3 1 2 and Xj the mole fraction of chemical component
Sj, then we obtain
o 1 o
> for j from 1 to 5 do
Therefore, the composition of the participating p[j] :=x[j]*P
chemical components at equilibrium is evaluated od:
by the following matrix algebra: j :=' j' :
for i from 1 to 3 do
> xi:=vector(3): print(value(eqn['i']»
print(xi); od:
n :=vector(5):
print(n);
ne:=add(n,multiply(alpha,xi»:
print(ne);

132
Before solving this system of nonlinear equations
we determine the temperature dependence of the
constants In(Ki ), i = 1..3. To obtain an expres-
sion for the reaction enthalpy we use Kirchhoff's
law with a polynomial ansatz for the description
of the molar heat capacity. We have
> diff(H(T),T)=
Sum(A[j].(s.T)~j,j=O.. 6);
The individual mole fractions Xj are calculated by
dividing nej by the total number of moles. Thus, d
L Aj (sT)j
6
the sum over the component index should yield dTH(T) =
unity. j=O
> nsum := sum(ne[j],j=1 .. 5): > expand(dsolve(value("),H(T)));
x := map(y -> y/nsum,ne); assign(II):

6 n3 + {l - 6 2 2 4
nl - {l - 6 n2 - {l - H(T) = A T A l sT A2s T3 A3S 3T
x := [ %1 ' %1 ' %1 ' 0+ 2 + 3 + 4 +

n4 + 3{l + {2 + 26 ns + 6 J A4s4Ts Ass sT6 A6s6T 7 Cl


5 + 6 + 7 +-
%1 '%1
Here, s (= 10- 3 ) denotes a scaling factor of the
%1 = nl + 26 + 6 + n2 + n3 + n4 + ns temperature T as used in thermochemical tables.
> Sum(x[j],j=1 .. 5)= Inserting the expression for H(T) into the equa-
simplify(sum(x[j],j=l .. 5)); tion of van't Hoff and then integrating yields
> diff(lnK(T),T)='H(T)'/(R.T~2);

d H(T)
dT InK(T) = RT2
The equilibrium mixture defined by {i, i = 1..3, > expand(dsolve(", InK(T)));
must simultaneously satisfy the equilibrium condi- assign(II):
tion for each reaction, i.e. since Xi = xi(6,6,6)
we have to solve the following equations for the
I K(T) _ A6S6T 6 AsssTs A4s4T 4 A3S3T3
reaction extents simultaneously: n - 42 R + 30 R + 20 R + 12 R +
> for i from 1 to 3 do A2S2T2 AlsT Ao In(T) _Cl C2
f[i] := In(value(rhs(eqn['i'])))- 6R +"""2R+ R -RT+-
In(lhs(eqn['i']))=O:
print("); The coefficients A j are determined by the cor-
od: responding coefficients of the pure substances in
each reaction. These coefficients can be obtained
from thermochemical data prepared for computer
In (P2 (n3 + {l - 6)( n4 + 36 + 6 + 26)3) _ calculations [5J. The following coefficient matrix
(nl - {l - 6) is used:
In(nl +2{l +6+n2+n3+n4+ns)2(n2-{l-6))-
aOCH4 aOH2o aOco aOH2 aOC02 aOe
In(Kt} =0 ale
al CH4 alH20 al co al H2 al CO2
In ((n 4 + 3{l + 6 + 26)(ns + 6)) -In(K2) = 0 a2CH4 a2H20 a2co a2H2 a2C02 a2e
(n2 - {l - 6)(n3 + {l - 6)
a9CH4 a9H20 a9co a9H2 a9C02 age
In (p(n 4 + 36 + {2 + 2{3)2) _
(nl - {l - 6) a4CH4 a4mo a4co a4H2 a4C02 a4e

a5CH4 a5H20 a5co a5H2 a5C02 a5e


In(nl +2{l +6 +n2 +n3 +n4 +ns) -In(K3) = 0
a6CH4 a6H20 a6co a6H2 a6C02 a6e

133
Now, reading in the coefficients In(K[i])=eval(lnK(T));
print(");assign(");
> readlib(readdata): _C1:='_C1':_C2:='_C2':
U:=readdata(fprothero.dat f ,6): od:
U:=convert(U,matrix):
and then including carbon (graphite) into the sto- In(Kd =
ichiometric coefficient matrix 0::
-2.266129470 1O- T 6 + 2.7517048361O- 16 T 5 -
2o

> beta:=stack(alpha,[O,O,l]);
1.439640670 1O- 12 T 4 + 4.206807101 1O- 9T 3 _
-1 0 -1 7.207461326 1O- 6 T 2 + 5.133144050 1O- 3 T+
-1 -1 0
5.2643363741n(T) - 23067.92495~ -10.97646894
1 -1 0
/3=
3 1 2 In(K2 ) =
0 1 0 -8.800218119 1O- 21 T 6 + 1.129751855 1O- 16 T 5 _
0 0 1 6.422612785 1O- 12 T 4 + 2.153951730 1O- 9T 3 _
allows calculation of the coefficients A j , j = 0..6, 4.851992918 1O- 6 T 2 + 8.483621895 1O- 3T-
for the three reactions by the following matrix
multiplication: 2.665443083 In(T) + 4698.749275~ + 8.82258362
> V:=multiply(U,beta): print(V);
In(K3 ) =
10.45411100 -5.293134000 2.846880000 -2.0366411411O- 20 T 6 + 2.568659013 1O- 16 T 5 _
20.38716900 33.69417100 36.52153400 1.4047837711O- 12 T 4 + 4.3494237471O- 9 T 3 -
-85.87703600 -57.81158600 -98.41227000 8.259514570 1O- 6 T 2 + 9.195504045 1O- 3 T+
100.2483700 51.32875000 103.6469300
1.433592386 In(T) - 8107.550186~ - 3.56194983
-57.17781800 -25.50851700 -55.79341600
6.730507200 15.30281000
This completes the thermodynamic model. Next,
16.39330720
we consider a feed mixture of nl = 1 moles of
-1.890068240 -0.7339833400 -1.698663200 methane and n2 = 1 moles of steam under a pres-
sure of P = 5 bar and solve the equilibrium equa-
The integration constants _Cl and _C2 can be
tions for the reaction extents ~i, i = 1..3. In Maple
calculated by using special values of H(T) and we applied the procedure fsolve which permits the
InK(T) at standard conditions (T = 298.15° K)
numerical solution of equations. Assuming a step
for the three equations [6J. Inserting the value of
size of 10 degrees the program fsolve had to solve
the gas constant R and taking into account the
46 times a system of three nonlinear equations
conversion factor F between the unit cal (used in
within an accuracy of 6 digits over the interval
Prothero's thermochemical table [5]) and the SI
T = [750..1200J. On a RS/6000-32H workstation
unit Joule we eventually arrive at:
this computing task requires about 80 seconds.
> HO[l] :=206185: HO[2] :=-41165: The temperature dependence of the reaction ex-
HO[3]:= 74873: tents and the resulting mole fractions for steam,
lnKO[l] :=-57.3621: InKO[2] :=11.546:
lnKO[3] :=-20.47458665: hydrogen, carbon monoxide, carbon dioxide, and
s:=10-(-3): R:=8.3143: F:=4.1868: methane are displayed in Figures 2 and 3. When
for i from 1 to 3 do the reaction extent 6 is zero or negative, the con-
for j from 0 to 6 do dition for no carbon formation (see Fig. 2), then
A[j] :=F*V[j+1,i]; a two dimensional calculation model has to be ap-
od;
solve ({HO [i] =subs(T=298. 15, plied. Setting 6 = 0 we obtain the two roots of
H(T))},_C1) ;assign(II); 6(T) as follows:
solve({lnKO[i]=subs(T=298.15,
InK(T))},_C2);assign(");

134
3.0" .
0.' 0.' ,.
x1(ll x1(lJ

0.' 0.'

0.' 0.'

0.'
xl[2J
xl

+---;!ti==".........::::::::::::",loo----;,:o'Ooo~o -=::::::""'iilltlio~==~oo • 0 , 0 uoo


T (lCelvlnl T (Kelvin)

~o. 2 -0. ;Z

Figure 2: Temperature dependence of the reaction Figure 4: Temperature dependence of the reaction
extents ~i, i = 1..3, under the conditions P = 5 bar extents ~i, i = 1..3. Same conditions as in Figure
and a steam to carbon atom ratio H 2 0: C = 1 : 1. 2. In regions with no carbon formation a two di-
mensional calculation model is applied.
X[jll- ''-''""..:..(x..:.:[J.:.:.J•.:.:.l-'.:.:.
......;''_ _

6= .729953,6 = .0616126,T = 1095.76


0.'
6 = .190220,6 = .143352, T = 837.633
Figure 4 shows the effect on the reaction extents
6 and 6 when a two dimensional calculation is
done in regions with no carbon formation.
For the fast numerical solution of the nonlinear
equations we used the Newton-Raphson algorithm
and the programming language FORTRAN. The
, 0 uoo
Jacobian matrix needed for this algorithm is cal-
• 0 1000 1100
T (lCelvln)

culated in exact form by Maple. The system of


linear equations encountered in the Newton iter-
Figure 3: Temperature dependence of the mole ation is solved numerically by applying the LV
fractions Xj,j = 1..5. Same conditions as in Fig- decomposition routine dgetrs and the general lin-
ure 2. ear equation solver dgetr f from LAPACK [7J. A
preprocessor for FORTRAN code generation and
> P:=5: n[l] :=1: n[2]:=1: optimization was implemented in Macrofort [8], a
n[3] :=0: n[4] :=0: n[5] :=0: macro language for FORTRAN code generation in
Digits:=6; Maple (see Appendix). This preprocessor provides
fl:=lhs(f[l]): f2:=lhs(f[2]): the capability to construct complete and ready-to-
f3:=lhs(f[3]): xi[3] := 0: compile FORTRAN code for a given problem size,
fsolve({fl,f2,f3}, {xi[1],xi[2] ,T},
{xi[1]=0.6 .. 0.8,xi[2]=.0 .. 0.1, i.e. larger systems of reaction equations can be
T=1070 .. 1100}): studied in the same way as demonstrated here.
Op(lI) ; The generated numerical programs were used to
fsolve({f1,f2,f3}, {xi[1] ,xi[2] ,T}, investigate the temperature and pressure depen-
{xi[1]=0.15 .. 0.25, dence of the reaction extents and the resulting
xi[2]=.05 .. 0.2, T=820 .. 860}): mole fractions (see Fig. 5 and 6).
Op(") ;

135
d
dt MA(t) = -kA1 MA(t) + L1MB(t) + dA
d
dt MB(t) = k1MA(t) - kB1 MB(t) + dB

The functions MA(t) and MB(t) describe the time


dependence of the nuclear spin magnetization of
a single nuclear species which is transferred back
and forth between chemically distinct sites
(A ~ B) by kinetic processes. The magnetic res-
onance signals measured in NMR experiments are
quantified as peak areas. The parameters k1 and
k_ 1 characterize the first-order rate constants for
Figure 5: Temperature and pressure dependence the forward and reverse reactions. The meaning
of the reaction extent 6. The steam to carbon of the other parameters will become clear in the
atom ratio is H 2 0: C = 1 : 1. sequel. From linear algebra we know that ODE
systems with constant coefficients can be solved
with the help of matrix exponentials [12J. To do
it in Maple we first have to define the appropriate
matrices.

> with(linalg):
C:=matrix([[-k[Al], k[-l]],
[ k[l], -k[Bl]]]);
D:=vector([d[A], dEB]]);
YO:=vector([MAO, MBO]);

C:= [-kkA1
1
Ll]
-k B1
D:= [dA,dBJ
YO:= [MAO,MBOJ
Figure 6: Temperature and pressure dependence
of the mole fractions Xj, j = 1..5. Same conditions Applying the Maple function for the evaluation of
as in Figure 5. matrix exponentials leads to the following solution
of the inhomogeneous ODE system:
3 Biochemistry > F:=multiply(exponential(C, t), YO):
f:=s -> multiply(exponential(C,
In recent years, in vivo nuclear magnetic reso- t-s), D):
nance (NMR) spectroscopy has allowed measuring P:=vector([int(f(s) [1] , s=O .. t),
rate constants of transport and diffusion across liv- int(f(s) [2] , s=O .. t)]):
81:= add(F,P):
ing cell membranes [9-10J. The theoretical basis
for the analysis of magnetization-transfer exper- It should be noted that the solution of the analo-
iments is a system of differential equations first gous one-dimensional ODE is found in a formally
introduced by McConnell [l1J. These equations, identical way. The correctness of the one dimen-
here formulated in a slightly different way as in sionl solution is easily verified:
Ref. [3], are given by > exp(c*t)*yO+int(exp(c*(t-s»*d,
s=o .. t):
> diff(MA(t),t)=-k[Al]*MA(t) + evalb(expand(diff(",t)=c*"+d»;
k[-l]*MB(t) + d[A];
diff(MB(t),t)= k[l]*MA(t) -
k[Bl]*MB(t) + dEB];

136
true the particular solution, is constant. Then, linear
algebra computations in Maple lead to the follow-
If matrix C is invertible then the solution of the in- ing compact analytical solution (see Ref. [13J for
homogeneous ODE system can be computed with details):
matrix algebra alone. We have

> CD:=multiply(inverse(C), D):


(V%1- k B1 + kAl ) MAlO
MA(t) = -
S2:=add(multiply(exponential(C,t), ( 2V%1
add(YO,CD)), -CD):
Again, this direct solution can be motivated by
the one dimensional case:

> dsolve({diff(y(t),t)=
c*y(t)+d, y(O)=yO}, y(t))i

y(t) = -~ +ect (~+ yo) (-kA1-kBl +v'%T).


e 2 + MeA
Comparing the solutions Sl and S2 yields
( -k Al + kBl + V%1) MB10
> map(simplify, add(Sl,-S2))i MB(t) = -
( 2V%1
[O,oJ klMA10) _(kAl+kBl+v'%T)·
e 2 +
Next, we introduce physical boundary conditions V%1
to obtain a special regular solution. Let MeA and
MeB denote the unperturbed equilibrium magne- (V%1- kBl + kAl ) MB10 + klMA10 +)
tizations of A and B respectively, Le. the limits ( 2V%1 V%1
of MA(t) and MB(t) for t -+ 00. These limits are
given by the components of the constant vector (-kAl-kBl +~).

-CD in solution S2
e 2 + MeB
> MeA := -CD[l]i MeB := -CD[2]i #(*) where

MeA := dAkBl + dBL l


kAl kBl - Llkl
MeB:= kldA + dBkAl and
kAl kBl - k_lk l MAIO = MAO - MeA,
provided that both eigenvalues of matrix C
MB10 = MBO - MeB.
> eigenvals(C)i
Solving the ODE system via the Maple function
dsolve needs much more time compared to the
k A1 kBl Jk~l - 2 kAl kBl + ktl + 4 k_lkl more direct method using the matrix exponentials.
--2--2+ 2 On a RS/6000 workstation we measured a factor
greater than 60 between these two methods. This
_ k A1 _ kBl _ Jk~l - 2 kAl kBl + ktl + 4 k_lkl
is explained by the more general algorithms used
2 2 2
in dsolve which work for nonlinear equations and
are negative. For realistic parameter values this may not be efficient for homogeneous linear sys-
condition holds. We have kl ~ 0, L l ~ 0, k Al = tems.
l/TlA + kl ~ kl , and kBl = l/TlB + L l ~ k_ l .
Here, l/TlA and l/TlB denote the relaxation rates The analytical solutions for MA(t) and MB(t) de-
of the spins in the two environments A and B. pend on the eight parameters MAO, MBO, MeA,
Under condition (*) the solution of the original MeB, TlA, TlB,k l , and L l . Here, MAO and MBO
inhomogeneous ODE system can be simplified to denote the initial values of MA(t) and MB(t) at
a sum where one term is the solution of a homo- time 0. Usually, the parameters involved in MA(t)
geneous ODE system and the other term, usually

137
and MB(t) are determined by a nonlinear least- system such as Maple enables an automatic and
squares analysis, Le. by fitting the model parame- computerized solution of problems in ways that
ters to experimental data for MA(t) and MB(t) ob- are not possible with conventional computing sys-
tained at different values of time [1-3J. For the nu- tems.
merical parameter fitting we used the ACM In our first example we study the thermodynamic
program NL2S0L [14J which is based on the behavior of steam reforming reactions and deter-
Levenberg-Marquardt algorithm and which needs mine the temperature and pressure dependence of
an analytic Jacobian matrix as input. The sym- the chemical compositions at equilibrium. Using
bolic evaluation of the Jacobian matrix is done Maple's symbolic computation capabilities a sys-
by the Maple procedure jacobian. Again, for the tem of nonlinear equations for the reactions ex-
translation into optimized FORTRAN code and tents is derived. For the fast numerical solution
the generation of a driver program for the fitting of the nonlinear equations we applied the Newton-
routine we implemented a preprocessor in Macro- Raphson algorithm and the programming language
fort [8J. This program generator is capable of FORTRAN. A FORTRAN preprocessor in Maple
constructing complete and ready-to-compile FOR- calculates the Jacobian matrix needed for this al-
TRAN code for a given set of functions and pa- gorithm and generates a complete and ready-to-
rameters. compile FORTRAN program.
Now, for plotting the functions MA(t) and MB(t) In the second example we demonstrate how the
we substitute special values for the formal param- McConnell equations in Biochemistry, a linear in-
eters. These values were computed by fitting data homogeneous system of differential equations with
from inversion transfer experiments to investigate constant coefficients, can be solved analytically in
transport processes in a special biological system a direct way by using Maple's symbolic linear al-
[15J (see Fig.7). gebra routines. In addition, the automatic gener-
ation of numerical code for the determination of
the formal parameters involved in the solutions is
MA(t) described.
140

1>0 References
[lJ J. J. Led and H. Gesmar, J. Magn. Res. 49,
444-464, (1982).
MB(t)

[2] P. W. Kuchel and B. E. Chapman,


J. Theor. BioI. 105,569-589, (1983).
[3] G. Robinson, B. E. Chapman, and P. W.
Kuchel, Eur. J. Biochem. 143, 643-649,
(1984).
[4] A. Ovenston and J.R. Walls, Chem. Engi-
Figure 7: Plot of MA(t) and MB(t) for the special neering ScL 35, 627-633, (1980).
parameter values k1 = 6.6, k_ 1 = 10.5, MeA =
153.5, MeB = 78.8, MAO = 130.4, MBO = [5] A. Prothero, Comb. Flame 13, (1969).
27.08, T1A = 1.4, and T1B = 1.8.
[6] I. Barin "Thermochemical Data of Pure
Substances", VCH Verlagsgesellschaft,
Weinheim (1993).
4 Conclusion [7] J. Dongarra et al., "The LAPACK user's
guide", SIAM publications, Philadelphia,
The combination of symbolic and numeric compu-
(1992).
tation techniques leads to new approaches in areas
of applied mathematics and science. It is shown, in [8] C. Gomez, "Macrofort: a FORTRAN code
examples from Physical Chemistry and Biochem- generator in Maple" , Maple Share Library,
istry, how the use of a modern computer algebra Version 5.0.

138
[9] K. Kirk, NMR Biomed. 3, 1-16, (1990). [I 'eps,maxiter:' I], [J],
[readm,input,[ld22.15 I ,i6],
[10] P. W. Kuchel, NMR Biomed. 3, 102-119, [eps,maxiterJ] ,
(1990). [writem, output ,
[I 'start,step,nsteps:' I], [J],
[11] H. M. McConnell, J. Chem. Phys. 28,430- [readm,input, [12e14.7,i6 1] ,
431, (1958). [start,step,nsteps]]] ;
# while instruction
[12] P. Hartman, "Ordinary Differential Equa- linit:=[[writem,output,
tions", John Wiley & Sons, Inc., (1964). [I'Inital vector Xi:,I] ,[]],
[readm,input, [II .d. le14.7 1],
[13] J. Grotendorst, P. Jansen, and S. M. [seq(xi[ii] ,ii=l .. d)]]];
Schoberth, The Maple Technical Newslet- for ii from 1 to d do
ter, 1, 56-62, (1994). pushe([equalf,f[ii],ff[ii]],
'linit')
[14] J. E. Dennis, D. M. Gay, and R. E. Welsch, od;
ACM Trans. Math. Software, Vol. 7, No.3, lWhile:=[[matrixm,zj,jac],
[callf,dgetrf,[d,d,zj,d,
(1981 ). ipiv,infoJ] ,
[15] S. M. Schoberth, A. A. de Graaf, B. E. [callf,dgetrs, [I 'N,I ,d,l,zj,
d,ipiv,f,d,info]],
Chapman, P. W. Kuchel, and H. Sahm, XV [dom,k,l,d, [equalf,xi[k] ,
International Conference on Magnetic Res- -f[k] +xi[k]]]] ;
onance in Biological Systems, Jerusalem, for ii from 1 to d do
Israel, August 16-21, (1993). pushe([equalf,f[ii],ff[ii]],
, lwhile , )
od;
5 Appendix llwhile:=[whilem,znorm(f,d) >= eps,
linit,lwhile,maxiter];
# translate the mole fractions
It follows a listing of the FORTRAN code gener- fw:=[J ;
ator genJ'ort in Macrofort and an example how it for ii from 1 to dd do
was used within Maple: pushe ([equalf,y[ii],xl[ii]],
'fw' )
> with(share): od;
readlib(macrofor): fw:=[op(fw),[writem,4,[19(lx,e14.7),
read(gen_fort): lx,i6 1],[T,y,xi,nwhilel]]];
fl:=map(y->lhs(y) ,f): forloop:=[dom,j,l,nsteps,[[equalf,T,
gen_fort(fl,xi,3,x,5,l extents.f l ): start+(j-l)*step],llwhile,fw]];
# Maple program gen_fort in Macrofort
pg:=[op(pg),[openm,4,lresult.datl,
gen_fort:=proc(ff,xx,d,xl,dd,pg_name) UNKNOWN,forloop]];
local f,fo,ii,jac,jj,j,k,linit, pg:=[programm,newton,pg] ;
lwhile,m,pg,xi,zj,y,ipiv,n, # fo: quadratic norm of f
nwhilel,llwhile,forloop,fw,eps, fo: =[[declaref ,
maxiter,start,step,nsteps,P,T, limplicit double precision l ,
znorm; [I (a-h,o-z) IJ],
# calculate the jacobian matrix
[declaref,ldimension l , [f[m]]] ,
jac:=linalg[jacobian] [equalf,znorm,O.],
([seq(ff[ii],ii=l .. d)], [dom,j,l,d,[equalf,znorm,
[seq(xx[ii] ,ii=l .. d)]); znorm+f [j] **2]] ,
# pg: MAPLE list describing main pgm
[equalf,znorm,sqrt(znorm)]] ;
pg:=[[declaref, .. fo:=[functionm, Idouble precision I ,
limplicit double preclslon l znorm,[f,m] ,fo];
[I (a-h,o-z) IJ],
# FORTRAN code generation
[declaref,ldimension l , writeto(pg_name);
[f Ed] ,zj [d,d] ,xi[d] ,y[dd]]], init_genforO;
[declaref,dimension,[ipiv[d], precision := double;
n[dd]J] , optimized := true;
[writem, output , interface(quiet=true);
[I ,P,vector n; I I] , [J] ,
genfor(pg);
[readm, input, genfor(fo);
[ld22.15 I , I I .dd. li6 1],
[P,seq(n[ii] ,ii=l .. dd)]], interface(quiet=false);
writeto(terminal);
[writem, output , end:

139
Biographies
Johannes Grotendorst obtained his doctoral de-
gree in theoretical chemistry at the University of
Regensburg and his background also includes stud-
ies in mathematics and physics at the University of
Bielefeld. Since 1988, he has been at the Institute
for Applied Mathematics at the Jiilich Research
Center (KFA). His current research interests in-
clude integration of symbolic and numeric compu-
tation techniques for mathematical problem-
solving in applied science, extrapolation methods
in theory and practice and parallel computing in
computational chemistry.
Jiirgen Dornseiffer obtained his diploma in chem-
istry at the Technical University of Aachen
(RWTH) and is currently a Ph.D. student in the
Institut for Applied Physical Chemistry at the
Jiilich Research Center. His research interests in-
clude the conversion of hydrocarbon waste mate-
rials by steam reforming.
Siegfried Schoberth obtained his doctoral degree
in microbiology at the University of Gottingen.
He is currently a research scientist in the Institute
for Biotechnology at the Jiilich Research Center.
His research interests include "in vivo" NMR spec-
troscopy and general microbiology.
The authors may be reached at:
Research Center Jiilich
0-52425 Jiilich
Fed. Rep. Germany

j.grotendorst@kfa-juelich.de (J. Grotendorst)


j.dornseiffer@kfa-juelich.de (J. Dornseiffer)
s.schoberth@kfa-juelich.de (S.M. Schoberth)

140
MAPLE V ANALYTICALLY CALCULATING PLANE STRAIN
FE-MATRICES WITH ROTATIONAL DEGREES OF FREEDOM

G. Zirwas
Lehrstuhl fOr Baumechanik, MOnchen, Germany

Finite Element Method (FEM) in


Structural Mechanics
Structural mechanics in the civil or mechanical
engineering domain typically poses a variety of
systems of partial differential equations on arbitray
shaped domains with mutiple boundary conditions,
constraints and couplings. Due to their flexibility in A complete step forward is made when the
unknowns at the nodes are extended from the
solving these problems, FE Methods have become
very popular methods of approximation.
i
I
displacements u to the gradient u i j of the
displacements. This means that all rotations at the
nodes are known, but furtheremore the complete
Triangular Finite Elements state of strain is involved and thereby the state of
stress too. No jumps in stress or strain between the
There are many strategies to calculate the stiffness elements as in common formulations arise at the
matrices of finite elements [1][2][3]. A rough nodes because all state variables of interest are
workhorse for plane strain or plane stress in two involved in the degrees of freedom. With MapleV it
dimensional continuum mechanics is the CST has become possible to provide a triangular element
formulation with three nodes and six degrees of (TRTl8 Traingular element with RoTations and 18
freedom.
ut.
degrees offreedoms at three nodes) with a complete
i
formulation of u and Starting with the
formalism of continuum mechanics, we change over
to a symbolic solution in MapleV which is slightly
different from typical FEM algorithms which do
numerical integrations. At the end MapleV
It shows, due to a Constant STrain and STress
automatically codes the body of a TRTl8 subroutine
distribution in the element, only poor numerical
in C or FORTRAN for FEM-programs.
behaviour. Furthermore no rotational degrees of
freedom are handled, which leads to spurious
problems when combined in three dimensions with
elements which have, like beams, plates and shells, Continuum Mechanics of Plane
more than displacements as degrees of freedom at Strain/Stress
the nodes[4][5]. To overcome the situation it is not
necessary to give up the simple triangular geometry, The static and dynamic [6] situation of plane strain
which has advantages for example in meshing and and plane stress are described by the well known
mesh refinements. coupled system of partial differential equations of
Lame or Navier.
(2+ p)uil j + pujl: =0.
The gradient

141
i FE-Method, U in has to be integrated either
of the fields of displacements u is built up by an
antisymmetric part of rotations numerically or analytically (symbolically)

wij = ~ (uil j -uJ) UElement =


(V)
J Uin dV.
and a symmetric part of strain In the case of flat coordinates, like Cartesian
coordinates, where the base vectors do not change,
G·1J = .!.(u.,.
2 I J +u·I·)
J 1 gn = en = const
t j =wij + Gij . the covariant and contravariant derivatives
The two independent constants of Lame determine, ( )1 n ; ( )1 n
in linear elasticity, the strain related stresses simplify significantly because the Christoffel
=2 e: gij + 2,u Gij' symbols vanish
- r
CTij
The scalar product of strain and stress gn, k = n m k gm-
== 0 .
1 . .
U in =-
2
at
Cj provides the free inner energy as
Not only do triangles easily mesh arbitrary
geometries with arbitrary refinements, triangular
Lagrangian density for an approximation or a element formulations have the main advantage, in
1 . . contrast to other isoparametric deformed ones, of
strong solution.The inner energy [6] U in =- crt ~ vanishing covariant and contravariant derivatives.
2
in technical (physical) strain and stress is
Calculating with MapleV
U in = ~ [ CTx Gx + CTy Gy + 'fxy r xy ].
We start with initializations and prepare some
To get the energy UElement stored in the finite area variables.
of an element needed for the approximation with the All parts of the entire Maple V input file are boxed.

restart; with(plots): with(linalg):


versn:='### TRT_MSWS94 03.11.199412:00 GZ ###';

FAZ := 9; ### number of shape functions


DOF := 2*FAZ; ### number of Degrees Of Freedom
x := vector(2); ### global cartesian coordinates 2D.
s := vector(2); ### unit coordinates 2D.
ri ;= matrix(3,2); ### 3 coordinates of the element nodes.
g := vector(6); ### straight lines <=> planes.
fm := vector(FAZ); ### shape functions.
xtri := vector(2); ### element geometry; global coordinates.
Can := vector(DOF); ### coefficients for the shapefunctions.
GEO := matrix(2,2); ### base vectors.
u := vector(2); ### global field of displacement.
Jus ;= matrix(2,2); ### diff(ui,sj) gradients local derivation
Jux := matrix(2,2); ### diff(ui,xj) gradients global derivation
d := vector(DOF); ### degrees of freedom at nodes.
KI := matrix(DOF,DOF); ### one part of the Element Matrix
DC ;= matrix(DOF,DOF); ### d-Can-trans-matrix.
Txst := matrix(DOF,DOF): ### trans-matrix for Jacobian degrees.

142
unit global
/
/
/
/
/
/
/
/
/
/

(xb,yb)

Projection from unit to global coordinates

Three lines at the boundary and three going through of unknowns a shifted element with xa=O and ya=O
the midpoint are used is used. The three nodes are:

g[I]:=s[2]; ri[ I, 1]:=0;


g[2]:= I-s[ I]-s[2]; ri[l, 2]:=0;
g[3]:=s[I]; ri[2, I]:=xb;
g[4]:=1-2*s[I]-s[2]; ri[2, 2]:=yb;
g[5]:=s[1]-s[2]; ri[3, I ]:=xc;
I g [6]:=I-s[l]-2*s[2]; riD, 2l:=vc;

to build up as equations of planes the shape- The global geometry depends on the three nodes and
functions fm[l] to fm[9]. the unit coordinates. It is a projection from the sJ' S2
to the X (Sp S2) =Xi2 (SI,S2)
i2
fin[I]:=g[2] ;
fm[2]:=g[3] ; i2 ( ) _ i 2 i,
X tri8llg1 Sl' S2 - roomer
• fin i (Sl' S2 ) .
1
fm[3]:=g[l] ;
fin[4]:=g[2]*g[3] ;
xtri[I]:=O; xtri[2]:=0;
fm[5]:=g[2]*g[3]*g[4] ;
for il to 3 do ### 3 nodes.
fin[6]:=g[I]*g[3] ;
for i2 to 2 do ### 2 coordinates.
fin[7]:=g[I]*g[3]*g[5] ; xtri[i2]:=xtri[i2]+ri[i I ,i2]*fin[i 1];
fin[8]:=g[I]*g[2] ;
od',
fin 9:= 1 * 2 * 6 ;
od:
Nine shape functions for both of the displacement
A well known equation of tensor analysis states how
fields UX1 (81, ~) and UX2 (81, ~) in global to derive the base vectors. Because the curvature is
directions XI and x2 leads to 18 degrees of freedom. zero, they are constant and the situation becomes
To evaluate the projection of a triangle from unit simple.
coordinates to global coordinates only the linear
shape functions are needed. To decrease the number

143
integration. We seek the inverse relation from
X ( 5) ,52) to t ( XI , x2 ) for the chain rule in
i2 2

partial derivations that irS a a ]


=xb =xc

=)ds,]
_I _I

for it to 2 do
for i2 to 2 do
### flat base vectors gJ2..

GEO[i I,i2] :=diff(xtri[i I],s[i2]);


dxl _ [GEO] dSI
[dr,]- [aJ a _ &'1
Ox, =yb ""
l
&'2

a2
dSI

00;
00: and vice versa for the total derivatives written in a
matrix notation:
The determinant dF measures the changed size of
differential areas dx1dx2 =dF . ds)ds2 for later

cs) _ yc cs( _ xc

[G~O] [~:J =
& I xb yc - xc yb &2 xb yc - XC yb
[:::] - -CS2 =- ---"----
yb cs 2 _ xb
~
[IG] &) xb yc - xc yb &2 xb yc - XC yb

IIG:=inverse(GEO); 1/2*Oux[I,2]+Jux[2,1])1\2; ### cl.


dF:=det(GEO); ### c2=lam for Plane Strain or
### c2=2*lam*mul(lam+2*mu) for Plane Stress
The global fields of displacements UxI (5),52) and U2:=1/2* Jux 1,1 +Jux 2,2 )1\2; ### c2
U"-l (5) , 52) are superposed by the shape functions The chain rule expands in the prepared derivatives
jmil (5) ,52) with respect to 18 generalized with respect to the local coordinates to Jux:
coefficients or degrees of freedom Can. &X (5),52 ) &x; (5),52 ) &j (x),x 2 )
Jux..1 = =
u[I]:=O: u[2]:=O:
11 2 ix.
~

12
I
&.I)
3
& 12
~
for it to FAZ do JUSiliJ

u[1]:=u[1]+Can[2*il-1]*frn[il];
u[2]:=u[2]+Can[2*il ]*fm[il]; for il to 2 do
00: for i2 to 2 do
Jus[i I,i2]:=diff(u[iI],s[i2]);
Two material constants of Lame adjust the energy 00',
density in linear elasticity. It is a linear combination 00',
V in = c) VI + c2 V2 of two parts. The
combination depends on whether you have plane for il to 2 do
strain or plane stress. The Jacobian Jux for i2 to 2 do
Jux[il,i2]:=O;
for i3 to 2 do
Jux[i l,i2] :=Jux[il,i2]+Jus[i l,i3]*IG[i3,i2];
### chain rule for partial derivation
00',
has to be used. UI and U2 are positiv definite in the 00',
coefficients of the Jacobian Jux. 00',
The integration with respect to unit coordinates 5)
and 52 has to be taken into account by scaled
ImcI=mu. differential areas. The term Uln that remains from
UI:=Jux[I,I)A2+Jux[2,2]1\2+

144
the U1 portion of the energy is ready for integration d[ 6] :=subs(s[1]=0,s[2]=O,Jus[2,2]):
(numerical or syrnbolic(analytical». d[ 7]:=subs(s[I]=I,s[2]=O,u[I]): ### 2. node
d[ 8]:=subs(s[I]=I,s[2]=O,u[2]):
IUln:=UI*dF: d[ 9]:=subs(s[I]=I,s[2]=O,Jus[l, I)):
d[ 10]:=subs(s[1]=I,s[2]=O,Jus[ I,2)):
FE-Method extremises, as an approximation, the d[II]:=subs(s[I]= l,s[2]=O,Jus[2, I)):
inner energy d[ 12]:=subs(s[1]=I,s[2]=O,J05[2,2)):
1 .. d[13]:=subs(s[I]=O,s[2]=I,u[I)): ### 3. node
Uelement -- 2 Ki l i 2 d "d '2 d[ 14]:=subs(s[I]=O,s[2]=l,u(2)):
d[ 15]:=subs(s[I]=O,s[2]=I,Jus[ I, I)):
which depends on the stiffness matrix and the d[ 16]:=subs(s[I]=O,s[2]=I,Jus[ I,2)):
displacements d, which are up to now the d[17] :=subs(s[1]=O,s[2]=I,Jus[2, I)):
generalized ones, Can. Therefore the stiffness d 18 :=subs(s I =O,s 2 =1,Jus 2,2 ):
coefficients are the second derivatives of the stored
energy The dependency OC[il,i2] of nodal degrees of
freedom d[il] on the Can[i2] are inverted to the
dependency CO[il,i2] of the Can[il] on the nodal
degrees offreedom d[i2]. The linear transformation
is applied.
and here
for il to OOF do
for i2 to OOF do
OC[i I,i2]:=diff(d[i I],Can[i2));
od;
od:
In the nonlinear situation this is the tangent stiffness CO:=inverse(DC):
matrix. The double integration over the unit COt:=transpose(CO):
triangular area is split up for every coefficient in the KG:=multiplv(COt,multiplv(KI,CO»:
FE-Matrix, in order to manage the integration
workload. What we get in this step is a stiffness The Jacobians at the nodes are, for KG, still in a
matrix KI for generalized displacements Can. mixed formualtion. In a last transformation Txst the
displacements u are left invariant but the Jacobian
for il to OOF do Jus is expressed by the Jacobian Jux. The
for i2 to OOF do transformation appears as a block matrix for all
KII[il,i2]:=diff(Uln,Can[il],Can[i2)); three nodes
### stiffness-Integrand.
KI [i I,i2] :=int(int(KlI[i I,i2],s[1]=0..(1- ou X.
= ou X.

s[2])),s[2]=O.. I); Jus 11 'I

OS 12
od',
od:

We start to substitute Can by enumerated nodal or in matrix notation for every node
displacements, which are the coefficients of the
displacement vector and the Jacobian at the nodes.
The coefficients in the Jacobian can be realized as
degrees of rotations and stresses. To manage an
inversion of this 18 by 18 matrix the mixed Jacobian
Jus at the nodes has to be used.

d[ 1]:=subs(s[I]=O,s[2]=O,u[I)): ### 1. node


d[ 2]:=subs(s[I]=0,s[2]=O,u[2)):
d[ 3]:=subs(s[I]=O,s[2]=O,Jus[l, I)):
d[ 4]:=subs(s[I]=O,s[2]=0,Jus[I,2)):
d[ 5]:=subs(s[1]=O,s[2]=O,Jus[2,1)):

145
1 U2
1
u) U)
&1 &2 Ul ,x2
U2 U2
&1 &1
U),SI &1 &2
U),x 1 U2,xl
=
U1,sz ~ &2 U1,xz
X Ul
U 2,st &) &2 U2,Xl 2
&) &) U 2,x z
U2,sz
&1 &2

~ ~

The degrees of freedom are at every node


(xb,yb)
U1
U2
for il to DOF do
ex = U),x 1 for i2 to DOF do
fIJ) =U1,xz Txst[il,i2]:=O;
od:
flJ2 =U 2 ,Xl Txst[il,il]:=1;
od:
ey = U 2,xz for il to 2 do
for i2 to 2 do
for TRTl8. Condesing u 1, xI and u 2' x1 the element Txst[ 2+il, 2+i2]:=GEO[i2,il];
TRTl2 with 12 degrees offreedom can be derived. Txst[ 4+il, 4+i2]:=GEO[i2,il];
Here the drilling degrees of freedom are the side Txst[ 8+il, 8+i2]:=GEO[i2,il];
rotations. The degrees of freedom Txst[lO+il, 1O+i2]:=GEO[i2,il];
Txst[14+il,14+i2]:=GEO[i2,il];
U) Txst[16+il,16+i2]:=GEO[i2,i1];
od',
u2 od:
Txstt:=transoose(Txst):
fIJ) = u),xz

flJ2 = U 2,Xl Applying this transformation to KG, the entire to


global coordinates related stiffness-matrix TRT is
are shown at node c: achieved.

ITRT:=multiply(Txstt,multiply(KG,Txst»:

We can look at the entire analytically calculated


stiffness coefficients, which are functions of the
geometry of the element, normalized to the Lame
constant JJ and the thickness of the element

TRJ:j = TRJ:j(xb,yb,xc,yc).

146
A few results:

TRT. =98xc2 -98x cx b+49Yc 2 -49YeYb +2X b2 +Yb 2


[2,8] 90(XeYb -YcX b)

Automated code generation is, in MapleV, a readlib(C):


sophisticated way to plug the element into FEM- # C(TRT);
programs. # fortran(TRT);

The complete matrix or single coefficients can be


coded in C

TRT[18] [8] - -(-46.0*yb*xc*xc+60.0*yb*xc*xb-63.0*yb*yc*yc+34.0*yc


*yb*yb+4.0*yb*xb*xb+2.0*yb*yb*yb-SO.O*yc*xc*xb+S.O*yc*xb*xb-4.0*yc*xc
*xc-2.0*yc*yc*ycl/(xb*yc-xc*ybl/360;

or FORTRAN.

Concluding Remarks
analytical symbolic integration.with MapleV
Without influencing the basic solution process a
varying family of element fonnulations are derived. and
Condensing degrees of freedoms at the nodes, the
number of unknowns can be lowered from 18 automated and optimized C or FORTRAN code of
(TRT18 complete gradient) to 12 (TRT12 only the matrices
rotational degrees offreedom) and to 6 (CST no
rotational degrees of freedom). leads to a rational and fast application of
The MapleV solution can easily be applied to a computational resources.
pyramid shaped brick element (PRT48), with 4
nodes and 48 degrees of freedom. Downward we can
have a standard beam element in 3D.
All these elements fit together, because the fields of References
displacements at their boundaries are natural
splines of degree three. [1] K.J. Bathe. Finite Element Procedures in
Engineering Analysis. Prentice-Hall, Englewood
Application of computational resources during the Cliffs, N.J., 1982.
production of FE-codes leads to faster response at [2] K.J. Bathe and E. Dvorkin. A formulation of
the application afterwards. No numerical general shell elements - the use of mixed
integration has to be passed for every single interpolation of tensioral components. Int. 1.
element. Numer. Methods in Eng., 22,697-722, 1986.
[3] B. Szabo and I. Babuska. Finite element
Both analysis, John Wiley Sohns, 1991.

147
[4] TJR Hughes and F. Brezzi, On the drilling
degrees of freedom, Comput. Meths. Appl.
Mech. Engrg., 72, 105-121, 1989.
[5] M. Iura and S. N. Atluri, Geometrically
nonlinear membrane elements with drilling
degrees of freedom, Proc. of the Int. Conf. on
Compo Eng. Sci. (ICES 1991),393-398,
Atlanta, 1991.
[6] Flogge W., Tensor analysis and continuum
mechanics, Springer, N.V. 1986.
[7] G. Zirwas, Impedance Matrix of Viscoelastic
(layered) Halfspace, Proc. of the Int. Conf. on
Compo Eng. Sci. (ICES 1991), 1293-1296,
Atlanta, 1991

The author Gerhard Zirwas studied Civil


Engineering at the Technical University of Munich
in Germany. He is presently an Assistant at this
University. He recently works on continuum
mechanics of large scale structures and soil structure
interaction [7].

G. Zirwas
Lehrstuhl fur Baumechanik
Technische UniversiUit Miinchen
Arcisstr. 21
D-80333 Miinchen FRG

email: t5121ak@sunmail.lrz-muenchen.de
Tel: +498921058341

148
CHEMICAL ENGINEERING WITH MAPLE

Ross Taylor1 and Katherine Atherley2


Department of Chemical Engineering 1, Clarkson University, Potsdam, NY;
Waterloo Maple Software 2 , Waterloo, Ontario, Canada

Introduction graduate), it makes sense to consider adopting Maple


as the programming language for use in their
Chemical engineering students are required (by engineering courses (see the box Maple at
accreditation agencies) to make appropriate use of Clarkson). Maple is built around a programming
computers throughout their program. Appropriate language that is custom designed for symbolic
use is defined as including most of the following: (I) mathematical calculations and manipulations.
programming in a high level language; (2) use of Unlike Fortran, the Maple language supports
software packages for analysis and design; (3) use of standard mathematical structures as data-types, and
appropriate utilities; (4) simulation of engineering can work with them in sensible mathematical ways.
problems. Maple (Char, 1991) is a powerful and The language is more natural for mathematical
flexible computing tool that has the potential of work, and produces (much) shorter, easier to
becoming the software of choice for much scientific understand programs than Fortran.
and engineering work, perhaps replacing, at least in
part, other computer based methods such as Material and Energy Balances
traditional programming languages and special
purpose analysis and design programs. The fact that Maple allows you to solve elementary material
Maple is designed for symbolic manipulation should balance problems in a systematic way that makes it
not be taken to imply that it is unsuitable for the almost impossible to get the problem formulation
numerical calculations that dominate engineering wrong. Just a few lines of Maple code can set up the
computing today. Maple's symbolic mathematical material balances and mole fraction summation
abilities combined with numerical capabilities and equations for any process unit' regardless of the
sophisticated graphics allow new approaches to the number of components and input and output streams.
teaching of traditional materials. In this paper we Systems with chemical reactions also can be
focus on a few ways in which Maple can be used in modeled. Maple's ability to handle symbolic indices
selected courses in the chemical engineering makes it possible to identify components with a
curriculum. number, name, chemical formula, or any other
convenient label. The number of unknown variables
Computer Programming and independent equations can be quickly counted
and, hence, the number of degrees of freedom
Undergraduate engineering students are required to determined. Specification equations can be added to
do some programming in a high-level language. the model equations and Maple asked to solve the
Often, the programming course is the first one to entire set of equations in one go. Problems often
expose students to elements of engineering problem can be solved symbolically in terms of an
solving. Most students learn Fortran, but C or Basic unspecified parameter (reactor conversion, say).
are included in some curricula. With more and more This is useful if it is desirable to evaluate the
students learning to use Maple in their calculus solution at several parameter values. It is
classes (and fewer and fewer of them using any kind unnecessary even to choose a basis as the actual
of traditional programming language after they specification of interest can be included among the
set of equations.

149
Maple at Clarkson

In common with many other schools, undergraduate engineering students at Clarkson University are
required to take a programming course. Until this year, the language taught in this course was Fortran
(although some students received instruction in Basic). No longer will Clarkson students take courses in
Fortran (unless it be by choice); the introductory computing course has been completely revised and
Clarkson students will now be programming using the computer algebra system Maple.

The decision to abandon Fortran in favor of Maple was not reached lightly or without considerable
debate within the engineering school at Clarkson. Factors in favor of Maple included the fact that the
students were receiving some instruction in the use of Maple in their calculus classes and that the site
license allows Maple to be installed on nearly all machines owned by Clarkson. All students (regardless
of discipline) currently receive a PC when they enroll as freshmen. Clarkson's PC program has been in
place for over a decade and this year the freshmen received their computers with Maple already installed
on the hard drives of their PC.

The fact that Maple can exchange files across platforms is a great advantage for a computationally
diverse campus like Clarkson; in addition to the huge number of PCs (> 3000) there are nearly two
hundred IBM RS/6000 workstations and more than a few Suns and DECs.

Thermodynamics case it is possible to show graphically the conditions


under which liquid-liquid phase splitting can occur.
The calculation of the critical constants for a cubic
equation of state is a classic problem in
thermodynamics, one that is covered in most
thermodynamics textbooks (see, e.g. Walas, 1985;
Sandler, 1989). Usually, textbook examples include 0.8
finding the critical constants for the simplest cubic
equation of state, that of Van der Waals, or those of
the Redlich-Kwong family. With Maple, however,
it is possible to obtain explicit expressions for the
critical constants for a generic cubic equation of
state (Taylor and Monagan, 1993). Constants for
particular equations of state can be obtained as
special cases of the general result.

Maple is a useful tool for the visualization of


thermodynamic functions. Figure 1 shows the roots
of the compressibility polynomial for the
Soave-Redlich-Kwong equation as a function of
reduced temperature at a reduced pressure of 0.75. Figure 1: Compressibility as a function of reduced
The well-known fact that a cubic equation can have temperature (Tr) at a reduced pressure of 0.75
complex roots at certain parameter values is computed using the Soave-Redlich-Kwong cubic
well-illustrated here. This figure was obtained with equation of state. The vertical axis is the real part of
about 30 lines of Maple code which included the the compressibility, the horizontal axis at the back of
calculation and ordering of the roots themselves. the figure is the imaginary part of the
compressibility. All axes are dimensionless. The
Figure 2 shows the Gibbs energy surface for a region of three real roots is shown between a region
ternary liquid mixture computed with the NRTL posessing a real liquid-like root and complex
model (see WalasFig, 1985). 3D diagrams in Maple vapor-like roots and another region with a real
can be rotated and viewed from other angles; in this vapor-like root and two complex liquid-like roots.

150
what equations, and what numerical methods should
be used to solve (each subset of) the equations have
been thoroughly explored. Figure 3 shows an
incidence matrix (sparsity pattern) for a column
distilling a nonideal binary mixture in 10 stages. The
equations and variables are grouped by stage leading
to the familiar block tridiagonal pattern shown in the
figure; however, just two lines of Maple is all it
takes to reorder the equations so that they are
grouped by type rather than by stage. It is pertinent
to point out that although with Maple it is simple to
explore different computational strategies, Maple
also makes topics like this largely irrelevant (even if
they are interesting).

Figure 2: Gibbs energy surface for acetone(1),


benzene(2), carbon tetrachloride(3). xl and x2 are
the mole fractions of components I and 2. The
vertical axis is the dimensionless Gibbs energy.

A Maple procedure to obtain expressions for the


activity coefficients from any model of the excess
Gibbs energy and for a specified number of
components can be written in about 10 lines of
Maple code. Students can investigate different
models of the Gibbs energy function without running
the risk of getting the derivation incorrect.

Simple phase equilibrium calculations and the Figure 3: Incidence matrix for a small distillation
creation of phase diagrams for binary systems using problem (2 components, 10 stages). The pattern is
Maple have been discussed by Taylor (1994). "upside-down" because Maple plots cannot (yet) go
from high to low on any axis.
Separation Processes

Multicomponent distillation simulations require the Four pages of Maple code is all that is required to
numerical solution of a large set of equations: solve most multicomponent distillation problems
Material balances, energy balances, and equilibrium (including the derivation of all of the equations).
(thermodynamics) equations. These equations are This compares to the many hundreds (or even
sparse, nonlinear, and can easily number in the thousands) of lines that would be needed to solve the
hundreds and sometimes in the thousands. The same problem using Fortran. Interlinked columns
literature on distillation contains scores of papers and nonstandard specifications also are simple to
discussing methods of solving these equations (see deal with (and only slightly more difficult to solve).
Seader, 1985). Issues such as what form the Figure 4 shows the McCabe-Thiele diagram plotted
equations should take, what variables should be from the results obtained by numerically solving the
used, in what way should the equations and variables equations that gave us Figure 3.
be ordered, what variables should be computed from

151
the stability of each steady state could be determined
by computing the eigenvalues of the state matrix
using Polymath. All of these things are possible
with Maple; however, Maple is capable of
evaluating the eigenvalues of the state matrix
symbolically as well!

Figure 4: McCabe-Thiele diagram constructed from


the solution obtained with Maple to a binary
distillation problem. The y-axis is the mole fraction
of component 1 in the vapor, the x-axis is the mole -1

fraction of component 2 in the liquid. Both axes are


dimensionless. The upper curve is the equilibrium
line, the staircase represents the equilibrium stages, Figure 5: Multiple steady states in a strirred tank
9 of them here (the column has a total condenser). reactor. The vertical axis is the heat duty (Btu/hr x
to·S) , the x-axis is the reactor temperature (K). The
straight line represents the heat lost due to cooling
Chemical Reaction Engineering the reactor. The S-curve is the heat generated by the
reaction. Each intersection of these lines represents
Chemical reaction engineering problems often a solution of the steady-state material and energy
require the solution of systems of coupled balances. The middle solution is unstable.
differential equations. Textbook problems
sometimes are specially simplified so that the
equations can be solved analytically. While such Pocess Design
solutions can also be obtained with Maple, it is no
longer necessary to simplify problems in this way. We do not think it requires too great a leap of
Software packages that possess numerical methods imagination to expect students to set-up and solve
for solving ODEs can be used to solve more realistic entire process flowsheeting problems using Maple.
problems. This point of view has already been The techniques that are useful for material and
expressed by Fogler (1992) who uses Mathematica energy balances around simple units are readily
and Polymath for solving reaction engineering applied to process f10wsheets with any number of
problems. The advantages of a CAS over a purely units and their interconnections. Flowsheets
numerical method of solution include the fact that containing recycle streams are easy to handle.
the reaction system can be analyzed symbolically
and the material and energy balance equations also While Maple will not (nor should it) replace
may be derived. specialized programs designed for large-scale plant
simulation, Maple is a useful tool for teaching
Figure 5 is the well-known illustration of multiple students how f10wsheeting simulations work. The
steady states in a nonisothermal continuous stirred Maple programming language encourages problems
tank reactor (CSTR). This plot was created using to be formulated in a way that is reminiscent of
the parameters given by Shacham et aI. (1994) who equation oriented f10wsheeting (Westerberg et aI.,
also considered the CSTR dynamics and noted that 1979) but it is not too difficult to instruct Maple to

152
solve flowsheet problems using tearing or Unfortunately, Maple currently is many times slower
simultaneous modular strategies. Maple's open than compiled Fortran when carrying out large scale
interface and powerful language makes it possible numerical computations. Maple needs better (i.e.
for engineers to create their own unit models in the faster) routines for purely numerical computing. A
Maple programming language; others would then be fast sparse linear equation solver, for example,
able to use them as plug-in modules in their own would go a long way to making large scale
problems if these modules were to be made flowsheeting problems and multicomponent
available. distillation problems a practical proposition. For
now, you can set up the problem with Maple and
More Maple then translate the results into Fortran (or C) so that
you can compile the application yourself.
There are, of course, a number of ways in which
Maple needs to be improved. Many models in chemical engineering consist of
large sets of (stiff) ordinary differential equations,
Maple needs to gain the ability to read and write (ODEs) mixed systems of differential and algebraic
binary direct access files (as is possible in Fortran equations (DAEs) or partial diffemtial equations
and C). This will make it possible to access (PDEs). Fast numerical methods for stiff ODEs,
databanks of physical property data for direct use in DAE systems, and for solving PDEs by, for
engineering calculations. example, the method of lines would be very
Maple needs improved symbolic capabilities. There welcome.
are many engineering formulae where it is necessary
to differentiate arbitrary sums and products (Le. a Maple's graphics capabilities, although quite good,
sum or product of indexed variables where the could be improved by adding more basic plot types
index range is non-numeric: i.e. i = l..c). The fact that are encountered often in (chemical) engineering
that Maple cannot do this is a very serious (triangular diagrams and their three-dimensional
impediment to using Maple for certain important counterparts are examples that come to mind).
problems (e.g. the derivation of thermodynamic
properties of mixtures). We also need to be able to Conclusion
(elegantly) exclude selected elements from sums and
products of indexed variables. In this article we have highlighted only a few ways
in which Maple can be used in chemical engineering
A great many problems in chemical engineering education. Additional applications of Maple are
require finding numerical solutions to large (or listed in Table 1. Some of these worksheets are
small) systems of (sparse) nonlinear equations. This included in the Maple share library (and which is
is not one of Maple's strengths. The floating point provided as part of the new Release 3 of Maple V),
solver built into Maple lacks some of the features others are available from the first author. We have
that one would like to see. In particular, it is not also identified a few areas where Maple needs
possible to provide the initial estimates or to control improved capabilities.
the iteration history. On the other hand, it is
possible to program Newton's method in Maple so The fact is that Maple can have a significant impact
that all the user must provide is a set of equations, a in almost all areas of chemical engineering
list of unknown variables and a starting point; Maple education. However, there are some problems
can compute the Jacobian symbolically thereby associated with using Maple in existing courses.
removing one of the major chores that must be faced
when using the method as part of a Fortran program. Using Maple to derive expressions that are standard
In fact, Maple is used for precisely this purpose fare in current engineering textbooks will rapidly
within some companies that write software for demonstrate that it is not always easy to get from
process engineering simulations. Differential Maple an answer that you recognize. It may be
arc-length homotopy continuation methods, quite trivial for Maple to solve your problem
recommended by Seader (1985) for solving difficult correctly but it can require considerable skill in
nonlinear problems, also may be easily (and expression manipulation in order to get a familiar
elegantly) programmed in the Maple programming result. While this may not be important in solving
language. original problems, it can make matching the results

153
Table 1: Maple Worksheets in Chemical Engineering

1. Material balance calculations on a variety of chemical process units

2. Thermodynamics
(a) Critical constants for cubic equations of state (Taylor and Monagan, 1993)
(b) Phase equilibrium calculations and phase diagrams for ideal systems (Taylor, 1994)
(c) Activity coefficients in binary and multicomponent systems
(d) Gibbs free energy surfaces
(e) Phase equilibrium calculations for nonideal systems
(f) Flash calculations for ideal systems
(g) Advanced flash calculations
(h) Thennodynamic property relations and the Maxwell equations

3. Reaction Engineering
(a) Material balances in tubular reactors
(b) Isothennal tubular reactor (multiple reactions, numerical integration)
(c) Nonisothennal tubular reactor
(d) Multiple steady states in a CSTR
(e) CSTR dynamics
(f) Fitting reaction rate coefficients to rate data.

4. Equilibrium Stage Separations


(a) Constant molar overflow in distillation
(b) Multicomponent distillation - stage-to-stage calculations
(c) Multicomponent distillation - simultaneous solution
(d) McCabe-Thiele diagrams

5. Numerical Methods
(a) Newton's method for systems of equations
(b) Homotopy-continuation for systems of equations

in established textbooks a frustrating experience. teaching of calculus at many schools. It is


Perhaps we will have to get used to new ways of impossible to tum back the clock and abandon the
looking at old results. The problem of simplifying use of computer algebra in mathematics courses
the chore of obtaining recognizable results remains thereby making its use in engineering a nonissue. It
as a challenge for the computer algebra community. will not be possible to prevent students from using
tools they have leamed once it has become clear that
The exercises and examples in many standard they are useful. It will be up to us as educators to
textbooks (see, for example, Felder and Rousseau, find the proper time and place in our courses to
1986; Reklaitis, 1983) were designed to be solved by introduce students to engineering problem solving
hand. Many (if not most) of these problems are far with Maple.
too simple if Maple is on hand to assist with the
problem solving; when you have solved one, you References
have solved them all.
Char, B.W., K.O. Geddes, G.H. Gonnet, B.L. Leong,
This brings us to some important questions: Do we M.B. Monagan, and S.M. Watt, Maple V Language
want students to use Maple for solving engineering Reference Manual, Springer-Verlag (1991).
problems? Can the use of a CAS prevent students
from mastering essential skills that are better Felder, R.M. and R. W. Rousseau, Elementary
assimilated when solving problems by hand? principles of Chemical Processes, 2nd Ed., Wiley,
Computer algebra is finding increasing use in the New York (1986).

154
Fogler, H.S., Elements of Chemical Reaction with many aspects of Maple, from programming and
Engineering, 2nd Edition, Prentice-Hall, Englewood writing documentation to providing user support,
Ciffs, NJ (1993) and teaching Maple courses.

Reklaitis, G.V., Introduction to Material and Energy The authors are writing a book entitled "Chemical
Balances, McGraw-Hill, New York, 1983. Engineering with Maple".

Sandler, S.1. Chemical and Engineering


Thermodynamics, Wiley, 2nd Edition. New York
(1989).

Schacham, M., N. Brauner, and M.B. Cutlip,


"Exothermic CSTRs. Just how stable are those
steady states," Chern. Eng. Ed., pp. 30-35, Winter
(1994).

Seader. J.D. "The BC and AD of Equilibrium Stage


Operations," Chern. Eng. Ed., XIX(2), 88 (1985).

Taylor, R. and Monagan, M.B., "Thermodynamics


with Maple. I - Equations of State," Maple Tech,
Vol. 10, (1993).

Taylor, R., "Thermodynamics with Maple. II-


Phase Equilibria in Binary Systems," Maple Tech,
Vol. 11, (1994).

Walas, S.M. Phase Equilibria in Chemical


Engineering, Butterworths, Stoneham, MA (1985)

Westerberg, A.W., H.P. Hutchison, R.L. Motard,


and P. Winter, Process Flowsheeting, Cambridge
University Press, Cambridge (1979).

The Authors

Ross Taylor is a professor of Chemical Engineering


at Clarkson University. His interests are in the areas
of mass transfer and separation processes and he is
the coauthor (with Professor R. Krishna of the
University of Amsterdam) of Multicomponent Mass
Transfer (Wiley, 1993) and (with Harry Kooijman)
of ChemSep, a software package for separation
process simulation used in universities in several
countries. He can be contacted by email at
taylor@sun.soe.c1arkson.edu.

Katherine Atherley is Head of Documentation at


Waterloo Maple Software (WMS). She has a degree
in pure mathematics from the University of
Waterloo, where she first encountered Maple. She
worked with the Maple research group before
joining WMS. Since then she has been involved

155
IVA. MAPLE IN EDUCATION
MAPLE LABS AND PROGRAMS FOR CALCULUS

William W. Farr and Michael VanGeel


Department of Mathematical Sciences, Worcester Polytechnic Institute,
Worcester, MA

Abstract
curves in two and three dimensions. This pa-
This paper describes work done over the past per gives a brief summary of all the routines in
three years at Worcester Polytechnic Institute the CaleP package and provides examples of how
aimed at integrating Maple computer labs and some them have been used in the course. Our
projects into freshman calculus. We give an main motivation in writing the procedures was
overview of the course structure and then provide to keep the focus of the students on calculus and
examples drawn from labs we have used. We also to keep the Maple component of the course from
describe the Maple CaleP package, a set of about becoming too burdensome. On the other hand,
thirty Maple procedures written at WPI for use we do encourage the students to learn Maple by
in the course. using it to solve problems and students with pro-
gramming backgrounds are encouraged to learn
a little about programming. In fact, the second
Introduction author of this paper was a student in the Maple
calculus course who went on to help with the
For the past three years, we have been working on
programming in his second year at WPI.
introducing Maple into the calculus course taken
by nearly all entering freshmen at WPI. Most of The routines we have written have been col-
our students are engineering majors of one sort lected together in the form of the Maple package
or another, so they need to be able to use cal- CaleP, including help pages for each procedure in
culus to solve problems. Our main goals in in- the package. (For calculus with projects - see
troducing Maple into the course were to expose the course description below.) They have been
the students to a CAS, which we see becoming tested with the Xll/UNIX and PC-Windows
a standard tool for any technical profession, and, versions of Maple V, Release 2 and Release 3.
more importantly, to focus the students' atten- They are available by anonymous ftp from the
tion away from the details of manipulation and host wpi. wpi. edu in the files Cale/CaleP. R2 and
onto the fundamentals of using calculus to solve Cale/CaleP. R3. If there is sufficient interest, the
problems. package will be submitted to the Maple share li-
In the course of developing labs and projects brary. Maple users are encouraged to obtain and
for use in the course, we have written about use this package. Report any problems of bugs
thirty different Maple procedures for use by the to the first author, preferably via e-mail at the
students. They range from visualization tools for address bf arr<Owpi. edu.
topics like Newton's method and solids of revo-
lution to routines for computing curvature and
normal and tangential acceleration for parametric Course Format
Calculus classes at WPI normally meet four times
a week. The regular academic year consists of
four seven-week terms, each roughly equivalent
to a quarter in terms of contact hours. For the
Maple calculus sections, one of the four weekly

159
class meetings takes place in our computer lab, package. Examples are provided in the next few
equipped with 22 DECstation UNIX worksta- sections.
tions.
When students arrive at the lab, they are • The CalcP package contains three proce-
given a two-to-four page handout that contains dures that are useful in the visualization
background material on the lab topic, examples, and manipulation of polyline approxima-
and a set of exercises for them to complete. The tions to a function.
students work in pairs on the lab. During the lab ArcInt displays the integral to calculate
period, the instructor and student helpers circu- the actual arc length of a given func-
late around the room, providing help and answer- tion. It can be used to find a numerical
ing questions. Students generally do not complete value as well.
the lab in one hour. On the contrary, our inten-
PolyLength gives the numerical value of
tion is to provide a mix of routine computations
the arc length of a polyline approxi-
and challenging exercises in the labs. The stu-
mation to a function.
dent teams have about a week to finish the exer-
cises and write them up in the form of a joint lab PolyLine displays the graph of a polyline
report. approximation to a given function.
To encourage reflection, investigation, and un-
• Sequences defined by functional recursion
derstanding on the part of the students, we re- are handled by the following four proce-
quire that the lab reports consist of three parts. dures.
In the first part, the students are to describe in
their own words the main ideas of the lab. The PlotSeq plots the points of a recursive se-
second part consists· of their answers to the exer- quence.
cises, including explanations of what they did and Recur returns only the nth value of a re-
why. The last part is a Maple worksheet contain- cursive sequence.
ing the details of their work on the lab. We note
Sequence displays the first n values of a
that requiring this format makes the labs much
recursive sequence.
easier to grade; we don't have to dig through the
worksheet to figure out what they did. ShowSeq displays a graph of the values of
Students in the Maple course also spend about a recursive sequence. It differs from
three weeks per term working in teams of three PlotSeq in that it graphs the sequence
to four students on a project. These are gener- generator and the line y = x. It then
ally more involved applications of calculus, re- connects the points of the sequence to
quiring modeling and analysis on the part of the these two curves by line segments. The
students. Recent projects have ranged from de- resulting plot is a graphical interpreta-
sign of a roller coaster loop to analysis of crank tion of the convergence of a recursive
shaft diameter - connecting rod length tradeoffs sequence.
in engine design. Each group produces a joint
• Plotting of parametric curves in two and
report, with the teams having about two weeks three dimensions is performed by the fol-
to produce a draft report, which is criticized and lowing four procedures.
returned. The teams then have about a week to
produce a final draft upon which their grade is ParamPlot animates the drawing of a two
based. dimensional parametric plot.
Students in the Maple course also have tradi- ParamPlot3D animates the drawing of a
tional homework and exams, counting for approx- three dimensional parametric plot.
imately 30% of their final grades. The five labs
SurfLoop plots a two dimensional para-
and one project per term count for the remainder.
metric curve on a three dimensional
surface.
Maple programs Loopimate animates the drawing of a
parametric curve on a three dimen-
This section provides a brief description of the sional surface. Used in the study of
each of the Maple procedures defined in the CalcP surfaces and their parameterization.

160
• Solids of revolution can be explored using • The following are related to linear and
the following CalcP procedures. higher order approximations to func-
tions, including applications like Newton's
LeftDisk graphically displays the solid of method for solving single equations.
revolution for a function approximated
by disks or washers. Newton computes the Newton series ap-
proximation for a root of a function.
LeftInt returns the volume of the solid of
revolution approximated by n disks or NewtonPlot plots the function and the
washers. Newton series approximation to the
root of the function.
RevInt displays the integral to calculate
the volume of the solid of revolution of secantline returns an expression for a line
a given function. The numerical value that intersects a given curve in exactly
can also be computed. two places.
revolve plots the solid of revolution tangentline returns the expression for a
formed by rotating a given function line that is tangent to a given curve.
about a specified axis parallel to the TanPlane returns the expression for a
x-axis. plane that is tangent to a given three
dimensional surface.
• Several procedures for studying parametric
Taylor returns the expression for a trun-
curves can be found in the CalcP package.
cated Taylor series approximation to a
In the following descriptions, "vector func-
function. Unlike the standard Maple
tion" refers to a function of a single real
procedure taylor, Taylor is a polyno-
variable, with values in R 2 or R 3. mial that can be manipulated in the
Curvature computes the curvature of a usual manner.
two or three dimensional vector func- TayPlot shows the effectiveness of vary-
tion. ing Taylor polynomial approximations.
It plots the function itself along with
NormAccel returns the magnitude of the
specified Taylor polynomial approxi-
normal acceleration along a vector
mations.
function.
normalvect returns the unit normal vec-
tor to a given two or three dimensional Examples
vector function.
In this section, we provide examples of labs and
Speed returns the scalar speed of a parti- Maple programs.
cle moving along a two or three dimen-
sional vector function.
Definition of the derivative
TanAccel returns the magnitude of the
tangential acceleration along a vector In this lab, students use the secant line proce-
function. dure from the CalcP package to investigate and
compare the algebraic definition of the derivative
tanvect returns the unit tangent vector to
as the limit of the difference quotient and the ge-
a vector function.
ometric definition as the limiting slope of secant
unitvect creates a unit vector out of a vec- lines. As the examples given below show, the
tor or two endpoint of a vectors. secantline procedure takes three arguments: an
VDiff returns a vector which is the deriva- expression or procedure f, a base point a, and an
tive of a vector function. increment h. The result of the procedure is the
Maple expression for the straight line between the
VMag calculates the magnitude of a vec- points (a, f(a) and (a+h, f(a+h)). As also shown
tor. below, the result can be displayed, plotted, and
VPlot plots the graph of a two or three di- even animated. Figure 1 below shows the result
mensional vector function. of the plot command in the example.

161
> f := proc(x) x 3+2*x+l end;
4
2.250000000 x + 1
f := proc(x) x 3+2*x+1 end
4
> plot({f(x),secantline(f,x=O,l),
> secantline(f,x=0,1.0); secantline(f,x=0,0.5)},x=0 .. 1);
> with(plots):
3.000000000 x + 1 > animate({f(x),secantline(f,x=l,l-t)},
> secantline(f,x=0,0.5); x=0.5 .. 2.5,t=0 .. 0.99);

12

10

Figure 1: Example plot generated by the secantline command.

Solids of revolution By default, the revolve and LeftDisk commands


put caps on the ends of the solids. However, to
This topic appears about halfway through in- speed up the display, these can be omitted by
tegral calculus. The Maple programs help the using the nocap option. These two procedures
students by displaying the solid of revolution can also handle a set of two functions, in which
(revolve), the integral for the volume of the case the solid, or its approximation by washers,
solid (Revlnt), and by plotting and computing is that given by rotating the region between the
disk approximations to the solid (LeftDisk and two curves. It is also possible to rotate about an
LeftInt). Examples are shown in the Maple ses- arbitrary axis parallel to the x axis.
sion and figures below. In the lab dealing with solids of revolution, the
> f := proc(x) x 2+1 end;4
students are asked the following question.
f := proc(x) x 2+1 end
4

> revolve(f(x),x=-2 .. 2); Design a drinking glass by revolving a


> Revlnt(f(x),x=-2 .. 2); suitable function about the x-axis. In
2 your report, give the function, a three
/ dimensional plot of your glass, and de-
122
I Pi (x + 1) dx termine the volume of the liquid-filled
I part. You will be graded on the utility
/ and elegance of your design.
-2
> evalf(Revlnt(f(x),x=-2 .. 2»; Students seem to really enjoy this question and
86.28907824 come up with very nice designs, one of which is
> LeftDisk(f(x),x=-2 .. 2,5); shown below in Figure 3. The function used to
> LeftDisk(f(x),x=-2 .. 2,10); generate the glass design shown in Figure 3 is
> Leftlnt(f(x),x=-2 .. 2,5);
99.52163404 -x 3 + 0.15 if x < 0
> Leftlnt(f(x),x=-2 .. 2,10); 0.15 if 0 ~ x < 10
89.62938709 g(x) = { "':1:-10 + 0.15 if 10 ~ x < 20

4 +0.15 if x ~ 20

162
Figure 2: Solid of revolution and ten disk approximation.

The following Maple session shows the steps elif x < 10 then 0.15
needed to define this function and plot the solid elif x < 20 then sqrt(x-l0)/2+0.15
of revolution. Notice the quotes in the revolve else sqrt(10)/2+0.15 fi
call to delay evaluation. end:
> revolve('g(x)',x=-1 .. 30,nocap)j
> g := proc(x) if x<O then -x~3+0.15

Figure 3: Student glass design.

Taylor polynomials putations. Converting to a polynomial is straight-


forward, but is a complication that we wanted our
The standard Maple taylor procedure includes students to avoid so we wrote a wrapper func-
an order term and is not directly suitable for com- tion Taylor that handles the conversion. We also

163
wrote a procedure TayPlot that plots the func- In the labs, the students use these two commands
tion on the same graph as a set of Taylor polyno- to investigate convergence of Taylor polynomials
mial approximations. Examples are shown in the and the use of known Taylor series to generate re-
Maple session below and Figure 4, which shows lated Taylor series via multiplication, division, or
the output of the TayPlot command in the Maple substitution. For example, the series for exp(x 2 )
session. Notice the use of the numpoints param- is obtained by substituting u = x 2 in the series
eter. The TayPlot command will accept any of for exp(u), as is partially shown in the Maple ex-
optional arguments to the plot command. ample below.
> Taylor(sin(x),x=0,5); > subs(u=x 2,Taylor(exp(u),u=0,4»;
A

3 5 2 4 6 8
x - 1/6 x + 1/120 x 1 + x + 1/2 x + 1/6 x + 1/24 x
> Taylor(exp(x),x=1,3);
exp(l) + exp(l) (x - 1) + > Taylor(exp(x 2),x=0,8);
A

2 246 8
1/2 exp(l) (x - 1) + 1 + x + 1/2 x + 1/6 x + 1/24 x
3 By using Maple, it is easy for the students to ex-
1/6 exp(l) (x - 1) periment with Taylor polynomials and discover
> TayPlot(sin(x),x=0,{13,31}, for themselves, for example, the reason why the
x=O .. 6*Pi,y=-2 .. 2,numpoints=100); orders had to be different in the two commands
above to obtain the same order Taylor polyno-
mial.

-2

Figure 4: Plot of sin(x), along with the Taylor polynomial approximations of orders 13 and 31.

Vector calculus of parametric curves the Maple animation commands to show the ac-
tual motion along a parametric curve in two and
three dimensions. Some simple examples are
This topic often seems to be given short shrift in
shown in the Maple session below. Several of the
typical calculus courses. With help from Maple,
routines use the linalg package, though all will
it isn't too hard to give this the attention we
accept arguments that are lists of functions rather
feel it deserves. As described in an earlier sec-
than vectors. Notice that the curve computation
tion, the CaleP package contains quite a few
routines return either an expression if the third
procedures having to do with motion on curves,
argument is a name, or a numerical value if the
ranging from the curve computation routines
third argument assigns a value to the independent
Curvature, normalveet, and tanveet to the pro-
variable.
cedures ParamPlot and ParamPlot3d which use

164
> tanvect([cos(t),sin(t»),t); 2
[ - sin(t), cos(t) ) Aw
> r := proc(t) [t,t~2,t~3) end;
r := proc(t) [t,t~2,t~3) end 222
> TanAccel(r(t),t); A w +b
3 > NormAccel(helix(t),t);
4. t + 18. t 2 2 4 4 6 1/2
(b A w + A w)
2
4 1/2
(1. + 4. + 9. t )
t 2 2 2 1/2
> TanAccel(r(t),t=l); (A w + b )
5.879747321 > simplify(NormAccel(helix(t),t»;
> Curvature(r(t),t); 2
4 2 1/2 Aw
(9 t + 9 t + 1) # exercise 2
2 -------------------- > ellipse := proc(s)
2 4 3/2 [50*cos(s),40*sin(s)] end;
(1 + 4 t + 9 t ) ellipse := proc(s)
With Maple to do the tedious manipulations, the [50*cos(s),40*sin(s)] end
> VPlot(ellipse(s),s=-Pi/2 .. Pi/2);
students can be given exercises to work on that
> Curvature(ellipse(s),s)i
would probably not be possible by hand. Alter- 2000
natively, the students can shift their focus away
from the manipulations to the results. Below, we 2 3/2
list two sample exercises that have appeared in abs(- 900 cos(s) + 2500)
our labs.
The maximum curvature occurs at s=O.
Since the normal acceleration
1. Consider the helix is given by kappa*v~2, where kappa
is the curvature and v is the
r(t) = A cos(wt)i + A sin(wt)j + btk. speed, the result can be obtained
by solving the equation
(a) Show that the speed is constant. How
does it depend on the parameters?
(b) How do the curvature and the nor- for the maximum speed v_max.
mal acceleration depend on the param- > kappa_max:=
eters? Curvature(ellipse(s),s=O)i
kappa_max := 1/32
2. A hairpin turn on a roadway can be approx- > v_max :=
[solve(0.3*32=kappa_max*v~2,v)] i
imated as half of an ellipse, including the
v_max := [-17.52712185, 17.52712185]
major (longer) axis. If the major axis is 100 > speed_max := v_max[2]*3600/5280j
feet and the minor axis is 80 feet, what is # speed in miles per hour
the maximum constant speed at which a car speed_max := 11.95031035
can go through the turn while keeping the The hairpin curve produced by the VPlot com-
centripetal acceleration less than 0.3g? mand is shown below in Figure 5.
The Maple sessions below demonstrate how the
CalcP procedures can be used to do the compu- Conclusions
tations needed to answer these questions.
# exercise 1 The use of Maple labs and projects in calculus at
> helix := proc(t) WPI has been successful, with the department
[A*cos(w*t),A*sin(w*t),b*t) end; moving toward full adoption in the Fall of 94.
helix := proc(t) The students struggle at first, but most eventually
[A*cos(w*t),A*sin(w*t),b*t) end
> Speed(helix(t),t)i come around. With the aid of Maple, students
2 2 2 1/2 can certainly tackle problems that could not be
(A w + b ) done by hand, but we have found that there is an-
> Curvature(helix(t),t)i other aspect of using Maple that we did not really

165
anticipate. Simply stated, to use Maple to solve Institute. For the last three years he has been
problems the students first have to understand involved in restructuring the calculus curriculum
what they are doing and second to know how to there. His research interests are in the areas of
translate what they want to do into Maple com- studying how students learn and bifurcation the-
mands. For some students, both of these steps ory with symmetry. He can be reached via e-mail
are real impediments. However, we have noticed at bfarr«lwpi. edu. Michael VanGeel was a stu-
that for most students the first problem, that of dent in the new calculus course the first time it
understanding, is the more difficult problem. To was taught. The next year he was extensively
our way of thinking, forcing the students to un- involved in writing the CalcP package described
derstand what they are doing is not a bad thing. above. He has since moved on the the University
of Illinois at Champaign/Urbana, where he will
be a senior next year.
Biographical information
William Farr is currently an associate professor of
Mathematical Sciences at Worcester Polytechnic

401t - -_ _

20

10 20 30 40

-20

-40+-----

Figure 5: Hairpin curve for exercise 2.

166
MAPLE AT THE UNIVERSITY OF NORTH LONDON

Graham Taylor-Russell
School of Mathematical Sciences, University of North London, London, UK

1. Background 2. Maple as an investigative


tool in the unit MS217
Computer Algebra
The School of Mathematical Sciences of the
University of North London has been a user of
Maple for the past four years; during this time
the number of students exposed to the package
Students in the School of Mathematical Sciences
has grown significantly so that all degree
come with a wide variety of backgrounds.
students within the School have the opportunity
Students on the BSc Mathematics pathway are
to become familiar with the power and
expected to have studied Algebra and Calculus
sophistication available through Maple. For the
to the equivalent of UK A-Level standard and by
past two years the School has had a network of
and large are fairly fluent mathematically
PC's running Maple and computer algebra is
(although many require revision of some core
rapidly becoming central to the teaching of
material). On the other hand students on the BSc
Mathematics in the University.
Mathematical Sciences pathway (including many
who have come through non-traditional routes to
The author has been involved in promoting the
higher education ) are not required or expected
use of Maple via two main avenues:
to have seen material beyond the usual 16+
qualifications while in additioFl we have many
students enrolled on joint courses. This wide
i) the advanced level investigative unit
variety and the presence of non-traditional
called Computer Algebra available as an option
students presents challenges to staff and one
for Second and Final Year students
strategy adopted has been to develop
mathematical skills using computer algebra and
investigative techniques. This unit (developed by
ii) the supervision of final year projects in
the author) is the main vehicle in this area.
which Maple is used as a motivator for
introducing advanced concepts in areas of group
The unit is available to all students who have
theory and number theory.
passed the introductory calculus units in the
preliminary year and hence includes students
whose familiarity with the core areas of calculus
This paper describes the author's experiences and
and linear algebra varies widely. The unit is
details the type of assignments undertaken. therefore structured as follows:

i) Introduction to and familiarity with


Maple. To service this part of the course a short
guide has been produced by the author giving a
brief description of the main features of the
package and an introduction to writing
procedures.

167
ii) The use of Maple in Calculus problems. One problem that has been used in each of the
Here the intention is to underpin the students' last two years is to investigate the structure of
knowledge of techniques by extended examples perfect numbers and we now reproduce the
which might not be feasible without a computer documentation issued to students undertaking
algebra system. Students without a strong this task:
mathematical background are introduced to the
Student Calculus package of Maple and are
presumably given an idea of the way the
techniques they may have only recently mastered
INVESTIGATION PERFECT
can be applied. A toolbox of techniques is thus NUMBERS
made available to them which they may use
subsequently in units requiring a knowledge of
calculus. Definition:

iii) The main section of the unit aims to The number n is said to be perfect if the sum
foster investigative skills by providing students of all the divisors of n (including 1 but not n
with intensive assignments which give them a itself) is equal to n.
grounding in the techniques of mathematical
discovery which will stand them in good stead Thus 6 is a perfect number since 6 = 1 + 2 + 3.
throughout their university career and beyond.
Each student undertakes assignments from a
bank of investigative problems and is expected The following Maple procedure tests whether
to submit a full report on at least one, the report a given number is perfect. Note that
forming a significant proportion of the marks for commands such as divisors are only available
the unit (which is assessed by means of after the number theory package has been
coursework and a practical exam). They are also loaded.
encouraged to give oral presentations on their
conclusions to the rest of the class.
isperfect:=proc(j)
Since the background of the students is so varied local k,z,divsum;
it was decided that the fairest approach was to z:=divisors(j);
choose assignments with which no student was divsum :=sum(op(k,z),k=l ..nops(z»;
expected to be familiar. The vehicle chosen for if divsum=2*j then
many of the assignments was number theory. RETURN(true) else
This was because RETURN(false); fi;
od
a) There was a wealth of problems which end;
could be specified and introduced to students
without the need for large amounts of
background lecturing. Often all that was required Note:
was a few definitions and a motivation of why
the problems might be interesting. When this The variables op(k,z) and nops(z) are Maple
was not sufficient the lecture time (which variables which record respectively the kth
previously had been devoted to practical Maple operand of z and the number of operands.
concepts) was used to introduce theory.
Thus sum(op(k,z),k=l ..nops(z»;
b) Many of the problems in this area lend
themselves to investigation by computer computes the sum of the divisors of j.
techniques.

168
EXERCISES:
n 2°-1 (2° - 1) isperfect ispri
1. Type in this procedure and check that (2 0 - 1 (2° - 1» me(n)
it produces sensible answers when you try 1
2
isperfect(6);
3
isperfect(10);
4
isperfect(28);
5
6
2. 6 and 28 are known to be the first 7
two perfect numbers. In this question we want 8
to find the next perfect number and 9
eventually we would like to make a list of the 10
first few perfect numbers in order to make a 11
conjecture about their structure. 12
13
Write a procedure incorporating the test 14
isperfect within a for loop to create a new 15
procedure that finds the first perfect number
after a given starting point. 6. Try to refine your conjecture in the
light of the information contained in the table.

3. Use the procedures in 2. to write 7. Write a procedure for testing


down a list of the first 5 perfect numbers. For whether the number (2° - 1) is prime or not.
the 4th number start the search at 8000 while Run this test for all n between 1 and 15.
for the 5th start looking from 33550000.
8. a) Try to write down a condition that
describes all the perfect numbers
4. Compute the numbers in the found so far.
sequence
b) What would be the sixth and
seventh perfect numbers in the list if
your condition were correct.
for values of n from 1 to 15. (You may find it
useful to write a short Maple procedure to do c) Use the procedure isperfect to test
this). these numbers.

9. Use Maple to find the divisor sum of


5. Do the results to 4. tell you anything a number having your general form. This will
about the possible structure of perfect constitute a proof of a theorem having the
numbers? If yes make a conjecture about form
their form otherwise fill in the table overleaf.
"The number n is perfect if n =? and ?
" where you should replace the ? by some
appropriate statement.

10. Can you prove this theorem without


Maple.

169
MORE ON PERFECT NUMBERS EXERCISES

A. Suppose we apply the following a) Write a procedure to test whether a


process to a number n: given number n is triangular or not.

1. Add up all the digits of n. b) Show that all the perfect numbers
Call the result of this operation you have found are triangular.
digitsum(n).
c) Can you find a relationship between
2. Add up all the digits of the structure of a perfect number and the
digitsum(n). value ofk.

3. Continue performing this


operation until you have a one digit You should now write up a report containing
number. Maple output as well as a description of the
problem and the approach you took towards
4. Return the number found. solving it. Make sure that full explanations
are given of any results you are claiming and
that you present all the evidence you have for
any conjecture you make.
It can be shown that the number thus
returned is 1 for all perfect numbers other
than 6. Don't be afraid to describe any wrong ideas
you had while trying to find the results.
EXERCISES Conjectures made by professional
mathematicians often turn out to be false
when further evidence is considered but they
a) Write a procedure for performing are still an important part of the investigative
this task. process.

[This is not easy unless you try to show that n Having run the course for two years using this
=:1(mod9) instead] and similar assignments (covering Fibonacci
numbers, the Four Squares Theorem and prime
testing) the positive conclusions that can be
b) Verify the result for the first 7 perfect drawn are:
numbers.
• Students are motivated to work significantly
harder using this kind of approach. At times
this almost became a problem as there was a
danger of other courses being neglected.
B. TRIANGULAR NUMBERS
• Students appreciate that mathematics is not
a complete body of truths set down in stone
Definition: but that mathematical discovery often
proceeds by informed guesswork.
The number n is said to be triangular if
• The theoretical concepts introduced appear
n=I+2+3+ ... +k more relevant after students have struggled
to identify patterns and derive conjectures
for some number k. themselves.

170
3. The use of Maple as a 1) Find a Schreier transversal U for H
in G. This is a set which satisfies the
support tool in final year following:
projects
a) Ie E U
Students enrolled on all degree courses in the
School of Mathematical Sciences are required to
undertake an extensive project lasting either one b) U contains exactly one
or two semesters in their final year. It is expected element from each coset of H in G.
that this should involve an element of
investigative work as well as the acquisition of
theoretical knowledge and Maple has been a c) If w E U then so do all
useful tool in this aspect of the work. An left subwords ofw.
example of the possibilities is given below:

A Schreier transversal can be found using the


Maple command cosets or as a by-product of
the Todd-Coxeter coset enumeration process
Using Maple in Computational Group for which a computer implementation is
Theory - The Reidemeister-Schreier available.
rewriting process:
2) Calculate a set of Schreier generators
for H. These will consist of all distinct
Problem : Given a presentation (X I R) for
elements of the set
a group G and some generators for a
subgroup H in G can we find a presentation
A {(ux )(UX)-I : u E U, X E X U X-I}
for H.

where g is the coset representative of g


(Note: We are trying to expand on the
process used by the Maple command pres and
Complete the following table listing the
to describe the algorithm involved. The
elements of A and their inverses using the
theoretical justification for the process is dealt
Maple command cosrep.
with by directed reading and is omitted from
this report).

a b c a-I b- 1 C"l

Example:
UI
Suppose G = (a, b, c labc = b, bca = c, cab = a)
u2
Calculate a presentation for the subgroup
H = (ab, bc, ca ). u3

...
The problem can be broken down into four
steps: ur

171
where the u's are the elements of the • Using Maple as a computational device
transversal calculated above. allows students to encounter more
complicated examples than would otherwise
be possible.
3. Calculate the complete relation set

R' == {uru· t : u E U, r E R} • Through implementing an algorithm of this


type students obtain a better understanding
(This will have to be done by hand - though is of the processes involved.
not too tedious).

Simplify these relations if possible.


In conclusion I have no doubt that Maple will
continue to be a central tool in the final year
4. Write a Maple procedure that takes projects in the area of pure mathematics and
the complete set of relations R' calculated students will continue to acquire benefit from its
above and rewrites them in terms of the use.
Schreier generators. The algorithm for doing
this is as follows:

Suppose r' = x t x2 ••• xn E R' and define Graham Taylor-Russell is currently a lecturer in
elements u j and a j inductively as follows the School of Mathematical Sciences at the
University of North London. He received a BSc
ut = 1 in Mathematics from the University of York and
uj + t = cosrep( UjX j ) (1 ~ i ~ n) a PhD from London University in 1990. His
a j = uj xj uj + 1- t research interests are in combinatorial group
theory and the solution of equations over groups.
He may be contacted at
The rewritten version of r' is then the relation
at a 2 a3 •••• an and each a is an element of
the generating set A. School of Mathematical Sciences
University of North London
Having completed these steps we have a Holloway Road
presentation for H with generators A and London N7 8DB
relations as calculated in 4. Use the Maple U.K.
command pres to check your answers to this
and other examples. You will probably find
redundant relations in your presentation
which can be eliminated using Tietze
transformations.

Reference: Presentations of Groups.


D.Johnson Cambridge University Press.

The use of Maple in projects such as this would


appear to have the following educational
benefits:

172
INTRODUCING MAPLE TO FIRST YEAR ENGINEERING
STUDENTS VIA PROJECT STUDY

Ulf R"mnow
Department of Mathematics and Computer Science,
Institute for Electronic Systems, Aalborg University, Aalborg, Denmark

Introduction Linear Algebra. As a point of departure I have


chosen the subject, Artificial Neural Nets Applied
The fundamental educational model at Aalborg to Sorting.
University is project-based study. Under this form
of study, the students, every semester during their
entire course of study, work with specific projects Artificial N eural Nets
within a given theme. The students are usually
organized in groups of four to eight. Every group An artificial neural net model is a non-
chooses a subject relevant to the given semester's programmed, self-adapting computer system pri-
theme for their project work, and under the guid- marly developed for classification purposes (fig. 1).
ance of a teacher elaborate a project report which It is composed of many non-linear computational
at the end of the semester becomes the subject of elements operating in parallel and arranged in pat-
an examination. terns reminiscent of biological neural nets. The
Parallel to the project work, the students follow computational elements or nodes are connected via
courses in various subjects, some of which are re- weighted links that are typically adjusted during
lated to the current project theme, whereas others use to improve performance.
are more general. The latter include the mathe-
matics and physics courses ([2]).
In the first year, the project-based form of study
is practiced within some broad theoretic frame,
for example, Systems of Energy, Urbanization,
the Work Environment, Systems of Environmen- Neural
tal Technology. Typical project subjects for the •
Net
Basic year might therefore be

Energy Transmission by Wind Turbines.

Artificial Neural Nets Applied to the Sorting


of Letters.
Applying Global Positioning Systems in Agri- Figure 1: The Neural Net as classifier.
culture.

I will here describe an experiment in introducing Before a neural net can be used for a particular
Maple V for first year engineering students through classification job it must be "trained", Le. must
a project instead of, as traditionally, doing it in be presented with a series of test data, each one of
relation to the courses in Calculus and which consists of an element from the set of objects
to be classified together with information about
the correct classification of the given element. Via
this presentation the internal structure of the neu-
ral net is adjusted, and when the quality of the
classification performance has reached the desired
level, the neural net is ready to do its classification
job.

173
There are several types of neural nets [lJ. In the
present paper we will take a closer look at the neu-
ral net models of the Multi-Layer Perceptron type
(MLP), the general structure of which is shown in
fig. 3.
Mathematically, a trained net can be consid-
ered as a function mapping the set of objects to
be classified into the set of classifiers. However,
the construction and mode of operation presup-
pose that the domain of objects to be classified,
as well the range of classifiers, are represented as
vectors, which means that a neural net can be con-
sidered as a function W defined on a vector space
JRIL into another vector space IR" (fig. 2).
Figure 3: Internal structure of a neural net of the
type MLP.

where
1 __
2 __ ___I /k = X I-t [N(X)]Nk
Uk = Y I-t WkY - Ok, = 1,2, ... ,M.
---2
k
Neural Net
___ v

/1-- The variables x and Ok (thresholds) are Nk di-


mensional vectors, Y is an N k - 1 dimensional vec-
tor, whereas Wk (weights) is an N k x Nk-l ma-
trix. The neuron functions N(x), i = 1, ... ,Nk
are (mathematical) expressions cp: in the scalar
variable x T ei, where
Figure 2: The external structure of a neural net of
the type MLP. eT [0 °... t °... °
1 J

Since the internal structure of a Multi-Layer


Perceptron net has the following appearance
(fig. 3), W can obviously be represented as i.e.

w = 'l/JM o'l/JM_l 0 ... o'l/J o H(x) cp~(xTel)


where f~(x) cp~(xTe2)

V I-t IRN1 (/-L = No) k = 0, /k(X) = N(x) cp:(x T ei)


IRNk I-t IRNk +1 k = 1, ... ,M-1,
IRNM I-tIRNM (v = NM) k = M.
ftk(x) cp~k(xTeNk)

M is the number of layers whereas Nk is the num-


ber of neurons in the k'th layer. The net is trained by initially selecting small
Regarding the structure of a single neuron in a random weights and thresholds and then present-
Multi-Layer Perceptron net we see (fig. 4) that ing all test data repeatedly. Weights and thresh-
olds are adjusted after each trial using the infor-
k =0, mation about the correct class. The adjustment
k=1, ... ,M-1, is accomplished by a gradient search technique to
k=M. minimize a performance function P equal to the

174
Setting
1·1
U
1
ap
k=M
aUM'
1·1
~ ap aUM aUk+l
aUM aUM-l ... aUk '

k = M -1, ... 1,
we have

Figure 4: Structure of the i'th neuron in the k'th and thus


layer.

mean square difference between the desired and


Similarly
the actual net outputs, i.e. between Y D and YM

where Setting up and running a N eu-


ral Net
YM = w(uo), Uo E V.
A Maple program can now be constructed for
this mathematical structure. It consists essentially
Therefore the adjustment quantities are given by of two parts, a Classification Routine and a Back
Propagation Algorithm.
The Classification Routine, which presents the
function W, is from a mathematical point of view
a piece of matrix algebra, whereas the Back Prop-
agation Algorithm, which is used to adjust the
weights and thresholds, combines functional ma-
trices and matrix multiplication.
and thus the adjusted weights and thresholds To adapt oneself to the variable convention of
Maple, the program is built up backwards, which
means that the two programming parts are woven
together (see the box on the next page). The pro-
gram structure is applicable in all three phases of
the program running
where a is a scaling factor to be adjusted during
the training phase. - The Setting Up, the Training and the Execu-
tion phase.
Using the chain rule we have
In the setting up phase the various mathemati-
cal expressions are (internally) developed i.e. cal-
ap ap aUM
= aUM aUM-l culated symbolically (which is the special feature
aW~j of Computer Algebra systems). In the training
phase, the Classification Routine and the Back

175
Propagation Algorithm are run over and over, once By input/output at the end of the code is meant
for each element of the test data, until the desired input/output for the training phase, whereas the
level of performance is reached. And finally, in the input/output in the parenthesis is for the execu-
execution phase, only the Classification Routine is tion phase.
used. Even though there are no neuron functions in
The pseudo code of the central part of the pro- the O'th layer, the quantity CPo is introduced in the
gram for the neural net is presented below in the code: This permits us to use the back propagation
box. A few words of comments is needed to explain loop down to n = 1. The crucial programming line
the use of symbols and terms. in the code is
The expression ["']k means a k x 1 dimen-
sional array; in particular the symbol [ai]k Un f- wnfn-l (un-d - On
means the array [ai,a2,'" ,ak]. The expression
8v for n = 1. It becomes a valid instruction only if
j acobian( v, z) is presented in the text as 8z; the CPo is defined and the elements in CPo are assigned
term 'assign cP k' means that the function cP k is to the identity 'x ~ x'.
assigned to the k'th neuron function. Written out as Maple code the program looks as
follows.
The Multi-Layer Perceptron Net
> with(linalg):
input M, N i , i =O,l, ... ,M
Read in M, N[i]
P f- [HYD - YM]T[YD - YMJL Set up neuronf ct [i]
a f- jacobian(P, YM) > P := array(l .. l,
YM f- fM(UM) [1/2*dotprod(y(D)-y(M),y(D)-y(M»]);
fM f- {x ~ [cpf1 (x Tei)]NM} > delta := jacobian(P,y[M]);
aM f- ajacobian(fM,UM) > y[M] := f[M];
# Start of back propagation loop. > f[M] :=
for n = M, M -1, ... , 1 do array (1. . N[M] , [seq (phi[M] [i] (u [M] [i] ) ,
i = 1. . N[M]) ] ) ;
assign CPn > delta[M] := evalm(delta & *
Un f- wnfn-i (Un-i) - On jacobian(f[M] ,u[M]);
> for n from M by -1 to 1 do
for i = 1, 2, ... , N n do
> phi[n] := neuronfct[n]; #assign the
n'th neuron function
> delta[n] := map(eval,delta[n]);
for j = 1, 2, ... , N n - 1 do > urn] := evalm(w[n] & * f[n-l] -
~wij f- an jacobian (un,wij) Theta[n]);
> for i to N[n] do
end > Delta[Theta] En] [i] := evalm(delta[n]
end & * jacobian(u[n] , [Theta[n] [i]]»[l,l];
> for j to N[n-l] do
fn-l f- {x~ [cp~-i(xTei)JNn_J
> Delta[w][n][i,j]:= evalm(delta[n]
an-i f- anjacobian(un,un-d & * jacobian(u[n],[w[n][i,j]]»[l,l];
> od;
end
# End of back propagation loop. > od;
> f [n-l]
assign CPo array(l .. N[n-l],[seq(phi[n-l][i]
initialize Wk, Ok, k = 1, 2, .. , , M (u[n-l] [i]), i=1. .N[n-l])]);
> u[n]:= map(eval,u[n]);
input Uo, YD, (or uo) > delta[n-l]:= evalm(delta[n] & *
output YM, P, ~Wk, ~Ok, jacobian(u[n],u[n-l]»;
k = 1, 2, ... , M, (or YM) > od:

176
> phi[O] := neuronfct[O]: #assign the Educational benefits
O'th neuron function
> randomnumber := rand(-100 .. 100)/100.: When evaluating the educational benefits in re-
> for 1 to Mdo lation to the sketched project one question is cru-
> for i to N[l] do cial.
> Theta [1] [i] := randomnumber():
- Does Maple enhance students' under-
> for j to N[l-l] do
standing of the significance of Mathe-
> w[1] [i, j] randomnumber () :
matics, i.e. mathematical concepts, nota-
> od;
tions, definitions and theorems, etc. as a
> od;
tool whereby concrete, practical, techni-
> od:
cal problems are solved?
Input: u [0] and y [D]; (or u [0])
Output: y[M], P, Delta[w] [k], It is less important if Maple improves the stu-
Delta [Theta] [k]; (or y[M]) dents' ability to solve their problems from the
courses in Calculus and Linear Algebra, or even
The Setting Up phase can be rather (cpu-)time if Maple helps students to improve their general
understanding of mathematics.
intensive, mainly because of the jacobian-terms.
However this phase can be speeded up consider- What really matters here is the relationship be-
ably if we make use of the following calculations tween mathematics and the applications. Or bet-
ter, the understanding of this relationship.
ap I will explain a bit more. In using Maple to con-
YM struct a neural net, the students experience how
the matrix notation, the matrix algebra and the
matrix formulation of the chain rule for multivari-
ate functions facilitate their programming activi-
ties. They see that these are not just gimmicks
where interesting to mathematicians, but rather tools
whereby they really can operate. This means that
explaining mathematical rules, proving theorems
etc. now become interesting and even compelling
for the students.

and
Concluding remarks
o o The purpose of the above considerations is to
o o show another way to introduce a Computer Al-
gebra system to engineering students, that is via
project study.
aUk 0 aUk 0 Our experience is that Maple in this respect is
and -
awt Yj f-i a(Jkt -1 f-i received positively by the students. In my opin-
0 0 ion it is important not to integrate Maple - or
any other Computer Algebra system - into the
0 0 mathematical education proper, where mathemat-
ical concepts, definitions and methods are central.
as Maple is better introduced as an useful, but in-
k k (Jk dependent tool, when working with mathematical
u~ Wu w lNk_l Yl 1
models.
With our point of departure in this view, it is
uk k
Wil
k
w iN Yj
(Jk rather a question of inventing projects, such as the
t k- 1 J
above, which demand the construction of mathe-
k matical models. And in this respect the possibili-
k
w Nk w kNkNk_l (Jk
UNk 1 YNk-l Nk ties are immense; besides technical subjects, areas

177
such as physics and economics offer a wealth of
subjects.

References
[1] Richard P. Lippmann. An Introduction to
Computing with Neural Nets. IEEE ASSP
Magazine, pages 4-20, april 1987.

[2] VIf R0nnow. Strategies for Future Education


in Mathematics to Engineering Students. In
Industrial Mathermatics Week (Proceedings
of the 9th Nordic Conference on Mathemat-
ical Education at the Technical Universities.
Norwegian Institute of Technology.) p.42-46,
1992.

The author VIf R0nnow received his Ph.D. de-


gree in Mathematics at University of Copenhagen
in 1963, and is currently Associate Professor of
Mathematics at Aalborg University. He can be
reached at the following address:

Ulf R0nnow
Dpt. of Mathematics and Computer Science
Aalborg University
DK-9220 Aalborg
Denmark

E-mail: ugriesd.auc.dk

178
ANOTHER LOOK AT LEARNING THE TECHNIQUES OF
ELEMENTARY INTEGRATION

Joseph A. Pavelcak
Department of Mathematics and Computer Science, Merrimack College,
North Andover, MA

any underlying organized approach to


integration is obscured by these
Synopsis subgoals. It is argued that the myriad
applications serve to motivate the
Pattern recognition plays a central role learning of the techniques of integration.
in discovery and progress in both There is validity in this argument;
science and mathematics. Integration however, the other concepts covered in
involves the ability to recognize when a these chapters form a dense underbrush
particular method should be applied. through which the student is expected to
Every CAS utilizes pattern matching observe some order in integration,
procedures in the algorithms for without a clear delineation of that order.
integration. Emphasis is placed on this Nowhere is there a mention of pattern or
aspect of the technique, thus developing, of how to recognize or search for any.
at least, the awareness of the importance
of pattern recognition and presumably, Yet proficiency in integration is the
leading to some facility in it. Use the aim, so every section in these chapters
openness of Maple to expose a pattern in contains a large dose of exercises used to
the techniques of integration. give the student the drill/practice
needed to attain that proficiency. In
general, these exercises receive a less
The Way It Is than enthusiastic response, motivational
problems not-with-standing.
The standard calculus textbook used in
the Freshman course, intersperses This 'traditional'
integration techniques over a number of drill/practice/problem approach,
chapters which have other goals. which seemed to work in the past, is now
Examples of such chapters would be considered a failure ostensibly because
those on the introduction of circular too many students fail the course.
(trig) and transcendental functions, and Current remedies for this contain a
applications such as the calculation of mixture of graphics and real-world
surface area, volumes, moments etc. (realistic) problem projects. This is
Though the major goal is integration, done by reprinting those traditional
texts with more graphs and inserting
problems formulated to use graphing
calculators or computer graphics
packages. Associated with these new
versions are supplemental publications
composed of 'realistic' projects designed
for laboratory sessions.

179
Both of these supplements are good. language - problem solving requires the
Graphics is an excellent vehicle for ability to write mathematics.
pattern recognition. Practice in
problem solving, whether project size Exposing the student to problem solving
or textbook size, is important and methods and practices is generally
expected of a course in mathematics. recognized as being an expected and
important role of math courses, even
The Way It Might Become elementary math courses. Thus time
must be found for this tedious task,
One of the perennial difficulties within whether lab sessions are scheduled or
the calculus course sequence is the not. More importantly, the order of
shortage of time necessary for devoting topics comes into play, in particular,
sufficient attention to the requisite basic skills must be taught
topics. In order to introduce new tools or (practiced/learned) before and
topics, time must be taken from another concurrently with problem solving
topic or some topic(s) dropped out of the techniques, else this venture will move
sequence - which leads, of course, to too slowly and not have the proper
considerable debate. Thus when real- intellectual effect on the student.
world project problems are introduced,
a laboratory session is added, increasing Many instructors of the Calculus II
the number of contact hours, but usally integration segment, observe that
leaving the number of credits unchanged. introducing (trying to teach) techniques
of integration, imbedded as it is among
Impetus for such changes to the calculus other topics, usurps a considerable
comes from the emerging school of amount of time and, for the majority of
thought that places practice in problem students, is barely successful. Clearly,
solving at the head of the list of goals for a more methodical approach to
the course - ahead of the acquisition of integration must be set forth. Here is
basic skills. The rationale seems to be where Maple comes in.
that basic skills are a spin-off from
working through the project problems. Much effort, indeed man-years, has gone
One might be tempted, following this into the development of the processes
reasoning, to introduce, along with the which are invoked with the simple
commands needed for plotting, the upper command into Since Maple is open, in
level Maple commands diff. int, the sense that the code of the procedures
solve.fsolve, et. al. With these is accessible, we may exploit the work
powerful tools, a student has little and results of the designers. The
immediate need for basic skills, but this developers of the integration procedures
path bodes disaster for learning calculus in CAS's have imposed an order upon the
or any mathematics. integration algorithm which is efficient.
An excellent outline of the approaches to
The Way It Should Be symbolic integration used in CAS's is
given by Joel Moses in Communications
Problem solving facility is an ideal of the ACM August 1971, Vol. 14
difficult to reach and impossible to Number 8.
teach. To get started in the formulation
and subdivision of a problem, leading Following the same or similar approach
toward a (possible) solution, the student in the classroom presentation of the
must be comfortable with and capable of calculus, due to the efficiency of the
symbolic manipulation i.e. basic skills. method, will reduce the time currently
Mathematics is a language. As is needed to cover the topic, as well as
characteristic of languages, it takes a lot bring order to the confusion experienced
of practice before one can write in a

180
by many students in this part of the
course.

The student is not expected to learn


another language (Maple), else we would
be guilty of clouding the issue, just as
we have accused the current Calculus For this case the 'match' procedure is
textbooks of doing. However, in this used to determine the coefficients and
proposal for teaching the integral exponent. With these values, a subs
calculus, the student will be given command can be used to perform the
illustrations, written in Maple, of the integration.
"recognize, branch and perform" loop,
used in the search to classify the
integrand. The student is then expected II - Knowledge of the integrals of
to write and test short sequences of elementary functionals is assumed.
similar Maple commands for special Here the student should generate a table
cases. One of the pedagogical pluses of of antidifferentiation "formulas" which
programming a computer is that it he/she knows from the differentiation
recognizes no hand waving and scorns part of the course. If the table is
fuzzy thinking. To 'teach' a computer to incomplete, he/she will be unable to
execute an algorithm correctly, the perform some of the integrations, thus
student must know how to perform that leading him/her to extend that table
algorithm correctly, thus leading to with more functionals.
learning.

Outline for Calculus II III - Substitution. This technique is


Integration based upon the chain rule for
differentiation. N. B. Change of variable
The order for introducing the substitution or trigonometric
techniques, is that used by the standard substitution is not covered here. In fact,
text on Calculus. Only a subset of the some of the substitutions in Calculus
integration procedures in Maple are books are given with no explanation,
used since the problems from the text leaving the student mystified. Such
don't require all the power. The student esoteric procedures should be removed
can experiment with that power and is from the textbooks, since they add little
urged to do so. to the mathmatics of integration, but
take up time.
Four distinct techniques are covered. In
each, the student is expected to use a
pattern matching procedure and/or the f f(u)du, u = g(x), du = g' (x)dx
Boolean 'type' construct, identifying the
integrand, in order to determine the
In order to decide whether the integrand
technique to be applied. The student will
fits this model, the student finds the
need to learn the use of a small number
functional f, extracts the function u,
of Maple commands; here, the
performs (via Maple) the
illustrations will serve as models.
differentiation, then divides the
integrand by the differential. If a
See appendixes for illustrations for each
of the following algorithms. quotient is a constant, then the
integration is a table lookup with f as
index.
I - The first formula introduced is :

181
IV - Integration by parts. This
technique is based upon the derivative of Not all of the special integration 'tricks'
a product. The procedure intparts should be considered, since the text
from the student package is used. The gives no rationale, simply presents
student determines the factors of the these as complicated mechanical
integrand, selecting one of the factors procedures. These procedures require
for differentiation, i.e., u in: time, time which can be spent more
productively on topics such as
numerical techniques and curve fitting.
JUdv = uv-fvdu This permits the introduction of
problems, absent from the integration
chapters, for which there is no method
Invoking intparts returns the right- in the integration process tree. Such
hand side of the above equation. The problems need more attention since
student must decide how to proceed. textbooks tend to leave the impression
With the aid of Maple, trial and error that closed forms exist for all integrals.
tests can be performed rapidly. This
experimentation is an important part of The tools available in Maple will
the learning process - repetition. facilitate the learning process, but must
be used judiciously. The hope is that the
interest of the student will be tweaked to
V - Integration of rational integrand by the point that he/she will investigate the
partial fractions. Investigation of the procedures of Maple more thoroughly.
Maple procedures is recommended to the
student, since by this time he/she is
familiar with the procedures used above Appendix
and should be comfortable with the
idiosyncrasies of Maple. Through Implementation overview.
experimentation the student is expected
to find that the integration of rational In the illustrations that follow it is
functions is a difficult problem, assumed, for purposes here, that the
involving factoring procedures. student knows that the integration
operator is linear. Therefore only
All of the above require some pencil and products are used.
paper work. The algorithms are
presented with examples then the Clearly there needs to be far more
student uses Maple. explanation of the Maple operators than
is given in the appendix. However, I
believe it would not be very extensive.
Conclusion Practice is what students need and with
Maple taking care of the mechanics, the
Extracting the integration from the methods as methods will be seen more
chapters in which it is imbedded and easily. However, a major concern with
presenting the process for study in a this approach is the fact that our
unified manner will improve the students are weak in algebraic
learning of the algorithms both in time manipulation.
and retention, because the student will
see the pattern, which leads to It is my hope that this approach will
understanding. That pattern is a save some time which can be used in V
decision tree. A test is made on the (partial fractions) to clear up some of
integrand to determine its type which those difficulties with algebra. There
determines the next step (branch) in again, Maple can be used as a tool for
the process. drill.

182
Appendix 2
Illustrative Examples

I: Integration of the form c*xAn, n <> -1. The two commands introduced are 'match'
and 'subs' (substitute). The first Maple command below is 'Int' (Inert integration).
It is not used in the procedure, it simply displays the the integral.

> Int(c*xAn, x);

> match(x A2*sqrt(x) = C*xAEx, x, V);.


true

> V',
{C= 1, Ex= S/2}

> Ans := subs(V, C*xA(Ex+ 1)/(Ex+ 1) )

Ans := 2 x"Yz
7

A procedure can be written to generalize the above. The students are expected to improve
that procedure, e.g. include the case for n = -1. A starter is "Integrate".

> Integrate := proc(lntegrand, X) local V;


if match(lntegrand = C*XAEx, X, V)
then subs (V, C*XA(Ex+ 1 )/(Ex+ 1) )
fi;
end;

> Integrate(3*x A2, x);

> Integrate(6*YA(1/Z), V);


4y/2

> Integrate(XAY, X);


X(Y+l)

Y +1

> Integrate(XAY, X);

183
II: Here the student uses his/her knowledge of differentiation to generate a table of
antidifferentiation formulas. The table can be as comprehensive as the student wants to
make it. Below is an example table and its use.

> IntSet:= table( [ (sin) = -cos,


(cos) = sin,
(sec * tan) = sec,
(1/sqrt(a A 2 - uA 2) ) = arcsin,
(tan) = -In @ abs ,
(sec A 2) = tan,
(sqrt) = 2/3*sqrt A 3 ,
(In) = proc(u) u*(ln(u) - 1) end,
(sec) = proc(u) In(abs (sec(u) + tan(u) » end ]);

Integration is done via table lookup.

It is pointed out that an 'else' clause can be included in the "Integrate" procedure, which,
along with a table similar to this one, would give the student a fairly good integration
routine.

Some examples.

> IntSet[sin](x);
- cos(x)

> IntSet[sec*tan](u);
sec(u)

> IntSet[tan](X);
- In( sbs(X»

> IntSet[sqrt](x-l );
~(X_l)3/2
3

> IntSet[sec](x+4);
In(abs(sec(x+4) + tan(x+4»)

Questions for the student: Is it correct to use any argument in the above integration by
table lookup? What, if any, are the restrictions? Use Maple 'int' to check.

184
III: Substitution is based upon the chain rule in differentiation. The student is asked to
perform some pencil and paper examples in a stepwise fashion, then do the same with the
help of Maple.

Stepwise example with Maple.

> Integrand := 5*x A2 * sin(x A3);

2 3
Integrand:= 5 x sin(x )

> match(lntegrand = C*xAEx * sin(xAExx), x, V);

true

> V',

{Exx = 3, C = 5, Ex = 2}

> Pow:= op(2, op(l, V));

Pow:= 3

> Div := diff(xAPow, x);

Div: =3 x 2

> match(lntegrand/Div = K * sin(xAPow), x, Vs);

true

> Ans := subs(Vs, K * IntSet [sin](xAPow»;

5 3
Ans := - - cos(x )
3

To write a general Maple procedure for this, requires learning more of the language
than we expect of the student. Perhaps some will be interested enough to try.

The student must specify the conditions under which the above algorithm will work.

IV: Integration by parts is based upon the derivative of a product. The student will
perform trial and error experimentation using the Maple 'intparts' to do the mechanical
work.

Ju dv = f
uv - v du

185
An approach usually suggested is to chose that part of the integrand which you know how
to integrate for dv, the remainder is then u. Alternatively, chose that part of the
integrand for u , which, upon differentiation becomes simpler.

Some examples.

> Integrand:= x*exp(x);


Integrand := x exp(x)

> intparts(lnt(lntegrand, x), exp(x»; # exp(x) is u.

1/2 exp(x) x
2
- II/2exp(x) x dx 2

Poor choice for u, since the remaining integral is more complicated than the original.

> intparts(lnt(lntegrand, x), x);

xexp(x) - Iexp(x)dx

> Integrand := xt\2 * In(x);


2
Integrand:= x 1n(x)

It is easier to differentiate In than integrate In, so let u = In(x).

> intparts(lnt(lntegrand, x), In(x»;

> Integrand:= arcsin(x);


Integrand := arcsin(x)

Let u = arcsin(x), since the dervative is known.

> intparts(lnt(lntegrand, x), arcsin(x»;

.
arcsm(x) x -f(I-x)
x
2 1I2 dx

The student will need to apply these methods to perform the remaining integrations.

Joseph A. Pavelcak received a SA in mathematics from the College of St. Thomas


,St. Paul Minnesota 1951 and a MA in mathematics from University of Massachusetts,
Amherst in 1957. He is currently Associate Professor in the department of
Mathematics/Computer Science at Merrimack College, North Andover Mass. Tel. (508)
837-500 X4301 or X4202 or JPavelcak@Merrimack.Edu .

186
WORKSHEETS: CAN WE TEACH MATHEMATICAL
ALGORITHMS WITH THEM?

Michael Monagan
Departement Informatik, ETH Zurich, Switzerland

Introduction present the method as a textbook would, as a


sequence of steps, and show the method with
worked examples. Unlike a book, we are free
What is the traditional way we teach to execute larger, more realistic examples. We
mathematics? There are essentially three also include the capability of DOING the
activities. Students read textbooks, they hear computations interactively.
and see an instructor give explanations, and
they do exercises. Some students prefer to Let me clarify the difference between the two
read textbooks. I prefer to listen to an uses. In the first approach, the instructor is
instructor. Most students need to work not interested in how Maple gets the answer
through the exercises. Where does a to a given command. Of course, the instructor
computer algebra system (CAS) like Maple fit may be curious as to how Maple did it.
into this picture? However, the primary purpose is to obtain a
result, THEN study it. In the second way, the
In this article I am interested in showing how instructor does care about those intermediate
a CAS, specifically worksheets (notebooks), steps because he is teaching the students how
can be used to PRESENT worked examples to solve the problem. He is teaching the
which demonstrate mathematical procedures students a mathematical algorithm and the
or algorithms. These worksheets could be primary purpose of using Maple is to help the
used by the instructor during the lecture to student understand the algorithm through
present worked examples instead of using the seeing worked examples. In both cases, the
blackboard in order to save time and to possibility of doing computations live makes
present more realistic examples. Secondly, it possible to study what happens when we
they could replace and/or supplement wor~ed change the problem slightly. In the first way,
examples in a textbook or laboratory exercIse the instructor may want to demonstrate what
book. There are two modes in which this happens to a solution when a parameter is
presentation can be made. One is "live", changed. In the second way, one may want to
using the computer; the other is "dead", on see what happens to an algorithm when the
transparencies or on paper. size of the problem is increased, perhaps to
compare two different algorithms.
There are essentially two ways in which one
might use Maple in teaching. One is as a How do mathematics students learn
support tool, a calculator, to SHOW examples algorithms? Traditionally, an instructor
or phenomenon. The purpose might be to presents, in English, the key ideas behind the
motivate a discussion. Here the instructor is algorithm then presents the algorithm as a
using Maple to show an application. Maple is sequence of steps to be performed. The steps
used to DO the mathematics. The second way may not be written down explicitly, as many
is to use Maple to TEACH a method or instructors proceed directly from the ideas and
algorithm for solving a problem. We can theorems to demonstrate the method with
examples. Some instructors prefer to give a
more detailed (theoretical) explanation of the
method, leaving examples mainly for the
exercises. Most instructors do not give a
rigorous proof of an algorithm like they do a
theorem.

187
The question being asked in this paper is: Is to compute the eigenvalues of a square
there any role for a CAS in teaching students matrix
mathematical procedures (algorithms)? Can > restart; # clear all variables
this be done effectively through worksheets? > with(linalg,matrix,det,nullspace);
It appears to be considerably more difficult to
use a CAS to teach an algorithm, than just to [det, matrix, nullspace]
'do' a calculation and look at the answer.
Perhaps the answer is: yes, good students > A := matrix([[a,b],[b,a]]);
would profit from this exercise, but average
students would find it difficult.

I am not proposing that we teach a


A :=[: :]
Recall that the eigenvalues are the roots
mathematical algorithm by asking students to
of the characteristic polynomial which is
write a program that implements the
algorithm. Though I do think that it would be the determinant of the characteristic
a good exercise for every student learning matrix lambda I - A where I is the identity
mathematics to do, at least once, matrix. In Maple, we need to construct
programming is not sufficiently trivial for this matrix, then compute its determinant.
students to do this all the time. Instead I This requires that we either type it in again
believe that with worksheets we have a (which is most likely what an instructor
medium that permits us to present an would do on the blackboard) or we have to
algorithm as an interactive sequence of steps. learn a new command.
This is not the same as would be found in a
textbook. Nor is it the same as presenting a > C := evalm( lambda-A );
computer program. It is more like seeing the
execution of a program. C:=
-a + A- -b]
[ -b -a + A-
The best way to show what I mean is to
present some carefully chosen examples from Note: Maple understands the scalar
algebra and calculus. Four Maple worksheets lambda here to mean lambda I. Next, we
follow. You will notice two fonts used for the compute the determinant.
commentary within the worksheets. > p := det(C);
Comments in the Times Roman font (this 2
font) are for you, the reader. Comments in p := a2 - 2 a 1..+1.. - b2
the Helvitica font are part of the worksheet. Next we factor the polynomial p(lambda)
and solve for the roots.
Eigenvalues Worksheet > p := factor(p);
p := (A- + b - a) (A- - b - a)
We teach our students that the eigenvalues of
an n by n square matrix A are the roots of the > solve(p=O, lambda);
characteristic polynomial p(lambda), a
polynomial of degree n. And we give them a -b + a, b + a
few examples to compute, perhaps as part of Let us try the same procedure on a more
an application. The examples we give them complicated example, which we cannot
are necessarily small because of the algebra reasonable do by hand.
involved. The first example appeared as a > A := matrix([[a,b,c],[b,a,b],[c,b,a]]);
question on an assignment. The second
example shows the power of a CAS
permitting us to show an example too
complicated to do by hand. The third
example shows a real application taken from A:=[: : :]
organic chemistry. All three examples
involve parameters, so numerical software is > C := evalm( lambda - A );
not applicable.

Here are some worked examples for how

188
-a + A -b of local variables should not be avoided by
-c ] not declaring them to be local. That would be
C:= -b -a +A -b bad programming. Since the concept of local
[ variables is present in every programming
-c -b -a +A language, and will have been met by every
> P := det(C); student who has taken an introductory course
in programming, this level of programming
2 3 language knowledge should be considered
p := -a 3 + 3 a2 A- 3 a A + 2 a b2 + A
acceptable for a mathematics class.
-2Ab2-2cb2+c2a-c2A The following example arises in the study
of Huckel molecular orbitals in organic
> p := factor(p);
chemistry.
p := ( -a + A+ c) > A := matrix([[a,b,O,O],[b,a,b,O],[O,b,a,
2 b],[O,O,b,a]]);
( A - 2 a A- c A+ a2 - 2 b2 + c a )
a b o o
> solve(p=O, lambda);
b a b o
A .-
·-
a - c, a + !2
c +! 2 ' Jc 2 + 8 b2 o b a b
o o b a
a+!c-!Jc2 +8b2 > eigenvalues(A);
2 2

We should remind our students that for large


a-!b+!
2 2
rs
2 J )b, a-!b-!
2 J ) b, rs
matrices, we may not be able to solve the
characteristic polynomial exactly. In this case 1 1 r; 1 1 r;
a numerical approach may be the only a+-b+- J5 b a+-b-- J5 b
possibility. Note that this method for
2 2 ' 2 2
computing the eigenvalues via the There are some interesting points that should
characteristic polynomial is very poor be mentioned. Factoring the characteristic
numerically. Thus numerical methods use a polynomial is redundant as the solve
completely different approach which cannot command does this anyway. It is included to
be explained in passing. The advantage of a emphasize what the solve command does. It
CAS here is that the method an instructor essentially tries to factor the polynomial
would show on the blackboard can be before applying formulae for the roots.
reproduced on the computer. Once the Neither the intructor nor the students will
student has seen the method executed likely know how to factor multivariate
interactively, it is reasonable that the student polynomials. Does it matter? No since it is
desire to code it. clearly what factoring polynomials means.
Here is a program to compute the
eigenvalues followed by an example of a Partial Fraction Decomposition
4 by 4 matrix
Worksheet.
> eigenvalues := procCA)
> locallambda,C,p;
We normally introduce partial fractions when
> C:= evalm( lambda-A ); teaching integration of rational functions.
> p:= del(C); The idea is conceptually simple.
> p:= factor(p); To compute a partial fraction
> solve(p=O,lambda); decomposition of a rational function F(x),
> end: we write F(x) in the form
Unfortunately, one must explain the concept > restart; # clear all variables
of local variables. Everything else in this > F(x) = P(x)+Sum( a[i](x)/d[i](x), i=1 ..n
program is trivial in the sense that there is a );
one to one correspondence between the
worked examples and the program. The issue

189
understand it better, and you will be able to

L
n
use the same technique to integrate a special
a;(X) function g(x) multiplied by any rational
F(x) = P(x) + function once you know how to integrate
d.(x) g(x)/x and g(x)*x.
I
;= 1

where P(x) is a polynomial and d[i](x) are Recall that the sequence of steps is
the factors of d(x), the denominator of 1: Split f(x) into a polynomial p(x) and
F(x), where deg(a[i](x)) < deg(d[i](x)). proper rational function r(x)/d(x) with
The factors d[i](x) must be pairwise deg(r(x)) < deg(d(x».
relatively prime, Le. GCD(d[i](x),dU](x)) = 2: Factor the denominator d(x) into linear
1 for all k>j. or perhaps quadratic factors with real
The problem is the mechanics and algebra coefficients.
needed to DO a partial fraction > d(x) = product( d[i](x)l\e[i], i=1 ..n );

II
decomposition. Even a relatively simple n
problem, such as this one
> (2*xI\4-4*xI\3+3*xI\2+1)/(xI\3-2*xI\2+x d(x) = d;(x/;
) = 2*x+1/x+21(x-1 )1\2; ;= 1

2x4-4x3+3xl+ 1 3: Write down the form r(x)/d(x) for the


-------= partial fractions
> r(x)/d(x) = Sum( Sum(a[i,j](x) / d[i](x)

L L"
1 1 I\j, j=1 ..e[i]), i=1 ..n );
2x+-+2 2 n

~=
x (x - 1)
would be a real challenge for most students a,jx)
to get right. Consequently, many instructors d(x) d.(xY
don't cover partial fractions very well. And I
there is no way that we can ask students to ;= 1 J= 1
tackle a realistic problem like this one where deg(a[i,j](x») < deg(d[i](x».
> f := (2*xI\4-4*xI\3+3*xI\2+1)/(x 1\ 3-x 1\ 2* 4: Construct a system of linear equations
b-2*xI\2+x*b*2); to solve. Solve for the unknowns ali] and
substitute the solutions into (3).
2x4-4x3 +3xl+ 1
f·----- --
.- x3 - xl b - 2 x 2 + 2 x b For example, let us step through this
problem
> f = convert(f,parfrac,x); > f := (2*xI\4-4*xI\3+3*xI\2+1)/(xI\3-xI\2*
2x4-4x3+3xl+l 1 1 b-2*xI\2+x*b*2);
-------=2x+2b+--
3
x -xlb-2xl+2xb 2bx 2x4-4x3 +3xl+ 1
f·----- --
13 1 .- x3 - xl b - 2 x + 2 x b
2

2 (-2+b)(x-2) > n := numer(f); d := denom(f);

3 ~ - 4 b3 + 1 + 2 b4 n := 2 x4 - 4 x3 + 3 xl + 1
+
b(-2+b)(x-b) d := x (xl - x b - 2 x + 2 b)
I believe we can teach students more The rem and quo functions do polynomial
effectively how to do this using a CAS. Of long division. They compute the quotient
course, I am assuming we consider it useful to and remainder.
teach the students the method. Many students > p := rem(n,d,x);
will tell us that if the system can do it, why
should I bother to learn how to do it? To this p := (3 + 2 b2 ) xl - 4 X b2 + 1
I reply: if you learn how to do it, you will
> q := quo(n,d,x);

190
q:= 2x + 2 b
> d := factor(d); SOlS:={A=!~,B=-~
2b 2 -2
1,
+b
d := x (x - 2) (x - b) 4
3 b2 - 4 b3 + 1 + 2 b )
Thus to integrate f(x) we have C=-------
> Int(f,x) = Int(q,x)+lnt(p/d,x)j b (-2 + b)
> subs( sols, ANSWER );
2.0-4x3+3X2+ 1
-------dx= 1 1 13 1
fx3-x2b-2x2+2xb -- -
2bx 2 (-2+b)(x-2)
3b2-4b3 + 1 +2b4
f2X+2bdx +
b ( -2 + b) (x - b)

+
(3 + 2 b
2
) x2 - 4 X b2 + 1
To do this example in Maple we have to learn
several Maple commands and be able to use
f x(x-2)(x-b)
dx them effectively. This is an impediment. But
once the set of commands is put down on
paper, the student and instructor can take this
The answer that we are looking for must example and solve their own problems.
be of the form
> ANSWER := A1x + B/(x-2) + C/(x-b); How does this activity of working through the
steps of an algorithm differ from writing a
ABC
ANSWER := - + - - +-- program? If we want to write a program, we
x x-2 x-b would have to program the construction for
the formula for the ANSWER and then the
Equating the answer with p/d. mUltiplying construction of the equations. This would
through by the denominator we have have to contemplate an arbitrary number of
> e := A*(x-2)*(x-b)+B*x*(x-b)+C*x*(x-2 factors d[i]. This is where the programming
) = pj is tricky. We did this by hand in the
worksheet. We just wrote down the form of
e := A (x - 2)( x - b) + B x (x - b) the ANSWER. We didn't have to think about
+Cx(x-2)= how to write a program to construct it. This is
the principle technical reason why I feel that
(3 + 2 b2) x 2 - 4 Xb2 + 1 the worksheet is a better medium for teaching
an algorithm than a program. It is simpler. It
Grouping the all coefficients of xl\i avoids the tricky parts of programs because it
together, we have provides the flexibility of mixing steps done
> e := collect( Ihs(e)-rhs(e), x )j by hand, and computations done by Maple.
e := (A + C - 3 - 2 b2 + B) x2 From the student's point of view, this
approach is better than seeing a program
+ ( -B b + 4 b2 - 2 A - A b - 2 C) x because the student always sees the steps
being done. The student is free to step
+2Ab-l through them interactively. This reinforces
This must be identically zero. Thus each the algorithm without hiding the algorithm in
a black box which happens when you write a
coefficient must be zero.
program.
> eqns := { coeffs(e,x) }j
eqns := { -B b + 4 b2 - 2 A - A b - 2 C, Series Solutions of Linear
2
A + C - 3 - 2 b + B, 2 A b - 1 } ODE's Worksheet
> sols := solve( eqns, {A,B,C} )j Suppose we are given the following ODE.
> restartj # clear all variables
> ode := diff(y(x),x$2) + x*diff(y(x),x) +

191
xJ\2*y(x) = 0;
+ (12 a4
+ 22 a ) Xl
a +0
ode :=(:>(X))+x(:xY(X») + ( 6 a3 + a l ) x + 2 a 2
+xl y(x) =0 We then discard terms of degree higher
than 3. They are not correct as they
How can we compute a Taylor series depend also on higher order terms.
solution? Let s(x) be the Taylor series > r := rem(r,xJ\4,x);
solution for the ODE.
> sex) = Sum( a[k]*xJ\k, k=O..infinity ); r := (20 as + 3 a3 + aI ) x3

L ak.xk
00

+ ( 12 a4 + 2 a2 + ao) xl
s(x) =
k=O + ( 6 a 3 + a l ) x + 2 a2
One approach that will give us the first
Solving for the unknown coefficients a[2],
few terms of s(x) is to truncate the series
a[3], a[4], and a[5] in terms of a[O] and
s(x) and substitute it into the equation
a[1] (which themselves depend on the
symbolically
initial conditions of the ODE)
> s := sum( a[k]*xJ\k, k=O..5 );
> eqns := {coeffs(r,x)};
s := ao+ a l x + a2 + a x4
a ~34
xl +3 eqns := {6 a + a , 12 a + 2 a + a
3 I 4 2 0'
+a s x5
20 as + 3 a3 + ai' 2 a2 }
> r := subs( y(x)=s, ode ); > sols := solve(eqns,{a[2],a[3],a[4],a[5

r:=(:; %1 )+X(:x %1 )+x' %1;0 ]});

sols := {a = - a ,a = - ! a
s 40 I 3 6 I'
~
%1 := a + a I x + a2 x2 + a3 x3 + a4 x4

12 a =o}
=-~a
o
a4
+ as x5 0' 2

We evaluate the derivatives and group leads to the solution


like powers of x together > S := subs( sols, s );
> r := eval( r ); 1 1 1
s := a + a x - - a x3 - - a xA - - a x5
r:= 2 a2 + 6 a3 x + 12 a4 xl + 20 as x3 + x o 1 6 1 12 0 40 1

(a 1 + 2 a2 x + 3 a3 x2 + 4 a4 x3 The key to finding the coefficients ark] of


the series s(x) is that for a power series to
vanish identically over any interval, each
+ 5 as x4 ) + xl (ao + a1 x + a2 x2
coefficient in the series must be zero. Let
+a3 x3+a4 x4+a S xs)=O us verify that the solution computed
satisfies the ODE to order O(xA4)
> r := collect(lhs(r),x); > r := eval( subs( y(x)=s, ode) );

r := as x7 + a4 x6 + (5 as + a3 ) x5 r := -a x - a xl - - a
1
x3
1 0 2 1
+(4a4 +a2 )x4
1 xl--a
+x ( a --a 1 x3--a
1 xA )
+ ( 20 as + 3 a3 + a1 ) x3 I 2 1 3 0 8 I

192
+a i-- 1 + k)k+a xkk2
xl (ao + a l x - ~6 a 1 x3 - ~
I+k k+2
+ a .0
12 0 +3ak 2xkk+2a xk
+ k+2
-~a
40 1
xS):::::O +6a
k-2
i- k - 4)+2a
-l+k
i-- 3 + k)

+i-I+k)a k+i- k+ 2)a k


> expand( r ); I+k k+2
1 7 1 1 > termk := coeff(s,xJ\k);
-- a .0 - - a x 5 - - x6 a - - x7 a =
3 0 24 1 12 0 40 1 termk := a
k-2
+ ak k + ak+2 k2 + 3 ak+2 k
o +2a
k+2
This gives a method for computing the
first few terms. To find a formula for the Since this coefficient must be zero, we
k'th coefficient, ark], in terms of the obtain a formula for a[k+2] in terms of ark]
previous coefficients, we use the and a[k-2], namely
following method. Since the ODE is of > rec := solve(termk,a[k+2]);
order 2, we must look at the term xl\(k+2) a _ +a k
because under differentiation it will k 2 k
ree:= -
become a term in xl\k. And, since the k2 + 3 k + 2
coefficients of our ODE are polynomials
of degree 2, we must consider the term of The purpose of this example is to show
order xl\(k-2) as well. Hence we need clearly that such examples cannot reasonably
only consider the terms be attempted by hand. Also, like the partial
fraction example, writing a program to do it is
> S := sum( a[i]*xJ\i, i=k-2..k+2 ); tricky. So we don't attempt to do it. Note:
s:= a i- k- 2) + a
k-2 -I+k
i-- I +k) + ak xk this example is taken from the Maple V Flight
Manual. There the example is given but only
+a i-I+k)+a i- k+ 2) the output of the last step, the result, is shown.
1 +k k+2 To understand the steps, it is vital that the
Substituting these terms into the ODE, student can see what each command is doing.
evaluating the derivatives, then It is also important to state what each
simplifying, we obtain command does if it is not clear; just as one
> S := eval( subs(y(x)=s,ode) ): would explain steps in a textbook. If you are
preparing worksheets, always show the output
> s := simplify(lhs(s»; of all steps.
s:= -2 a i- k- 2) - a X(-I +k)
k- 2 -1 +k
The Euclidean Algorithm
+a x(l+k)+2a i- k+ 2)
1 +k k+2 Worksheet
+ a i- k- 2) k2 - a x( k- 2) k + xk a
k k k-2 There are several reasons why I want to show
+i-I+k)a +x(k+2)a this example. Firstly, it is a very nice
-1 +k k example for comparing recursive procedures
versus procedures which have a loop.
+i- k+ 3 )a +i- 4+ k)a Secondly, it is the oldest procedure known in
l+k k+2
Mathematics. It is due to the Greek
+i- k - 2)a k+i--I+k)a k mathematician Euclid and dates back to circa
k-2 -I +k
300 Be. So it is of important historical
+xka k+a
k k-2
)e
i- k- 4 interest. Thirdly, it is important because
Maple uses it whenever it does arithmetic
-Sa
k-2
x(k-4)k+a
-I+k
i-- 3 + k )e with fractions. That makes it relevant to the
student. Do you remember how to add two
-3a i-- 3 + k) k + a i-- I +k) k2 fractions? For example
-I +k 1 +k You add two fractions using the following

193
formula Here is how we can use these three facts
> restart; # clear all variables to compute the GCD of 38 and 24.
> aIb+c/d = (a*d+b*cV(b*d);
GCD(38,24) = GCD(14.24) = GCD(24,14)
a c ad+bc GCD(24.14) = GCD(10,14) = GCD(14.10)
-+-= GCD(14.10) =GCD(4,10) =GCD(10.4)
b d bd GCD(10,4) = GCD(6,4) = GCD(2,4) = GCD(4.2)
GCD(4.2) = GCD(2.2) = GCD(O,2) = GCD(2.0) = 2
If we apply this formula to 3/4 + 5/6 we
get 3/4 + 5/6 =(3x6+4x5)/(4x6) =38/24. When Euclid originally wrote down his
The answer is correct, but it is not method, he did so in words, because he
simplified. We can cancel out a factor of didn't have a better language in which to
2 from the the numerator 38 and the express his method. It took him about a
denominator 24 to get 38/24 = page of Greek to describe his method.
(2x19)/(2x12) =19/12. Maple does this We can do better with a programming
simplification automatically. language like Maple
> 3/4+ 5/6; > GCD := proc(a,b)
19 > if a<b then GCD(b,a)
> elif b=O then a
12 > else GCD(a-b,b)
The problem Euclid was trying to solve is > fi
the following. How can we find the > end:
"greatest" integer that divides both the > GCD(38,24);
numerator and the denominator of a
fraction? Alternatively, how can we find 2
the "greatest common divisor" of two Now there are three things that one must
integers a and b? We denote this think about when writing a recursive
quantity by GCD(a,b). program like this. The first is, will it stop?
Clearly this program will stop only if b
One way to compute the greatest becomes O. Can you argue that b must
common divisor of two integers a and b is eventually become O? What is Euclid's
to factor both integers into prime factors. key idea here? The second is, if the
It is easy to see what the GCD is when procedure does stop, is the output
you have the factorizations. correct? In this example, this is clear
Unfortunately, the problem of factoring because each branch of the if statement
integers is known to be a hard problem, simply implements one of the stated
that is, an efficient method is not known, identities.
and is believed by many experts not to The final thing to consider is whether the
exist. About the best we can today on the program is efficient. Whereas a
fastest computers using the best known mathematician might be happy with the
methods for factoring integers is to factor above program, a computer scientist
100 digit integers. But we need not factor would not. What happens when we run
two integers if we want to compute their the program on GCD(1QA10,1)? It
GCD! Euclid has a better method. His repeatedly subtracts 1 from 1Ql\1 0 until it
method or algorithm is based on the reaches zero. This is a lot of steps!
following three observations What Euclid's algorithm is really doing is
computing the remainder of the integer a
1: GCD(a,b) =GCD(b,a), e.g. GCD(4,6) divided by b by repeated subtraction
=GCD(6,4) =2 instead of long division. Let us modify
2: GCD(O,a) =a, e.g. GCD(O,2) =2 fact (3) so we can use long division
3: GCD(a,b) =GCD(a-b,b), e.g.
GCD(6,4) =GCD(2,4) =2 3: GCD(a,b) = GCD(irem(a,b),b), e.g.
=
GCD(lO,4) GCD(2,4) 2 =
You may want to try to prove fact (3).

194
We arrive at the normal version of that Maple can display are limited. Maple
Euclid's algorithm that is used in Maple does not support a rich enough set of
and many other computer algebra mathematical characters to cover all
systems. The irem function in Maple mathematical disciplines. These limitations,
computes the remainder of two integers though annoying, will eventually be removed
using long division as Maple's mathematical typesetting
> GCD := proc(a,b) capabilities are improved.
> if a<b then GCD(b,a)
2: A serious limitation is the difficulty of
> elif b=O then a manipulating parts of formulae. Suppose we
> else GCD(irem(a,b),b) are given the expression
> fi > e := 1 + alphaJ\21sqrt(Pi)*x - alphalsq
> end: rt(Pi)*x + alphaJ\3/sqrt(Pi)*xJ\2 - alph
This Maple procedure is acceptable. It alsqrt(Pi)*xJ\2;
allows us to compute efficiently the GCD
of integers of hundreds of digits in size. rl X ax a 3 r- ar-
However, it is recursive, and because of
this it keeps all the intermediate integers
e '-1 + - - - - + - - - - -
.- j; j; F j;
computed in the remainder sequence How would you simplify the above
around before it can finally return the expression as a polynomial in x ? In this case
GCD. This requires a lot of memory. In we can use the collect command to group
this case, however, this problem can be together all coefficients powers of x
eliminated by rewriting the program in a > e := collect(e,x);

e:=(~- F)h(F-F}+l
loop. This is in fact how it would be
implemented in most systems.
> GCD := proc(a,b) local c,d,t;
> C := a; d := b;
> while d <> 0 do Collect does not work, though, if we want to
> t := irem(c,d); c := d; d := t; collect in sqrt(Pi). To simplify each
> od; coefficient, however, the collect function
provides the option of allowing us to apply
> c
any function to the coefficients.
> end:
> collecl(e,x,simplify);
> GCD(10J\60,2J\200);
1152921504606846976 a (a 2 - 1) xl a ( a-I) x
As an exercise, show that the new
j; + j; +1
program is correct. Hint: try to argue that
when the condition d <> 0 is tested each The following I find particularly difficult to
time round the loop, that GCD(c,d) = do using Maple. Select the coefficient alpha
GCD(a,b) holds. of p*yrr in the expression
> 1+alpha*P*Vrr - beta*PJ\2*VJ\2fTJ\2;
Discussion a PV ~ p2 V2
We list a number of problems, limitations and
1+ T 12
recommendations that we have found in Alternatively, how do you replace all
presenting algorithms using worksheets. occurrences ofP*yrr by R, say, in this
Some are problems with Maple, not expression to obtain
worksheets, which can be repaired. Others
are problems inherent with using worksheets.
> 1 + alpha*R - beta*RJ\2;
1 + a R - ~ R2
I: Maple worksheets are presently limited in
that we cannot write mathematical formulae lt is these manipulations that often limit the
in the text regions, and secondly, the formulae usefulness of worksheets. Note, even if
Maple provided a way to select and edit parts

195
of expressions with the mouse, this is not Maple doesn't use a canonical order, what is
helpful. A worksheet must consist of only opO,f) in your Maple session might not be so
Maple commands. Fortunately, in a when your students run your worksheet.
worksheet you can type in the answer you Note: you can use the sort command to order
need, if necessary. That is exactly what a the terms of a polynomial.
textbook does. And then you can continue.
This is what we did in the first example for Conclusion
the partial fraction example. We didn't know
how to create the equation to be solved using
a Maple command. We just typed it in. In The proposal in this article is to use
the collect example above, it doesn't matter worksheets to present mathematical
that we don't know how to extract the algorithms. The algorithm would be
presented in English, as in a textbook,
coefficient alpha, we can simply type it in.
together with a worked example where all
steps are shown. This can be done either live
3: Another difficulty is not being able to get
on a computer, or dead, on transparencies or
Maple to produce the answer that YOU want.
For example, Maple will simplify (-8)"'0/3) paper. The proposal not does insist that an
to be a complex number, and refuse to algorithm be presented as a program. There is
simplify sqrt(xI\2*y) to be x*y. a big advantage in simply presenting an
algorithm by showing the sequence of
calculations done for one or two examples. In
> simplify( (-8)1\(1/3) ); cases where the algorithm is simple, as in the
1 +I}3 eigenvalues and Euclidean algorithm
examples, it is usually very good to present a
> simplify( sqrt(xJ\2*y) ); program. In other cases, such as the partial
fraction example, it would be an impediment.
Jx2 y
How can I get Maple to do what I want here, Finally, one word of advice for those writing
namely, to return -2 and x*sqrt(y)? The worksheets. Always show the output of all
commands, if they exist, may not be easy to commands if you intend to put the worksheets
find. This is an inherent problem. Can Maple on paper or transparencies. It is difficult to
provide a command for everything follow the method if you can't see what those
manipulative that you might want to do? The commands are doing, especially if the
argument that the programming language commands are manipulative and not part of
provides the flexibility to effect the actual algorithm.
transfonnations not provided is simply not
valid. Many are simply difficult to program.
Thus I expect difficulties like this to remain
for many years. Incidentally, you can get The author Michael Monagan did his Ph.D. at
around these two common difficulties in the University of Waterloo in computer
Maple V Releae 3 as follows: algebra in 1989. He is presently Oberassistent
> readlib(surd): at ETH Zurich. He is a member of the Maple
group, an author of the Maple books, and
> convert( (-8)1\(113), surd );
author of the column "Tips for Maple Users"
-8 113 in the Maple Technical Newsletter.
> simplify( II ) ;
Dr. Michael Monagan
-2 Institute for Scientific Computing
ETH Zentrum,
> simplify( sqrt(xJ\2*y), symbolic ); CH 8092 Zurich

xh Switzerland
monagan@inf.ethz.ch
4: Avoid the op command in worksheets. The
op command (for extracting the ith operand of
an expression) depends on the order of the
tenns in sums and factors in products. Since

196
IV B. MAPLE IN SCIENCE AND THE APPLICATIONS
COMPUTER ALGEBRA AS A TOOL FOR ANALYZING
NONLINEAR SYSTEMS

Diana Murray
Physics Department, SUNY, Stony Brook, Stony Brook, NY

ABSTRACT phenomena. Of interest in the design of charged


particle accelerators is to understand the
We have studied a variety of weakly perturbed conditions for resonant oscillations of betatron
nonlinear dynamical systems using the method of motion due to the multipole components in the
normal forms, a reduction scheme. introduced by guiding magnetic fields. In this example, the
Poincare in the late nineteenth century. The unperturbed motion is simple harmonic. Studies
method was formalized by Birkhoff who applied in celestial dynamics and of electrical circuits
it extensively to Hamiltonian mechanics. By have also led to weakly perturbed oscillatory
invoking a near-identity coordinate systems. Predator-prey systems in ecology and
transformation. the method of normal forms convection in fluid media such as the atmosphere
converts the nonlinear differential equations into can be modeled as multi-dimensional systems of
simplified equations of motion for the zeroth- nonlinear ordinary differential equations.
order approximation to the true solution [1,2,3].
These coordinate transformations. nonlinear We have applied normal form perturbation
functions of the zeroth-order approximations, are expansion methods to two general classes of
found by solving a sequence of linear equations weakly perturbed nonlinear problems:
which are determined by the spectrum of the I. oscillatory conservative. dissipative and
operator associated with the linear, unperturbed parametric systems where the unperturbed motion
motion. The algebra related to these calculations is simple harmonic:
is intensive and well-suited to the symbolic and
programming capabilities of Maple. Through the
use of procedures written in Maple we have dx dv
-=-Y. - ' =x+sF(x.w.w*;s).
performed high-order normal form computations dt . dt .
and have investigated the exploitation of an dw dw* .
-=-lW --=lW
inherent nonuniqueness of the zeroth-order dt ' dt
approximation [4.5]. We will show how this
nonuniqueness can be utilized to obtain where x,y.w.w* are scalar variables, F is a scalar
transformed equations of motion that can be function and E is a small parameter;
tailored to the needs of the investigator. Coupled II. n-dimensional first order ODE systems:
with computer algebra, the method of normal
forms is a potentially powerful tool for the dx
-=AX+8G(X~8)
examination of nonlinear systems [6]. dt

Nonlinear differential equations in the form of where x and G are n-dimensional vectors and A
linear systems with small nonlinear perturbations is a constant nxn matrix. The method of normal
are useful in modeling a wide range of physical forms invokes a change of the dependent
variables to transform the original equations of
motion into simpler ones that more clearly depict
the interaction between the linear aspect and the
nonlinear perturbations and the resonances which
arise due to this interaction. The transformations
are generated in the neighborhood of a fixed

199
point of the system. These normal form With the method of normal forms one seeks a
calculations are algebraically severe and polynomial near-identity coordinate
extremely difficult and tedious to perform (at transformation
least correctly) by hand. Maple, with its
Z= U+E Tdu,U*)+1> 2 T2 (u,u*)+O(g 3) (3)
symbolic, numerical and graphical capabilities. is
a natural and indispensible tool in such in which the dynamical system takes a simpler
investigations. This paper will illustrate through form. The variable u is the zeroth-order
simple examples the method of normal forms approximation to Zand satisfies the normal form
(NF) and its capacity to reduce dynamical
equation:
systems to compact forms. We will also discuss
du .
-=-IU+g U ](u.u*)+g-~ 0 (I» 3
(4)
the application of procedures written in Maple to dt
U~+
-
perform high-order perturbation calculations and
to analyze the results numerically and As we will demonstrate. there is a (well-known)
graphically. lack of uniqueness associated with the zeroth-
order approximation that can be exploited to
We will explain the essential elements of NF by construct the resulting normal form in a number
analyzing the unforced Duffing equation: of ways. Substituting eqs (3&4) into eq (2), and
collecting terms in each order of the expansion
parameter. € • convert the nonlinear differential
equation into a series of equations that can be
The frequency of oscillation of this conservative solved recursively for the polynomials, Tj , and
system is a function of the small parameter € and
the normal form terms, U i :
is determined from the first integral. the energy:

l.~ 1 2 1 U = -I. 'T'1, +1. U--I * 3 (5.a)


OI; . u---(u+u)
OI; i
E = - x- +- x +- I>
224
X
4
= constant. For € >0 I ] au au* 8
there is one stationary point, x = O. which is a
center. Real motions exist only when the energy
is positive and these are periodic. For € < 0 U~ =-1' T ' OT~ . 01'2
~+lU-- -IU-

there is a center at x = 0 and 2 saddle points at - - au au * (5b)


3i OI; OI;
VM·
~
--(u+u*t(T] +1]*)-U]--U * -
x= ± Real motions exist for all energy 8 au ] 00*
values. Separatrices, trajectories through the
saddle points, separate regions of periodic and Note that each expansion equation is of the form
aperiodic motion. A first "conditioning" step is Ui = Lo1; +known term where
to transform the system to the diagonalized
coordinates associated with its linear part. This
reduces the amount of computation involved
L =- i (I - u ~
00
+ u* ~)
00*
is the homological
because now the determination of the coordinate equation [1] which operates on the Tj , and also
transformation is uncoupled. For complicated
and higher-dimensional systems, the that the U j and Tj for each order p can be
diagonalizing transformation is easily derived
with the aid of Maple's linear algebra package. expressed in terms of monomials: Cj,k uJ U*k ;
Introducing z = x + i y, eq (1) becomes j+k=2p+1.
These observations will help in constructing a
dz . 3i *3
-=-IZ-g-(z+z) (2) straightfoward Maple procedure to solve eqs
dt 8 (5a-b).

where the asterisk denotes complex conjugation. Taking a closer look at the action of the operator
In this case the diagonalization provides a further L, it is seen that the transformation polynomial
simplification as the results for the second associated with order p cannot be used to
transformed variable, z*. are simply the complex
annihilate a monomial ofthe form uP+! u *P in
conjugation of those for z.

200
the order p calculation. These monomials are choice, referred to by Bruno as the
called "resonant" monomials; they have the same "distinguished" transformation [4]. results in the
phase as the zeroth-order approximation u: fewest number of monomial terms in the near-
identity transformation and, as will be shown
Lou=Lo(u p+1 u*p)=O.
below. smooth and uniform convergence of the
Herein lies the origin of the nonuniqueness of the expansion.
normal form [4.5]. Although a resonant
monomial in Tp cannot affect the order p Since the goal of performing a normal form
analysis is to obtain simplified equations of
calculation, it will stategically appear in higher
orders offering the investigator the opportunity to motion. one may choose each f j to annihilate the
endow the normal form with one of several corresponding V i+! resulting in a "minimal"
desirable properties. The idea of a "tailor-able" normal form (MNF) [7]. Choosing
zeroth-order approximation will become clear by
examining the results of the Duffing calculation: 17, f ,= -131
fI = - - , etc., resu Its III
. the
64 - 8192
following normal form for an order n calculation:
3i ,
VI = --u- u*
8 ' du .
-=-IU-8-U
3 i 2 U *+ 0 (8 n+1 ).
3 U *2 - -Iu *3 + F (u u *) U
1 3 --u dt 8
'T'
=-u
Writing u =p exp( - i ~ ) where p is the
1,
I 16 16 32 1

amplitude of the perturbed oscillation and ~ is


where FI (u U *) = fl U U* , f l = constant is the the phase, we obtain
undetermined resonant term associated with the
dp. d~ 3 2
first-order expansion polynomial T1 . By -=0. co=-=1+8-p.
dt· dt 8
definition L 0 Fn (u u *) u = o. In each order the The amplitude of oscillation is constant as
expected for a conservative system. The key
Fn (u u*) u are chosen here to have the same
consequence of the minimal form choice is that
monomial character as Tn· Although f 1 does not the full functional update of the fundamental
frequency of the perturbed oscillation is obtained
affect U I' it appears in U2 (and all Ui ' i > 1):
in a first-order calculation. We will show that
this choice also leads to the "best" (as defined
below) approximation to the true solution from
3f
V , = (51- - - )IU *'
. 3 U- among a number of other traditional choices:
k 256 4 I
1) choosing the undetermined terms to be zero
V, =(_1419 + 51 f -.2f2-.2f,)iu..\u*3 (the "usual" choice).
) 8192 64 I 8 I 4- 2) making the normalizing transformation
canonical thus preserving Hamilton's equations in
3 5 15 13 4
T, =--U +(--+-fl)u U* each order.
- 1024 256 16 3) requiring that the initial conditions be satisfied
69 9 2 3 21 3 ..\ by the zeroth-order approximation.
+(---f)u u* +(----f )uu* For the details concerned with these choices see
512 16 1 1024 32 I
ref. [8].
--U*)
1 - +£ou·u*-
3'
512 - The minimal normal form is the simplest, most
As can be seen, the f j can be chosen specifically compact equation of motion. A notable
consequence of the normal form analysis of the
to alter either the NF or the near-identity Duffing equation is the numerical superiority of
transformation. the MNF choice over the other options
enumerated. For this example. the MNF choice
One possible choice for the undetermined terms, leads to a better approximation of the exact
the "usual" choice, is f j = 0 for all i. This solution. The criteria for this conclusion have

201
been graphically tested with Maple. When a
calculation is performed to a prescribed order, n. TnTn *
it is found that the mismatch of the MNF choice Rn/O -
-
--
2n TT- *
is the least. The exact solution x(t) of the P 0 0

differential equation in eq (I) is replaced by the for n = 3.....8. The magnitude of each successive
various normal form approximations which obey transformation polynomial decreases, indicating
the equation through order n. What is left over. that for E < I and for intitial conditions
the mismatch. is of order n+ I: sufficiently small [9]. the series will indeed
converge.

The determination of the normalizing


transformation, although straightfoward, is
algebraically intensive and involves symbolic
Fig. I depicts the mismatch for several orders of quantities (the undetermined terms). Since the
calculation. Although the MNF approximations expansion equations in each order have well-
are an order of magnitude better than the usual defined structure and involve monomials that are
and canonical approximations. the errors in each easily enumerated. a simple Maple procedure can
case are quite small. In fact, each of the be defined to execute these calculations. A
approximations plotted along with a numerical comprehensive program performs the following
solution shows excellent agreement. but the MNF functions:
approximation has the longest time-validity. I) accepts as input the order of the perturbation
calculation, the way in which the nonuniqueness
Another graphical test addresses the issue of of the zeroth-order approximation will be
convergence of the perturbation expansion. utilized, the initial condition and the value of the
There is no unique convergence criterion. We expansion parameter E .
have studied the ratios between consecutive terms 2) determines the normalizing coordinate
in the near-identity transformation [8]: transformation, the normal form, the
undetermined terms and the initial value of the
zeroth-order approximation by inverting the
normalizing transformation,
3) calculates the exact frequency of oscillation (if
The advantage of this definition is that the ratio possible),
is independent of the amplitude and hence of E . 4) determines a numerical approximate solution
using a fourth-order Taylor series procedure,
R! ' the ratio ofT! and To = u and R 2 are 5) graphically illustrates the efficacy of the
plotted in Fig. 2 for the choices discussed. As approximate solutions.
can be seen. MNFs represents the largest
correction in first order and the smallest When is it important to be able to perform
correction in second order (and the next several efficiently very high order (n ~ 10) calculations
higher orders as well). By introducing a large of this type? We recently contributed to an
correction in first order, MNFs captures most of investigation [9] of the ability of MNFs to obtain
the effect of the perturbation early on. accurate solutions to non-integrable Hamiltonians
of the type encountered in accelerator physics in
Fig. 3a displays the ratios for usual normal forms comparison to the more widely used method of
to very high order (n =15). The asymptotic Lie transformations (10]. As a particle will
convergence of the usual expansion seems to be revolve around a circular accelerator on the order
uniform and bounded. In the MNF case, the
of 10 9 times it is necessary to track its motion
higher order ratios, beginning with R 7 • with an approximate solution that has the proper
intermittently display large values indicating that time validity (i.e. to high order in the expansion
perhaps the high order expansion series is parameter). Table I contains a comparison of
divergent (Fig. 3b). Further investigation shows exact and MNF results for the frequency of
that this is not the case. Fig. -t is a graph of oscillation for motion subject to the following
Hamiltonian:

202
1001 , ....
H = - (x- + p~ ) +- (x 3 + p.l ) + X + P + X p- amplitude equation dp = - ~ I> p3 has a simple
0

2 3 dt 8
where x is the position and p is the momentum of closed-form solution:
the particle. Our collaborator performed the Lie
transform calculations on a Cray supercomputer.
We were able to keep pace. running our Maple
procedures on a Sun workstation. For these types
p( t) =--,==P=o,===
3 0

of problems. MNFs is as effective as Lie 1+--gp-t


4 I)

transforms.
The method of normal forms is similarly applied
In dissipative systems [11]. there is amplitude as
to systems whose perturbations have Taylor series
well as frequency updating. Consider the simple
expansions. The pendulum with cubic damping
system with cubic damping:
2
dx dy , d x dx 3 .
-=Y -" =-x-I>y- -0 +(-) +SIl1X =0
dt 'dt . . dt" dt

Performing an analysis similar to the one is also dramatically simplifed under MNFs.
outlined above for the Duffing equation results in Considering only small amplitudes, we expand
the following normal form: the sine function and introduce the scaling
x ----;, ~ x to obtain

du . 3, 0 3
-=-IU-I>-U-u*+I>-(-(f -f*)
dt 8 8 1 1
27 i 3 0 3 3 0
+-) U u*~ +8 (--(2 f1- +f1 f l *-3fo +fo*).
We find that the usual choice leads to amplitude
256 8 - -
27 i 567 and phase equations that are both updated in each
+-(f +[*)--_)U''U*3+0(1)'') order, whereas MNFs yields the greatly simplified
128 1 1 8192
equations:
With the usual choice, through sixth order in I> •
dp =_l> p3+J..-1>2 p5. d~=I_J..-f>p2 exact
one obtains amplitude and phase equations that dt 64 dt 16
are updated in alternating orders and are to all orders.
calculationally quite unwieldy:
For perturbed harmonic oscillator equations such
as those discussed. the reducing power of MNF's
is ubiquitous. Further examples are listed in
Table 2.

The next example has an exact solution and was


concocted to exhibit behavior expected to be
"troublesome" for the method of normal forms:

The benefit of implementing MNFs here is


twofold - to all orders the fundamental frequency dx 1 1 1,
-=--x--xy+-x'
dt 10 10' 4
of oscillation has no update: d~ = (J) = I and the dy 1 1,101,
dt -dt =- -5 x +-2 x" - -5 y- +-2 x" v_.:
1
x(O) = 1. Y(0) =-.
10

203
Fig. 5a depicts the phase portrait associated with Acknowledgement: D.M. is grateful for the
the exact system. Although the components financial support of the Institute for Pattern
initially increase despite their negative Recognition at SUNY Stony Brook.
eigenvalues. they eventually decay towards the References
stable fixed point (the origin). The initial
condition is outside the basin of attraction of the 1. V. I. Arnold, Geometrical methods in the
stable fixed point. As seen in Fig. 5b. a low- theory of ordinary differential equations,
order normal form result is a poor approximation Springer-Verlag, NY (1988)
to the exact solution. Using computer algebra it 2. J. Guckenheimer and P.J. Holmes, Nonlinear
is simple to perform an "infinite" order oscillations. dynamical systems and bifurcations
calculation and actually determine the solutions of vector fields, Springer-Verlag, NY (1983)
to the original system in closed form: 3. S. Wiggins, Introduction to applied nonlinear
dynamical systems and chaos, Springer-Verlag,
u
x = r,--: v = -.-v were
h u an d v are gIVen
. NY (1990)
vl-v . I-v 4. A.D. Bruno, Local methods in nonlin,tar
by the normal form equations: differential equations. Springer-Verlag: Berlin
(1989)
du 1 dv 1 1 ~ 5. M. Kummer, How to avoid secular terms in
-=--U' -=--v+-u-
dt 10' dt 5 2 . classical and quantum mechanics, Nuovo
Cimento, IB. 123 (1971)
The hope in performing an analytical 6. RH. Rand and D. Armbruster, Perturbation
perturbation expansion calculation is to derive a methods, bifurcation theory and computer
qualitative understanding of the dynamics of the algebra. Springer-Verlag, NY (1987)
original system from the transformed, simplified 7. P.B. Kahn and Y. Zarmi, Minimal normal
equation of motion (the normal form). For forms in harmonic oscillations with small
example, one may seek to construct a phase nonlinear perturbations. Physica D 54, 65-74
portrait for the system or to perform a bifurcation (1991)
analysis [12]. We have shown that by exploiting 8. P.B. Kahn, D. Murray and Y. Zarmi, Freedom
the nonuniqueness associated with the method of in small parameter expansions for nonlinear
normal forms we are able to handle a wide variety perturbations, Roy. Soc. Proc. A 443, 83-94
of weakly perturbed nonlinear systems in a (1993)
number of ways. In particular, implementing 9. E. Forest and D. Murray, Freedom in minimal
minimal normal forms yields strikingly simple, normal forms, Physica D, to be published (1994)
compact equations of motion. Conceptually and 10. A.J. Dragt and J.M. Finn, Lie series and
computationally it is desirable to have the invariant functions for analytic symplectic maps,
amplitude and phase equations fixed early in the 1. Math. Phys. 17,225 (1976)
calculation. This simplicity coupled with the 11. D. Murray, Normal form investigations of
computational power of Maple allows one to dissipative systems, Mechanics Research
investigate a number of complex, but important Communications, to be published (1994)
issues including 12. J.D. Crawford, Bifurcation analysis, Rev.
- convergence properties of the near-identity Mod. Phy. 63. nO.4. 991-1037 (1991)
transformation
- dynamical systems for which one needs to Diana Murray (murray@mathlab.sunysb.edu) is
develop an approximate solution valid for long expected to receive her PhD in physics from
times SUNY Stony Brook in August 1994. Her
- the transient motion in multidimensional research interests include the application of
dissipative systems (see ref. 11 for an example) perturbation expansion methods to nonlinear
- the effect of truncating modes in a dynamical systems and nonlinear time series
multidimensional system. analysis.
This last point and the extension of the analysis
to higher dimensional problems will be described
elsewhere.

204
TABLE 1

Comparison of exact and MNF results for the frequency of oscillation due to the Hamiltonian of eq. 6.

X(O) w (exact) w(MNF) error


0.1 1.02382272107350180 1.02382221705492299 4.9 10-7
0.125 1.03838122227850189 1.03837742078126191 3.7 10-6
0.15 1.05706875210537283 1.05704910 131313645 1.9 10-5
0.175 1.08025281094985680 1.08017486853108192 7.2 10-5
0.2 1.10827235537607029 1.10801860918391330 2.3 10-4
0.225 1.14141494048353416 1.14070667845660645 6.2 10-4
0.25 1.17990185548137750 1.17815520027277578 1.5 10-3
0.275 1.22388247066031169 1.21999328548711406 3.2 10-3
0.3 1.27341938452659925 1.26548913825049846 6.2 10-3

TABLE 2

Some simple perturbed harmonic oscillator systems and their minimal normal forms (exact to all orders):

X+X+l::X 2 =0 u=-iu+l::25i/12u2 u*

X+ X+ l:: x 2 = 0 U= - i u + l:: 2 i/6 u2 u *


..
X+X+l::X 3
=0 U= - i u - l:: 3 i/8 u2 u *

X+X+l::X 3 =0 U= -i U -l:: 3/8 u 2 u *


X+ x + l:: x 2 + l:: 2 x 3 = 0 u=-i u+l:: 2 i/24u 2 u*
X+ x + l:: x 2 + l::2 x 3 = 0 u=-iu-l:: 2 5ij24u 2 u*

X+X+l::X 4 =0 U= - i u + l:: 2 7ij40 u 4 U*3

X+ X+l:: x 5 = 0 u=-iu-dijI6u 3 u*2


..
X+X+l::X·5
=0 u=-i u- d /16u 3 u*2
X+X+l::(x 3 +x 3 )=0 u=-iu-s(l+i)3/8u2 u*-s2 3/32 u 3 u*2

X+X+E 2 x 3 +E 3 x 4 =0 U=-iU-E 2 3i/8u2 u*

X+X+l::X 2 +E 2 x 3 +s3 x 4 +E 4 x 5 =0 U= - i u + s 2 i/24 u 2 u *


X+ sin(x) = 0 for small amplitude u=-iu+Eij16u 2 u*

205
Figun: I a 2nd ordl:r
mismatch of thl: nonnal
fonn apprOXImatIOns for
the Dulling equatIOn
1.1 usual
2'j canoni..:al
3', zero order 11ll! \'11
..:onJitlOns
4) \1NF a

Figure Ib: 3rd order


mismatch

Figure 2a: The


convergence ratio for the
four choices of tree
function:
I) usual
2) canonical
3) zero order initial
conditions !
4) MNF a:

206
Figure 2b:11h~
converg~ncc ratio R2

Figure 3a: RI through


R15 for "usual" normal
forms.

Figure 3b: RI through


RI5 fror MNF.

c
0::

207
Figure 4 Rn/O for MNF

Figure Sa Phase portrait


for two-dimensional exact
model.

-
,-...

>-
- 3

X(t)

Figure 5b: Exact solution


and MNF approximations
up to twentieth order for
y(t).

t

208
MAPLE V AND GEOMETRICAL OPTICS: ABERRATION
COEFFICIENTS IN ARBITRARY OPTICAL SYSTEMS

Eisso Atzema
CAN/RIACA, Amsterdam, The Netherlands

Abstract one or more of the specifications of the system to go


undeclared it is possible to find expressions for the
Traditionally, ray tracing methods are used to ob- aberration coefficients in terms of the undeclared
tain numerical approximations for the aberration variables. This opens up the possibility of hitherto
coefficients of a fully specified optical system. In unavailable means of optimalisations of the optical
this paper, it will be shown how computer algebra system. In this way, for instance, the effect of trans-
can be used to compute the aberration coefficients lation of one single lens in an optical system can be
in a completely symbolic way. fully determined in one go.

1 Introduction A possible drawback for any package based on sym-


bolic software could be the speed of the computa-
In recent years, it has been shown that computer tions. When written in symbolic form, the expres-
algebra can play an innovative role both in science sions one has to deal with soon become enormous
and in industry (see [3]). An example of a technical and very difficult to manipulate, even for a com-
discipline to which computer algebra can be success- puter algebra system. Therefore, it is of the utmost
fully applied is the field known as either technical or importance to find algorithms that allow computer
geometrical optics. In particular, computer algebra algebra systems to work their way through the for-
is of assistence in the design of optical instruments. mulae in the most efficient way possible. As it is, it
From a purely theoretical point of view, it is looks as if for the case of geometrical optics at least
not too difficult to formulate criteria for the per- two algorithms aspiring to this st<:ttus are available.
formance of optical instruments. The basic concept Ultimately, both algorithms go back to the fact that
here is that of aberration, i.e. the deviation from a the transition of a system of rays gives rise to a so-
perfect image. The criteria for the performance of called symplectic transformation, but they make use
a system are then expressed in terms of the coeffi- of different consequences of this property. One of
cients of particular Taylor expansions related to the these algorithms is based on the theory of so-called
eikonals, the other makes use of so-called Lie trans-
systems. These coefficients are known as aberration
formations. In the former case, the coefficients of
coefficients.
the Taylor expansion of the eikonal with respect to
In practice, the computations that are required
all its variables can be taken as the aberration coef-
to determine the aberration coefficients soon be-
ficients. In the latter case, Lie transformations are
come far too involved to be performed by pad and
used to compute efficiently a Taylor series that has
pencil and approximating methods have to be re-
the aberrations coefficients for its coefficients.
sorted to. With the help of computer algebra, how-
ever, the exact values of the coefficients can be de-
termined without much ado. Besides, by allowing The application of computer algebra to the eikonal
approach has recently been considered by Andre
Heck and Marc Biemond at CAN (see [8] & [9]).
The other approach has been discussed in, among
others, [11] and [15]. In this paper, some further
applications of computer algebra to the computa-
tion of the optical map and the use of Lie transfor-
mations will be studied. Whereas Dragt and Wolf
concentrate on the optical transformation for one

209
surface, the emphasis in this paper will be on the
use of Lie transformations for the optical transition
through several surfaces. As far as we know this
topic has not been systematically considered yet.
In the following, first the basic concepts in geo-
metrical optics and the ideas underpinning aberra-
tion theory will be sketched. After this, an outline
will be given of the principal ideas underlying the
Lie approach to geometrical optics. Also, its im-
plementation in computer algebra software will be Figure 1: An optical system
discussed. Finally, some illustrations of the possi-
ble applications of the software to geometrical op-
tics will be provided. All programming is done in surfaces of this system by F 1 through F n . The
Maple. It has not yet been attempted to write soft- medium between F i and F i +1 will be denoted by
ware that is maximally efficient. The principal goal Mi. The medium in front of the first refracting
of this paper is to give a first impression of how com- surface is Mo. Mo will be referred to as the object
puter algebra can be used in the case of geometrical space. Likewise, M n is the medium behind the last
optics. refracting surface and will be referred to as the im-
age space. The index of refraction of a medium Mi
is J.Li. Furthermore, we assume that refracting sur-
2 What is geometrical optics about? faces are intersected perpendicularly by one single
line, the optical axis. The distances between sur-
Classically, geometrical optics is divided into the faces Fi and Fi+1 are denoted by di . For every Fi ,
fields of the optics of reflection and that of the op- there are two reference planes with respect to which
tics of refraction. Underlying all theory in these the incident and the excident rays are defined. We
two fields are the laws of reflection and refraction, will denote the distances of these reference planes
respectively. According to the former, any light ray for a surface Fi as measured along the optical axis
that is reflected at a surface is reflected under an by e~ and <, respectively. An exception will be
angle of excidence which is equal to the angle of made for the distances of the most outlying refer-
incidence. The angle of incidence could be defined ence planes. The distance from the reference plane
here as the angle of the incident ray with the nor- before the system to F 1 will be denoted by eo, that
mal to the surface at the point of incidence. In a of the plane behind the system to F n by en' All
similar way, the angle of excidence can be defined. lengths are measured in the direction from Eo to
Both the case of refraction and that of reflection are En. It will be assumed that the reference planes
covered by between two surfaces coincide. We will denote the
coinciding planes between F i and Fi+l by E i (see
Theorem 1 (Snell's law) Suppose we have a re- fig. (1)).
fracting surface F. Let us denote the medium in Finally, we will coordinatise the space of the op-
front of F by Mo. Likewise, the medium behind tical system with orthogonal coordinates (x, y, z),
the surface is denoted by MI' We assign so-called with the z-axis coinciding with the optical axis. In
indices of refraction J.Lo and J.Ll to M o and M 1 , re- all reference planes, we will use the x,y-coordinates
spectively. Furthermore, let us denote the angle of induced by the x, y, z-coordinates of the ambi-
incidence of an incident ray by ~o. Similarly, ~1 de- ent space. The direction of a light ray departing
notes the corresponding angle of excidence. Then from a plane E i will be indicated by a vector Si =
for the case of refraction, one has
(ai,13i,'i) with ISil = 1.
sin(~o) : sin(~d = J.Lo : J.Ll·
With this notation, any incident ray is characterised
In the case of reflection, the same law applies, where by a pair (io, iTo) with respect to Eo, where io =
one has to choose J.Li such that J.Lo + J.Ll = 0 (xo, yo) are the coordinates of the point of inter-
section of the ray with Eo and the vector iTo is
In this paper, we will deal with the refraction of formed by the first two components of the vector
systems of rays at a series of surfaces. Such a se- So = (ao, 130, 10) indicating the direction of the light
ries is called an optical system. We will denote the ray. In order to emphasise the link between geomet-

210
rical optics and mechanics, we will write iio for xo; Writing iii := Xi and Pi := J1i(Ti, we thus obtain
to indicate the direction of the light ray, we will
_ _ + (J10 - J1d . iio
use Po = J100"0. Thus, any incident light ray will iiI = iio, PI = Po R .
be given by a pair (iio, po). In the same way, any
excident ray is characterised with respect to En by These linear expressions describe the refraction of
a pair (ijn,j5 n ). We will denote the space of incident paraxial rays at a surface. Put geometrically, these
directions Po by Fo. The space of excident direc- equations describe how the coordinates iiI, PI of a
tions will be referred to as Fn . Thus, the transition refracted ray with respect to the tangent plane of
of the incident light rays through the optical system the refracting surface relate to the coordinates iio, Po
gives rise to a map of the incident ray with respect to the same tangent
plane.
Note that it is also possible to describe the re-
lation between the coordinates of the incident and
This map will be called the optical map for the sys- the excident rays with respect to planes other than
tem. Ultimately, all properties of an optical system the tangent plane. Indeed, suppose we have a ref-
can be expressed in terms of the properties of its erence plane Eo parallel to the tangent plane with
optical map. a distance eo to F. Then, it is easily verified that
for one and the same ray
2.1 Paraxial Optics Po =P, iio = ii + (eo/ J10) . p.
For small angles of incidence at an optical system, A similar relation applies to the relation between
the angles of excidence will be small as well. This the coordinates of the refracted ray with respect to
gives rise to the so-called theory of paraxial optics. an arbitrary reference plane E l and its coordinates
The basic idea here is the following. Suppose we (iiI, PI) with respect to the tangent plane at the
have a system of refracting surfaces centred around vertex of the refracting curve.
an axis, such that the axis intersects all these sur- The above relations are linear. Therefore, the
faces perpendicularly. Then, all incident paraxial relations between the coordinates of an incident ray
rays, i.e. all rays very near and almost parallel with respect to a reference plane Eo and those of
to this axis, will still be paraxial after transition the excident ray with respect to a reference plane
through the system. For the refraction of these rays E l will be linear as well. In fact, we have
at a surface F of the system, this means that we can
Theorem 2 Suppose we have an incident system
now approximate Snell's law by a more convenient
of paraxial rays which are refracted at one surface.
expression. Essentially, we consider the linear part
Let the coordinates of an incident ray with respect
of the optical map only.
to a reference plane Eo at distance eo from the re-
fracting surface be (iio, po), with (iiI, PI) those of the
Let us restrict to spherical refracting surfaces. In corresponding excident ray with respect to a plane
this case, we may assume that the axis of the system E l at distance el. Then, up to the first order,
is the z-axis. The tangent plane at the vertex of the
refracting surface F can be taken as the x, y-plane.
Up to the first order, the equation of the refracting
surface will now be of the form
x2 + y2
z=
2R where Ci = e;j J1i and R = R/ (J10 - J1d·
where R is the radius of curvature of F. For an It is now easily verified that for all reference planes
incident paraxial ray with optical direction 0"0 and Eo there is a reference plane E l such that pencils
corresponding excident ray with direction 0"1, both of rays departing from a point on Eo will unite on a
O"i will be very small. Likewise, the lengths of the point of E l after refraction. Such pairs of planes are
vectors Xi will be small. It is now not too difficult called conjugate planes. The kind of transformation
to check that, up to the first order, Snell's law is between the reference planes induced by transition
equal to the condition through the optical system is a dilatation and the
dilatation factor is called the magnification of the
optical system with respect to the reference planes.

211
2.2 Aberrations the extension to more general cases is straightfor-
ward. Suppose we have a refracting sphere F given
Note that the preceding only applies to the case of by the equation
paraxial optics. In general, the rays departing from
one point will not unite into one point again after 1 2 2
Z = P(x,y) = 2R(x +y ) + .... (1)
refraction. Indeed, it can be shown that if this can
be achieved, then the magnification of the system The normal at a point x of this surface will be in-
has to be either 1 or -1 for all conjugate planes (see dicated by s = (-P",,-P , l) = (51,82,-1), where
y
[2]). This situation can, for instance, be achieved by P", and P are short for the derivatives of P with
y
using mirrors only. In the case of general systems respect to x and y, respectively. Furthermore, we
we have to count on deviations from the perfect im- assume that the reference planes Eo and E both
1
age. These deviations are called the aberrations of a lie at the top of F. The coordinates of the inci-
system. Essentially, the principal task of geometri- dent light rays will be indicated by (iio, Po), those
cal optics is to find means to measure the deviation of the excident rays by (iiI, pd. Finally, we will
from the perfect image and to reduce these aber- indicate the point where the incident ray impinges
rations to a minimum while retaining the desired
on F by the coordinates ij = (Q1' Q2 , Q3). It now is
magnification of the system. not difficult to see that the coordinates of ij can be
A good measure for these aberrations is pro- determined up to any order with the help of basic
vided by the coefficients of the higher-order terms perturbation theory. In fact, let us parametrise an
of the optical map of the system. For this reason, incident ray £ by
these coefficients are also called aberration coeffi-

systems we only have aberration coefficients of odd


-
cients. Note that in the case of rotation symmetric Pi: ii ~ (iio,O) + A(PO, JJL~ (Po,Po)), A E JR.

order. In fact, it can be easily shown that because After substitution of this parametrisation into the
of the rotation symmetry, the (2n + 1)th-order part equation (1) for the refracting surface, we now ob-
of the Taylor expansion of M is of the form tain an equation of the form

L ((abc, (iio,po))UaVbc c,
a+b+c=n,
where Zl is a function of iio and Po only and Z2 is
where a, band c are integers 2: 0, (.. ) denotes the
quadratic in iio and Po. Rewriting gives us
standard inner product, (abc is a 4-tuple of numbers
and U=(iio, iio), V =(iio, Po) and W =(Po, Po) are the
rotation invariants.
In the following, we will discuss how these aber- where Z3 is a function of iio and Po only and Z4 is
ration coefficients may be computed for a given sys- quadratic in iio and Po. Consequently, let us denote
tem with given reference planes. the Taylor expansion of A around the origin and up
to order m by Am, while Am denotes the mth-order
part of A. Then,
3 The computation of aberrations

The most direct procedure to determine the aber-


ration coefficients is to determine the optical map where ~ means that equality only applies for the
up to a certain order. A procedure to do so is easily mth-order terms. This means that if we know A up
indicated. In the case of one refraction, the determi- to order m - 1, then we are able to compute A up
nation of the optical map is an elementary applica- to order m as well.
tion of perturbation theory. Once we have obtained In order to compute the coordinates of the ex-
the optical map for this case, the optical map for a cident rays, we have the following two relations:
compound system simply is the composition of the
optical maps for the constituent refracting surfaces. _ (PI, s) _ _ (po, s) _
PI - -_(
_) 8
8,8
= Po - -_ (
_) 8
8,8
(2)
The procedure to determine the optical map for
one refracting surface is the following. For the sake and
of practicality, we will only consider the case of
spherical refracting surfaces. Note, however, that

212
where s is the normal at the point of impingement where adO(g) is the identity map.
of the ray. The first of these equations is a vector
formulation of Snell's law. The second relates the In general, the series on the right-hand side can-
point where the incident light ray impinges on F to not be formally computed, neither can an arbitrary
the point of excidence. Together with the expres- function on an even-dimensional space always be
sions for ij up to a given order, these two relations written as a Lie transformation. However, for our
suffice to determine the optical map up to one order purposes the following suffices. Suppose we have
less. In fact, suppose we have determined (iil,jh) a Lie transformation. We can extend the domain
up to order nand ij up to order n + 1. Then, the of this transformation to a 2n-tuple of functions by
first equation yields ih up to order n + 1, while the applying the Lie transformation to the components
second one gives iii up to order n + 1. Some care is of the tuple. Then, we have
needed for the lowest order cases, but even in the Theorem 3 Let M be a symplectic diffeomorphism
first-order case, everything turns out to work prop- from JR.2n to JR. 2n, such that its Jacobian Jac(M)
erly. Thus, it is not difficult to write a short com- can be written in the form J ac( M) = exp( J S),
puter algebra procedure which computes the optical where J is the antisymmetric 2n x 2n matrix de-
map for one refraction up to arbitrary order. (For fined by
a similar approach, see [5], pp.124-133.)
(-~n 10 )
Once the optical map is obtained for one refraction,
and S is a symmetric 2n x 2n-matrix. Then, for any
there should not be any difficulty in obtaining the
given order m, there is a function M : JR.2n -+ JR.
optical map for more refractions. In fact, we only
such that, up to order m,
need to compose the individual optical maps and
truncate the resulting map after the required or-
der. In practice, however, the relative substitutions
give rise to expressions which contain a large num- Proof see [4],p.2217 o
ber of terms higher than the one required. Only
at the last moment these terms are discarded. The Since the optical map is symplectic (see [7]) and
result is that the internal memory of Maple is used since it can be checked that it has the required prop-
up long before the program has arrived at the final erties, we have
expressions (so-called intermediate swel0.
One way to obviate this problem is to make use Corollary 1 The optical map for an optical system
of the fact that M can be written as a Lie transfor- can be expressed in terms of a Lie transformation.
mation. In order to see what this means, we first In particular, for any optical "!:!!:p M : Eo x Fo f-+
need En X Fn , there is a function M on Eo x Fo such
that
Definition 1 Let g be an infinitely differentiable
function acting on a space JR.2n = {(ii, p)}. Then, -)
e ad(M)(-qo,Po = M(-qo,Po-)( = (-qn,Pn
-)) .
the 'adjoint operator' ad(g) is a function that maps
any infinitely differentiable function f to another For a general optical transformation, M will be hard
one according to to compute. For the optical map of one refract-
ing surface, however, the Lie transformation can be
ad(g)(f) := ~ 8g 8f _ 8g 8f. computed rather easily. Indeed, we already know
L..J
i=l 8p·1. 8q·1.
8q·7. 8p·t how to compute qll, the first component of iih up
to order m. Now, suppose we have computed M up
The adjoint operator can now be used to define a
to order m. Let us denote this part2f M by Mm.
Lie transformation.
We will denote the m-order part by Mm. For other
Definition 2 Let Coo be the space of infinitely dif- series, the same notation will apply. Then, we have
ferentiable functions. Suppose g is a Coo -function
acting on a space JR.2n. Then, the Lie transforma-
tion ead(g) of g working on Coo, the space of in-
Since [M2 , qOl] = 0, it follows that

f: i:
finitely differentiable functions, is defined as

ead(g) := L ":fadi(g),
001
t.
i 2 m l
1!ad (M )([M + , qod) ~
i=O i=O

213
qll - ead(Mm)(qod. Corollary 2 For a sequence of optical transforma-
tions M 1, ... , M n with M := M n 0 ... 0 M 1, we have
This allows us to compute [M m +1 , qod. In fact, the
left-hand side of this equation may be viewed as a
~ w applied to M 2 , which in turn is applied to
[Mm+! , qod. In other words, we have Thus, we have obtained an analogue of the matrix
formulation of paraxial optics. As in the case of
paraxial optical, it is better to split up the refrac-
tion at one surface in three parts. First we con-
The map w(M2) is called the derivative of the Lie sider the transformation induced by the "flow" of
transformation of M 2. Derivatives of Lie transfor- the rays from an arbitrary reference plane Eo to the
mations are invertible and we have reference plane E tangent to the refracting surface.
Secondly, we compute the transformation induced
by the refraction with reference to E and finally we
consider the flow from E to an arbitrary reference
plane E 1 .
where B i denotes the ith Bernoulli number (See [1],
All three of these transformations can be written
p.90, ex.3b with V = Id.). Upon closer inspection,
as a Lie transformation. In fact, we already know
we see that
that the actual refraction can be written as a Lie
aMm+1 transformation. Furthermore, we easily verify that
[M +!, qod = - a - -
m
POl
a Lie series of the form

Thus, making use of the ~mmetry of the optical e l.ad(VJ.L~-(pO'PO)) .. (- -)


qo, Po (-I -I)
I-t qo, Po

map, we can determine M.1 m+!, i.e. the part of


M m +! that does not depend on iio o!!!J'. We de- describes an optical flow over a distance l in a me-
duce the remaining part M.2 m+1 of Mm+!, from dium M o with index of refraction /-Lo. In the same
the property that way, a flow in any medium M i can be described.
Therefore, we have
!!!: ead(Mm_l+M.1m+l+M.2m+l)(p )
P11 -- 01 .
Theorem 5 Suppose M is an optical transforma-
It follows that tion with respect to two arbitrary reference planes
corresponding to refraction at one surface. Then,
-
a M . 2m+! !!!: ad(M - M is described by the composition of Lie transfor-
aq01
-e m _ 1 +M.1 m + 1 )(
POl
)
-- Pll·
mations

This suffices to determine M .2 m +! and hence the


full expression Mm+!.
In general, M will be a more manageable expres- This provides us with a full generalisation of the
sion than M itself. This will prove to be essential ifformulae for the paraxial case to the general optical
we want to find the optical map for a compound sys- map.
tem in a more efficient way than by straightforward Compared to straightforward substitution, this
substitution. The crucial point is the following formulation offers various advantages. First of all,
the expressions for one surface are more compact
Theorem 4 Suppose we have a set of Lie transfor- and easier to deal with. Secondly, in order to com-
mations Ii = ead(j;) (i E {1, .. n }). Then pute one component of the optical map up to or-
der m with the help of the Lie transformation, it
is not necessary to compute the other components
up to order m -- 2, as is the case for substitution.
Proof This directly follows from the properties of Furthermore, since the concatenation of Lie trans-
Lie transformations given in [6], p.13 or [13], p.55. formations uses no term of order higher than the
o ones we are interested in, the Lie approach is more
efficient and uses less space than substitution.
For an optical transformation M induced by n re- Finally, one more edge over straightforward sub-
fractions M i , it follows that stitution should be mentioned. In this paper we

214
have only discussed the geometrical optics in opti- order m. In order to do so, we first have to ex-
cally homogeneous media. Clearly, it is also possible pand the parametrisation of :F up to the desired
to develop a geometrical optics of non-homogeneous order and to compute pin. 3 [mJ up to order m.
media. For this kind of geometrical optics, however, Next, we compute lambda, the parameter in the
the rays are no longer straight lines and the straight- parametrisation of £, for the point of intersection
forward approach sketched in the preceding will no of £ with:F. The procedure to do so has been
longer work. In contrast, the Lie approach can be outlined in the main text. We immediately see
easily generalised to non-homogeneous media. that lambda [[OJ J and lambda [[1] J, the zero-th
and first-order part of A, are equal to zero. We take
these values as our point of departure. The coor-
4 The Computer Algebra dinates q_imp. i [mJ are now easily determined, as
are the coordinates s. i [m-1] of the normal to :F at
In this section, we will say something more about
the implementation of the methods described above q
to compute the optical map for an optical system Our next step is the computation of the coordi-
formed by several spherical surfaces in a modern nates qex. i [mJ and pex. i [mJ of the excident rays
computer algebra system. We have chosen to use up to order m with the help of the two equations (2)

Maple V Release 2 for programming because the and (3). We first use (3) to determine the qex. i [mJ.
package is easy to use, efficient, and sufficiently After this, we use (2) to determine pex. i [mJ. In
powerful to do all the required computations. All order to keep these computations manageable for
calculations were done on a Silicon Graphics Chal- Maple, we have to truncate and collect the expres-
lenge L with two 150 Mhz R4400 MIPS processors, sions we are dealing with as often as possible. Thus,
128 MB internal memory, and 256 MB swap space; we have for the computation of pex. i [mJ the code
computer times are in seconds. However, many of
>for j to 2
these computations are still feasible on less powerful
>do
computers as well. Because of lack of space, we will
> pex.j[iJ:= pin.j -
concentrate on the general design of the program
«pin.1 - pex.1[i-1J)*s.1[i-1J +
and the results obtained so far. We only give very
(pin.2 - pex.2[i-1J)*s.2[i-1J -
few details concerning the actual code.
(pin.3[i-1J-pex.3[i-1J»*
s.j[iJ*s_inv[iJ;
4.1 A Single Refracting Surface > pex.j[iJ:= collect(mtaylor
(pex.j[iJ ,[qin.1,qin.2,pin.l,pin.2J,
The optical map M for a single refracting sphere :F i+l), [qin.1,qin.2,pin.l,pin.2J,
can be relative easily computed up to a rather high normal,distributed);
order. Once M is obtained, there is no problem in >od;
obtaining the corresponding corresponding function
M in the exponent of the Lie transformation. Since the expressions just computed have to be rota-
A minor difficulty resides in the symbols we can tion-symmetric, we can write them in a more com-
use. Because of the limited range of characters in pact form with the help of the rotation invariants U,
Maple, we have to be careful in choosing our nota- V and W (see p.4). For qex. 1 [3] we thus obtain
tions, so as not to loose all relation to the standard
mathematical notations. In the program, we refer > qex.l[3J:= simplify(expand(qex.l[3J),
to the variables in the object space by adding in {U=pin.1-2+pin.2-2, V=pin.l*qin.l+
(of 'incident') and by adding ex (of 'excident') to pin.2*qin.2, W=qin.1-2+qin.2-2},
the variables of the image space. Components of an [qin.l,qin.2,pin.1,pin.2,U,V,W]);
expression will be indicated by . i. Thus, we write
pin. i, pex. i, muin and muex. Furthermore, we will qex.1[3J : = qin.l + (- muin + muex).
write M[nJ for M n . The expression M[[nJ J will cor-
respond to Mn. Other notations will be explained ( R pin.l W + muin qin.l W )
when introduced.
We start by computing the expressions for the / 2
coordinates q_imp. i [mJ of the point of impinge- / R muex muin
ment ij of a rayon the refracting surface up to /

215
This result is in accordance with the expression
found in the literature (cf. [14], p.64, where the 2
eikonal for a spherical surface is computed up to 12 mu.O R.1 mu.1 + Wmu.O mu.1 +
the fourth order. Switching from the eikonal to the
optical map gives the expression above.) 2 2
The Lie transformation M for one single refrac- Wmu.O + Wmu.l + 6 R.1 V mu.O +
tion M can now be found by following the proce-
dure explained in the main text. To shorten the / 3
procedure, we have defined new routines AD(f ,g), 6 R. 1 V mu. 1) / (R.1 mu.O mu.!)
EXP(f ,g,m) and LIE_DERV_INV(f ,g,m). It will be /
clear what the first of these three does. The second As far as we are aware, this result has not been
computes the Lie transformation of a function f given in this explicit form in the literature yet.
applied on 9 up to order m in the variables qin .1, The above procedures to compute the optical
qin.2, pin.l, pin.2. The last one computes the
map M for one surf~e up to order m and its corre-
derivative w(j)-l of a Lie transformation applied
sponding exponent M in the Lie transformation up
on 9 up to order m in the variables qin .1, qin. 2, to order m + 1 turn out to be reasonably efficient.
pin.l, pin.2.
In the following, the statistics are given up to lOth-
The procedure outlined in the main text requires order. Simplification with the help of U, V and W
that we alreadLhave the expression for the second- has been omitted.
order part of M. However, it can be easily verified
with the help of the formulae on p.3 (see also [5], run-time statistics for one refracting surface
p.112), that Time (in seconds) Memory (MB)
m M M M M
3 0.7 1.4 0.8 0.8
5 3.3 6.6 1.1 1.6
After we have obtained Mtilde [[i-l]], we can now 7 23.6 64.0 2.9 4.7
obtain the next-order part as follows. 9 142.1 495.3 13.6 19.5
This table shows that the computation of the func-
> qex.l[l,i-l]:= select(x->
tion M for one refracting surface soon becomes very
> degree(x,[qin.l,qin.2,pin.l,pin.2])<i,
time consuming. To compensate for this, the com-
qex.1[l ,m]);
putation of the optical map for several refractions
> lie_derv[qin.l,i-l] := qex.l[l,i-l] -
with the help of Lie transformations turns out to be
EXP(Mtilde[i-l],qin.l,i);
more efficient than straightforward substitution.
> lie_derv[[qin.l,i-l]]:= select(x->
degree(x,[qin.l,qin.2,pin.l,pin.2])=i-1,
lie_derv[qin.l,i-l]); 4.2 The case of several surfaces
> DMtilde[[pin.l,i-l]]:=
A routine for straightforward composition of sub-
LIE_DERV_INV(Mtilde[[2]],
sequent refractions at a number of surfaces is now
lie_derv[[qin.l,i-1]],i-l);
no longer any problem. We start by switching to
the optical map for arbitrary reference planes. It
The expression M.1 m+ 1 can now be directly com-
is easy to verify that the formulae we need for the
puted by integrating DMtilde [[pin. 1, i -1]] with
transition from a reference plane E x F to a plane
respect to pin. 1. This, however will not give the
E' x F' are of the form
whole of the expression and a symmetry argument
has to be applied to find the terms not depending q~ = qi + l . pi! P3 i = 1, 2.
on pin. 1. The expression M.2 m +1 can then be de-
termined in a similar way. Special care has to be Thus the new coordinates may be computed as
taken to get the signs correct. In the case of i = 4, follows. The first loop is for the reference plane
we thus find in the image space, the second for that in the ob-
ject space. Note that the optical direction does not
Mtilde[4] change under the first shift of reference plane. Af-
2 ter this, we can simply compose the optical maps
- 1/24 (mu.O - mu.l) W (6 R.l U+ we have obtained.

216
The procedure for the Lie transformation looks [12], p.225. The particular lens we used consists of
similar. We start with the Lie transformation for four lenses and hence eight refracting surfaces. An
the flow from the last refracting refracting surface element of symbolic computation is retained in that
to the final reference plane and then go backwards. we have not specified the position of the reference
The last transformation is that of the flow from Eo planes in the object and the image space. For the
to the first refracting surface. other variables, we used the following specifications
>R.1:= 0.53000: R.2:= -4.60000:
It is interesting to compare the cpu-times and mem- >R.3:= -1.39700: R.4:= 2.40000:
ory that both methods need. In the following ta- >R.5:= 0.59500: R.6:= -0.42200:
ble, we have listed the respective cpu-times for the >R.7:= -0.38000: R.8:= -1.61000:
computation of the 1st-order optical map for w re- >
fracting surfaces. Simplification with the help of U, >mu.O:=l: mu.1:=1.517: mu.2:=1:
V and W has been omitted. As before, in the case >mu.3:=1.620: mu.4:=1: mu.5:=1.517:
of the Lie Transformations, only one coefficient (ql) >mu.6:=1: mu.7:=1.620: mu.8:=1:
has been computed. >
run-time statistics for w refracting surfaces >d[l] :=0.19500: d[2]:=0.02565:
Time (in seconds) Memory (MB) >d[3] :=0.05000: d[4] :=0.37050:
w subst. Lie series subs. Lie series >d[5]:=0.17000: d[6] :=0.00940:
3 0.6 0.8 0.1 0.1 >d[7]:=0.05000:
4 1.2 1.3 0.1 0.1 In the following table, we have listed the respective
5 5.0 3.3 1.2 0.8 cpu-times for the computation of the mst-order op-
6 28.0 10.8 3.3 1.3 tical map for the Petzval lens. Simplification with
7 192.4 45.1 11.8 4.3 the help of U, V and W has been omitted. In the
8 - 227.9 - 17.6 case of the Lie Transformations, only one coefficient
has been computed.
Obviously, in the paraxial case considered here, we
only have to do with simple linear transformations run-time statistics for a Petzvallens
and no advanced theory seems to be needed. How- Time (in seconds) Memory (MB)
ever, even for paraxial optics some of the advan- m subs. Lie series subs. Lie series
tages of the Lie method that we hope to find come 1 2.8 1.0 0.9 0.1
to the fore. At first, the Lie transformations are 3 - 5.2 - 1.2
slower than straightforward substitutions, but from 5 - 37.0 - 1.5
the start they are more efficient with respect to 7 - 150.8 - 6.6
memory. For w large enough, the Lie method be- 9 - 1063.1 - 12.4
comes faster as well. For w = 8, the substitution
Already for the first-order aberrations, the substitu-
program crashes because of an object-too-large-
tion method fails. The program is able to compute
error. For higher-order optical maps, the compu-
the transition through the first seven surfaces, for
tations in both cases require enormous amounts of
which it needs about 4000 seconds. For the eight
time for w > 2; we have not checked which of the
surfaces of the Petzvallens, however, Maple crashed
two methods is faster. For two surfaces and the
on an object-too-large-error. Clearly, the Lie
third-order optical map, substitution requires 13
method does much better here. In fact, at least for
seconds, whereas the Lie transformation requires 5
the lower-order aberrations, it still does not crash
seconds.
as more variables are left unspecified. This gives us,
for instance, the possibility to move a lens along the
4.3 A Petzval Lens optical axis. With the help of the expression thus
When most of the parameters of an optical systems obtained, a further optimalisation of the design of
are specified, both the substitution method and the the Petzval lens can be achieved.
Lie method become much faster and we are able to
deal with larger systems as well. In order to show 5 Conclusions
what our software is able to achieve in this case, we
have computed the optical map for a so-called Petz- From the above examples it is clear that computer
val lens, where we have taken the specifications from algebra can be used to compute the aberration co-

217
efficients for an optical system. It is too early to say [8] A. Heck & M. Biemond, "Computer Algebra
anything about which of the two methods we intro- and Geometrical Optics I: The Eikonal of a
duced is most efficient. In both cases, the program Single Refracting Surface." In: H. Appiola, M.
can probably be considerably improved. In both Laine and E. Valkeila (Eds.), Proceedings of
cases, we used a step order one for our approxima- the Workshop on Symbolic and Numeric Com-
tions. Since all even order aberrations vanish in puting, Helsinki 1993. Research Reports - Rolf
the case of rotation-symmetrical systems, it seems Nevanlinna Institute B10 (1994): 127-138.
plausible that a step order of two is feasible as well.
Furthermore, no optimal use of the symmetries has [9] A. Heck & M. Biemond "Computer Algebra
been used yet. Finally, it still has to be investi- and Geometrical Optics II: The Eikonal of a
gated whether the combination of the mtaylor and Symmetric Optical System." (to appear)
collect functions are really the most efficient way [10] M.B. Monagan "The Collect Function in Ma-
to deal with Taylor series. ple," Maple Newsletter 4 (1989), pp.17-19
Regardless of the current state of our software,
the computation of fully symbolic expressions turns [11] J. Sanchez Mondragon & KB. Wolf (eds.), Lie
out t9 pose particular problems. In the case of only Methods in Optics. Proceedings of the CIFMO
a small number of unspecified variables, however, - CIO workshop held at Leon (January 7-10,
computer algebra can be fruitfully used in combina- 1985) (Springer, 1986) (= Lecture Notes in
tion with Lie transformations in order to compute Physics 250.)
such expressions as are relevant for the design of
[12] W.J. Smith Modern Lens Design. A Resource
optical instruments.
Manual (McGraw-Hill, 1992)

References [13] S. Steinberg "Lie series, Lie transformations


and their applications." In: [11], pp.45-103
[1] N. Bourbaki Elements de Mathematiques. [14] J.L. Synge, Geometrical Optics. An Introduc-
Groupes et Algebres de Lie. Chap. 2 et 3 (Her- tion to Hamilton's Method (Cambridge Uni-
mann, 1972) versity Press, 1937) (= Cambridge Tracts in
[2] C. Caratheodory, "Ueber den Zusammen- Mathematics and Mathematical Physics, vol.
hang der Theorie der absoluten optischen In- 37)
strumente mit einem Satze der Variations- [15] KB. Wolf (ed.), Lie Methods in Optics II -
rechnung," S.B. Bayerische Academie der Proceedings of the Second Workshop held at
Wissenschaften. Math. -naturwissenschaftliche Cocoyoc (July 19-22, 1988) (Springer, 1989) (=
Abt. 1926, pp. 1-18 Lecture Notes in Physics 352).
[3] A.M. Cohen, Computer Algebra in Industry.
Problem Solving in Practice (Wiley & Sons,
1993)
Eisso Atzema (atzema@can.nl) received a M.S. de-
[4] A.J. Dragt, J.M. Finn, "Lie series and invari- gree in mathematics from the University of Nijme-
ant functions for analytic symplectic maps," gen (The Netherlands) in 1988 and a Ph.D. degree
Journal of Mathematical Physics 17 (1976), pp. in the history of mathematics from the University
2214-2227 of Utrecht (The Netherlands) in 1993. He is cur-
[5] A.J. Dragt, E. Forest, KB. Wolf, "Foundations rently project coordinator for a project devoted to
of a Lie algebraic theory of geometrical optics. the application of computer algebra to geometrical
In [11], pp.105-157 optics at the Research Institute for the applications
of Computer Algebra (RIACA) in Amsterdam.
[6] W. Grobner, Lie-Reihen und ihre Anwendun-
gen (D.V.W., 1960)

[7] V. Guillemin & S. Sternberg Symplectic Tech-


niques in Physics (C.U.P., 1984)

218
SOLUTION OF BANDED LINEAR SYSTEMS OF EQUATIONS
IN MAPLE USING LU FACTORIZATION

Robert M. Corless 1 and Khaled EI-Sawy2


Department of Applied Mathematics 1, Department of Civil Engineering 2 ,
University of Western Ontario, London, Ontario, Canada

Abstract sary. It is the case that no zero pivots are encountered,


for example, if the matrix [A] is column diagonally
We describe two Maple implementations of an LU- dominant [4]. This often occurs in the finite-difference
factorization method for the solution of column diag- applications we have in mind. Note, however, that
onally dominant banded matrices. We compare the even though no zero pivots are encountered, numeri-
efficiency of these programs with Maple's built-in rou- cal stability may still be a problem. Row-exchanges
tine linsolve. We also give an example of the new tend to increase the bandwidth of the matrix, and
indexing functions for Maple V Release 3. The code for efficiency we are willing to lose a bit of numeri-
described in this paper is available by anonymous ftp cal stability by not doing the row-exchanges. Once the
to pineapple.apmaths.uwo.ca (129.100.23.160) in the matrix [A) is factorized, the solution to [A]{z} = {c}
directory pub/maple/band. can be found using forward elimination for the system
[L]{lI} = {c} and then back substitution for the sys-
Introduction tem [u]{z} = {y} (just write [A]{z} = [L][U]{z} =
[L]([U]{z}) = [L]{lI} = {c} where [u]{z} = {y}).
Many engineering problems require a system of linear This is efficient because the most expensive part of the
equations [A]{z} = {c} to be solved. In many applica- process is the factorization, and this need only be done
tions (e.g. finite difference and finite element methods) once.
the system of linear equations takes a banded shape Using the previous factorization and taking advan-
(most simply, a tridiagonal shape). One can solve this tage of the structure of the banded matrix [A], we
system ignoring the structure of the matrix [A] using can refine this factorization so that no zero operations
ordinary Gaussian elimination. This method reduces are performed [3]. This will save a lot of time, espe-
the matrix [A] to a triangular form using row opera- cially with matrices oflarge dimensions and small band
tions and after that solves for the unknowns by back- width. We have written a package to factorize banded
substitution. No use of the structural properties of the matrices [A].
matrix [A] is made. Programmed naively, this method We compared the efficiency of our package with Ma-
has the drawback of being applicable only once for each ple's linalg package. We expected that the method
vector/matrix {c}. To solve for another vector/matrix which took advantage of the banded structure of the
{c}, the same process must be repeated, which is a system would be faster by a factor n 2/p2 where p is
waste of computer time (i.e. money). the bandwidth of the matrix, and this turned out to
The standard refinement of Gaussian elimination be roughly true for matrices with floating point en-
for efficiency in the solution of multiple linear sys- tries. However, we were surprised that if the matri-
tems is to factorize (decompose) the matrix [A] into ces had integer entries, Maple's built-in routines were
the product [A] = [L][U], where [L] is a lower triangu- faster than our special-purpose routines. We expect
lar matrix and [U] is an upper triangular matrix (i.e. that one of the reasons for this is that Maple uses a
[A]{z} = [L][U){z} = {c}). In the case that row ex- special algorithm to minimize the size of the calcula-
changes are necessary for numerical stability, we can tions' intermediate integers.
write this factorization as [P][A] = [L][U] where [P] is
a permutation matrix. In the applications of this pa- Short Tutorial on LU Factorization
per, we will presume that no row exchanges are neces-
The LU factorization can be illustrated in the following
example. Suppose [A) is a 4 x 4 matrix and is defined

219
by > od;

~:]
Now we can ask Maple to solve for the unknowns in
[L] and [U].
[A] = [: : : > solve ({eqns}, {unknowns});

1
-1 0 -1 3 = 6 - U12
U1,l' ,
= ...
Now we are looking for a factorized form [A] = [L)[U],
where three lines omitted
Lu o 0
Ua,a = Ua,a, U~,~ = U~,~ }
L 21 L 22 0
[L] = Lal L a2 Lu
[ The solution is not unique! This is because the number
Lu L~2 Lu of unknowns is larger than the number of equations.
Let us use Doolittle's assumption Li,i = 1 to choose a
and unique solution.
Uu U12 Un > for i to 4 do
U22 U2a > for j to 4 do
[U]= : o Uu > if i"j then L[i,j] :=1 fi
[ > od
o 0 > od;
This can be done in Maple as follows. We r~prepare the equations and unknowns by exe-
cuting the same commands as before. We then re-solve
> 1 := array (1. .4, 1. .4, for the unknowns in [L] and [U].
> [ [ 6, 2, 1, -1],
> [ 2, 4, 1, 0] , > solve ({eqns}, {unkno1ms});
> [ 1, 1, 4, -1],
> [-1, 0, -1, 3] ] ) ;
2
-3' U.~, ~ = ...
6 2 1 -1
one line omitted
1 0
-9}
2 4
A .-
·-
1 1 4 -1 L~ ,a = 37
-1 o -1 3

The following is one way to define the matrices [L] and > assign (n);
[U). > print (L);
> L := array (1. .4, 1. .4): 1 0 0 0
> U := array (1. .4, 1..4): 1
> for i to 4 do 1 0 0
3
> for j to 4 do 1 1
> i f (j-i»O then L[i,j] :"0 fi; 1 0
6 5
> if (i-j»O then U[i,j] :"0 fi; -1 1 -9
> od 1
6 10 37
> od;
Now we prepare the equations and unknowns.
> print (U);
> eqns :.. lULL:
> unknollns := lULL: 6 2 1 -1
> LU := evalm(L a. U): 10
0 -, 1
2
> for i to 4 do 3 3 3
> for j to 4 do 37 -9
0 0
> eqns : .. eqns, LU[i,j] .. l[i,j]; 10 10
> if not type(L[i,j], nuaeric) then 191
0 0 0
> unkno1ms:=unknovns, L[i,iJ 74
> fi;
> if not type(U[i,j], nuaeric) then
It is easy to check that [A] = [L][U]. Executing the
command evalm(l - U*U) yields the zero matrix.
> unkno1ms:=unknovns, U[i,j] Thus the 16 entries of [A] can be used to determine
> fi; 16 of the 20 unknowns in [L] and [U]. If a unique solu-
> od tion is desired, four additional arbitrary conditions on

220
the entries of[L] and [U] are needed. Different choices full matrix, a savings of 93%. The 12 unnecessary zeros
of the additional arbitrary conditions are due to Crout, visible in [A] are thus of no consequence for large n.
Doolittle and Choleski. Crout's method uses Uii = 1, The second way to store banded matrices efficiently
while Doolittle's method uses Lii = I, and Choleski's is to define this array using a user-defined index func-
method (for symmetric matrices) uses Lii = Uii. The tion. This will be discussed in the following section.
method used in this study is Doolittle's factorization.
Of course, we do not wish to solve a system of non-
linear equations every time we want to factorize a ma- Banded Arrays and User-Defined Index Func-
trix, and of course this solution has already been done
tions in Maple
for us. The solution process is in fact just Gaussian
The elements of arrays are stored somewhere in mem-
elimination. For a detailed description of the actual ory. Typically in Fortran there is a definite amount of
algorithm, see for example [3].
space (say eight bytes) alloted for each matrix entry,
and a contiguous block of memory is set aside at com-
Banded Matrix Definition and Storage pile time containing n 2 of these eight-byte blocks for
a given n x n matrix A. Elements of the matrix are
If a matrix [A] has nonzero entries in the qlh super- stored and recovered by first computing the address of
diagonal, then the upper band width of [A] is at least q. the eight-byte block corresponding to Ai; by an index-
Similarly the lower band width p can be defined. The ing function such as base address +8(n(i-l)+i). This
total band width bw can be defined as bw= p + q + 1. expression allows you to find the value of the matrix
There are at least two ways to deal with the stor- entry Ai; in storage, or to place a new value there.
age of banded matrices in Maple. The first is to store In Maple, matrix entries need not take a fixed amount
them in a modified indices format to minimize the of space. Thus it would be very difficult for the pro-
memory requirements, so that most zero terms are not grammer to explicitly calculate where each entry Ai;
stored. This method is commonly used in FORTRAN is. Maple provides some indexing functions built in to
programs. For example, consider the matrix [A] of di- Maple, based on its mechanism for tables. This effec-
mensions n x n = 8 x 8, upper band width p = 3, lower tively separates the programmer and the user from the
band width q = 3 and total band width bw= 7 defined details of just where the matrix entry is to go. This
below. "information hiding" allows for great ease of use and
power.
An A 12 Au Au 0 0 0 0
Maple provides built-in indexing functions for sym-
A 21 A 22 An A 24 A 26 0 0 0 metric matrices and for sparse matrices, and some oth-
ers. You can simply tell Maple that a matrix is sym-
A 31 A 32 A 33 A 34 A 36 A 36 0 0 metric, and it will only store half the matrix (roughly),
Au A 42 Au Au A 46 A 46 Au 0 giving a great savings. If you tell Maple that your ma-
trix is sparse, Maple will store only those entries you
0 A 62 A 63 A 64 A 66 A 66 A 67 Au explicitly create, returning zero for all uninitialized en-
tries (without actually creating storage for all those ze-
0 0 A 63 A 64 A 66 A 66 A 67 A 68
ros). There is no built-in indexing function for banded
0 0 0 An A 76 A 76 A 77 A 78 matrices. We can, however, write our own.
The syntax for doing this in Maple V Release 2 and
0 0 0 0 A 86 A 86 A 87 A 88 earlier was to create a function 'index/<blah>' which
required three formal parameters:
The modified indices format of this matrix is defined
by [A] where A = array to which index function
is to be applied
0 0 0 An Au Au Au index = [i, i] is the reference to the desired entry
0 0 A 21 An A 23 A 24 A 26 is-LHS = boolean variable
= true if A[ij] is being assigned to
0 Au A 32 A 33 A 34 A 36 A S6 = false otherwise
Au A 42 Au Au A 46 A 46 Au
[A] =
A 62 A 63 Au A 66 A 66 A 67 Au It is not completely straightforward to pass extra
arguments such as the band width to the indexing func-
A 63 A 64 A 66 A 66 A 67 A 6S 0 tion. A global bandwidth variable is not suitable be-
A74 A76 A 76 A77 A 78 0 0 cause we may want to use different band widths for
different matrices in the same session.
A 86 A S6 A 87 Ass 0 0 0 We used a simple trick to deal with this situation
in the Maple V Release 2 implementation. The band
For this example it looks as though not much space width of the array was parsed from the index function
has been saved. However, that is due to the small name <blah> which must have the format "band???"
size of the example. If we used this scheme on a 100 where the "???" represents a number for the band
by 100 matrix, of bandwidth 7, then [A] would have width. The statement used to parse the name for the
7 x 100 entries compared with 100 x 100 entries in the

221
bandwidth is and assigns the result to 'index/band<
> bv := traperror (sscanf (lIIy_index_fcn, programs are available by anonymou!
> 'index/bandti ')[1]) ; ple.apmaths.uwo.ca in the subdirectory
The indexing function used this statement on its BandIndexFcn := proc(D:posint,q
own name to find out what the bandwidth is. This in- assign( 'indexlband~.p.'-'.q,
formation was thus associated directly with each ma- sUDs('index/band/lover'7,p,
'index/band/upper'=q,
trix. ~rOC(indicesftabl) local
1 := indices 1];
We found it helpful to have a procedure BandlndexFcn, j := indices 2];
which automatically created an index function for a t The nUlllber of actual argumen'
given bandwidth. The argument for this procedure t distinguishes assignDlent frol
if nargs=2 then
was the index function name written in the format if tTPe(indices,list(i
"band???" where ??? is the total band width bv of the (1-j > 'index/bandl
j -1 > 'index/band/,
matrix. An example showing the use of this procedure o
to create an index function for tridiagonal matrices is e18e
eval(tabl[op(indices
given below. fi
elif tfpe(indices,list(~
> BandIndexFcn (band3); (1- j > 'index/bandl
j-1 > 'index/band/I
OK .•. Band Index Function, band3, is created ERROR( 'band vidth',' ~
'index/bi
> 1 := array(band3, 1 •. 6, 1 .• 6); 'exceede.
else
1 := array(band3, 1 .• 6, 1 ., 6, []) tabl[op(indices)] := I
fi
end»;
> print (1); 'indexing function band' .p. '-'.c
end:
A1,1 A1,2 0 0 0 0
The basic mechanism of the new ind.
A2 ,1 A 2 ,2 A 2 ,3 0 0 0 is that if they are called with three a:
0 A3,2 A3,3 A 3,. 0 0 assignment is occurring; while if they
only two arguments, then the value of tl
0 0 A.,3 A.,. A.,s 0 wanted. Recursive use of the various pc
0 0 0 As,. As,s As,s functions is automatic-the table that
this indexing function has had one inc
0 0 0 0 As,s As,s name (band<p>-<q» stripped from its :
ther references are made with respect t
The advantage of doing this over the FORTRAN-style indexing functions, if any. IT there are 1
modification discussed earlier is that Maple's other lin- in table indexing is used. This provide
ear algebra routines work directly with this form: we way to define matrices with more than
can add, subtract, multiply, and divide banded matri- Remark. A matrix A with a band inc
ces formed in this way (though the result is not known defined by the procedure above will retu
to Maple to be a banded matrix and hence will be full evaluate Aij where i or j is outside the
of unnecessary zeros on occasion). Utilities such as matrix. We could correct this by testin
rovdim and print also work. the indices i and j are inside the bounds.
we prefer not to do this, since any prog
Indexing Functions in Maple V Release 3 to the matrix outside the bounds is if
(though it is possible that by returnin
The indexing functions have completely changed in allow the program to compute correct I
Maple V Release 3, so the first indexing procedure we This is in keeping with the seemin@
wrote no longer works. However, the first method, that the new indexing functions, which alle
of mimicking the FORTRAN storage of a banded ma- get him- or her-self into trouble by mil
trix, had the happy advantage of being directly portable ible indexing functions. For example, '
to Maple V Release 3. matrix both sYJllllletric and antis)'llllll'
We have re-written the indexing function approach, functions, and then the results of print
with the kind assistance of Jerome Lang and David the ordering of the indexing functions.
Clark. The indexing functions in Maple V Release 3 gard this as a bug, but rather as a II
are far superior-we can now have matrices with more which requires concomitant care on tJ
than one indexing function, so we can very simply and user.
easily define a symmetric banded matrix, for example.
Because the new indexing functions are so different It is useful in programs to determinf
from before, we feel it is worthwhile to include the code trix object what its bandwidth is. We 1
here. trick from the previous implementation
Here is the code to create an indexing function for this, by scanning the index function naJ
matrices with (p, q) bandwidth (that is, p nonzero sub-
diagonals and q nonzero superdiagonals). It uses sub-
stitution of the global variables 'index/band/lover'
and 'index/band/upper' into a template procedure,

222
bandvidth := proc(A:array) local idxfnc,nj We can solve this system by solving L1I = band Uz = 11
idxfnc := [linalg[indexfunc](A)]; in turn. This method is encoded in bandsolve.
idxfnc := select{
(p -) substring(p,1 .. 4)=".band),idxfnc); > x := bandsolve(F,b)j
if 1dxfnc=[] then
n := linalg[coldim](A)-l; -97936493 827068483 -35165237
[n,n] z '- [ 96643926 '483219630' 48321963'
else
sscanf(idxfnc[l],'bandXd-Xd') 18382928 17187770]
fi
end: 16107321' 144965889
Finally, explicit creation of the indexing function
is a chore best done automatically. If a user wants a We verify that the solution is correct by examining the
banded matrix, she or he simply asks for one, and the residual. This is always recommended. See the section
following procedure will create the necessary indexing on accuracy, below.
function if it has not already been done. > evalm(At*x - b);
bandmatrix := proc(p:integer,q:integer) [0,0,0,0,0]
local bandidx;
bandidx := 'band'.p.'-'.q;
if not assigned('index/'.l>andidx) then Maple has some advantages over purely numerical sys-
BandlndexFcn(p,q)
fij tems. For instance, one can compute the residual at a
array(bandidx,args[3 •• nargs]) higher precision than that used for calculation, if that
end:
is necessary (here we used exact arithmetic and so the
Here are some examples. We first create a random residual is exactly zero).
5 by 5 banded matrix, with one subdiagonal and one Another advantage is that we can experiment with
superdiagonal (so the matrix is tridiagonal). The rou- the use of 00. In the routine bandecolllp, we chose to
tine randband is a simplistic random banded matrix replace zero pivots with 1/00. Since we were not going
generator procedure contained in our package but not to exchange rows, a zero pivot normally means termi-
detailed here. nation, but we thought we might see what happened
> A := randband(1,1,1 •• S,1 •• 5)j if we let Maple handle this (hopefully rare) case sym-
-85 -55 0 0 0 bolically.
> B := bandmatrix(1,1,1 •• 2,1 •• 2,[[O,1],[2,O]]);
-37 -35 97 0 0
A·- 0 50 79 56 0
B= [ : : ]
0 0 49 63 57
0 0 0 -59 45 This matrix obviously has a zero pivot.
> c := linalg[randvector](2)j
We have also written two simple routines for LU factor- c:=[77,66]
ization and solution of banded linear systems, based on
Algorithms 5.3.1-5.3.3 in [3]. The routine bandecolllp
computes the factorization, and returns the results in

-:J
> BF := bandecomp(B)j
a matrix of the same banded shape as A.

BF,~
> F := bandecomp(A);
-85 -55 0 0 0 [,:
37 -188
97 0 0
85 17
We see that the factorization contains 00.
-425 48651 > xb := bandsolve(BF,c);
0 56 0
94 94
xb:= [(77 + ~ 66 - ~54OO) 00, _~ 66 - ~5400]
4606 2807077
0 0 57
48651 48651
-2870409 289931778
0 0 0 > map(expand, II);
2807077 2807077

Both the [L] and the [U] factors are stored in the one
[33, -33 ~ + 77]
matrix, as is usual in FORTRAN and convenient here
(except if you forget whether or not you have factored Now that solution can be interpreted as [33,77], which,
[A] already and pass the wrong matrix to the solver, as it turns out, is the exact solution to the original
below). Note that since the diagonal of [L] contains problem. Unfortunately, the fact that that worked is
only l's we don't need to store them at all. because of a bug in the infinity handling in Maple-it
Now choose a random right-hand side. is supposed to complain if asked to cancel 00/00.
> b := linalg[randvector](5); > evalm(B t* II - c);
b := [-8, -93, 92, 43, -62] [ll -3 :700 -77, 0]

223
Comparison Between LV Solver and Maple's
> map(expand. "); 'linalg/linsolve'
[-33 ~, 0] Accuracy
The instability of LU factorization without pivots (which
It may be that for some examples incorrect answers is exactly the same as Gaussian elimination without
will be generated-in particular if the matrix is sin- pivots or row exchanges) for general matrices is well-
gular we expect this to be the case. However, if we known [3]. What do we mean by "instability"? We
are careful to always check the solutions this should be mean that the problem solved by the algorithm will
fine. Maple should generate an error message if it is in general be far away from the problem you wanted
asked to subtract 00 - 00, or divide 00/00, so if there it to solve.
are infinities in the calculation there should always be We use here the principle that a good numerical
infinities in the answer, 80 we will be warned to be algorithm will give you the exact solution of a nearby
careful. Unfortunately as noted above this may not problem. In engineering and other physical contexts
always hold. this idea makes a great deal of sense, and is both sim-
It may also be that processing the symbol infinity pler and more useful than a 'forward error analysis'
will add a significant overhead to the efficiency of this or comparing the computed solution with the 'exact'
program. IT that turns out to be the case, we will re- solution, which, after all, will usually be the exact solu-
move the statement and replace it with an error mes- tion of a simplified problem which is only some rough
sage. approximation to the true reality anyway. It cannot
We are presuming that small pivots are not a prob- be stressed enough that we need to study the effects of
lem, because of the arbitrary precision floating point perturbations in the data (which incidentally allow us
arithmetic. IT rounding errors are causing a difficulty, to understand the effects ofrounding errors in the solu-
then the precision will be increased. This, too, can be tion, which are usually trivial compared to the effects
very computationally expensive, but if it is too expen- of data error). This leads to the study of 'condition
sive, then likely this is the wrong approach anyway and number'. This will not be gone into here, but see [1]
some form of partial pivoting must be tried. for an introductory essay on the topic. See the LA-
Note that we had to teach Maple how to efficiently PACK manual for an introduction to deeper views.
solve banded systems. Just telling it how to define Here we face a different problem: a numerical method
a banded matrix was not enough, because otherwise is unstable if it solves a problem that is not close to
it would have used inappropriate algorithms to solve the intended one. The simplest way we can look at
them. This holds true, of course, for the FORTRAN- this here is to compute residuals:
style banded matrix as well.
{r} = [A]:i: - {b}
Solving Linear Systems of Equations in Maple where :i: is our computed solution. Note that {r} is a
computable vector, and its size reflects the stability of
The linear solver in Maple is designed to accept dif-
our algorithm because :i: is the exact solution to
ferent types of input and accordingly choose the solv-
ing strategy. For floating point calculations, a Gauss- [A]{y}={b+r}
Jordan method with partial pivoting on the maximum
pivot is used to minimize the round off errors, while for and if {r} is small compared to {b} with respect to the
integer calculations the same method is used with par- physical details we have omitted in our model, then we
tial pivoting on the minimum pivot to reduce the size of are finished: we have the exact solution to a problem
the intermediate integers produced while solving (i.e. that is just as good a model of the underlying problem
reduce the memory and time requirements). In this as was originally written down.
study pivoting is not used because row exchanges will It is known that Gaussian elimination without row
destroy the structure of the banded matrices, although exchanges is unstable for general matrices. Thus we
simple extensions of the program can be made [3]. can expect here that the residuals Az - b will not usu-
The solution method used here can be applied both ally be small compared to z, A, or b for the random
to banded matrices and to full matrices. For banded problems examined above. In fact, they were usually
matrices, the matrix can be stored in the normal for- acceptable for the problems we have solved, but we re-
mat (using either the standard indexing functions or mark that whenever this method is used in practice,
the banded indexing functions of the previous section) the residual must be examined. The accuracy in the
or in the FORTRAN-style modified indices format. solution, of course, is related to the residual by the con-
The matrix is LU factorized first and the simple for- dition number of A which should also be computed.
ward elimination and back- substitution are performed. It would be relatively trivial to modify the Maple
A package of procedures LUpacll: (for the FORTRAN- V Release 3 band indexing function to allow partial
style storage system) has been developed for that pur- pivoting, at the cost of increasing the upper band width
pose. of the factored form of the matrix. The maximum
increase in band width is known in advance, and thus
the factored matrix can be created to be that size,
and 'sparse'. This would cause fill-in no more than
necessary. It is anticipated that this modification will

224
be explored shortly. This modification would greatly
increase the stability of the solution, and it is clear that
the user should be allowed to choose whether or not to
pivot.
250r---.-----.---.-----.---.-----.----,
Flop counts
Before we start the comparison of the actual perfor- 200

mance of the different solvers, it is better to have a


look at the theoretical number of operations used by
each of them. The following table shows details of
the different solvers' number of operations. The fol-
lowing table compares 'flop counts' for each algorithm.
One 'flop' is one floating-point multiply or divide plus
one floating-point addition or subtraction. Notice that
this is an inappropriate measure for integer or rational 60
computations, because each rational operation takes
an amount of time dependent on the size of the num-
bers involved, while the floating-point operation takes
20 120
a fixed amount of time. Of course, if the floats are 1~0

many digits long, this time itself may be large.


For large values of n the order of the number of
operations for both the Gauss Elimination Solver and Figure 1: Computation times for the solution of ran-
dom banded floating-point systems. The upper curve
Full Matrix LV Solver is 0 ( ~3 ) , while the order for is the time taken by linsolve and is apparently qua-
the Banded Matrix LU Solver is O(n,B2). This shows dratic in n, the size of the system. The lower curves
the reduction in the number of operations achieved by are the times for the modified index method and the
the LU solver (since ,B << n). Maple V Release 3 indexing function method.
To check this reduction in number of operations,
we did a numerical comparison between three meth-
ods of solving. We solved a series of random n by
n problems, each with a band width equal to 7, and
recorded the times for each method. We took n =
10,20,30, ... ,130. We compared the algorithms when
the problems had floating-point entries, and when they
had integer entries.
The methods used were 5O'r---,----,--....---,..--...---.--.....,

• Maple's 'linsolve' using sparse matrix storage


for the coefficient matrix [A],
• a banded matrix solver and our indexing func-
tion,
• an LU solver for the FORTRAN-style modified
indices storage for the coefficient matrix [A].
Fig. 1 shows the results of the comparison. For
floating point calculations, it is clear that the proposed
LU method is suitable, especially for large matrices.
The CPU time used by the LU solver is much less than
the time used by the linsolve method. The method
using the banded indexing function is also much faster
than the linsolve method, but takes about 75% more
time than the FORTRAN-style modified index method, Figure 2: Execution times of the two banded matrix
as is shown more clearly in Fig. 2. By looking at a log- solvers, for solving seven banded linear systems of size
arithmic plot, we see that the time taken by linsolve n. The modified (FORTRAN-style) indexing method
grows roughly as O(n 2 ) while the band solvers each is the lower curve, taking approximately 0.064n - 0.87
take O(n) time. By fitting straight lines to the data in seconds to solve seven linear systems, while the Maple
Fig. 2 we find that the band index function solver takes V Release 3 band indexing function method takes ap-
approximately O.lIn -1.35 seconds (on an mM RISC proximately O.lIn - 1.35 seconds to solve the same
6000 running a ,B-version of Maple V Release 3), while systems.
the modified index method takes 0.064n - 0.87 seconds
to solve the same problem. We suspect that the ap-
proximately 75% higher cost of the Maple V Release 3

225
Table 1: Algorithm complexity

Multiplications/ divisions Additions/ subtractions


n'-n
Gauss -3-
Elimination
No Pivoting

LU full
matrix

LU banded
matrix

n = matrix no. of rows, {3 = p = q (case where upper = lower bandwidth)

appears to grow as O(n 2 .1 ) while the band index func-


soo tion solver cost appears to grow as O(n 2 .3 ). For some
reason, the cost of the FORTRAN-style modified index
method appears to be growing as O(n 2 .6 ). We do not
250
put much trust in these decimal places, because we
have only tested these routines on a relatively small
200 number of problems.

f,~
. Conclusions
i
100
1. We have implemented a matrix factorization in
Maple. There is a matrix factorization package
already in the Maple Share Library, but it does
~
not take banded matrices into account [2].
2. We have shown that for floating-point matrices,
00 20 140
the expected efficiency gains from the use of banded
matrix solvers can be realized.
Figure 3: Computation times for the solution of ran- 3. We have given an example ofthe new user-defined
dom integer systems. Two of the curves are indistin- indexing functions in Maple V Release 3.
guishable on this graph. All three curves are compara- 4. We have demonstrated that Maple's built-in lin-
ble, but linsolve is slightly better for larger systems. ear solver is more suitable for integer calculations
All are apparently O(n for 2 < a < 3.
Q
)
than the proposed LU method.

band indexing function approach is due to its greater References


generality-we allow a (p, q) bandwidth in that pro-
gram, not just the same bandwidth on each side, and [1] Robert M. Corless, "Six, Lies, and Calculators",
this doubles the number of comparisons that must be American Mathematical Monthly, 100, no. 4, 1993.
done in the indexing function (the actual comparisons [2] Robert M. Corless, David J. Jeffrey, and M. A. H.
don't take that much time, it is the overhead of inter- Nerenberg, "The Row Echelon Decomposition of a
preting the longer code that increases the cost). Matrix", in the linalg subdirectory of the Maple
The rate of growth in time in the case of integer Share Library, 1990.
calculations is shown on Fig. 3. Surprisingly, for in-
teger calculations we see that the linsolve routine is [3] Gene H. Golub and Charles F. Van Loan, Matrix
roughly as suitable as either LU solver, but slightly bet- Computations, Johns Hopkins, 1983.
ter. This is partly because Maple chooses the minimum
[4] William W. Hager, Applied Numerical Linear Al-
pivot to minimize intermediate expression swell, and
gebra, Prentice-Hall, 1988.
partly because it, too, takes account of sparsity. All
three sets of solutions have costs which grow roughly [5] Sergio Pissanetzky, Sparse Matrix Technology,
as O(n 2 ), though to be more precise the linsolvecost Academic Press, 1984.

226
Robert M. Corless is an Associate Professor in
the Department of Applied Mathematics at the
University of Western Ontario, and has been at
Western since 1987. His Ph.D. was in classical
applied mathematics (though it was from the
Mechanical Engineering Department) under the
supervision of G. V. Parkinson at the University
of British Columbia in 1987. Earlier, he got an
M. Math. from the University of Waterloo in
1982, again in applied mathematics. It was at
Waterloo early in 1981 that he was introduced to
Maple.

Professor Corless is the author of Essential


Maple, an introductory work on Maple for
scientific programmers. The book is to be
published by Springer-Verlag.

He is currently on sabbatical leave, visiting the


A # group at IBM T. J. Watson Research Center
in Yorktown Heights, New York.

Khaled EI-Sawy is a Ph.D. student in Civil


Engineering at the University of Western
Ontario, under the supervision of Professor Ian
Moore. He received his Civil Engineering B.Sc.
in 1982 from Ain Shams University in Cairo,
Egypt. He then worked for several years, mainly
as a design and construction supervision
engineer for Mohamed Ibrahim Consulting Office
in Cairo. He then came to Canada and received
his M.Sc. in Civil Engineering in 1991 from the
University of Western Ontario.

227
USING MAPLE TO DESIGN A
COMPLEX MIXTURE EXPERIMENT

Richard A. Bilonick
CONSOl Inc., Pittsburgh, PA

Introduction on the list of candidate trials. In the unconstrained


case, each extreme vertex represents a unary mixture,
The design for an experiment can sometimes be i.e., a "mixture" that consists of a single pure
taken directly from one of many books on the subject. component. Additional trials are usually desired
Often, the design must be at least slightly modified. beyond the unary mixtures. Each pair of unary
All too often, a complex experiment requires a design mixtures represents an edge of the simplex
that cannot be found ready-made. Most experimental hypertetrahedron (e.g., a triangular pyramid in 3
design software has focused on 2- and 3-level dimensions when q equals 4). The next set of
factorial designs and other specialized designs (e.g. potential trials consists of the centroids of each edge
Box-Benkin). Adapting or creating an experimental which represent binary mixtures (i.e., mixtures of two
design can be a daunting task for many experimenters components). The centroid of each edge is simply and
and even applied statisticians. Little experimental exactly the arithmetic average of the two end vertices.
design software exists to tackle the more complex This process can be continued by determining the
design problems. Maple can be used to produce centroids of the 3-dimensional faces (trinary
complex designs and by using its built-in procedures mixtures), and so forth down to the single overall
tile programming task is greatly simplified. In ilie centroid of tile simplex (the [q-l)-ary mixture). (Note
following, Maple is used to design a complex mixture however that the true center-of-mass centroids in
experiment consisting of seven factors. general are not equal to the simple arithmetic
averages of the vertices that define each face.
However, in most cases the simple arithmetic average
Extreme Vertex Designs for Mixture is a good approximation.) If this list of trials is very
Experiments large, a subset of the q (O-dimensional) extreme
vertices, the q!/(2(q-2)!) centroids of the edges, the q
In a mixture experiment, tlle independent variables centroids of the q-2 dimensional faces, and tlle single
(or factors) are referred to as "components" and tlleir q-l dimensional overall centroid is chosen.
levels are proportions [1). These component levels When the components are subject to both upper
sum to one for each trial. The measured response and lower constraints, the experimental region is no
depends on these proportions alone and not on the longer a simple hypertetrahedron but instead an often
absolute amounts. For example, the texture of a pizza very complicated hyperpolyhedron. In tlle pizza crust
crust will depend on the proportions of the example, an acceptable crust could never consist of
ingredients: flour, milk, sugar, olive oil, and yeast. It 100% of any single ingredient, nor would the
will also depend on the oven temperature and time in proportion of any ingredient be set to 0%. The
the oven. A pure mixture experiment would vary numbers of extreme vertices, edges and so forth will
only the ingredients while fixing temperature and vary depending of the constraints. With four or less
time. A typical crust may consist of 71 % flour, 24% components, the design space can be visualized in 3
milk, 2% sugar, 2% olive oil, and 1% yeast by weight. or less dimensions. With five or more components, a
In mixture experiment designs where the q complicated algorithm must be used to determine the
components are unconstrained, each component can set of extreme vertices.
vary between 0% and 100%. Because the component The object of an extreme vertex design is to have
proportions sum to one, the mixture experimental the independent variables take on the lowest and
region is a q-l dimensional simplex. When designing highest possible values within the imposed
an experiment with unconstrained components, the q constraints. This would allow the maximum effect
extreme vertices (one for each component) would be (change in tlle response) to be observed. By limiting
the independent vartables via the constraints,
experimental effort is directed to maximizing the
information gained over the area of interest. Even
without adding various centroids to the design, the
constraints ensure that all the mixtures will be
combinations of all components when all components
have upper bounds less tllan 100% and lower bounds

228
greater than 0%. Adding the various centroids helps hyperpolyhedron defined by all eleven vertices. (The
to fill the experimental region more evenly with Maple procedures find_vertices and adjustment
observations. This helps to reduce the prediction error shown in the Appendix, only determine the vertices.
within the experimental region, and allow fitting Additional Maple procedures, available from the
models which include the possibility of curvature of author, convert from original components to
the response surface. Replicates of the centroids in pseudocomponents, find edges and faces, find the
addition provide an independent and direct estimate various centroids, convert from pseudocomponents to
of the experimental error, and further provide the original components, and so forth.)
means to check llle model for lack-of-fit.

Outline of the Desired Experiment


Finding the Vertices of a Design with Lower
and Upper Constraints An experiment was to be conducted to estimate
various characteristics (e.g. viscosity) of a mineral
Detennining llle vertices of a mixture design with oxide mixture as it is burned. Coal ash typically
bolll lower and upper constraints requires the use of a contains the following constituents: Si02, A1203,
relatively complex algorithm specified by Crosier [2). Ti02, Fe203, CaO, MgO, Na20 and K20, among
This algorithm has been encoded into two Maple others. The experiment was to consist of a number of
procedures find_vertices and adjustment shown in trials where llle proportions of these constituents were
the Appendix. Before using these procedures, the varied and the effects studied. For example, a
lower and upper constraints should be checked for response surface could be estimated for each
consistency [3), and if consistent (i.e., all the bounds dependent variable measured. These response
are attainable), eitller the L or U pseudocomponents surfaces could then be used to find an appropriate
should be computed. Both the L pseudocomponents mixture lllat satisfies certain requirements which are
and U pseudocomponents have lower bounds of zero. advantageous for electric power plant boilers. It is
When find_vertices is executed it produces a list of desirable to detennine in advance an optimal set of
all the vertices without duplicates. Crosier [2) trials which will maximize the amount of infonnation
presents an example for q=4 with U gained for a given number of experimental trials.
pseudocomponent upper bounds of 0.2, 0.8, 0.9 and
0.7 for the pseudocomponent axes Zl, Z2, Z3 and Z4,
respectively. The maximum number of vertices is 12. Coal Ash Constituent Constraints
The maximum number of edges is 18. The Maple
procedure find_vertices produced the steps shown in Each experimental trial would consist of a sample
Figure 1. The output exactly matches the original in constructed from the components whose proportions
Crosier [2) which identified 11 vertices (here labeled are within the ranges indicated in Table I below. Note
Vertex 1 to Vertex 11). Figure 2 shows the identified that Ti0 2 is fixed at I % for all trials. The sum of the
vertices and edges in the pseudocomponent space. other seven components must therefore total 99%.
Additional potential design points would include (but Each trial will have the smne weight, only varying in
are not limited to) the midpoints of each edge, the the proportion of each constituent. Because Ti0 2 is
centers of each face, and the center of the fixed at I %, after conversion to pseudocomponents it
can be ignored when considering how the other

Figure 1. Output seq(fi,eval(comment[i])j,i=O..j)


from the Maple procedure find_vertices. Figure 2. Example Simplex (Based on an
Example by Crosier[2)).
[0. [[ o. o. o. 0 I. Start; adjustment = ll1,
[1, [[ 1, 0, 0, 0 I, OOes not fitl I.
[2, [[ lIS, 0, 0, 0 I, Needs adjustment. 4/511, z,
[3. [[ lIS, 4/5, 0, 0 I, Vertex, 111, /11.
[4, [[ lIS, 0, 4/5, 0 I, Vertex, 211,
[5, [[ lIS, 0, 0,415 I, OOes not fitll, / \ \
[6. [[ lIS, 0, 0, 7/10 I. Needs edjustment, 1/10ll, / \ \
[7, [[ 115. 1/10, 0, 7/10 I, Vertex. 311. / \
[8, [[ lIS, 0, 1/10, 7/10 I. Vertex. 4l I. / \ \
[9, [[ 0 , 1 , 0 , 0 I, OOes not fitll,
[10, [[ 0, 4/5, 0, 0 I. Needs adjustment, 1/51 I. / \ \
[11, [[ lIS, 4/5, 0, 0 I, Violates duplicate rulell, / \ \
[12, [[ 0, 4/5, lIS, 0 I, Vertex, 511,
[13, [[ 0, 4/5, 0, 115 I, Vertex. 611, / \ \
[14, [[ 0, 0, 1. 0 I, OOes not fitll, / \ \
[15, [[ 0, 0, 9/10, 0 I, Needs adjustment, 1/10ll.

1~/
.. 3~\
[16, [[ 1/10, O. 9/10. 0 I, Vertex, 711,
[17, [[ 0, 1/10, 9/10, 0 I. Vertex, 8ll, \
[18, [[ 0, 0, 9/10. 1/10 I, Vertex. 911, / " \ \
[19, [[ 0, O. 0, 1 I, OOes not fitll,
[20,
[21,
[[ 0, O. 0, 7/10 I. Needs adjustment, 3/101 I.
[[ 3/10, 0, 0, 7/10 I. OOes not fitll.
z/--:. 5~ '.6 2•. 1.0"': '""":"':-,;- '>z,
[22, [[ lIS, 0, 0, 7/10 I. Violates duplicate rulell.
[23, [[ 0, 3/10. 0, 7/10 I, Vertex, lOll. 8 Z, 9
[24. [[ 0, 0, 3/10. 7/10 I. Vertex, 111l

229
components should be varied. steps to locate all 94 unique vertices (and was
executed with infinite precision). These results would
be virtually impossible to produce by hand. The
A 7-Component Extreme Vertex Design results could have been obtained by creating a C
language program, but additional code would be
The following steps were performed: required to handle the more tedious chores
(constructing matrices, tables, and lists) that Maple
1) Verified the consistency of the lower and upper handles automatically.
constraints. Another Maple V procedure was used to detennine
which of the extreme vertices were connected and
2) Converted the lower and upper constraints to formed edges. A total of 291 edges were found. The
pseudo-constraints. edge lengths were also computed. This information
was used to determine 1) which vertices were close
3) Identified all the extreme vertices using the together (arbitrarily defined as lengths less than 0.1)
pseudo-constraints. and could be removed and replaced by an "average"
vertex, and 2) which vertices were "far" apart
4) Determined which vertices are connected (so that (arbitrarily defined as lengths greater than 0.6) so that
edge and face centroids can be computed). an edge centroid could be computed. The 23 longest
edges were identified. There were 14 (the maximum
5) Determined which connected extreme vertices are possible) 5-dimensional faces. The vertices fonning
close together (so that they can be replaced by a these faces were detennined and centroids computed
single vertex). for each face. The grand average of all 94 extreme
vertices was calculated and used as an estimate of the
6) Converted the pseudocomponents back to the overall (6-dimensional) centroid.
original component space. The various centroids have been added to the list
of experimental trials in order to be able to
To facilitate computations, the original component approximate the resulting response surfaces with
proportions are converted to L pseudocomponents [2]. quadratic or cubic models. The pseudocomponent
At this point, the original component constraints were coordinates of the extreme vertices were then
determined to be consistent (required in order to use converted back to original units so that they sum to
Crosier's algorithm for finding extreme vertices). 99/100 (allowing for the TiOz fixed at 1/100). The
Constraint consistency means that all of the specified overall (6-dimensional) centroid will be performed 5
upper and lower bounds are attainable (although not times, while the 5-dimensional face centroids will
necessarily simultaneously). each be performed twice. These replications will
Ninety-four extreme vertices (out of a possible 140 decrease the predictive uncertainty and also provide
vertices) were identified for the q = 7 components an independent estimate of the experimental error.
with the constraints shown in Table 1 (but ignoring The total number of trials is 133 and they are
for the moment TiOz ). The algorithm required 364 summarized in Table 2 below.

Table 1. Constraints on Each Constituent Analysis of the Experimental Observations

The following Scheffe (full) cubic model for a


given trial could be fitted to the observed data:
Constituent Minimum Maximum
% % 7
y = ~ ~iXi + ~~ ~ijXiXj + ~~OijXiXj(Xi-Xj ) +
SiOz 35 60 1= 1 I<.J I<.J
LLL~i'kXiX'Xk
. '<k J J
+€
Alz03 15 30 I<.J
using the method of least squares [1]. The term Xi
FeZ03 5 40 represents the proportion of component i, and y is the
observed response. The random error is denoted by €
CaO 0.5 10 and is assumed to be distributed normally with mean
equal to 0 and variance equal to cr z . This model
MgO 0.5 4 requires the initial estimation of 84 coefficients
represented by Ws and o's. The ~i'S represent the
NazO 0.5 4
linear blending values of component i. The ~ij'S
KzO 0.5 4 represent the nonadditive blending values of
components i and j. The Oij'S represent the synergistic
TiOz 1 1 or antagonistic blending between components i and j.
Finally, ~ijk represents ternary blending among

230
components i, j, and k. degrees of freedom for the overall centroid).
Alternatively, the model can be expressed as Therefore, if the cubic model is inadequate, this
should be detectable. In this event, some other
Y=X~+£ possibly nonlinear model may be indicated or the
response variable metric should be suitably
where Y is an n byl vector of the n observed transformed.
responses, X is an n by 84 design matrix (one column Analysis of the 21 intercorrelations between the 7
for each model parameter), ~ is an 84 by 1 vector of purely linear design variables indicates that almost all
parameters (7 ~i'S', 21 ~ij'S, 210ij'S, and 35 ~ijk'S), intercorrelations are extremely small. Only three were
and £ is an n by 1 vector of normally distril5uted larger in absolute value than OJ. The intercorrelation
random errors with mean equal to 0 and variance matrix is shown in Table 3 below. Only the
equal to cr z. correlation between SiOz and FeZ03 is moderately
The estimate of the model parameters is then given large at -0.73. A plot of SiOz by FeZ03 shows that the
by addition of one or more trials with proportions of
SiOz and FeZ03 simultaneously at their maximums
should reduce the intercorrelation to almost zero.

where Xt represents the transpose of X and (XtXr I


Considerations for Design Improvements
represents the inverse of the matrix product xtX. The
predicted responses for the observed responses are The current design should be adequate,
given by X~. Confidence intervals for each parameter however, improvements may be possible. In addition
could be determined and used to simplify the model to adding at least one trial with simultaneously high
(reduce the number of parameters) where possible. proportions of SiOz and FeZ03, some other
With 133 observations and 84 parameters modifications may improve the design. For example,
(initially) to be estimated, the total number of degrees the trade-off between replicating the 5-D face
of freedom for the error sum of squares will be 49 (= centroids and including more edge centroids should
133 - 84). The 49 degrees of freedom can be be studied. A much more ambitious approach would
partitioned to allow for a lack-of-fit test for the cubic look at all extreme vertices, edge centroids, 5-D face
model by using the 18 degrees of freedom attributed centroids and overall centroid and choose a subset of,
to the replicated trials (one degree of freedom for for example, 133 trials that produces the "optimum"
each 5-D centroid [14 degrees of freedom) plus 4 design. Design improvement could be gauged by
using the D-optimality criterion. D-optimality seeks
to maximize the detenninant of XIX. This minimizes
Table 2. Number of Trials for (XIX)-I which is proportional to the variance of~.
Each Class of Vertex

References
No. of
Vertex Class Trials [1) J. A. Cornel, Experiments with Mixtures,
2nd edition. New York: Wiley, 1990.

[2) R. B. Crosier, "The geometry of


O-D Extreme Vertices constrained mixture experiments,"
(after removing closely 72
Technometrics, 28,2,95-102, 1986.
spaced clusters)
5 [3) G. F. Piepel, "Defining consistent
Average Vertices of constraint regions in mixture
Closely Spaced Clusters experiments," Technometrics, 25,1,
23 1983.
1-D Longest Edge
Centroids

5-D Face Centroids 28


Richard A. Bilonick received his Ph. D. degree in
(including replicates) statistics from the University of Pittsburgh in 1979.
5 For the last 15 years, he has provided statistical
6-D Overall Centroid consultation to the research and development,
(including replicates) engineering, marketing, and legal departments at
CONSOL Inc. He can be reached at the following
133 address:
Total

231
Richard A. Bilonick
CONSOL Inc.
Consol Plaza
Pittsbtrrgh, PA 15241-1421
USA

(412) 831-4509

Table 3. Intercorrelations Between Independent Variables


for the Proposed Experimental Design

Alz03 Fez03 CaO MgO NazO KzO

SiOz -0.16 -0.73 0.01 0.02 0.02 0.02

AIz03 -0.41 -0.05 0.02 0.02 0.02

FeZ03 -0.34 -0.16 -0.16 -0.16


CaO -0.01 -0.01 -0.01

MgO -0.00 -0.00

NazO -0.00

Note: The three largest correlations are shown in bold type.

232
Appendix A .. Finding All the Extreme Vertices

The following Maple procedure detennines all the extreme vertices of the hyperpolyhedron simplex
without duplicates:
find_vertices .- proc();
#
# Given a set of consistent L or U pseudocomponent constraints
# based on an original simplex, this proc
# finds all vertices in the q-1 dimensional simplex.
# You must supply: q - the no. of components, and
# the 1 x q array constraints (use proc pseudo_constraints to extract
# the L or U pseudocomponent constraints generated by proc
# consistency) .
# find_vertices produces the array vertices_nd which holds the unique
# vertices, nv is the no. of unique vertices, j is the no. of steps
# in the algorithm.
# Algorithm details are given in arrays work and comment and stored in the
# table keep.
#
# This algorithm uses proc adjustment recursively
#
# First initialize some indices
u . - 0;
n .- 1;
i . - 1;
j . - 0;
nv := 0; #no. of vertices
work := table([]);
work[j] := array(l. .q, [seq(O,m=l. .q)]); # This line and the next creates
# first line of work table
comment[j] := [eval(work[j]), 'Start; adjustment = 1'];
keep := table([]);

# For each of q components do the following: for i from 1 by 1 to q


do
j := j + 1;
work[j] := array(l. .q, [seq(O,m=l. .i-1) ,l,seq(O,m=i+l. .q)]);
adjust[n] := 1 - constraints[i];

# If adjust[n] is positive, recursively re-adjust until a fit occurs


if adjust[n] > 0
then
comment[j] .- [eval(work[j]), 'Does not fit'];
j := j + 1;
work[j] .-
array( 1 .. q, [seq (0, m=l .. i-1) ,1 - adjust [n] ,seq (0, m=i+1 .. q) ]) ;
keep[i,n] := copy(work[j]);
comment[j] := [eval(work[j]), 'Needs adjustment', adjust[n]];
iO : = i;
adjustment(iO); # This is the difficult part!

# Otherwise, if adjust[n]=O and we have found a vertex else


u := u + 1;
vertices[u] := copy(work[j]);
nv := nv + 1;
vertices_nd[nv] := copy(work[j]); #no duplicates
comment[j] .- [eval(work[j]), 'Vertex', nv];
fi;
od;
vertices_set := {seq(eval(vertices[i]),i=l .. u)};
RETURN (seq ( [1, eval (vertices_nd[i])], i=l .. nv));
end;

233
This procedure is used by find_vertices:
adjustment ;= proc(iO) local k;
#
# recursive proc used by find_vertices
#
for k from 1 by 1 to q
do
if work[j] [k] = 0
then
j := j + 1;
work[j] ;= copy(keep[i,n]);
work[j] [k] := adjust[n];

if (adjust[n] - constraints[k]) > 0


then
comment[j] := [eval(work[j]), 'Does not fit'];
j ;= j+1;
n := n + 1; # go forward
adjust [n] : = adjust [n-1] - constraints [k] ;
work[j] := copy(keep[i,n-1]);
work [j] [k] : = constraints [k] ;
i f k < iO
then
comment [j] : = [eval (work [j] ) ,'Violates duplicate rule'];
else
keep[i,n] := copy(work[j]);
comment[j] := [eval(work[j]), 'Needs adjustment', adjust[n]];
kO : = k;
adjustment (kO) ;
work[j] := copy(keep[i,n-1]);
fi;
n ;= n - 1; # go back
else
u := U + 1;
vertices[u] .- copy(work[j]);
if (work[j] [k] = constraints[k]) and (k < iO)
then
comment [j] : = [eval (work [j] ) , 'Violates duplicate rule'];
else
nv : = nv + 1;
vertices_nd[nv] ;= copy(work[j]);
comment[j] := [eval(work[j]), 'Vertex', nv];
work[j] .- copy(keep[i,n])
fi;
fi;
fi;
od;
end;

234
With this principle firmly in mind, the author of Maple via Calculus
brings to teachers and students a fresh look at the standard calculus
curriculum, colored by the existence of technology like Maple - a
Preface • Basic Plotting· tool that can be used in class during lectures and exams and at home :
while working assignments, a tool whose universal access will even- i
Parametric Equations •
tually make a software-based approach to mathematics the norm. I
Optimization Problems •
Whether one uses this book primarily to learn Maple or to learn cal- 1
Interpolation • Conic Through
culus, the student who works through the exercises will learn a great!
Five Points • An Implicit
deal about both. Drill exercises and rote manipulation are replaced.
Function • Inverse Functions • here with conceptual learning activities and an exploratory interac- ,
Partial Fraction Decomposition • tion with mathematics not seen in traditional courses. A surprising!
Derivatives By Definition • feature is that fewer than 90 Maple commands are necessary to do i
Implicit Differentiation • Taylor all the calculus activities in the book, thus making it an ideal text for:
learning Maple basics. By implementing this owerful computer.
Polynomials • Teaching the
algebra system in their courses, teachers can clearly delineate the!
Definite Integral • Deriving fundamental ideas of calculus while demonstrating the efficient use !
Simpson's Rule • Numerical of Maple.
Integration • Improper Integrals •
The techniques illustrated in this text have passed the test of student
Integration by 1rigonometric acceptance. The author has used them with great success in his own
Substitution • Integration by courses and demonstrated them in workshops and presentations in
Parts • Integration by Parts Twice many locations in North America and Europe. Everyone interested
• Surface Area ofa Solid in bringing the computer into the calculus classroom will find the
book a valuable resource.
Revolution • A Seperable
Differential Equation • Newton's
Law ofCooling • Logistic Growth
• L'Hopital's Rule • Lines and For Price Ordering Information: CALL: Toll-Free 1-800-777-4643.1n NJ please c>.l1201·348-4033.Your rerer-
ence number is Y804.· WRITE: Birkh'user, Marketing Depl.,675 MassachusensAve., Cambridge, MA 02139.' YlSIT: Your IOL.-.J
Planes • Curvature from Every fec.hnicaJ bookslorc: or urge your librarian to order for your dep:ulmem. Payment can be made by check. money order or credit oed. Plosc

Angle • The Lagrange Multiplier, enclose S2.50 for shipping & handling for the first book ($1.00 (or(';]ch addilional book).md lL, NY. NJ. MA. yr. PA. VA. TX& CA residents. p~ ",dd
sales tax. Guud~1l residcms pbsc.dd 7% GST. Prices arc ,·:lIid in Nonh America only and arc subject to change widlOUI nalia. For price and ordering

Part One • The Lagrange information outside Nonh America, plea.se COnlaet BirkhauSC'r Verlag AG, P.O. Box 133, Kloslerberg 23. CH4010. Basel. SwilUrland. Fax GJ 271 7666.

Multiplier, Part Two • The


--~~-~---------

Lagrange Multiplier, Part Three •


Iterated Integration Birkhiiuser
Boston. Basel. Berlin
by
..... .
-~
William E. Baylis

The way in which students in all fields of study learn mathematical skills is being fundamentally changed
through the advent of inexpensive computers and the creation of powerful mathematical packages for symbolic
manipulation, numerical approximation, and graphical representation. Teachers of mathematics through the
entire calculus and applied mathematics sequence now have at their disposal a number of these tools, among
which Maple V has become an acclaimed leader. Theoretical Methods in the Physical Sciences is a textbook
that takes advantage of this technological development to teach a wider variety of more complex and realistic
problems than was ever before possible.

The book is designed for a one-term course, to be taken in the first or second year after the student has
completed introductory courses in physics and calculus. It uses the Maple package as an integral part of
learning how to solve a range of problems taken from elementary physics, astronomy, chemistry, and geology.
At the same time, it encourages the reader to think about what is being calculated, to relate results to physical
experience, to make order-of·magnitude estimates of both answers and errors, and to carry out dimensional
and unit checks of calculations. Above all, it uses the power of the computer, when applicable, to deepen
perception and understanding. It is packaged with a 3.5-inch diskette containing Maple worksheets for each
chapter and useful data files of physical constants, conversion factors, and chemical isotopes. The diskette is
formatted for MS Windows, but its files can also be used on Apple and Unix platforms.

Teachers will find this book a useful resource as the main text for introductory courses in applied mathematics,
mathematical physics, and theoretical science and engineering, or as an ancillary to texts in mathematics,
engineering, and the physical sciences. Both students and research workers can use it for self-instruction as a
quick, practical introduction to Maple.

CONTENTS: Introduction • Maple V for Physical Applications • Approximations of Real Functions •


Vectors • Basic Data Analysis and Statistics • Curve-Fitting • Integration • Complex Numbers and
Fractals • Vector Algebra of Physical Space • Appendices • Index

1994 304 Pages Softcover, comb bound


3.5" high density IBM diskette
$34.50 ISBN 0-8176-3715·X
Birkhiiuser
Boston· Basel • Berlin
TO ORDER, CALL 1·800·777·4643

You might also like