Up to Main Lab Page | Next Lesson - Expressions |
This lesson is intended to introduce you to the basic syntax of Maple.
Maple comes with an extensive online help system and you are encouraged to use
this system.
To get help on a keyword place the cursor on the word and press ctrl F1.
Or us the help menu, try looking at browse.
Pressing F1 gives you the keyword search table.
You can also get help on a keyword by entering ?keyword. So
> ?help
gives you help on help.
When a Maple function is introduced it is not a bad idea to look up help for
that function.
You can save and load your work using the File menu, which contains the
standard Saving and Loading commands.
The default extension for a saved Maple session is '*.ms'.
Commmands are entered at the > prompt.
Lines beginning with a # are comments and are ignored by Maple:
> # This is a comment
Maple processes the command on a line whenever enter is pressed while the
cursor is on that line.
Note that this can become confusing since variables, expressions, functions etc. are only updated when enter is
pressed on the line that contains the definition.
Since you can jump around the worksheet, change things and press enter, the linear order of a conventional
program is lost in an interactive session.
Maple can also execute a worksheet in a linear order automatically by selecting
|Edit| |Execute| |worksheet| menu.
Each command line must end with either ';', ':' or '\',
; | Tells Maple to process the line and print output |
: | Tells Maple to process the line but not print output |
\ | Tells Maple that the command continues on the next line |
NOTE: if you don't end a line with anything Maple will simply ignore it but it will not produce an error.
Copy the following lines into Maple and try pressing enter on them
> 2+2;
> 2-1:
> 2*(1+2)-9/(1+2)+2\
> +5-2;
Maple understands the usual arithmetic operations and parenthesis.
+ | a+b The sum of a and b |
- | a-b The difference of a and b |
* | a*b a times b |
/ | a/b a divided by b |
^ | a^b a to the power of b |
mod | a mod b the remainder when a is divided by b |
Notice how Maple represents divisors as fractions in simplest form.
If we wish, we can tell Maple to give an answer in floating point form (decimal form).
To do this we use the function evalf(x);
evalf tells Maple to evaluate in floating point.
Try the following line:
> evalf(2/14);
We can set the number of digits which Maple reports by using the global
variable Digits.
NOTE: Maple is case sensitive, digits is not the same as Digits.
If we execute the line:
> Digits := 100;
This will tell Maple to report all decimals to 100 places.
Maple also understands many important mathematical constants:
E | The base of the natural logarithm, E ~ 2.718281828... |
Pi | The ratio of the diameter of a circle to its perimeter, Pi ~ 3.141592654.... |
I | The square root of -1, I = (-1)^(1/2) (this allows us to use complex numbers). |
Maple is a Symbolic mathematical package, it tries to keep things in symbolic form as much
as possible. What happens if you don't use evalf? Try
> exp(1)^2;
> evalf(exp(1)^2);
Maple also understands infinity and draws a nice little symbol to represent it.
We will find having a way to represent infinity useful as we progress.
>infinity;
The double qoute symbol "
To represent the last executed command. Repeating qoutes means go back that number
of commands. Thus "" means the result of
two commands ago.
> 1+1;
> %+1;
> %%*2;
Up to Main Lab Page | Next Lesson - Expressions | Top of this Lesson |