Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 1

Basic Syntax


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

  1. Use Maple to find the following: (don't forget the ;)
    1. 1+1
    2. 2 to the sixty fourth power
    3. The remainder of 357 when divided by 97
    4. 1.47 divided by 3
    5. 20497512 times 10458629
    6. 16 times the sum of 7 and 1
    7. one over seven
    8. 2 over 14
    9. the sum of 37/9 and 15/376
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);

  1. Try evaluating the following in floating point form:
    1. 3/7
    2. 54/17
    3. 37/9+15/376

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.

  1. After executing the above line, try going back to the previous section and re-evaluating your answers (by pressing enter).

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);

    1. Use Digits and evalf to find exp(1) and Pi to10, 30, 50 and 100 digits.
    2. Find the following to 50 decimal places:
      1. The sum of exp(1) and Pi.
      2. Pi squared.
      3. exp(1) to the 33rd power.

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


Maintained by: JP Amore, 2001