Department of Mathematics, University of Utah

December, 1995

This document tells how to open a Maple file on the undergraduate lab machines, how to save and reopen files, how to print Maple sessions and plots, and introduces a few basic Maple commands. For further information about Maple commands see

- Multivariable Mathematics with Maple
- Or for an introductory course in Maple try Mathematics 108 .

- What is Maple?
- Starting a Maple File
- Saving Your Maple File
- A Sample Maple Session
- Copying and Pasting with the Mouse
- Printing a Plot
- Pasting a Plot into your Maple Window
- Using Maple Help Files
- Some Higher Dimensional Examples
- Assignment Statements
- Loading Packages
- Editing Your Maple File
- Printing Your Maple Session
- Ending Your Maple Session
- Picking Up Where You Left Off -- Your Second Maple Session

Maple is a general purpose software package containing tools useful in the study of a wide variety of problems. We can use Maple like a calculator to carry out numerical computations or we can use the programming features of Maple to produce a more complicated sequence of computations. In addition to numerical computation, we can do symbolic or algebraic computations in Maple. This software package has built-in functions for solving many kinds of equations, for working with matrices and vectors, for differentiation and integration. It also contains functions which allow us to create visual representations of curves and surfaces from their mathematical descriptions.

Using a software package like Maple gives new ways to think about problems. For example, we can use the computer to run numerical experiments. This means that we can not only look at more realistic versions of standard problems, but we can easily look at many more examples, in the process developing a better intuitive feel for the essential features of a general problem and its solutions. Often these experiments suggest further questions or interpretations that might otherwise go unnoticed. Patterns that appear in these experiments give insight into and motivation for the standard approaches to these problems --- and frequently highlight the limitations of these methods.

In many situations the graphics features of Maple are a useful tool for visualizing the geometric ideas behind important definitions and standard techniques. Again, this goes a long way toward giving a better feeling for the essentials.

In the beginning computing can be frustrating because we are used to dealing with people, who are intelligent and cn undrstond whot u meen evn if it isn't quite right from a literal point of view. Anyway, you will soon get past this stage as the right moves become automatic. Eventually computers will be smarter and better designed, and this will make life easier for all of us.

Before you start learning Maple, it would be helpful if you familiarize yourself with the basics of the Xwindows system used on the lab machines. See the introduction.

Move the cursor into the ** local** window and
type `xmaple & ` to open a Maple window.
Presently the ghost of a new window will appear in a kind of
``dotted outline form.'' Move the mouse to position this window
and click with **left** mouse button when satisfied.
(Try to place windows so that part of the title bar is visible
for each window. Sometimes the mouse
gets a bit wild and hard to control so you may end up with a
window whose title bar is completely obscured. In that case,
you can move and resize windows to get
access to the title bar.) If you need help, ask! Getting used
to the mouse and multiple windows can be very frustrating at
first, especially if you are unwilling to get help when you need
it.

At the top of your ** Maple ** window you
will see several menus. Click on the ** File**
menu with the
left mouse button. To name a Maple file click on the option
**Save As** with the left mouse button.
A **Save Session**
window appears: If the box labelled **Selection**
near the bottom of this window is empty
and you want to save your Maple file under the name `hw1`
(for example), then click anywhere
in the ** Selection** box with the left mouse button and
type `hw1`. Then press the return key or click on the
**Save** box at the bottom of the
**Save Session** window.
(It sometimes happens that the ** Selection** box appears
containing your full computer address. In that case you must place
the cursor at the end of the name that appears in the box (after
the /) and type your file name, etc.)

If this process was successful the name `hw1.ms` should
appear at the top of the Maple window. Maple adds the `.ms`
extension to identify the saved file as a Maple file. To avoid
headaches you should use some care in naming your files. Keep
it simple. Use only letters and numbers in your file names.
Don't use any special symbols and in particular, avoid using
spaces, periods, and hyphens.

All you have done so far is save a blank file. As you
continue working you will need to update your saved file. Do
this by clicking on the ** File** menu and then the option
** Save** in that menu. *Do this frequently.* Power
failures or Maple memory failures can occur * without
warning* at any time. In that case you will lose all work done
since the last time you saved the file.

The following examples give an introduction to a few basic Maple commands and further technical details of using Maple in the Undergraduate Lab.

** Example:** * Find the point of intersection of the two lines
defined by 3x + 2y = 5 and 2x + 4y = 5 in the plane. Use Maple to
find the intersection algebraically and graphically.*

** Solution:**
It is of
course an easy matter to solve this system by hand, but for
larger systems with more equations the help of a machine will be
very welcome.
The first line of your Maple window should contain
the symbol `>`. This is called the Maple prompt. It is an
indication that Maple is waiting for your next command.
To solve in Maple, we write:
`
> solve( { 3*x + 2*y = 5, 2*x + 4*y = 5 } );
`

and Maple
responds with this:
`
{ x = 5/4, y = 5/8 }
`

Except for minor (but important) differences of punctuation,
we formulate the problem for Maple in the same way as we do for
a fellow mathematician. Note that we give the system of
equations as a *set*: a list of items separated by commas
and enclosed by curly braces. This tells Maple to apply the
function `solve` simultaneously to both equations. Typically, a
Maple command takes a set as its argument if the order of the
elements is not important --- in other words, since nothing
about this problem changes if we give the equations in the
other order, we give the list of equations as a set. The
solution is also a set --- its elements are the simplified
equations.

Notice that Maple commands end with a semicolon. Maple is very finicky about such things. It will not carry out any of your instructions until you end the command properly.

For the most part, spacing is not important in a Maple command, although generous use of the space bar makes your commands much easier to read.

If you made some typing mistakes in your command you may have
gotten a ** syntax error**. This means that Maple doesn't
understand your command. With practice you will be able to use
Maple's error messages to get clues about what kind of mistake
you have made but at first they will probably be a bit
mysterious. For example, you may see that you left out one of
the `*` symbols or that you have typed `=`
instead of `+`. To
correct this kind of error you need not retype the entire
command.
You can use the arrow keys to move the cursor back into the
line and then use the backspace key to erase your mistake.
Insert the missing symbol and
press Return. Maple will attempt to carry out your
instructions.
(You don't need to move the cursor to the end of the line.
Maple will just look at the line the cursor is in.) Another
common error is to forget to type the semicolon at the end of
your command. You can move back into the line and add the
semicolon as with the other typos. However, for a mistake like
this you will probably have to enter the command twice before
Maple gets it straight.)

Often you will want to enter a command that is a small variation on an earlier command. In that case instead of retyping you can use the mouse to copy an old command and then paste it onto a new command line. Then you can move the cursor into the command and make modifications.

- Press the
**left**mouse button at the beginning of the text you want to copy. - Hold the button down and drag the mouse until you have blackened the desired text. Release the mouse button.
- Move the cursor to the position where you want to paste.
Click the
**left**mouse button to mark this spot. - Click the
**middle**mouse button to paste.

For example, notice that in our intersecting line problem Maple
gave the result in fractional form. If possible, Maple tries
to use algebraic methods to find solutions exactly. If we
rephrase the question using decimals instead of integers for
even one of the coefficients, then Maple approaches the question
very differently and we get answers in decimal form:
`
> solve({3*x + 2*y = 5.0, 2*x + 4*y = 5});
`

gives
`(1.250000000, 0.6250000000)` as the point of intersection.

Use the mouse to copy and modify the `solve` command
above to get an
answer in decimal form as described above.

You can paste repeatedly---the copied text stays in memory and anytime you press the middle mouse button it will be pasted at the current cursor position. (This can cause some problems for you if you accidentally hit the middle mouse button later on so you may want to copy some blank space to clear the copied text.)

Another way we could use the `solve` command is to solve the
equation 3x + 2y = 5 for y as a function of x:
`
> solve( 3*x + 2*y = 5, y);
`

We see that the line 3x + 2y = 5
is the graph of the function
f1(x) = -3x/2 + 5/2. Maple has a built-in command `plot` for
producing graphs of curves in the plane. To obtain a graph of
the line for
x in [-2, 2] we use the command:
`
> plot( -3*x/2 + 5/2, x = -2..2);
`

In this command we see an example where spacing is
important in Maple; * no space is allowed between the dots*
in this command. A new window, called a **plot** window
should appear in response to this command. This plot can be
printed by itself or it can be pasted into your Maple window to
be printed later (see below).

We have graphed the line given by the first equation and we can
modify our work above to get a plot that contains both lines.
`
> solve( 2*x + 4*y = 5 , y);
`

tells us that the second line
is the graph of the function f2(x) = -x/2 + 5/4 and we can
tell Maple to graph f1 and f2 together:
`
> plot( {-3*x/2 + 5/2, -x/2 + 5/4}, x = -2..2);
`

Again notice the use of
braces to tell Maple to apply the command `plot` to both
functions. We see from the resulting plot that the lines meet at
the point (5/4, 5/8)= (1.25, 0.625) as expected. Use the
**left** mouse button to click on the intersection point; the
coordinates of this point will then appear in the upper left
corner of your plot window.

It is often a good idea to give your plot an explanatory title:

> plot( {-3*x/2 + 5/2, -x/2 + 5/4}, x = -2..2, title = `the lines 3x + 2y = 5 and 2x + 4y = 5`);The quotation mark here is the backquote, located in the upper left corner of the lab keyboard; don't confuse it with the single quote. Also, note that this command is too long to fit on a single line.

You should be aware that Maple chooses the scale on the
x-axis and the y-axis independently. To force Maple to
use the same scale on both axes you can choose the option **
Constrained** in the ** Projection**
menu in the plot window.
Another way to achieve the same thing is to specify the range
of variation for y in your Maple command:

> plot( {-3*x/2 + 5/2, -x/2 + 5/4}, x = -2..2, y = -2..2);or to specify the scaling option in your plot command:

> plot( {-3*x/2 + 5/2, -x/2 + 5/4}, x = -2..2, scaling = constrained);Back to Table of Contents

- In the
**plot**window click on the**File**menu with the left mouse button. - Click on the option
**Print**. A new menu will appear. - Click on the option
**Postscript**. A small window will appear. - If you click on the box labelled
**Confirm**or hit the return key you will create a printable file named`plotoutfile.ps`. - To actually print the plot you must return to the
local window and type
`print plotoutfile.ps`. The plot will be enlarged to fill one standard size page.

* Remark:* The extension `.ps` after a file name should mean
that the file is a `postscript` file. All your plot files and
the printable version of your Maple file are of this type. It
is very helpful to indicate the file type with an appropriate
extension as part of the file name.

Rather than printing the plot out separately you may prefer to include the plot in your Maple window and then print out your entire Maple session instead. This has the advantage that the plot appears with the commands that produced it. To do this

- Click on the
**Edit**menu in the**plot**window. - Click on the option
**Copy**. - Go to your
**Maple**window and place the cursor anywhere in the line that contains the command which produced the plot. - Click on the
**Edit**menu in your**Maple**window and choose the option**Paste**.

Your plot will take up about half a page in the printed version. Often you won't need the plot to be so large. You can make the plot smaller (see directions above for resizing a window) before you paste it into your Maple file.

To get rid of a **plot** window click on the
** File** menu
in the ** plot** window and choose the
** Exit** option. If
you change your mind and you want to get the plot back, just
move the cursor into the command line that produced the plot and
press Return.

In the example above we saw two ways
to use the `solve` command in Maple. Are there others? We can
ask Maple for more information about the `solve` command by
typing `? solve` or `?solve` after the prompt.
If we do this a
** help** window will appear, containing a lot of (probably)
incomprehensible information about the command `solve`. If you
scroll to the end of the ** help** window then you will see a
list of examples. At first these examples won't be very easy to
use but as you get more familiar with Maple these will become
quite useful for figuring out how to get Maple to work for you.

So far we have looked at lines in the plane and we've seen an
example of two useful Maple commands---`plot` and `solve`.
Next we look at some three dimensional examples.

** Example:*** Let P be the plane given by the equation 3x + y
-2z = 2. Use Maple to plot this plane.*

**Solution:** Maple has a built-in command
`plot3d` for drawing
surfaces in 3-space, but we have to describe the surface in the
terms Maple expects. Although we can specify our plane with a
linear equation as above, the command `plot3d` will not accept
this description of P (we would get a syntax error).
However, this plane can also be described as the graph of a
function of two variables, namely as the graph of
f(x,y) = (3x + y - 2)/2. From this description we can get a
plot of P if we specify a range of x-values and of
y-values over which to graph the function f:

> plot3d( (3*x + y - 2)/2, x = -3..3, y = -3..3);This command produces a

> plot3d( (3*x + y - 2)/2, x = -3..3, y = -3..3, axes = boxed );The surface in this case is very simple, but we also need to understand how this 2-dimensional object sits in 3-space. To get a better understanding of this we can turn the surface and look at it from different angles. Click on the plot with the

Try `?plot3d` to bring up the `plot3d` help file;
the examples there give some more interesting surfaces.

Another important feature of Maple, assignment statements, are illustrated next. Assignment statements are used to store an expression or function or other quantity under a name.

** Example:** * Use Maple to solve the system
3x + y -2 z = 1, 2x - 3y + 5z = 2, and 4x - 5y -3z = 3.*

** Algebraic Solution:**
We want to solve a system of equations so we define
these equations in Maple,
using the symbol `:=`(read "gets") to assign a name to each of
them for future reference.

> e1 := 3*x + y - 2*z = 1; e2 := 2*x - 3*y + 5*z = 2; e3 := 4*x - 5*y - 3*z = 3;Then to solve the system:

> solve({e1, e2, e3});

** Geometric Solution:** We can solve the system above
by finding the intersection of the three planes defined by equations
` e1, e2, e3 `. To do this we need to
plot these three planes together; the best approach is to
describe each plane as the graph of a function of
two variables and then use ` plot3d ` to produce the
picture:

> f1 := solve( e1, z); f2 := solve( e2, z); f3 := solve( e3, z); > plot3d( {f1, f2, f3}, x = -2..2, y = -2..2, axes = boxed);

In our examples we have seen a few of the built-in features of Maple. For a list of the functions available in Maple type

> ?libraryIn addition to this standard library of functions there are specialized packages of functions for working with special topics--- for example there is a collection of functions, called the

> with(linalg); # the warning you see is normal --- ignore it > with(plots);For more information type

> ?packagesBack to Table of Contents

Often it will take more than one session at the computer to complete your analysis. You will need to save your work and come back to the lab and open your Maple file again to continue working. Often it will be useful to take with you a printed copy of your Maple session so you can think about what you have done so far and how you want to continue when you come back to the lab or so that you can talk to your instructor or your lab partner about any questions you may have.

Before you learn how to print your Maple session
you should
learn how to clean it up a bit.
In the **Edit** menu of your
** Maple** window you will find some useful commands for this
purpose. For example the option **Delete Cursor Region**
will delete whatever line the cursor is in. Note that holding
down the "control" key while you hit the "delete" key will
have the same effect. This gives you a quick way to erase your
mistakes.

Also in the **Edit** menu you find the option
**Delete by
Type**. Choosing this option brings up another menu. Most of
these choices are rather drastic and self-explanatory. Try the
option ** Delete all Separators**.

It is also a good idea to include some explanations with your
work. There are two ways to do this.
First you can use comments. In any command line, Maple ignores
anything typed after the symbol `#`. So inserting a line like

> solve( 3*x + 2*y - 5*z = 1, z); # Get z in terms of x and y:makes your work much easier to follow. Notice that you can move anywhere you like inside your

Also in the **Edit** menu you find the option
**Insert
Text**. This allows you to type some explanations into your
Maple file. However, editing is very crude and there is no way
to get decent looking mathematical formulas with Maple's text
mode so if you want to say something complicated you may be
better off with a handwritten note. Also be careful using **
Delete Cursor Region** with text. Maple will delete ** the
whole section of text** rather than the line the cursor is in.
(Try **Display Region Boundaries** in the ** View
** menu of
your Maple window.)

- Click on the
**File**menu and choose the option**Save**to update your file. - Click on the
**File**menu; again choose the option**Print**. A**Page Setup Dialog**window will appear. - Click on the box labelled
**OK**at the bottom of this window to create a printable version of your Maple session and store it in a file named`hw1.ps`(assuming that your Maple file is named`hw1.ms`as in the example above). - To actually print your Maple session, you must go to your
**local**window and type`print hw1.ps`.

Go to the ** File** menu and choose the option ** Exit
** to
end your Maple session. If your file contains results you will need
later be sure to update with the **Save** option in the
**File** menu before you quit.

In your work above you created a Maple file and saved it under
the name `hw1`. Our task now is to reopen that file and get
back to where we left off.

- Go to your
**local**window and open a**Maple**window. - Click on the
**File**menu with the left mouse button and select the option**Open**. A**Load Session**window will appear. - In the middle-right of this window you should see a list
of Maple files, including your file
`hw1.ms`. Click on this file name with the left mouse. Then press the Return key or click on the box labelled**Load**.

The easiest way to get Maple to remember what happened last time
is to go to the beginning of your file and hit the Return key
until you get to the last line of the file.
(You might want to use the arrow keys to skip the lines that
displayed plots or requests for help files). This will ensure
that Maple's memory of your last session is restored. The most
important lines to re-enter are the lines where you loaded a
package or read in a file (using the command `with` or
`read`) or
lines where you made assignments (using `:=`).

* Remark:* You will find it inconvenient to work with a Maple
session file that is more than a few pages long. It is a good
idea to start a new Maple file when you begin a new section of
problems.