Hints for using Maple 6
Syntax
As you type in commands, Maple waits for a semicolon ; or a colon : before
it evaluates the expression. If a colon is entered, the result is not
displayed. This is useful when reading files or defining procedures.
Maple interpretes several characters differently than other programming
languages:
- The colon-equal := is assignment to variables. Note that Maple does not
syntactically distinguish between variables and indeterminates.
Hence x := x+1 will cause a bad crash, because now the variable
x contains the value of x + 1, which is a self-reference.
[In newer Maple versions, such recursion is caught without crashing.]
- The equal sign = designates an equation, which yields an expression,
not an assignment. A common mistake is to write x = 2 meaning
x := 2 instead.
- The percent sign % refers to the result of the last eval
uation, and two %% to the penultimate result.
[In older Maple versions,
the double quote " refers to the result of the last evaluation
(ditto character) and does not deliminate strings.]
- The double quote " deliminates strings, as in "REF.mpl".
The backquote ` deliminates variables names with special characters,
as in `My Documents`.
- The double vertical bar || is string concatenation.
[In older Maple versions, the period . is string concatenation. Thus REF.mpl is actually
the symbol REFmpl. It is now used as the non-commutative multiplication symbol.]
- The single quote ' is used to delay evaluation. Thus 'T' evaluates
to the symbol T rather than the value that T may have been assigned.
- The circumflex ^ is used as the exponentiation operator.
- The pound sign # is used to indicates comments. Everything
following the # sign to the end of the line is ignored.
Unexpected behaviour
- solve returns nothing if the system is inconsistent.
- When a variable is assigned a matrix (from the linalg library),
the variable evaluates to itself, rather than the value. To get
the assigned matrix, you must call evalm.
- Similarly,
evalb tests if the matrices are
at the same storage location; equal tests them
as equal.
- When computing the value of a matrix expression by evalm
you must use &* for matrix multiplication. This is because
Maple assumes that the operator * is commutative and will
perform simplifications before calling evalm.
Useful tricks
- You may obtain help to almost anything that you read. For example,
you can type ?while to obtain the syntax of a while loop.
Even the code that I provide has help files built in, so you can
do ?ref to obtain the specifications of that function.
- The printlevel variable controls how much tracing
information you get. In mathematical computations it is often important
to know how a certain result was obtained. If you set
printlevel:=3 the functions that I write will provide you
with the intermediate results that you will find in the book.
- Producing multiple plots. A plot in Maple is an object that
is assignable to a variable. If assignment is done, it is not
displayed. The plots library package contains a function
display that then allows to view the plots. For example,
to show simultaneously the sin function and 2 points you can type:
plot1 := plot(sin(x), x=0 .. 2 * Pi):
plot2 := plot([[1,2], [3,4]], style=point):
plots[display]({plot1, plot2});
- You can also animate multiple plots by displaying them in sequence.
First, set the Plot Display to a separate Window via the Options menu
on your Maple window. Then display the plot with the option
insequence=true. Finally, Play the plot
by clicking the right mouse button on the plot and selecting
the Animation submenu.
In Maple, as in many languages, one may package a collection
of procedures for purpose of
- avoiding name conflicts of the procedures with the users' variables
- dynamically loading of selected procedures in a package
- accessing the entire package via short names for the procedures
- providing online help, for example, for a package and its procedures
Each purpose is accomplished by Maple by a different command.
- the customary protection mechanism of a name is by
giving the procedures in a package compound names,
such as
`pkg_name/proc_name`, where pkg_name
is the name of the package and proc_name the name of
the procedure. An alternative is to use a subscripted name
pkg_name['proc_name'] for the procedures in the
package. In any case, pkg_name must be protected.
readlib is used to load a previously
saved procedure. The global Maple variable
libname contains the paths to all the directories
that are searched for the procedure.
with ``points'' a selected procedure or an
entire package to their short names. The names
of the procedures in the package are retrieved from a Maple table that has
to be stored in the variable pkg_name before
issuing the with command. Each proc_name
has an entry of the form
pkg_name[proc_name] := 'readlib(`pkg_name/proc_name`)';
or a direct definition
pkg_name[proc_name] := proc...end;
in this table.
?proc_name retrieves the help file from
a library. The help file is stored in the database maple.hdb
by the makehelp command.
©1997, 2001 Erich Kaltofen. Permission to use layout
provided that copyright notice is not removed.