\documentstyle[12pt]{article}
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\Alph{subsection}.}
\begin{document}
\title{New Differential Forms Package for Maple}
\author{Frederick J.\ Ernst \\
	FJE ENTERPRISES \\	
	Rt.\ 1, Box 246A \\
	Potsdam, NY 13676}
\date{June 6, 1992 (revised December 2, 1993)}
\maketitle
\begin{abstract}
As part of a continuing assessment of the potential of various general 
purpose symbolic manipulation programs for handling research level 
problems involving differential forms, we have rewritten a number of 
application programs that were originally written for Ernst's {\em Grad 
Student Rational Calculator}.  Getting these programs to work under
Maple required the modification and enhancement of the {\bf difforms} 
package.  The revised package developed by FJE ENTERPRISES has the name
{\bf fjeforms}, and is described in this report.
\end{abstract}

\newpage
\section{The Grad Student Rational Calculator}

Since 1980 the author has employed microcomputers to perform most of
the calculations he encountered in his research in gravitation theory.
His {\em Grad Student Rational Calculator} was developed to run under
MS-DOS on a machine with very limited memory.  Nevertheless, with it
he was able to perform the symbolic calculations he sought to do.

With the advent of powerful workstations, he had either to port his
own software to the UNIX environment or find an existing software
package that could adequately handle the type of differential forms
calculations he so often encounters.  The former alternative would be
fun, as he would be tempted to enhance the {\em Grad Student Rational
Calculator} in ways that would be impossible on the small machine he
had been accustomed to using, a ten megahertz 8086 with only 320 k of 
RAM.  Such an enhancement would surely be necessary for the next phase
of his research, which will involve the integration of exact and
numerical techniques in the study of spacetimes with symmetries.  On
the other hand, if Maple or some other general purpose software can
really do the job, the author would prefer not to have to start from
scratch, for the time saved in software development could be
profitably spent on research problems in general relativity.

During the last half dozen years the author has written about a
hundred application programs for the {\em Grad Student Rational
Calculator}.  The features of the GS program that made programming
easy included:
\begin{enumerate}
\item Automatic presumption that any object not declared to be a
	form was in fact a scalar (i.e., 0-form).
\item Automatic warning if the user had accidentally added 
	differential forms of different degrees.
\item Ability to employ notation of the user's choice for
	components of the exterior derivative of a scalar
	with respect to basic 1-forms.
\item Ability to declare scalars and forms as complex variables.
\item Ability easily to extract coefficients of basic forms.
\item Access to the duality (star) operation on forms.
\item Access to the asymmetrical Grassmann (step) inner product on forms.
\item Automatic interpretation of juxtaposition as ordinary product,
	wedge product or matrix product, through context.
\item Automatic interpretation of exponentiation in terms of ordinary
	product, wedge product or matrix product, through context.
\end{enumerate}

Coming to the project with no previous experience using Maple, it took
us a mere three weeks to come up with revisions and enhancements of
Maple's {\bf difforms} package that would give Maple some of the
listed attributes of the {\em Grad Student Rational Calculator}, and
thus permit us to use Maple to perform research level calculations 
involving differential forms.  In 1993 the capabilities of the
program were further developed.  In the following sections, we shall
describe the {\bf fjeforms} implementation as it now stands.

\section{type/const, type/form, type/scalar, wdegree and defform} 

As we rewrote the application program {\bf kerr} for processing
under Maple, we grew increasing annoyed by the need to declare every
scalar field as a scalar.  We had no desire to manipulate objects of
undeclared {\bf wdegree}, but we would accidentally introduce such
objects, through failing to declare them as scalars.  Moreover, Maple
was perfectly happy to accept unintentionally summed forms of
differing {\bf wdegree}s, something which is, of course, possible but
extremely rarely, if ever, used in practical calculations.  We were
also mystified by Maple's willingness to apply ordinary commutative
multiplication to forms, either directly or through the exponentiation
operator.  As far as we know, there is no legitimate mathematical 
definition of such products.

More significantly, the existing {\bf difforms} package had the nasty 
habit of forcing us to declare that functions returned values whose 
{\bf wdegree} in no way depended upon the {\bf wdegree}s of their 
arguments.  For five of the functions we introduced, {\bf cc}, {\bf 
re}, {\bf im}, {\bf star} and {\bf \&step}, this was certainly not the 
case.  The first three returned values the {\bf wdegree}s of which 
were the same as those of their arguments, while the duality operator 
{\bf star} returned a value with a {\bf wdegree} equal to the
dimension of the {\bf star} minus the {\bf wdegree} of its argument.
The {\bf wdegree} of the step product, when the latter did not vanish,
was equal to the difference of the {\bf wdegree}s of its two
arguments.  

Accordingly, we were forced to revise the {\bf difforms} package so 
that the functions that we introduced would be handled specially.
Into {\bf wdegree} we inserted code that would do the job.  

In addition, we rewrote {\bf type/const} so that it would double as a 
detector of operations that we should prefer to consider illegal.  
Since it is called by the other type checkers, {\bf type/const} 
seemed to be the proper place to insert this code.  Into {\bf 
type/form} we placed code that would correctly identify as forms
or not forms expressions that involved the functions that we
introduced.  Finally, {\bf type/scalar} was modified so that it would
identify as a scalar any object that was identified as being neither 
of {\bf type/const} nor of {\bf type/form}.

We also revised {\bf defform} so that the user cannot declare forms to
be of unspecified {\bf wdegree}, and we eliminated the declaration of
scalars.  

\section{The Exterior Derivative d}

Not infrequently it is nice to be able to express the exterior
derivative of a scalar field as a linear combination of specific 
1-forms.  The {\bf difforms} package actually gives one that ability,
albeit with a very restrictive notation for the coefficients of those
one forms, the names of which are created automatically by a procedure
called {\bf difforms/d/mknme}, which was, for some mysterious reason,
absent from the version of Maple we were using.  The GS program also
had this capability, but it was left to the user to stipulate how the
names were to be assigned.  If we were expanding ${\bf d}(f)$ in terms of
1-forms $\{ e[0], e[1], e[2], e[3] \}$ it might be nice to write
$${\bf d}(f) = {\bf d}[0](f) \; e[0] + {\bf d}[1](f) \; e[1] 
+ {\bf d}[2](f) \; e[2] + {\bf d}[3](f) \; e[3],$$
but if we were expanding ${\bf d}(f)$ in terms of a null-tetrad 
$\{ k, m, t, cc(t) \}$, it might be nice to write
$${\bf d}(f) = {\bf d}[m](f) \; k + {\bf d}[k](f) \; m 
+ {\bf d}[cc(t)](f) \; t + {\bf d}[t](f) \; cc(t).$$
In any event it is probably useful to designate the various
coefficients as functions of $f$ rather than simply as names,
as was possible in the GS program.

Accordingly, we revised {\bf difforms/d} so that the user could
optionally supply as many additional arguments as he wishes, with 
each additional argument being a two-element list such as, for
example, $[e[0],`{\bf d}[0]`]$ or $[k,`{\bf d}[m]`]$.  This gives 
us the additional flexibility we sought, and it enables us to use 
coefficients that are functions rather than just names.  This 
aspect of the new {\bf fjeforms/d} is nicely illustrated in the 
application program {\bf np}.

\section{User-defined Differential Operators}

In practical calculations we have frequently wanted to introduce 
differential operators, that is, linear operators that satisfy 
the usual Leibnitz property when applied to products.  Therefore,
we have included in the {\bf fjeforms} package a procedure called
{\bf defdiffop} that permits the user to do precisely that.  In
particular, this is often useful in connection with the 
multiargument option of {\bf difforms/d} described earlier.

\section{Complex Constants, Scalars and Forms}

Maple's intrinsic knowledge of complex variables is rather scant.  In
particular, although it recognizes the symbol $I$ as the square root
of $-1$, it assumes that all other names stand for real objects.  
Among the various dot-m files we found nothing that would help us
in handling complex variables in a natural way.  Therefore, we have in
{\bf fjeforms} supplied five functions {\bf defcomplex}, {\bf iscomplex}, 
{\bf cc}, {\bf re} and {\bf im}, the first of which is used to declare
specific variables as complex valued, the second is used to test whether
a name represents a complex variable, and the others evaluate the complex
conjugate, the real and the imaginary part of a complex expression.
We considered this as essential, as we so often deal with complex
variables in our research.

\section{Extraction of Coefficients of Forms}

In our calculations, we frequently have to extract the components of
form-valued expressions with respect to a basis.  Therefore, we have
in {\bf fjeforms} provided a procedure {\bf coef} that accomplishes
this.  It makes use of a procedure called {\bf perm} to determine the
required sign change, when, for example {\bf expr} involves 
$m \; \& \! \wedge k$ but we ask for the value of 
$\mbox{{\bf coef}}({\bf expr},k \; \& \! \wedge m)$.  

\section{The Duality Operator star}

While there is no universally accepted definition of the duality
operator {\bf star} on differential forms, it is a linear operator
that maps $p$-forms into $n-p$-forms, where $n$ is the dimensionality
of the duality operator.  What people do not seem to be able to agree
upon is the sign of $\mbox{{\bf star}}(\mbox{{\bf star}}(u))$ 
relative to that of the
$p$-form $u$ itself.  Our Maple implementation of the duality operator
requires the user to assign a positive integer value to the global
variable {\bf DIMENSION}, but it does not force upon him any
particular sign convention.  If he wishes calculations to be explicit
he must define the values to be returned by {\bf star}, when the
operator is applied to the number 1, to a symbol that represents a
basic form, or to a wedge product of such symbols.  

The use of the {\bf star} operator is illustrated in the application
program {\bf ts}.

\section{The Grassmann Inner Product \&step}

No one has exploited the Grassmann inner product more completely in
connection with the general theory of relativity than have Hauser and
Ernst.  In fact, they have employed two such products, one that acts
upon the tangent manifold, and another that acts upon the cotangent
manifold.  It is the latter {\bf \&step} product that we have included
in the {\bf fjeforms} package.  We insist that the {\bf \&step} product
satisfy certain indispensable identities and be linear in each of its 
arguments.

If the user wishes results to be explicit, he must supply the values
to be assigned to {\bf \&step} products of the basic forms, i.e., he
must specify the metric.  To avoid error he must do this in a manner
that is consistent with 
$$fm1 \mbox{ {\bf \&step} } fm2 = 0$$
when $fm2$ has lower {\bf wdegree} than does $fm1$, and
$$\mbox{{\bf wdegree}}(fm1 \mbox{ {\bf \&step} } fm2)
= \mbox{{\bf wdegree}}(fm2) - \mbox{{\bf wdegree}}(fm2)$$
otherwise.

It should be noted that once one specifies the sign conventions for
the duality operator, there is a definite relationship established
between the {\bf star} and {\bf \&step} operators.  This permits one to
express the one operator in terms of the other, as was done in the GS
program, where the {\bf \&step} operator was defined in terms of the 
{\bf star} operator.  We decided to provide two independent operators
here, for the user can always redefine either operator appropriately
in terms of the other.

\section{Conclusions}

We were impressed with the basic Maple kernel and with the Maple
programming language, but we were not at all happy with the {\bf 
difforms} package.  In a short time we discovered how to modify the
contents of m-files, so that differential forms are now handled in a
manner that is more to our liking.  

What would be necessary in order to make us completely happy would 
be to adjust the user interface so that expressions that make sense 
to humans would also make sense to Maple.  We detest having to spell 
out to the computer what product to use, when the computer could 
perfectly well figure out the user's intentions through context.  
Having grown accustomed to the {\em Grad Student Rational Calculator}, 
we keep forgetting that Maple must be told explicitly which product 
is intended.  

We appreciate that writing an intelligent parser for a general purpose
symbolic manipulator is a good deal more difficult than writing one
for a program that is concerned with a limited number of functions,
but we think it is an objective that deserves attention.

Finally, the user of the present version of {\bf fjeforms} should be
aware that we have not yet used {\bf fjeforms} in connection with the
{\bf linalg} implementation of matrices, so we cannot vouch for its
compatibility.

\section*{Acknowledgement}
This work was supported in part by grants PHY-91-16681 and
PHY-93-07762 from the National Science Foundation.

\end{document}

