Instructions for Use of Maple in Mathematics 251

The computer program Maple is a powerful tool which can help you solve a wide range of mathematical problems: it can differentiate, integrate, and otherwise manipulate mathematical formulas, perform arithmetic calculations, plot curves and surfaces in two and three dimensions, solve differential equations, and carry out a variety of other useful mathematical operations. At Rutgers, Maple is available on the student computer eden. The instructions in this handout are for a special version of Maple, called xmaple, which is customized to run under the X-windows system. This means that they apply when you are working on an x-terminal connected to eden. Maple is also available on the Windows PCs and Macintoshes in the public labs. Although the commands you use to do mathematics with Maple will be the same on all these machines, there are differences among computers, such as in the way that files are opened, saved, and printed.

Table of Contents

Getting started:

From an x-terminal in one of the public labs (e.g., in ARC) you should log in to eden, then start Maple by typing the command xmaple & (note that ``xmaple'' is in lower case; typing the & allows you to continue using your xterm window for other purposes while Maple is running). A Maple window will open. At the top of the Maple window is the Menu Bar, consisting of a row of menu buttons ( File, Edit etc.). Underneath the row of menu buttons is the Tool Bar, most of which are shortcuts to menu commands. Directly below the Tool Bar is the Context Bar, which consists of more buttons which are shortcuts to menu commands. If you place the mouse pointer on any of these buttons and hold down the left mouse button, a rough idea of what the button does will appear at the bottom of your Maple window. Finally, below the Context Bar is a window with the label Untitled (1). You can now give an instruction to Maple by placing the mouse pointer in this window (just to the right of the prompt >), typing a Maple command, and then typing a carriage return. Maple carries out the command and prints a response. For example, if you type 1 + 1;, Maple will respond with 2. Note that you must type a semicolon after each Maple command, to indicate that you have finished entering the command.

Since you will not be given a Maple manual, you should learn to use Maple by using the built in Help facility. To get help on a particular topic, such as the plot command, type, after the prompt >, the command ?plot;. A window will open describing the basic structure of the command and giving examples of its use. To close this window when you have finished with it, click the left mouse button on the rectangle in the upper left corner of the window and then drag the mouse pointer down, releasing the button when Close is highlighted. Another way to invoke Help is to place the mouse pointer on the word Help at the far right of the Menu Bar, click the left mouse button, and drag the mouse pointer down, releasing the button when the desired item (such as Topic Search) is highlighted. We shall refer to this process as choosing Topic Search from the Help menu. Fill in the Topic box, click the left mouse button on the item that you want, and then click on OK.

To continue, you will need to know some basic commands and syntax of Maple.

Return to the Table of Contents


The operations addition, subtraction, multiplication, division, and exponentiation are indicated by +, -, *, /, ^ respectively. All grouping of expressions is done with the left and right parentheses ( and ). The product xy must be written x*y, not xy or x y; if you type xy, Maple assumes you are referring to a variable called ``xy''. Thus, to enter the expression
(2 x +y 2)/(2 x + e x) +1 into Maple, you type:

(2*x +y^2)/(2*x + exp(x)) + 1;

Note that the exponential function is built into Maple and is referred to as exp. Similarly, Maple knows the functions log, sin, cos, tan, and many more standard functions.

When operating on integers, Maple does exact arithmetic, rather than using decimal approximations. To get a decimal approximation, use the Maple command evalf. The Maple command evalf(4/7,20); produces a 20 digit approximation to 4/7. Typing only evalf(4/7); will produce a 10 digit approximation--as will typing 4.0/7.0;.

Return to the Table of Contents


To help you do algebraic manipulations, Maple has the commands expand, factor, and simplify, which you can learn about by using the Help facility. You can also solve algebraic equations by using the commands solve and fsolve.

Return to the Table of Contents

User-defined Functions and Expressions:

In Maple, x^2 - 2*x +3 is an expression. You can assign a name to this expression for future use by typing g:= x^2 - 2*x +3;. Expressions can contain several variables, as in h:= y*t - sin(y). To evaluate an expression at a particular value, use the Maple command subs. For example, subs(x=2,g); will produce the value 3. (Maple also has a construct called a function, with the syntax f:=x -> x^2 - 2*x +3;. We won't use these, but you might see them in examples on Help screens.)

Return to the Table of Contents


The basic plotting command in Maple is plot. This command has many forms--for example, several functions can be plotted at once--so you should look carefully at the examples given at the end of its Help page to get some idea of its flexibility. There are many other plotting commands in Maple; in this course we will use primarily plot3d and implicitplot. To use some of the plotting commands you must first issue the command with(plots);. For example, this is necessary in order to use the command implicitplot. It is frequently useful to enlarge the size of a plot. To do this, place the mouse pointer in the region occupied by the plot and click the left mouse button. This places a box around the plot and changes the Menu Bar and Control Bar so that new options are offered to manipulate the plot. The plot is resized by placing the mouse pointer at one of the small dots along the edge of the box and dragging the pointer. To enter additional commands, move the mouse down to the next prompt > and click the left mouse button. When viewing three dimensional plots, it is useful to view the plot from different viewpoints. First, place a box around the plot by moving the mouse pointer in the region occupied by the plot and clicking the left mouse button. Now, place the mouse pointer inside the box and while holding down the left mouse button, move the mouse pointer to different positions. A cube will appear which rotates as the mouse pointer moves. When you are at the desired viewpoint, hold down the right mouse button and choose Redraw. Explore the effects of using the Axes and other commands on the Menu Bar. (Note that each time a change is made, you must also use Redraw.)

Return to the Table of Contents

Differentiation and Integration:

In addition to performing basic calculations and evaluating standard functions, Maple can also differentiate and integrate functions. The diff command differentiates expressions. For example, diff(x*sin(x), x); differentiates x sin(x) with respect to x, and either diff(x*sin(x), x, x); or diff(x*sin(x),x$2); gives the second derivative. If you have typed g:=x^2*y;, then diff(g,x); is the first partial derivative of x2 y with respect to x and diff(g,x,y); is the mixed second partial derivative.

The command for both definite and indefinite integration is int. If Maple cannot evaluate a definite integral exactly, numerical integration may be used. Type ?int and ?int[numerical] for details on integration in Maple.

Return to the Table of Contents

Maple Worksheets:

The window which appears when you start Maple is called a Maple worksheet. To complete each computer assignment in Mathematics 251 you are asked to turn in an edited printout of your work; such a printout can be obtained by editing, and then printing, your worksheet. The printout should include only the numerical, symbolic, and graphical output of Maple which is appropriate for the solution of the problems assigned, plus text material in which labels are provided for graphical output and explanations added. Maple includes various editing capabilities which should enable you to produce neat and coherent output, and which we now describe.

To remove an unwanted portion of your Maple worksheet (e.g., a region containing commands that you typed incorrectly or that were not directly relevant to the solution of the exercises), select the region to be deleted by clicking the left mouse button at the beginning, then dragging the mouse across to the end of the portion of the worksheet you wish to delete. The region should now be highlighted. Then choose Cut from the Edit menu. To copy a region to a new location, select the region as above, but now choose Copy from the Edit menu. Then click the left mouse button in the position in which you wish to insert your selected region and choose Paste from the Edit menu.

To insert text, such as a label for a plot, into your worksheet, click the mouse at the beginning or end of the plot and choose Text Input from the Insert menu. Now type your label. To continue using your worksheet, move the mouse pointer down to the next prompt > and click the left mouse button. If there is no prompt, insert one by clicking on the prompt symbol > in the Tool Bar Menu.

Sometimes it is useful to be able to place a comment after a Maple command, rather than insert text elsewhere in the worksheet. To do this, enter the sharp symbol #. Everything typed on a line following this symbol will be considered by Maple to be a comment, and therefore not executed.

To make your worksheet less cluttered, it is a good idea to have Maple suppress the output of various commands, e.g., the command with(plots) or a command given to assign a name to a plot. To do this, end the command with a colon (:), instead of a semicolon (;).

Return to the Table of Contents

Printing your Maple Worksheet:

To print your Maple worksheet, choose Print from the File menu or click on the print button in the Tool Bar (this is the fourth button from the left). A panel will appear with the options ``Output to File'' and ``Print Command'' at the top. Clicking on ``Print Command'' directs your output to the printer, while clicking on ``Output to File'' places your output in a file, whose name is given in the adjacent box (the default is If you wish to change this name, click in the box and type in a new name. Since the file will be a postscript file, the file name should have the form When you have finished making your choices, click on the ``Print'' button.

Return to the Table of Contents

Saving your Maple Worksheet:

If your work is interrupted, you can save your work so that you can later resume where you left off. To save your Maple worksheet, choose Save As from the File menu. Then type the name of the file in which you wish to save your worksheet in the Selection box where the mouse pointer is. (First delete the asterisk.) The file name should have the form something.mws. After you have typed the filename, click on ``OK'' to save the file. Once you have named the worksheet and saved it in a file, you can save further changes by choosing Save from the File menu. Maple automatically keeps track of the filename.

Return to the Table of Contents

Opening a Previously Saved Worksheet:

To open a previously saved worksheet, choose Open from the File Menu. Click on the name of the file you wish to open and then click on OK. If you wish to close one of your open worksheets, make it active by clicking in it, and then select Close from the File menu. Maple will prompt you to save the worksheet if you have changed it since the last save.

Return to the Table of Contents

Ending your Maple Session:

To end your Maple session, choose Exit from the File menu. A box will open, reminding you that all unsaved work will be discarded. If you have saved what you need or wish to exit anyway, click on ``Exit.''

Return to the Table of Contents

Obtaining Copies of the Labs in Worksheet Form:

In some of the labs, you will be asked to simply execute a string of Maple commands to learn what they do. To avoid retyping these commands, you can first obtain a modified copy of the lab in worksheet form. This modified copy will omit instructions and problems and contain only strings of Maple commands you are asked to execute. Once you obtain this file, you can access it by following the instructions in the section Opening a Previously Saved Worksheet: To obtain the file lab0.mws, for example, login to eden, and before starting up Maple, type cp /eden/u8/falk/math251/lab0.mws lab0.mws If you look at the files in your home directory (by typing ls), you should see the file lab0.mws. Now start up Maple and open the file lab0.mws .

Return to the Table of Contents

Useful Commands and Techniques:

If Maple gets hung up in a calculation or is taking too long, click the mouse on the stop button in the Tool Bar menu (fifth button from the right).

Any Maple command previously entered in your worksheet can be re-executed without retyping it in a new location. Simply move the mouse to the position of the command you wish to execute and hit the Return key.

It is often useful to be able to refer later to the result of a computation--the output of some command--in a simple way. To make this possible, simply assign the output of the command to a variable. For example, if you enter a:= evalf(2*Pi); then you can later square the result of evalf(2*Pi); by typing a*a;.

You can assign a name to a plot just as described above for assigning a name to an expression. Several previously named plots can then be displayed on the same graph by using the command display. Type ?plots[display] for details.

If you assign the name a as above and then continue your Maple session, you may want to reassign the name a to another expression. To do so, first unassign a by typing a:='a';. To clear all the assigned variables in a Maple session, type restart;. One common problem is to try to use such a variable without unassigning it, forgetting that is has already been assigned a value. A simple way to avoid this is to issue the restart command before beginning a new problem. This will not change anything on your screen.

Return to the Table of Contents

Getting Help From Other Students:

The purpose of the Maple assignments is partly to learn about Maple, a very useful program for symbolic, numerical, and graphical computations, and partly to help you understand the material in the course. Just as with other homework assignments, it is permissible and helpful to discuss the Maple labs with other students. However, the Maple labs you are turning in are being graded and will be part of your final course grade. It is therefore expected that the work you hand in is your own in the sense that you have personally input everything that appears on your Maple worksheet, using notation that you have determined, in a style and layout that is your own, and with text comments that reflect the way you finally understand what is being asked. In light of the above, it seems highly unlikely that any two students would turn in nearly identical assignments, and if such an event occurs, the students involved would be considered in violation of the policy on academic integrity and subject to university sanctions.

Return to the Table of Contents

Last modified August 26, 1998 by Richard S. Falk,