An Introduction to Maple for Linear Algebra:

The first order of business is to start up Maple and open a new worksheet. Maple is on the machines in many of the labs, and some of you have a student version with your book. The icon we want says Maple 16 and has a little maple leaf . (Start -> all programs -> Maple 16 -> Maple 16). Close any extra "special tips" menus, etc.

If you don't get a blank document, then go to the file menu and highlight new. Note that there is "document" mode and "worksheet" mode. Go ahead and pick document mode. (The worksheet mode is the older version--for people like me who learned it one way and don't want to have to learn anything new.)

Now tell Maple you want to do some linear algebra. At the slanted prompt type:

with(linalg);

***Every time you start up Maple to work on projects you will need to do this command***

You should now see a long list of linear algebra terms, a few of which you now know. Here is an extremely short tutorial of commands that will be useful for us, with comments following. The commands are often case sensitive, so use capitals where you see them.

The first thing to know is that the slanted prompt / means Maple is expecting what we would call math input. If you want to add some text to your worksheet, the easiest way is to go the buttons at the top and click on “text.” The slanted prompt should go away and you should be able to type in meaningless text. Click the math button to get back to math mode. (I believe that F5 also toggles between these two modes.)

When you get back to the slanted prompt, go ahead and type the following.

v := Vector([2,3,5,4])

The symbol := means set the variable v equal to the vector you see there. The capital V makes it a column vector. Now you can access different components of your vector.

v[3]

v[7]

There are several ways to define a matrix. You can do it one row vector at a time.

M := matrix ([ [1, 0, 3, 5], [3, 3, 3, 4], [2, 3, 4, 5], [1, 0, 4, 1/2] ])

Another way is to use the palettes on the left side of the window. Find the “matrix” button toward the lower end of the menu and select a 4x6 matrix. Then input the entries of A from exercise 3 of your assignment:

A:=

Now try...

M[2,3]

A[3,3]

M

evalm(M)

Think of this last command as evaluating the matrix. Whenever you do some operation to a matrix, Maple does not necessarily show you the result unless you ask for it.

U := gausselim(M)

Recognize this? How about...

R := gaussjord(M)

To solve a system of equations, we usually want to row reduce the augmented matrix. Recall the vector v above. Let's tack it on the end of M in the usual way...

Mv := augment(M,v)

Now there are several ways to solve the system. The standard way is to reduce the matrix to reduced echelon form. To do this type

gaussjord(Mv)

and make a mental note of the solution.

Maple does algebra as well as arithmetic. Try this....

g:= Vector([g1,g2,g3,g4)]
Mg:=augment(M,g)
gaussjord(Mg)

A few more important commands you will find useful for upcoming assignments:

E:= diag(1,2,3,4)

C := inverse(M)

There are a couple of ways to multiply matrices. Matrix multiplication is the period .

S := M .C
evalm(S)

Or we can write

multiply(M,E)

This works for matrix-vector products as well:

multiply(M,v)

M.v

Remember that C is the inverse of M and compute the product

C.v

You might need to take evalm(C.m). The symbol % in Maple means "the previously computed expression" so one cool way to handle this would be

evalm(%)

Where have you seen this before? Make sense? Try this set of commands

H:=diag(1,1,1,1)

MH:=augment(M,H)

gaussjord(MH)

The * symbol used to be scalar multiplication--I think it still is, but I believe you can also use it for matrix multiplication or matrix-vector multiplication. First try:

T := 3*M;
evalm(%);

You can also do this in one step if you want to look at the result right away

evalm(5*M+H.C);

The matrix A from earlier is from exercise #1 of your assignment due today. Just for kicks, why don’t you check your answer to this by asking Maple to compute

nullspace(A)

colspace(A)

rowspace(A)

In each case, Maple gives you a basis for the space in question. If you see different vectors than the ones you wrote down, does that mean you got it wrong? (No. Why?) If you see a different number of vectors that you wrote down for your basis, does that mean you got it wrong?

**

We will eventually need some more commands, but this is enough to get you started. I will supplement each upcoming project with some Maple help tips. The answer to nearly every question about whether Maple can do something is 'yes'. There is an elaborate help system built in, and you can also ask me if I am around.

Full disclosure: The newest version of Maple has an even more powerful linear algebra package available, but I went with the older one because (1) I know it better (2) it tracks more closely with the way we have approached these topics (3) it ironically can't do one thing we will need for an upcoming project. If you go to the help menu it is possible you may see some different commands and different syntax than what you have learned here.