Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 2

Expressions


Up to Main Lab Page Next Lesson - Functions Previous Lesson - Basics

Maple uses the assignment operator := to assign values to variables.
> a:=2*3;
> a;

Note that Maple only updates a line when you press enter, try changing the assignment of a above and pressing enter on both lines in turn.

  1. Find the following for each of a = 1, 57, 36912 and b = 4 and 67
    1. a + b
    2. a*b
    3. a mod b
    4. a^b
    Hint: Since in an interactive Maple session you can jump around you can write the evaluation lines once and then change the values of a and b.

Once an expression has been defined it acts as an alias for its definition, and can be used to define further expressions.
NOTE: Using expressions in this way can become confusing, particularly in an interactive session.

Try the following lines:
> a:=b+c;
> a;
> b:=17;c:=4;
> a;
> c=12;
> a;
> c:=a;
> a;

Maple also allows us to assign variables values which have unassigned variables within them, such an assignment is called an expression.
> a := x^2+3*x+4;
We can then assign a value to the variable
> x := 2;
> a;

    1. Define m as the expression x^2+3*x+4, and n as expression x^3-2*x^2+x-2.
    2. Define p to be the expression m + n and q to be the expression m*n.
      Notice how Maple gives p and q in symbolic form.
    3. Find m, n, p and q at x = 3, 5, 79 and 368.

Anything within single quotes (e.g. 'a') is interpreted by Maple as a literal string. We can unassign an expression by telling Maple to put the variable back to a letter
> a := 'a';
> a;

    1. Clear the value of x.
    2. Redefine n to be the expression x^3-c*x^2+dx-2, where c and d will be undefined constants.
    3. Find p and q.
    4. Find n, p and q at x = 3, 79 and 368.
    5. Find p when x is 3, c is 5 and d is 78.
    6. Find p when x is 3, c is 5. (This should be an expression in d)

Maple also has a command 'restart' to restart a session. This command clears all function and expression definitions.
Clear all the assigned values:
> restart;


Up to Main Lab Page Next Lesson - Functions Top of this Lesson Previous Lesson - Basics


Maintained by: P. Danziger, January 1998