What Is Maple?: Using Math Software Under UNIX
What Is Maple?: Using Math Software Under UNIX
Introduction
What is Maple?
Maple is a computer program for people doing mathematics. Using Maple to do your calculations should make the work more interesting, allow you to focus more on the concepts, and help you to avoid silly calculation mistakes.
File -> Open Choose the file menu, and select Open. a := 5; a := 5 Input to be typed at the Maple prompt. Output from Maple. An important tip.
q q
On Macintosh computers, go to Apple Menu -> Statistics and Math -> Maple V Release 5.1 (PowerPC). On UNIX workstations, the X windows version is invoked by the command xmaple &. Maple is also available on most IU central systems - see the Availability page.
Other operating systems have a similar toolbar. Every time you work with maple, you will use a "worksheet". The worksheet is the big, blank area in the middle of the screen. You may have more than one worksheet open at a time. The following toolbar buttons let you work with the worksheet. The first four buttons on the toolbar, in order, do the following: open a new, blank worksheet; open an existing worksheet; save the current worksheet; and print the current worksheet. The next three buttons are the standard cut, copy, and paste functions. The next two buttons let you "undo" and "redo" your last action. The next three buttons let you manage what "mode" Maple is currently in. The standard mode is represented by the capital Sigma button. This means that anything you type will be considered to be mathematical input. If you click the capital T, Maple switches to Text mode. Anything you type will be considered as text commentary, and Maple won't try to treat it as math. To switch back to math input mode, click the [> button. Notice that the prompt in the worksheet window changes to let you know what mode you are in.
The next two buttons let you un-indent and indent lines in your worksheet. The next button has a stop sign on it. It is used as a "panic" button. If you start a computation and you would like to stop, click the stop sign. (Cntl-C will also do this.) The next three buttons control the amount of zoom.
The Kernel
The kernel is the part of Maple that does the actual calculation. The kernel is invisible, but you do need to know about it. You talk to the kernel by typing mathematical statements and commands at the Maple prompt. Here is an example.
If you're using a graphics-enabled browser, you'll notice that input appears in red. Output from the kernel appears in blue, with variable names in italics. The Maple prompt looks like [>. The kernel will execute when you press the Enter key. The kernel decides what to execute by looking at the current execution group. An execution group is a set of input lines connected (along the left-hand margin) by a long, thin [. When you press Enter anywhere in the execution group, the entire group is executed. By default, each input line (along with its output) is an execution group unto itself. You can join execution groups together using the F4 key, or split them apart using the F3 key. Execution only occurs when you press the Enter key, or if you choose Edit->Execute->Worksheet. Execution does not occur when you open a worksheet.
Worksheets
The worksheet is the basic unit of work in Maple, like a document in a word processor. A worksheet stores every line of input and every line of output. To save your worksheet, choose File->Save As. To open a worksheet, choose File->Open. You may have more than one worksheet open at a time. However, they all share the same kernel. So any work you do in one worksheet is accessible from another open worksheet. This can lead to confusing results.
*, /
Multiplication, division
8 ^, sqrt Power, square root 2^3; sqrt(2); 2^(1/2); evalf(7/3); 2.333333333 7.0/3; 2.333333333 2 + 3*I; (2*I)^2; evalf(Pi); %; %%%; 2+3I -4 3.141592654 3.141592654 -4
evalf, .
I,Pi
%, %%
Some syntactical caveats: q Maple is case sensitive. foo, Foo, and FOO are three different things. q Using the % operator can give confusing results. It always returns the last output from the Kernel, which may have nothing to do with where the cursor is (or which worksheet is active). q If Maple doesn't recognize something, it will assume it is a variable. For example, typing i^2 will give you i2, while you may have wanted -1. q You can move your cursor up to a previous line, press Enter, and the line will re-execute. q When copying and pasting using a mouse, by sure to also highlight the execution group symbol ([). If you don't, the lines will be pasted in reverse order due to a bug. q Spaces are optional. q Greek letters may be entered by spelling their name. For example, alpha is always displayed as , and Gamma is displayed as (note upper-case).
p := k /(x+y);
k := 'k'; simplify(p);
k y
solve(p=3,x);
2,6
dpdx := diff(p,x);
dpdx := 2x - 8
int(p,x);
subs(x=4,p); subs(x=t^2,p);
-1 t4 - 8t2 + 15
The subs command substitutes expressions into other expressions. Notice that p's value is unchanged.
Each of the commands listed here has many powerful, advanced features. See the help files for more information. Use the restart; command to unassign all variables, reset built-in variables (such as Digits) to their original values, and unload all packages. Of course, this should be used with care.
f := x -> x^2; f := x -> x2 This defines f to be a function, such that f(x) = x2. f(3); f(t); 9 t2 The function works as standard notation.
A common mistake is to write f(x) := x^2;. This does not define a function. Instead, it makes the four characters on the left an abbreviation for the three characters on the right. Functions are often more useful than expressions. However, many Maple commands (for example, diff) expect an expression as input. If f := x -> x^2, then diff(f,x); doesn't work. However, diff(f(x),x); will work, since f(x) produces the expression x2. To convert an expression into a function, use the unapply command. p := x^3 + 1; p := x3 + 1 f := unapply(p, x); f(3); f := x -> x3 + 1 28
Using packages
When you first load Maple, it knows how to execute several different functions. For example, we used the evalf and simplify functions without having to load them first. Maple comes with a huge number of other useful functions, bundled up in units known as packages. Maple has a modular design -- not all of
http://pytheas.ucs.indiana.edu/~statmath/math/maple/gettingstarted/printable.html (7 of 10) [3/30/2000 11:01:37 AM]
its functions are loaded at startup. The more specialized capabilities must be explicitly loaded. For example, if you want to work with matrices and vectors, you would want to load the linalg package. with(linalg); The output from with is a list of the new commands that you now have access to. If you don't want to see the list (which can be rather long), use a colon as your end-of-line marker. with(linalg): Even if you use a colon, you may see warning messages. These usually indicate that a command has a new definition. In most cases, this should not be a concern. Some Maple functions are not in packages; instead, they are stored in the older library format. For example, to add the multivarate Taylor series function, mtaylor, use the command readlib(mtaylor); Go exploring among the packages. These are some of the most commonly used packages: student Includes commands for use in a classroom/homework setting. plots Tools for graphics, 3-d, animation, and visualization. linalg Matrices, vectors, and many linear algebra functions. detools Tools for working with ODEs and PDEs. To get a comprehensive list of available packages, choose Help->Introduction, then browse to Mathematics->Packages->Overview.
Basic Plotting
Maple can produce graphs very easily. Here are some examples, showcasing the basic capabilities.
plot([x, x^2, x^3], x=-2..2); Plot multiple expressions by enclosing them in brackets.
You can control where plots are drawn by choosing Options->Plot Display->Inline or Window. Either way, if you select a plot with the mouse, you can use the toolbar to change the rendering style, axes, and lighting. To copy a plot to the clipboard (as a graphics file), right-click (or Option-Click for Mac users) on the plot and select Copy. Look into these commonly used plotting commands: textplot, textplot3d Draw text anywhere in a plot display Display several plots at once animate, animate3d Adds a dimension of time to your plot. plotoptions Various options, including line weight, color, sampling, etc.
Further Reading
For further guidance as a new user, try the tour. Choose Help->New User's Tour. Other sources of information include:
http://pytheas.ucs.indiana.edu/~statmath/math/maple/gettingstarted/printable.html (9 of 10) [3/30/2000 11:01:37 AM]
q q q q
The UITS Knowledge Base UITS Education Program Software Manual Locations If you are affiliated with Indiana University, you may also get use Stat/Math Consulting .
Permission to use this document is granted so long as the author is acknowledged and notified. Please send comments and suggestions to:[email protected] Copyright 1995-1999, Indiana University. Last modified: Wednesday, 01-Mar-2000 16:42:46 EST URL /~statmath/math/maple/gettingstarted/printable.html