\documentstyle [twocolumn]{article}

\input mvmmacros.tex

 \title{Maple V \mma}

 \author{Paul C. Abbott\\
 Department of Physics\\
 University of Western Australia\\
 Nedlands  6009\\
 AUSTRALIA\\
 email: paul@earwax.pd.uwa.oz.au }

\begin{document}\maketitle
 
\section{Abstract}

A comparison of two popular computer algebra systems (CAS), Maple and \mma\ is presented from a users viewpoint.  Solved examples highlight the different conventions, environment and tools that each system provides.  Special attention is paid to system design through examples of consistency of function naming, syntax, and the ease with which output from one computation can be entered as input to another.

\section{Introduction}

This review assumes a passing knowledge of computer algebra. An introduction to CAS is given in [1-3] and I encourage the reader to refer to the detailed descriptions of Maple [4-7] and \mma\ [8-10] for more information.

Both Maple and \mma\ are very large programs and this review does not even attempt to cover their scope.  There have been many reviews of each system individually and some comparative reviews [11-12].  The focus here is on the results of one user trying to solve a set of problems using each system.

Maple and \mma\ are under active development, both by their respective manufacturers and by the inclusion of contributed packages from the large and rapidly growing community of CAS users.  The capabilities of each package are changing dynamically.  Both packages have comprehensive (symbolic) programming languages and so the implementation of capabilities only found in one of the systems is, in general, achievable.  Of course, the ease of doing this is another matter altogether.

I have restricted this review to \mma\ and Maple because both programs are widely available on a large number of machines, including most unix workstations, the Macintosh, 386-based PC and the NeXT.  Maple and \mma\ are the most widely distributed and supported general purpose systems presently available and, in my opinion, this is the closest to a head to head contest.  Many users will  make their choice of CAS on the basis of a comparison between these systems and I believe that the best way to make an informed decision is to actually try using both systems. 

There are a plethora of other CAS and I will only mention those that I have used.  Derive is an excellent small CAS but only runs on the PC.  Theorist, which has a friendly interface but more modest algebra, is presently restricted to the Macintosh.   The capabilities of older packages such as Macsyma and Reduce have, to a very large extent, already been subsumed by \mma\ and Maple.  The recent AXIOM package (formerly Scratchpad) is very powerful and has a strong mathematical foundation, but presently runs only on a very limited range of hardware and is not intended for the casual user.

 The questions that I will attempt to answer are: 

\begin{itemize}
\item  Which system is easier to use?

\item  Which environment is better?

\item  Does the system work as expected? 

\item  Can the user easily develop intuition about which commands achieve what result?
\end{itemize}

\noindent
These questions (and their answers) are, to a large extent, subjective.  To answer them I have attempted to produce a ``good'' solution using each system and let the reader decide which system is more ``natural'' for each problem.     

Many users can, with effort, become expert even on systems that are not very user-friendly.  Perhaps surprisingly, students are often more malleable than professors as they usually have less pre-conceived notions about programming styles or a wide range of experience to help them decide what is a good
system.  Nevertheless, good system design permits users to go further faster.  Though expert users can work around bugs and design problems, casual users are often put off.  

In this review I focus on high-level system design and have not listed bugs that exist in either system.  Certainly, neither is perfect.  My hope is that CAS designers will treat this review as constructive criticism.

Although both systems have extensive graphics capabilities reviewers have been unanimous in declaring \mma's graphics to be superior.  At the risk of making this review dull, I have therefore decided not to present any examples of the graphics capabilities of either system.

Since both programs have many capabilities in common, the choice between them can become simply a matter of style or taste.   The reasons for choosing one system over another may include:

\begin{itemize} 
\item  cost or availability

\item  programming background

\item  prior experience with a system

\item  graphics capabilities

\item  colleagues are more familiar with a particular package

\item  source code availability

\item  local computers already have one system installed

\item  available hardware

\item  one system has routines or special purpose packages that does just what is required 
\end{itemize}
 
\ni These differences will be ignored for the purpose of this review.

At the time of writing, I personally have used \mma\ for 3 years and Maple for about one year and I presently use both on a regular basis.  In addition I worked for Wolfram Research and am presently a contributing editor for {\it The Mathematica  Journal}.  I manage a company which distributes technical software and I sell and support both products. Nevertheless, I certainly have more experience and expertise with \mma\ and this review should be judged with that in mind.  I have certainly not been reluctant to seek help from experts, ensuring that I am ``doing the right thing'' in both systems.  Any errors that remain are solely my responsibility.

\section{Hardware Used}

I have produced this review on a Macintosh SE/30 with 8 MByte of RAM running system 7.0.1.  Only interface-specific comments are restricted to this environment.

I used Maple V for the Macintosh, Version 5.0.1 (November 1991) and \mma\ for the Macintosh 2.0.4 (September 3, 1991).  I set \mma\ to use 5,120 kBytes of RAM and Maple to use 2,500 kBytes.

\section{Examples}

Using examples, I will attempt to compare the usability of each system by presenting a solution using Maple followed by one using \mma.

\subsection{Recalling previous expressions}

\mma\ automatically keeps track of every input and output during a session.  Previous expressions can be referred using the relative referencing, {\eg}, \verb+%+, \verb+%%+, \verb+%%%+, for the previous, second previous and third previous expressions or using absolute referencing, {\ie}, \verb+%n+, where \verb+n+ is an output number --- in general absolute referencing is discouraged as the line numbers will change from session to session.  However it can be useful when you have proceeded down an unfruitful line of investigation and you quickly want to return to an earlier result.

For relative referencing Maple uses an analogous device, {\ie},
\verb+"+, \verb+""+, \verb+"""+.  However, Maple only keeps the last three expressions.  To keep track of all previous output it is necessary to load the \verb+history+ library package.  However, this only permits the use of \verb+"+ relative referencing.  Absolute referencing is denoted by \verb+On+ where \verb+n+ is an output number.  

The history mechanism is used sparingly in this review but it is mentioned because, when using a CAS, the ability to go back and review or recompute previous computations is essential.  

\subsection{Timing}

Because the examples presented are short, timings are not presented.  Note that in general, reviews only show system timings.  The ``user-interface time'', which can be quite substantial, is difficult to quantify as it can depend upon the user's expertise with the interface.

\subsection{Notation}

For both systems, input is displayed left-justified as,
\begin{verbatim}
input
\end{verbatim}
\ni whilst ouput is indented:
\begin{verbatim}
    output
\end{verbatim}

\subsection{Solution of equations}

This section will examine how easy it is to manipulate and evaluate the solutions to the system of equations, 
$7 x + 3 x y^2 = 0$ and $x y + 3 x - 7 y = 1$.

\subsubsection{Maple }

The exact solution to the system of equations is found using,

 
\begin{verbatim}
s := solve({7*x + 3*x*y^2 = 0, 
            x*y + 3*x - 7*y = 1}, {x,y}

s := {x = 0, y = -1/7},

                      2
  {y = RootOf(7 + 3 _Z ),

         30                 2     29
    x = ---- RootOf(7 + 3 _Z ) + ----}
         17                       17
\end{verbatim}
 
At first glance there appears to be only two solutions.  However Maple uses \verb+RootOf+ as a placeholder for {\bf all} the solutions of the specified polynomial.  This is elegant and permits the solutions to be expressed in a very concise form.    

The Maple solution, \verb+s+, is not in a very convenient format from the perspective of ease of use in other related calculations.  Using \verb+evalf(s);+ or \verb+map(evalf, s);+ one gets syntax errors.  The problem is that \verb+solve+ returns a sequence (an \verb+exprseq+ object) which must be converted into a set 
(\verb+{ }+) or a list (\verb+[ ]+), {\eg},

\begin{verbatim}
evalf({s});
\end{verbatim}

\begin{verbatim}
{{x = 0, y = -.1428571429},
   {y = 1.527525232 I,
       x = 2.695632762 I + 1.705882353}}
\end{verbatim}

Alternatively, examining the second root, denoted \verb+s[2]+, one can get a numerical value directly, {\eg}, 

\begin{verbatim}
evalf(s[2]);
\end{verbatim}

\begin{verbatim}
   {y = 1.527525232 I,
      x = 2.695632762 I + 1.705882353}
\end{verbatim}

However, this is only {\bf one} of the possible values.  To obtain all such values \verb+allvalues+ must be used, {\eg},

\begin{verbatim}
allvalues(s[2][1]);
\end{verbatim}

\begin{verbatim}
               1/2                1/2
   y = 1/3 I 21   , y = - 1/3 I 21
\end{verbatim}

\ni and both the numerical values are obtained from

\begin{verbatim}
evalf({"});
\end{verbatim}

\begin{verbatim}
  {y = 1.527525232 I, y =  - 1.527525232 I}
\end{verbatim}

Now let's examine how the solutions can be re-used.  We substitute the second solution, \verb+s[2]+, into the linear equation $x^2 -3 y$:

\begin{verbatim}
subs(s[2], x^2 - 3*y);
\end{verbatim}

\begin{verbatim}
    / 30                 2     29 \2
    |---- RootOf(7 + 3 _Z ) + ----|
    \ 17                       17 /

                            2
         - 3 RootOf(7 + 3 _Z )
\end{verbatim}

\ni and evaluate it following the procedure above:

\begin{verbatim}
evalf({allvalues(")});
\end{verbatim}

\begin{verbatim}
                              2
{(2.695632762 I + 1.705882353)
      + 4.582575695 I,
                                 2
    (2.695632762 I + 1.705882353)
         - 4.582575695 I,
                                    2
    ( - 2.695632762 I + 1.705882353)
         - 4.582575695 I,
                                    2
    ( - 2.695632762 I + 1.705882353)
         + 4.582575695 I             } 
\end{verbatim}

\ni This expression is not simplified automatically and we need to expand it:

\begin{verbatim}
expand(");
\end{verbatim}

\begin{verbatim}
 { - 4.356401386 + 4.614289023 I,
      - 4.356401386 - 4.614289023 I,
      - 4.356401386 + 13.77944041 I,
      - 4.356401386 - 13.77944041 I}
\end{verbatim}

\subsubsection {{\em Mathematica}}

For \mma\ with the same problem,

\begin{verbatim}
s = Solve[{7x + 3x y^2 == 0, 
          x y + 3 x - 7 y == 1}, {x,y}]
\end{verbatim}

\begin{verbatim}
                  1
 {{x -> 0, y -> -(-)}, 
                  7
        58 + 20 I Sqrt[21]              7
  {x -> ------------------, y -> I Sqrt[-]}, 
                34                      3
        58 - 20 I Sqrt[21]               7
  {x -> ------------------, y -> -I Sqrt[-]}}
                34                       3
\end{verbatim}

We note several syntactical differences.  \mma\ accepts a space as implying multiplication, \verb+==+ denotes equality instead of 
\verb+=+, and no trailing semi-colon is required to terminate the input line.  The results are returned in the form of a (nested) list of replacement rules, \ie, \verb+x -> ...+ instead of as a list of equalities.  

To evaluate these solutions numerically we type:

\begin{verbatim}
N[s]
\end{verbatim}

\begin{verbatim}
  {{x -> 0, y -> -0.142857}, 
    {x -> 1.70588 + 2.69563 I, 
     y -> 1.52753 I}, 
    {x -> 1.70588 - 2.69563 I, 
     y -> -1.52753 I}}
\end{verbatim}

Replacement rules can be substituted into other expressions using the \verb+ReplaceAll+ ({\ie}, substitution) command which has the shorthand notation \verb+/.+.  To substitute these solutions into $x^2-3y$, we write

\begin{verbatim}
x^2 - 3y /. s // Expand
\end{verbatim}

\begin{verbatim}
     3    1259    97 I
    {-, -(----) + ---- Sqrt[189], 
     7    289     289
        1259    97 I
      -(----) - ---- Sqrt[189]}
        289     289
\end{verbatim}

\ni where \verb+//+ denotes a postfix operation --- acting much like a Unix pipe.  The numerical values are given by

\begin{verbatim}
N[%]
\end{verbatim}

 \begin{verbatim}
    {0.428571, -4.3564 + 4.61429 I, 
      -4.3564 - 4.61429 I}
\end{verbatim}

\subsection{Numeric differential equations}

Consider the differential equation $$y''(x) + \sin^2(x)  y'(x) + y(x) = \cos^2(x)$$ with initial conditions $y(0) = 1$ and  $y'(0) = 0$.

\subsubsection{Maple}

The command

\begin{verbatim}
g := dsolve({diff(y(x),x$2) + sin(x)^2 * 
  diff(y(x),x) + y(x) = cos(x)^2,
    y(0) = 1, D(y)(0) = 0}, y(x), numeric);
\end{verbatim}

\ni yields a Maple procedure for computing the numerical solution,

\begin{verbatim}
   proc(x) `dsolve/numeric/
        result2`(x,10523004,[2]) end
\end{verbatim}

This returns (a sequence) of \verb+x+, \verb+g(x)+ pairs, {\eg},

\begin{verbatim}
g(0.3);
\end{verbatim}

\begin{verbatim}
       .3000000000, .9993367370
\end{verbatim}

Here a list of \verb+x+, \verb+g(x)+ values is requested --- note that the pair structure is lost:

\begin{verbatim}
map(g, [$ 1..3]);
\end{verbatim}

\begin{verbatim}
    [1., .9347835943, 2.000000000,
         .5180974671, 3.000000000,
         .1830905706]
\end{verbatim}

There appears to be no simple way of computing numerical values of the derivatives of \verb+g(x)+.

\subsubsection{{\em Mathematica}}

For the same problem in {\mma}, the command,

\begin{verbatim}
NDSolve[{y''[x] + Sin[x]^2 y'[x] + y[x] == 
    Cos[x]^2, y[0] == 1, y'[0] == 0}, y,                
        {x,0,3}]
\end{verbatim}

\ni returns a nested list of solutions in the form of interpolating functions expressed as replacement rules, {\ie},

\begin{verbatim}
   {{y->InterpolatingFunction[{0., 3.}, <>]}}
\end{verbatim}

The output of \verb+NDSolve+ is consistent with \verb+Solve+ and hence caters for multiple solutions and coupled equations.  Assigning the result using,

\begin{verbatim}
y = y /. First[%];
\end{verbatim}

\ni permits \verb+y+ to be treated as a normal function, {\eg},

 \begin{verbatim}
y[0.3]
\end{verbatim}

\begin{verbatim}
       0.999336
\end{verbatim}

The \verb+Table+ command generates a list of \verb+{x, y[x]}+ values, {\eg},
 
\begin{verbatim}
Table[{x, y[x]}, {x,3}]
\end{verbatim}

\begin{verbatim}
 {{1, 0.934784}, {2, 0.518099}, {3, 0.183088}}
\end{verbatim}

Because the solution is returned as an interpolating function, derivatives can be computed, {\eg},

 \begin{verbatim}
y'[0.3]
\end{verbatim}

 \begin{verbatim}
         -0.00875584
\end{verbatim}

\subsection{Integration}

Here is an example which requires the Risch integration algorithm.

\subsubsection{Maple}

Consider the function $\sin(\sin(x))$.  In Maple notation, this can be entered as,

\begin{verbatim}
f := x -> sin(sin(x));
\end{verbatim}

\begin{verbatim}
    x -> sin(sin(x))
\end{verbatim}

One method of obtaining the second derivative is to use the composition operator (\verb+@+):

\begin{verbatim}
g := (D@D)(f);
\end{verbatim}

\begin{verbatim}
                               2
      x -> - sin(sin(x)) cos(x)
           - cos(sin(x)) sin(x)
\end{verbatim}

Alternatively one could use \verb+diff(f(x), x$2 );+.  The integral of this expression is

\begin{verbatim}
int(g(x), x);
\end{verbatim}

\begin{verbatim}
               4               2
(- 2 tan(1/2 x)  - 2 tan(1/2 x)

             tan(1/2 x) 2
     - 2 tan(----------)
                 %1
                   2     tan(1/2 x) 2
     - 2 tan(1/2 x)  tan(----------) )
                             %1

       /  /        tan(1/2 x) 2\   2
      /  (|1 + tan(----------) | %1 )
     /    \            %1      /

                        2
%1 :=     1 + tan(1/2 x)
\end{verbatim}
where \verb+%1+ identifies a common sub-expression.  Maple automatically generates these when handling large expressions.  
This simplifies to:

\begin{verbatim}
simplify(");
\end{verbatim}

\begin{verbatim}
                            2
    2 cos(x) cos(1/2 sin(x))  - cos(x) + 1
\end{verbatim}

One method of fully compacting this result,  is to write out fully the required simplification: 

\begin{verbatim}
  simplify(subs(cos(1/2*sin(x))^2 = 
      (1+cos(sin(x)))/2, result));
\end{verbatim}

\begin{verbatim}
        cos(x) cos(sin(x)) + 1
\end{verbatim}

Apart from a constant of integration, this agrees with

\begin{verbatim}
diff(f(x), x);
\end{verbatim}

\begin{verbatim}
        cos(x) cos(sin(x))
\end{verbatim}

\ni as it should.

\subsubsection{{\em Mathematica}}

Defining the function,

\begin{verbatim}
f[x_] = Sin[Sin[x]]
\end{verbatim}

\begin{verbatim}
      Sin[Sin[x]]
\end{verbatim}

\ni its second derivative is given by

\begin{verbatim}
f''[x]
\end{verbatim}

\begin{verbatim}
                                2
  -(Cos[Sin[x]] Sin[x]) - Cos[x]  Sin[Sin[x]]
\end{verbatim}

Alternatively, the user could have entered \verb+Derivative[2][f][x]+, or \verb+D[f[x], {x, 2}]+.

Requesting the integral of this expression

\begin{verbatim}
Integrate[%, x]
\end{verbatim}

 \begin{verbatim}
    Cos[x] Cos[Sin[x]]
\end{verbatim}

\ni we immediately get the simplified solution which agrees with,

\begin{verbatim}
f'[x]
\end{verbatim}

 \begin{verbatim}
      Cos[x] Cos[Sin[x]]
\end{verbatim}

\subsection{Pattern-matching}

\subsubsection{Maple}

The expression \verb+2*cos(1/2*sin(x))^2+, which arose in the previous section, can be simplified using generic substitution for the expression \verb+2*cos(y)^2+ where \verb+y+ is arbitrary.  In Maple, only rudimentary pattern-matching is available and it is not well integrated into the system.  For example,

\begin{verbatim}
match(2*cos(1/2*sin(x))^2 =
        a*cos(b*sin(x))^c, x, 'd');
\end{verbatim}

\begin{verbatim}
              true
\end{verbatim}

\ni reveals that the expressions do indeed match and the matching parameters are given by

\begin{verbatim}
d;
\end{verbatim}

\begin{verbatim}
        {b = 1/2, a = 2, c = 2}
\end{verbatim}

\ni However, attempting something like

\begin{verbatim}
match(2*cos(1/2*sin(x))^2*cos(x) =
      a*cos(b*sin(x))^c, x, 'd');
\end{verbatim}

\begin{verbatim}
        false
\end{verbatim}

\ni fails.

\subsubsection{{\em Mathematica}}

\mma\ relies heavily on pattern matching.  The combination of replacement and generic pattern matching capabilities makes manipulation of expressions straightforward.

The expression that Maple encountered in the previous section, \verb#2 Cos[x] Cos[Sin[x]/2]^2-Cos[x]+1# can be simplified using a rule which replaces {\bf all} expressions involving squares of the cosine function, \eg,

\begin{verbatim}
2 Cos[x] Cos[Sin[x]/2]^2 - Cos[x] + 1 /. 
  Cos[x_]^2 -> (1 + Cos[2 x])/2 // Expand
\end{verbatim}

\begin{verbatim}
          1 + Cos[x] Cos[Sin[x]]
\end{verbatim}

Here the generic expression \verb+x_+ matches with \verb+Sin[x]/2+.  I have deliberately chosen to use the symbol \verb+x+ in both expressions to demonstrate that no confusion arises (at least for \mma).

\subsection{Anonymous functions and Map}

\subsubsection{Maple}

Multivariate anonymous functions in Maple are implemented using standard mathematical notation, {\eg},

\begin{verbatim}
((a,b) -> a^2 + b^3)(c,d);
\end{verbatim}

\begin{verbatim}
     2    3
    c  + d
\end{verbatim}

For work on a set or list of pairs you can use either a third argument to \verb+map+, {\eg},

\begin{verbatim}
map((a,b) -> h(a,b), {1,2}, x);
\end{verbatim}

\begin{verbatim}
    {h(1, x), h(2, x)}
\end{verbatim}

\ni or the \verb+zip+ function, {\eg},

\begin{verbatim}
zip((a,b) -> h(a,b), [1,2,3], [c,d,e]);
\end{verbatim}

\begin{verbatim}
    [h(1, c), h(2, d), h(3, e)]
\end{verbatim}

There is no built-in generalization of \verb+map+ and \verb+zip+ to higher dimensions.

\subsubsection{{\em Mathematica}}

In \mma, multivariate pure (anonymous) functions may appear less elegant.  Two equivalent expressions are

\begin{verbatim}
Function[{a,b}, a^2 + b^3][c,d]
\end{verbatim}

 \begin{verbatim}
      2    3
     c  + d
\end{verbatim}

\ni or, alternatively, \verb-(#1^2 + #2^3)& [c,d]-.

If the argument is a list of pairs then one needs to map the function over the set of pairs, {\eg},

 \begin{verbatim}
Map[(h[#[[1]],#[[2]]])&, 
	{{1,c},{2,d},{3,e}}]
\end{verbatim}

\begin{verbatim}
       {h[1, c], h[2, d], h[3, e]}
\end{verbatim}

Two alternatives that achieves the same result are \verb+Map[#/.List->h &, {{1,c},{2,d},{3,e}}]+, which transforms all sublists into functions, and \verb+Apply[h, {{1,c},{2,d},{3,e}}, 1]+.  All results generalize immediately to any number of arguments, {\eg},

\begin{verbatim}
Apply[h, {{1,c,f},{2,d,g},{3,e,h}}, 1]
\end{verbatim}

\begin{verbatim}
       {h[1, c, f], h[2, d, g], h[3, e, h]}
\end{verbatim}

\subsection{Matrices}

\subsubsection{Maple}

 Maple supports sequences, lists, sets, arrays, tables, vectors and matrices and each object is a different data type.  After loading the \verb+linalg+ package (suppressing the long output using \verb+:+),

\begin{verbatim}
with(linalg):
\end{verbatim}

\begin{verbatim}
Warning: new definition for   col
Warning: new definition for   norm
Warning: new definition for   trace
\end{verbatim}

\ni one can work with matrices.  Note that tracing computations is now difficult because \verb+trace+, previously permitting system tracing, now computes the trace of a matrix.  This confusion can be avoided by loading the required functions using a more explicit invocation, {\eg}, \verb+with(linalg, matrix)+.  Nevertheless, it seems that different names (or contexts) should have been chosen for one of these procedures.

Consider constructing two general $2 \times 2$ matrices, $m_1$ and $m_2$:

\begin{verbatim}
m1 := matrix(2,2,(a,b) -> h(a,b));
\end{verbatim}

\begin{verbatim}
         [ h(1, 1)  h(1, 2) ]
         [                  ]
         [ h(2, 1)  h(2, 2) ]
\end{verbatim}
 
\begin{verbatim}
m2 := matrix(2,2,(a,b) -> j(a,b));
\end{verbatim}

\begin{verbatim}
         [ j(1, 1)  j(1, 2) ]
         [                  ]
         [ j(2, 1)  j(2, 2) ]
\end{verbatim}
 
To add these matrices one can use \verb+add+ or \verb+evalm+, {\eg},

\begin{verbatim}
evalm(m1 + m2);
\end{verbatim}

\begin{verbatim}
[h(1, 1) + j(1, 1), h(1, 2) + j(1, 2)]
[h(2, 1) + j(2, 1), h(2, 2) + j(2, 2)]
\end{verbatim}

\ni and for matrix mulitplication we have,

\begin{verbatim}
evalm(m1 &* m2);
\end{verbatim}

\begin{verbatim}
[h(1, 1) j(1, 1) + h(1, 2) j(2, 1),
    h(1, 1) j(1, 2) + h(1, 2) j(2, 2)]
[h(2, 1) j(1, 1) + h(2, 2) j(2, 1),
    h(2, 1) j(1, 2) + h(2, 2) j(2, 2)]
\end{verbatim}

\ni where \verb+&*+ is used to indicate non-commutative multiplication.  

Here is one way of computing $3 \times m_1 + 5 \times m_2$:

\begin{verbatim}
add(m1, m2, 3, 5);
\end{verbatim}

\begin{verbatim}
      [3 h(1, 1) + 5 j(1, 1),
          3 h(1, 2) + 5 j(1, 2)]
      [3 h(2, 1) + 5 j(2, 1),
          3 h(2, 2) + 5 j(2, 2)]
\end{verbatim}

In Maple, arrays and matrices are different objects although both output formats are identical and conversions are required to change between appropriate types.  Although the need for a range of data-types is recognised, automatic type coercion could be included.

\subsubsection{{\em Mathematica}}

\mma\ has fewer data structures and the list structure is fundamental --- all expressions in \mma\ can be acted upon as though they are lists.   No data-type conversions are required to change between appropriate objects such as matrices, arrays, vectors, sets, and tensors.  A \mma\ matrix is simply a list of lists of equal size and can be created using the \verb+Array+ command.  For example,

\begin{verbatim}
m1 = Array[h, {2,2}]
\end{verbatim}

\begin{verbatim}
    {{h[1, 1], h[1, 2]}, {h[2, 1], h[2, 2]}}
\end{verbatim}

\ni and
 
\begin{verbatim}
m2 = Array[j, {2,2}]
\end{verbatim}

\begin{verbatim}
    {{j[1, 1], j[1, 2]}, {j[2, 1], j[2, 2]}}
\end{verbatim}

\ni are two matrices and can be added using
 
\begin{verbatim}
m1 + m2
\end{verbatim}

\begin{verbatim}
   {{h[1, 1] + j[1, 1], h[1, 2] + j[1, 2]}, 
     {h[2, 1] + j[2, 1], h[2, 2] + j[2, 2]}}
\end{verbatim}

In \mma, matrix multiplication is indicated using the dot product operator (\verb+.+).  It can be argued that this is inconsistent from a mathematical viewpoint but, since each sub-operation in matrix multiplication is really a dot product operation, it is a neat mnemonic.  Here is the matrix product:

 \begin{verbatim}
m1.m2
\end{verbatim}

 \begin{verbatim}
      {{h[1, 1] j[1, 1] + h[1, 2] j[2, 1], 
        h[1, 1] j[1, 2] + h[1, 2] j[2, 2]}, 
       {h[2, 1] j[1, 1] + h[2, 2] j[2, 1], 
        h[2, 1] j[1, 2] + h[2, 2] j[2, 2]}}
\end{verbatim}

The \verb+.+ notation can also be used for the product of matrices and vectors, \eg, \verb+m1.{x,y}+, and keeps ordinary multiplication free to represent element by element arithmetic for appropriate sized matrices, {\eg}, \verb+m1 * m2+.

Scalar multiplication and addition are immediate, \eg,

\begin{verbatim}
3 m1 + 5 m2
\end{verbatim}

 \begin{verbatim}
    {{3 h[1, 1] + 5 j[1, 1], 
      3 h[1, 2] + 5 j[1, 2]}, 
     {3 h[2, 1] + 5 j[2, 1], 
      3 h[2, 2] + 5 j[2, 2]}}
\end{verbatim}

\subsection{Series}

\subsubsection{Maple}

In Maple, series are computed via the \verb+series+ operation, 
{\eg}, here is the expansion of $\sin(\tan(x)) - \tan(\sin(x))$ about 
$x = 0$ to eleventh order:

\begin{verbatim}
s := series(sin(tan(x)) - tan(sin(x)), x, 11);
\end{verbatim}

\begin{verbatim}
              7    29  9      11
      - 1/30 x  - --- x  + O(x  )
                  756
\end{verbatim}

This series can be integrated (\verb+int(s, x);+) or differentiated (\verb+diff(s, x);+), but other basic operations are not supported, {\eg}, \verb+s^2;+ does not work, and the user must be more explicit:

\begin{verbatim}
series(s^2, x, 17);
\end{verbatim}

\begin{verbatim}
           14     29   16      18
    1/900 x   + ----- x   + O(x  )
                11340
\end{verbatim}
 
Conversion to a number of other types is supported, 
{\eg}, conversion to a polynomial:
\begin{verbatim}
convert(s, polynom);
\end{verbatim}

\begin{verbatim}
                  7    29  9
          - 1/30 x  - --- x
                      756
\end{verbatim}
 
\subsubsection{{\em Mathematica}}

 \mma\ has the function \verb+Series+ for computing Taylor series.  A shorthand for requesting series expansions is to add the required order to the expression, {\eg},

\begin{verbatim}
s = Sin[Tan[x]] - Tan[Sin[x]] + O[x]^11
\end{verbatim}

\begin{verbatim}
          7       9
        -x    29 x        11
        --- - ----- + O[x]
        30     756
\end{verbatim}

Appropriate operations are supported, {\eg}, integration (\verb+Integrate[s, x]+), differentiation (\verb+D[s, x]+) and powers (\verb+s^2+).  The truncated (polynomial) form of the series is given using \verb+Normal+;

 \begin{verbatim}
Normal[s]
\end{verbatim}

\begin{verbatim}
          7       9
        -x    29 x
        --- - -----
        30     756
\end{verbatim}

\subsection{Recursive functions and tracing}

Both programs support recursive functions and each has tracing capabilities.  Maple traces expressions to a certain depth.  
\mma's tracing is linked to its pattern-matching capability.  The Fibonacci numbers are used to highlight the differences.

\subsubsection{Maple}

Maple supports recursive function definitions and type checking, 
{\eg},

\begin{verbatim}
fib := proc(n) 
    if not type(n, integer) then 
        RETURN( 'fib(n)') fi;
    if n = 0 or n = 1 then RETURN(n) fi;
    fib(n-1) + fib(n-2)
end:
\end{verbatim}

Switching on the tracing

\begin{verbatim}
trace(fib):
\end{verbatim}

\ni and trying 

\begin{verbatim}
fib(3);
\end{verbatim}

\begin{verbatim}
--> enter fib, args = 3
--> enter fib, args = 2
--> enter fib, args = 1
<-- exit fib = 1
--> enter fib, args = 0
<-- exit fib = 0
                                       1
<-- exit fib = 1
--> enter fib, args = 1
<-- exit fib = 1
                                       2
<-- exit fib = 2
                                       2
\end{verbatim}

\ni we see that \verb+fib+ is recomputing values (as its definition would suggest).  This can be prevented by adding a \verb+remember+ option to the function definition, {\ie},

\begin{verbatim}
fib := proc(n) 
    option remember;
    if not type(n, integer) then 
        RETURN( 'fib(n)') fi;
    if n = 0 or n = 1 then 
        RETURN(n) fi;
    fib(n-1) + fib(n-2)
end:
\end{verbatim}

\subsubsection{{\em Mathematica}}

In \mma\ one can adopt a rule-based approach, including argument type-checking, {\eg},

\begin{verbatim}
fib[n_Integer] := fib[n-1] + fib[n-2]
fib[0] = 0;
fib[1] = 1;
\end{verbatim}

The function \verb+Trace+ can trace all calls to the function \verb+fib+;

\begin{verbatim}
Trace[fib[3], fib]
\end{verbatim}

\begin{verbatim}
  {fib[3], fib[3 - 1] + fib[3 - 2], 
    {fib[2], fib[2 - 1] + fib[2 - 2], 
     {fib[1], 1}, {fib[0], 0}}, {fib[1], 1}}
\end{verbatim}

Supplying a pattern, (here using a conditional, \verb+/;+, read as such that) permits more selective tracing, \eg, to trace all calls to \verb+fib+ such that the argument to the function is $\geq 2$, we type,

\begin{verbatim}
Trace[fib[4], fib[n_ /; n >= 2]]
\end{verbatim}

\begin{verbatim}
      {fib[4], {fib[3], {fib[2]}}, {fib[2]}}
\end{verbatim}

We can see that \verb+fib+ is recomputing values.  To remember previous values we enter,

\begin{verbatim}
fib[n_Integer] := fib[n] = 
    fib[n-1] + fib[n-2]
\end{verbatim}

\ni which uses ``dynamic programming".  Tracing the \mma\ assignment operator, \verb+Set+ (\verb+=+), \eg,

\begin{verbatim}
Trace[fib[3], Set]
\end{verbatim}

\begin{verbatim}
  {fib[3] = fib[3 - 1] + fib[3 - 2], 
    {{fib[2] = fib[2 - 1] + fib[2 - 2], 
      fib[2] = 1, 1}}, fib[3] = 2, 2}
\end{verbatim}

\ni confirms that the intermediate expressions are now being saved.

\subsection{Consistency of function naming}

Naming consistency is important because it simplifies the user's task in finding the appropriate object.  More importantly, syntactical consistency helps to develop an intuition as to how a system will behave.

\subsubsection{Maple}

In Maple some of the special functions are capitalized, {\eg},
\verb+BesselI+ and \verb+FresnelC+ which should be compared with, {\eg}, \verb+sin+ and \verb+cos+.  However, \verb+gamma+ represents Euler's constant, $\gamma$, but \verb+GAMMA+ has been chosen for the function $\Gamma$(x).  All inert functions have their first letter capitalized, {\eg}, \verb+Sum+, \verb+Factor+ and \verb+Prem+ (but \verb+BesselI+ is not inert). 

In general, polynomial operations over the field of rational numbers use lower-case, {\eg}, \verb+factor+, \verb+gcd+, \verb+rem+ and \verb+quo+, whilst upper case refers to the corresponding inert form.  As an example, 

\begin{verbatim}
Factor(x^2 + 2*x + 2) mod 2;
\end{verbatim}

\begin{verbatim}
     2
    x
\end{verbatim}

Note that \verb-Solve(x^2 + 2*x + 2 = 0) mod 2;- does not work and \verb-msolve(x^2 + 2*x + 2 = 0, x, 2);- is required instead.

\subsubsection{{\em Mathematica}}

\mma\ appears to be completely consistent in function naming and syntax uniformity.  For example, all function names have the first letter of each (concatenated) word capitalized.  All words are spelled out fully.  All numerical functions are preceded by a capital 
\verb+N+, all \verb+Plot+ functions contain \verb+Plot+ and all commands for plotting (lists of) data have \verb+List+ as the first part of their name.  

Note that both systems permit the assignment of aliases which allows user customization.

\section{Conclusions}

\subsection{General}

I continue to use both programs and retain an active interest in the application of computer algebra to problems in the physical sciences.

Pattern matching and rule-based programming are vital components of \mma\ and are well integrated into the system.  This is an area in which Maple could be significantly improved.

For teaching and also for research laboratories, the principal disadvantage of \mma\ versus Maple is the size of the computer required to run the software --- 5MBytes versus 2MBytes on a Macintosh (with a similar requirement for a PC running Windows)   However, improvements in hardware and reductions in the cost of RAM are reducing this differential.

Both Waterloo Maple Software and Wolfram Research Inc., have site-licensing deals.  In addition, Wolfram Research have an Educational Grant Program for the establishment of teaching laboratories.  

Only \mma\ presently has the ability to have the computational kernel running on a separate compute-server with the graphical user interface front-end on local machines.  This mode can be ideal both for research and for teaching laboratories.

\subsection{Worksheets and Scratchpads versus Notebooks}

The \mma\ Notebook interface has a hierarchical structure which permits flow control and all graphics are immediately placed into the document.  In the Maple Worksheet, graphics appear in a separate window and need to be pasted into the Worksheet.  Hence graphics are not dynamically linked to the commands that produced them.  

Notebooks are strictly ASCII text and automated conversions to other formats {\eg}, \TeX\ and the Macintosh Rich Text Format (RTF) are supported.  For publication, dissemination and electronic transmission, the Notebook is certainly more flexible.

After using both the \mma\ Notebook and the Maple V interface, I find the Maple ``Active Worksheet Window'' concept complicated and I do not appreciate the need for both a Worksheet and a Scratchpad.  Scratchpads, which redirect their output to the Active Worksheet, indicate to me that they are not really necessary.   I quote from page 14 of [7]:

{\it Scratchpads are meant to be used primarily for rough textual work and transferring selected calculations from previous Maple sessions into the Active Worksheet.   The work done on Scratchpads can be thought of as work done on scrap paper when a problem is being done by hand.}
 
\section{Obtaining the software}

Maple: Waterloo Maple Software\\Phone: (519) 747 2373\\Fax (519) 747 5284\\email: wmsi@daisy.uwaterloo.ca

\smallskip

\ni \mma: Wolfram Research Inc. \\Phone: (217) 398 0700\\Fax (217)398 0747\\email: info@wri.com

\section{Acknowledgements}

Helpful discussions with Simon Fitzpatrick, Grant Keady, Michael Monagan and Benton Leong (Maple) and Emily Martin (WRI) are acknowledged.  Thanks go to Hilde Singer (Maple) and Ben Friedman and Jane Rich (WRI) for supplying the copies of Maple and 
\mma\ used in this review.  Further thanks to Tom Marchioro for assistance with \TeX.

\section{About the author}

Paul Abbott received his Ph.D. in theoretical atomic physics from the University of Western Australia in 1987.  His research relied heavily on computer algebra.  In 1989, Abbott was involved with the foundation of {\it The Mathematica Journal} as Technical Editor. In 1991 he founded Analytica, a company based in Perth, Western Australia, that sells and supports a range of technical software packages.  In 1992, Abbott was appointed to the staff of the Department of Physics at the University of Western Australia. 

\section{References}

\subsection{General}

{
% \viiipt
[1] R. Pavelle, M. Rothstein, and J. Fitch, 
{\it Sci. Am.}, 
{\bf  245}, 102 (1981)

\ni [2] Harper, D., Woof, C. and Hodgkinson, D. 
{\it A Guide to Computer Algebra Systems}
Wiley (1991)

\ni [3] Yun, D.Y., Stoutemyer, D. 
{\it Symbolic Mathematical Computation}
in Belzer, J. Holzman, A. G., Kent, A. (eds.) 
{\it Encyclopedia of Computer Science and Technology}
{\bf 15}, pp 235 -310 (1980)
}

\subsection{Maple}

{%^\viiipt

[4] Char, B.W., Geddes, K.O, Gonnet, G.H., Leong, B.L., Monagan, M.B. and Watt, S.M. 
{\it First Leaves: A Tutorial Introduction to Maple}, Springer (1991)

\ni [5] Char, B.W., Geddes, K.O, Gonnet, G.H., Leong, B.L., Monagan, M.B. and Watt, S.M. 
{\it Maple V Language Reference Manual}, Springer (1991)

\ni [6] Char, B.W., Geddes, K.O, Gonnet, G.H., Leong, B.L., Monagan, M.B. and Watt, S.M. 
{\it Maple V Library Reference Manual}, Springer (1991)

\ni [7] {\it Maple V for the Macintosh: Getting Started}
Waterloo Maple Software, Waterloo (1991)
}

\subsection{{\em Mathematica}}

{% \viiipt

[8] Wolfram, S. 
{\it Mathematica: A System for Doing Mathematics by Computer},
Second Edition Addison-Wesley (1991)

\ni [9] Maeder, R. 
{\it Programming in Mathematica},
Second Edition, Addison-Wesley (1991)

\ni [10] 
{\it The Mathematica Journal}:
published quarterly by Miller-Freeman
}

\subsection{Reviews}

{% \viiipt
[11] Simon, B., PC Magazine, 
{\bf 9} (10) (1990)

\ni [12] Simon, B., Notices of the AMS, 
{\bf 37}
(7) (1990)

}

\end{document}


