Raison d'Maple

 Four Properties of Maple

   Here we  intend to provide you with just enough information about the Maple language to give a headstart at using it productively in the problem solving process.  The particular version of Maple that we are using as we describe it is Maple 9 running in Windows  XP or 2000.  You may be using an earlier release on a different platform, but most of what is in this document is still relevant.

 Maple has at least four properties which make it  very useful in problem solving.  

It  is an immediate mode language:  

That means that you can type in commands and execute them, just like in the languages Basic and  Logo.  A Maple command is simply a string of characters ending in a semicolon  ';' or colon ':'.    For example,  the command

>     2+5, factor(x^2+5*x +6),expand((x+y)^2);

7, (x+3)*(x+2), x^2+2*x*y+y^2

>   

 tells Maple to do a sequence of three things: add 2 and 5,  factor  the quadratic, and expand  the binomial.   The strings   factor  and   expand  are called Maple 'words'.  These are names of procedures which have been defined for performing the action (sometimes) suggested by the name on the stuff enclosed in parentheses just  after the word.  That stuff is usually called the 'input' of the word.  The result of performing  the procedure on the input is naturally called the 'output' of the word.  If the command is terminated with a semicolon (colon), the output is displayed (not displayed).

It  is a symbolic and graphical manipulator:  

That means that it is built to work with algebraic expressions and draw pictures.  There is a large vocabulary of  Maple words, such as factor, simplify, and expand which are used to 'symbolically manipulate'  expressions  in the manner you are used to doing with pencil and paper.  There are also a number of plotting words, which are used to draw graphs of functions of  one or two variables,  curves and surfaces.  These drawings can be animated (ie displayed in sequence) to study change. Two of the  plotting words most often used,   plot   and   plot3d , are part of the regular Maple vocabulary.  The rest, and there are several, are found in the the  plots  package, a sort of specialized vocabulary of words which is loaded separately.   

It  is an extensible language.  

What this means is that you can define additional words and add them to the vocabulary.  Initially, there will be little need to do this, except to define functions.   The existing vocabulary is large enough to carry out the solution to many problems.  After awhile, it becomes very useful to be able to add new words to the vocabulary.    If you develop some  words to work on a specialized class of problems, these can be put into a package of words for easy access between worksheets.  Maple comes equipped with several such packages already, including    plots ,     a package of drawing words,  linalg - a very useful package of vector and matrix manipulation words, combinat - a package of words from combinatorics, and  networks  - a graph theory package.

It comes with a worksheet environment -- see below.

We want to learn to use Maple to solve problems.  In order make good use of the language for this purpose, we need to become familiar with the worksheet environnment, get to know the language, and foster our experimental urges.

 The Worksheet:  A handy place to solve problems.

When you click on the Maple Icon in Windows, an untitled worksheet opens up.  Think of it as a clean sheet of paper.  Typically, after awhile, the worksheet will contain a record of the work done to date on the problem or problems you have been working on.  Very often, you might be in a problem-solving team working on the problems.  The worksheet can be given a name and saved onto a disk for later working or for handing in.  The worksheet file consists of a number of cells of three different types:  Input cells, Output cells, and Text cells.

 

  Input Cells:  

 These are started with a right angle bracket '>'.  Here are a couple.

>     

>     

An input cell  is the place where you put the 'commands' or 'statements' you want Maple to execute.  The cell can contain one or more statements, each ending with a semicolon. The nice thing about these cells in a worksheet is that they can be modified and reexecuted over and over again.  This enables you to correct typing mistakes with relative ease.  For example, suppose I wanted Maple to calculate   '3*(4+5*3)*(7+6);'  but left out a parenthesis.

>    3*(4+5*3)*(7+6 ;

Syntax error, `;` unexpected

>   

 An error message  is generated which may help you find your  mistake.  So you can make a change in that input cell and reexecute it.   Use the  mouse to put the cursor at the spot where the error occurs and make the correction

You can also use this ability to change and reexecute input cells to  change the numbers in whatever problem you have worked out a solution to  and see how the solution is affected.  

Output Cells:  

Almost every input cell, when executed, gives an   output cell  containing the results of the calculations.  It is appended to the input cell which produced it.  For example, let's add 3 to the 23rd and 4 to the 12th -- then let's factor the result into prime factors.

>     s := 3^23 + 4^12;

>     ifactor(s);

s := 94159956043

``(727)*``(129518509)

>   

You inspect the output cell to see if it is what you want. If it is not, then go back and change the input cell, and reexecute it.  

Certain Maple words such as   plot   generate a separate window containing a picture or a page of text (see factor in the next section).  You can copy and paste these items into an output cell of your worksheet if the need arises.  

>    plot(x^3-x+4, x=-2..2);  

[Maple Plot]

>   

Exercise:   Execute the following   plot  command.  Then   copy  the graph from the plot window (use the   Edit Menu  in that window) and   paste  it  into your  worksheet.

>     plot(x^3-x+4,x=-2..2);

[Maple Plot]

>   

    Text or Comment Cells:   

A   Text  Cell   is to record remarks and explanations of the solution to the problem you are working on.  All of the comments here are typed into text cells.  It is a good idea to be liberal with text cells.  Undocumented calculations are for the most part worthless to anyone but the person who made the calculations, and even then the value is a rapidly decreasing function of time.   

You have very good control over the cells in your worksheet with the Menus at the top of this worksheet.  Depending on what platform you are using (Windows, X, or Mac), the menus may vary in their titles, but the effects are the same with minor differences:

  You change an input cell to a text cell and back again.   

  You can split a cell (input or text) and join cells.

  You open up new cells (input or text) between existing cells.

  You can erase cells (input, text, or output) at your discretion.

You can copy cells (input or text) and paste them into another location.

These controls make it relatively easy to work away on a worksheet, doing computations, recording observations, explanations, etc and then go back and polish the worksheet up into a public document.

 

The worksheet does not replace pencil and paper or the chalk board in the problem solving process.  When you are in the middle of analyzing a problem and deciding how to solve it, these tools are extremely useful.  It is easier to draw a rough diagram by hand than by Maple.  After you have decided on a plan and need to do some numerical calculation, some symbolic manipulation, or some plotting to carry out the plan, then a knowledge of the Maple language becomes useful.

Get to know the language  

   Maple has a large built in vocabulary of words especially defined to carry out many of the algorithms you have learned in your previous math classes.  There  are Maple words like   factor ,   expand ,   simplify , etc.  You can learn about them with online Help .   

There is a  Browser available in both X and Windows Maple which  has the Maple vocabulary nicely indexed by category.   Alternatively, you can ask for help in an input cell.

For example, to find out about   factor  just type

>    ?factor

>   

Knowing the word is one thing, but you also need to know the syntax   of the word.  What is syntax?  Every algorithm requires certain input information in order to be performed.  After it has been performed, certain output information is produced.  To know the syntax of a Maple word is to know the input information needed and the output information produced by the word.  The help screen gives you the syntax of  the word, and thus tells you how to use it.  For example, the help screen for    factor  tells us (in CALLING SEQUENCES) that there are one and possibly two inputs needed and one output produced by factor.  The most useful part of the help screen is the bottom part, where there are examples of the usage of the word in question.  These examples can be copied into a worksheet and tested out, which gives you a chance to develop a feel for the word by experimenting with its use.  In fact, there is a Maple word   example  which brings up a page of examples of the  usage of the word, in many cases.

Problems:

Exercise:   Discover the difference between    factor  and   ifactor  using    ?ifactor .

>   

>   

Exercise:   Use    ifactor  to factor your social security number.  

>   

>   

Exercise:    Use   nextprime   to find the first 30 primes after 5000.

>   

>   

Exercise:    How do   collect ,   coeff  and   expand  work?   Use them to expand    (x+2*y)^4  , collect the result into a polynomial in x, and find the coefficient of the   x^3  term of that result.

>   

>   

 Experiment!

  Experimentation is a prime source of learning.  We are constantly conducting little experiments, learning from them, and using that knowledge in some way. The same holds true when you are learning Maple and/or working on some math problem.  The help facility is a great aid to experimentation.  Say you are working on a math problem and you need to carry out some algorithm, like solve an equation you have set up.  You know the Maple word   solve  will carry out the algorithm, but you have forgotten the syntax.  You can use the word   example   to list some examples of its usage, rather than bring up the entire help sheet on   solve .  

>    example(solve);

>   

 Keep in mind that the help sheets are written for general use by both novices and experts, so don't be intimidated by unfamiliar terminology.  Often the examples at the bottom of the sheet suffice to tell you what you need to know.  Keep using help!    

 

Problems

Exercise:   Spend a few minutes with the online help deciding  what the terms  list  and    set     mean in Maple.  In particular, what is the main difference between a list and a set?

>    example(list);

>    example(set);

Exercise:   If you haven't already, find out the usage of the terms   seq ,   NULL ,   subsop  as used in the example sheet for set and list.

>   

>   

Experiment is used at the beginning of solving a problem to generate data to conjecture a solution.  Towards the end of the process, experiment is used to test the solution.  Maple makes the act of experimentation easier to carry out and easier to modify. A Maple Worksheet makes it easier to carry on work from one session to the next, and to prepare public documents, ie, homework assignments, reseach papers, etc for public consumption.