Maple as a calculator Addition, subtraction, multiplication and division operators (+,-,*,/): 2*(5-8)/(1+16); -6 -- 17 Note that all commands end with a semi-colon (;) or colon ( : , see below). Hit the Enter key to execute your command. The cursor does NOT have to be at the end of the line. Arithmetic is done exactly if possible. Very large integers can be handled. factorial(41); 33452526613163807108170062053440751665152000000000 Obtain approximate decimal expansions of numbers with evalf evalf(-6/17); -0.3529411765 Pi; evalf(Pi); evalf(Pi,75); Pi 3.141592654 3.14159265358979323846264338327950288419716939937510582097494459230781640629 Note: to continue an execution group on a new line, use Shift-Enter instead of just Enter. Note: In the latest version of the graphical interface, your input is formatted as you type. Use the right-arrow key to get out of a sub-expression. Powers, trig functions, etc.: 7^2; 49 sqrt(36); 6 evalf( exp(1) ); 2.718281828 cos(Pi); -1 arctan(1); 1 - Pi 4 Getting information about a command ?arctan A help window will open. Information on arctan and related functions will be accessible. Changing the precision of Maple's approximate "floating point" arithmetic: Digits:=50; evalf(Pi); Digits := 50 3.1415926535897932384626433832795028841971693993751 Assignment (giving names to expressions): a:=-16/7; b:=Pi+a; d:=b^2+c; evalf(d); -16 a := --- 7 16 b := Pi - -- 7 2 / 16\ d := 2 |Pi - --| \ 7 / 1.4650555611944851798880792301764391661308296120316 Restarting the Maple kernel (to clear all assignments): a:=77; a; restart: a; a := 77 77 a Suppressing output of assignments with the colon (:) expression terminator: a:=33; a := 33 a:=34: a; 34 Note that this doesn't work within loops, unfortunately. For the body of a loop, you only have two choices: display all results or display none, depending on whether you use "end do;" or "end do:". For selective display, use "end do:" and "print" the values you want to see. You can clear assignments more selectively than with restart, using unassign: a:=99: a; unassign('a'); a; 99 a Note that the forward quote has to be used in the above. An example of a calculation with Maple: file_bytes:=123e6; file_bits:=file_bytes*8; bits_per_sec:=3e6; transfer_time_in_minutes:=file_bits/bits_per_sec/60; 8 1.23 10 8 9.84 10 6 3 10 5.466666667 A big advantage of Maple over a calculator is that you have an easily editable record of what you have done. Be sure to Save your worksheet frequently: Maple crashes often, and you can lose all your work. ESCAPE ROUTE FROM MAPLE You will at some point in the future no longer be using Maple because there is a free and/or better alternative. You therefore don't want all your thoughts and work locked up in files that you cannot look at without using the Maple program. We can prepare for that day by writing our Maple code in text files instead of Maple worksheets. Using a plain text editor, such as gedit, create a file called "foo.maple" with some Maple commands in it. (You don't have to use a ".maple" extension, anything will do, but ".mw" or ".mws" will be misleading. Once you've entered your commands and saved the file, you can execute the commands from within Maple as follows. > currentdir(); "/orange1/ringland/public_html/337" This shows you what Maple's current working directory is. If necessary change the current directory to the one where your text file resides. You may first need to check the "allow system calls" box in the Tools>Options dialog. > currentdir("/orange1/ringland/public_html/337/testdir"); "/orange1/ringland/public_html/337/testdir" > read "foo.maple"; "Hello" 2 4 DITCHING THE WORKSHEET COMPLETELY If your work does not involve graphics, you can avoid using the Worksheet completely by writing your commands in a text file as above, and then executing them from the command line like this: ringland@ming(51-11:45am)> cat foo.maple print("Hello"); a:=2; a+a; ringland@ming(52-11:45am)> which maple maple: aliased to /eng/tools/maple11/bin/maple ringland@ming(53-11:46am)> maple foo.maple |\^/| Maple 11 (X86 64 LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. > print("Hello"); "Hello" > a:=2; a := 2 > a+a; 4 > quit bytes used=790696, alloc=655240, time=0.01 ringland@ming(63-11:50am)> maple foo.maple > foo.mapleout.txt ringland@ming(64-11:51am)> cat foo.mapleout.txt |\^/| Maple 11 (X86 64 LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. > print("Hello"); "Hello" > a:=2; a := 2 > a+a; 4 > quit bytes used=790840, alloc=655240, time=0.00 ringland@ming(65-11:51am)> |\^/| Maple 11 (X86 64 LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. > print("Hello"); "Hello" > a:=2; a := 2 > a+a; 4 > quit bytes used=790696, alloc=655240, time=0.01 ringland@luthor(56-4:52pm)>