Symbolic Computation with Maple

Basics

In this section is some basic information about Maple that may help with symbolic computation and the use of Maple. One of the first things is assigning equations to variables in Maple. This is very useful because it will allow you to enter an equation once and then perform many operations on or with that equation.

To assign an equation to a variable use the := operator. An example of this is shown below.

> f:=x^2+3*x+13;

                                     2
                               f := x  + 3 x + 13

> f;

                                  2
                                 x  + 3 x + 13

> f:=0;

                                     f := 0

> f;

                                       0

In the above example the equation x^2+3*x+13 was assigned to the variable f. f was then called and Maple printed out the equation. On the third line zero was assigned to f. This was done to clear the variable. Maple, unlike Mathematica, does not have a Clear function for variables. Before using a variable in an equation be sure you know what it represents or if you are not sure assign a constant such as 1 or 0 to it.

Another operator that is useful is the !. This performs the same function as in Mathematica. Namely it allows you to call a Unix command while still in Maple. With this you can view the contents of the directory you are presently in, change directories, clear the screen, or any other Unix command you wish to call.

When using Maple, remember to finish any line with a semicolon so Maple knows to process the command.

simplify and expand

The first function here, simplify has a lot of ambiguity attached to it. No one really knows how the simplest form of an equation is represented. Maple does have a command though that follows a wide collection of rules to obtain a result that it believes is in a more simple form.

Example:

> f:=(a+b/x+c/x^2);

                                               c
                              f := a + b/x + ----
                                               2
                                              x

> simplify(f);

                                    2
                                 a x  + b x + c
                                 --------------
                                        2
                                       x

In the example above the equation the was first saved to the variable f is simplified somewhat with the simplify command. There is also a command in Maple called expand which performs the opposite operation of simplify in that it will expand an equation out into all of its parts.

Example:

> f:=(a+b/x+c/x^2);

                                               c
                              f := a + b/x + ----
                                               2
                                              x

> g:=simplify(f);

                                      2
                                   a x  + b x + c
                              g := --------------
                                          2
                                         x

> g;

                                    2
                                 a x  + b x + c
                                 --------------
                                        2
                                       x

> expand(g);

                                             c
                                 a + b/x + ----
                                             2
                                            x

The example starts out by assigning an equation to the variable f and then simplifying this equation and assigning the result to the variable g. expand is then called with the equation in g as an argument and the result is the same equation that was saved in f.

solve

solve is a very useful function when dealing with various equations. Like the Solve function in Mathematica, it lets you solve an equation for some constant or for some variable within the equation. By using solve equations can be rearranged and put in terms of different variables within them. solve can take one or two arguments. The first argument is the equation that is to be solved. The second argument is the variable that the equation is to solved in terms of. Below is an example that was used with the Solve function in Mathematica.

Example:


> f:=3*x+2*x^2+5*y+2*y^3;

                                        2            3
                          f := 3 x + 2 x  + 5 y + 2 y

> solve(f=100, x);

                                  3 1/2                                3 1/2
    - 3/4 + 1/4 (809 - 40 y - 16 y )   , - 3/4 - 1/4 (809 - 40 y - 16 y )

In this example the equation 3*x+2*x^2+5*y+2*y^3 was saved to the variable f. Next, f was set equal to zero within the call to the solve function and the equation was to be solved in terms of x. Just like in the Mathematica example, solve returns the same two answers, although displayed in a different manner.

Below is and example of when only one argument needs to be sent to solve.

Example:


> solve(x^2-x+1=0,x);

                                    1/2               1/2
                       1/2 + 1/2 I 3   , 1/2 - 1/2 I 3

>  solve(x^2-x+1);    

                                    1/2               1/2
                       1/2 + 1/2 I 3   , 1/2 - 1/2 I 3

> solve(x^2-x+1+y);

                                          2
                           {x = x, y = - x  + x - 1}

solve will let you drop the variable, in this case x, and the =0 if there is no ambiguity in the equation. When solve does encounter an ambiguity it may just return a trivial answer which is shown in the third line of the example above.

References

[Rob96] Engineering Mathematics with Maple
John S. Robertson
McGraw-Hill, New York NY (1996).

[NW96] Maple: A Comprehensive Introduction
Roy Nicolaides and Noel Walkington
Cambridge University Press, New York NY (1996).

Last Modified: 97.08.18 Michael Carreno <mcarreno@cs.princeton.edu>