Book Cover

Introduction to Scientific Programming
Computational Problem Solving Using:
Maple and C
Mathematica and C

Joseph L. Zachary
Online Resources:
Maple/C Version
Mathematica/C Version

Using Maple Worksheet

Click below to download a Maple V worksheet. You can look at the appended non-interactive HTML version of the worksheet to learn what the worksheet covers.

This worksheet is designed to accompany Introduction to Scientific Programming: Computational Problem Solving Using Maple and C by Joseph L. Zachary. In it, we explore the basics of using Maple worksheets.

Worksheets are typically divided into sections. Below, you should see a list of the three sections that make up this worksheet. At the beginning of each section name is a box with a + sign in it. If you click on the + sign, it will turn into a - sign and the contents of the section will appear. If you click on the - sign, it will turn into a + section and the contents of the section will be hidden again.

Using a Worksheet

This is a Maple worksheet, through which you interact with Maple. There are four key elements to a worksheet: text (which gives information to the human reader but is ignored by Maple), commands (which request that Maple do some computatation), results (which display Maple's response to your commands), and formatting aids (which make it easier to read a worksheet).

You can see examples of text, commands, and formatting aids in this worksheet, but no results. To obtain results, you must evaluate the commands that the worksheet contains. To evaluate the command "2+2;" from below, click the mouse so that the cursor (a vertical bar) is somewhere in the command and then press the Return key.

> 2 + 2;

Notice that when you evaluate a command, the cursor jumps ahead to the next command so that you can evaluate it. By repeatedly pressing the Return key, you will eventually evaluate all of the commands in the worksheet. But you don't have to do things in the order dictated in the worksheet, and you can even change the commands that it contains. For example, instead of evaluating the command below, move the mouse cursor back to the command above, change the numbers that it contains (using the Backspace key to delete), and reevaluate it (by pressing the Return key).

The cursor will come back to the command below, which you can then evaluate

> sqrt(9.0);

Generally speaking, Maple ignores any white space (spaces, tabs, or newlines) that you insert into a command. For example, the following version of the prevoius command will work just the same, although it is much less readable!

> sqrt ( 9.0 ) ;

Of course, it won't do to put space just anywhere. You can't put it inside of a single number, and you can't put it inside of a symbol. If you do that, Maple will treat your number (or symbol) as two or more numbers (or symbols).

> sq rt ( 9 . 0 ) ;

You can even use more than one line to write a command.

> 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 +

> 9 + 10 + 11 + 12 + 13 + 14 +

> 15 + 16 + 17 + 18 + 19 + 20;

If you press the Return key without ending your command with a semicolon, Maple will display another ">" prompt at the beginning of the next line. Only when you have entered a semicolon will Maple evaluate your command.

Editing a Worksheet

You can edit a worksheet in various ways. You can remove text, commands, and results by selecting with the mouse and then choosing the "Cut" option from the "Edit" menu at the top of the window.

Try cutting out this line of text.

You can delete a region of a worksheet-an entire text area, an entire command, an entire result-by clicking the mouse in that region and then choosing the "Delete Paragraph" from the "Edit" menu. Instead of evaluating the command below, try deleting it in this way.

> Delete this command-don't evaluate it!

When you're done that, try deleting this text area in the same fashion.

Creating a Worksheet

There are many other options from the menu bar that you can experiment with. We'll turn now to a slightly different topic. So far you have been experimenting with a worksheet that we created. How do you create one yourself?

When you first start Maple, you will be looking at a blank worksheet containing a single prompt, just like the one to below. To issue a command, place the cursor so that it follows the prompt and type the command. Don't forget the semicolon. When you type the "Return" key, the answer will be displayed, followed by a fresh prompt. Enter a command at the prompt below.


Now you're ready to enter the next command. There's one problem, however: how do you insert textual commentary that describes the command that you just entered? To do this, select the square bracket that groups together the command and the result by placing the mouse over it and clicking once. When it is selected, it will be highlighted. Then choose the "Text Input" option from the "Insert" menu. Add a comment to the command above.

It is good practice to put comments, such as these, before each Maple command that you issue. Think of a worksheet as a document that you are writing for someone else to read. It will be much easier for your readers to understand what you did, and why you did it, if you include some explanations. It'll also make it much easier for you to understand your own work the next time you look at it. Although it is a good idea to insert simple comments as you work, you can always go back and put in more informative ones later.

When you hand in Maple assignments, you will be handing in nicely formatted worksheets such as this one. You will, of course, be needing to save your worksheets. To do that, pull down the "File" menu and choose the Save As..." option. A dialog box will appear into which you must type the filename by which you wish to save the worksheet. You will need to type the full pathname under which you wish to save the worksheet into the "Selection" box, and then click on the "Save" option. Ask for help if you don't understand about pathnames-it is somewhat easier to demonstrate than it is to explain.

Once you have saved a worksheet for the first time (or if you read it in under the same name that you wish to save it), you can save it again by choosing the "Save" option from the "File" menu. This option will do the save without asking you anything.

At this point you should experiment with creating your own worksheet from scratch. To obtain a blank worksheet with which to experiment, choose the "New" option from the "File" menu. Experiment with inserting text, commands, and results. When you're done, save it away to your home directory.