1. Whenever doing linear algebra on maple, first enter

> with(linalg): 

  1. For a list of commands available in the linalg package

> ?linalg 

  1. For help on any of the linalg commands, enter ?command, for example:

> ?det 

> ?mulrow 

> ?addrow 

> ?matrix 

> ?vector 

> ?multiply 

> ?augment 

  1. To define a matrix A, say 6 by 4 (6 rows and 4 columns) without specifying its entries:

> A:= matrix(6,4); 

  1. Example: to create matrix A while specifying its entries:

A =

6

3

-2

1

8

0

7

2

9

5

4

-3

> A:= matrix(); 

Spaces are allowed but not required. Also, the command may span several lines.

> A[3,4];  shows that -3 is stored in row 3 column 4 of A

> A[3,4]:=9;  stores 9 in row 3 column 4 of A

  1. Some common linear algebra commands. Suppose we have matrices AB, and C

A =

6

3

-2

1

8

0

7

2

9

5

4

-3

 

B =

7

2

0

-5

3

4

2

1

9

6

-7

2

 

C =

7

2

0

-5

3

4

2

1

9

 

> A:= matrix(); 

> B:= matrix(); 

> C:= matrix(); 

> det(C);  gives the determinant of square matrix C

> inverse(A);  gives the inverse of matrix A

> rank(A);  gives the rank of matrix A

> gaussjord(A);  gives the Gauss-Jordan canonical form of matrix A

> augment(A,C);  augments two matrices A and C

> multiply(A,B);  matrix product AB

> multiply(B,A);  matrix product BA

  1. To view an existing matrix:

> evalm(A); 

  1. To multiply row r of matrix A by k:

> A:=mulrow(A,r,k); 

  1. To multiply column c of matrix A by k:

> A:=mulcol(A,c,k); 

  1. To replace row r1 of matrix A by k × (row r1) + (row r2), where k is a constant:

> A:=addrow(A,r1,r2,k); 

  1. To obtain the characteristic polynomial of a square matrix C:

> p:=charpoly(C,x);  calls the resulting polynomial p

  1. To obtain eigenvalues of a square matrix C:

> eigenvals(C,'radical'); 

  1. To obtain eigenvectors and eigenvalues of a square matrix C:

> eigenvects(C,'radical'); 

  1. To solve a linear system of n equations for its n variables, you may define an n x (n+1) augmented matrix and then use the command gaussjord. For example, suppose we wish to solve the following system of 3 linear equations for its 3 unknowns x, y, and z:

6x + 3y - 2z = 1

8x + 7z = 2

9x + 5y + 4z = -3

> M:= matrix();  gives

M =

6

3

-2

1

8

0

7

2

9

5

4

-3

> gaussjord(M); 

1

0

0

142 / 197

0

1

0

-289 / 197

0

0

1

-106 / 197

As long as the identity matrix appears in the coefficient matrix portion, then the rightmost column gives the solution x, y, z.

If you use a decimal point anywhere, the solution will be given in decimal form.

Alternatively, you can solve the linear system Ax = b where A is an n x n coefficient matrix and b is the n-term constant vector by:

> A:= matrix();  defines coefficient matrix A

A =

6

3

-2

8

0

7

9

5

4

> b:= vector([1,2,-3]);  defines constant vector b

> linsolve(A,b);  gives the solution of system Ax = b in vector form

> det(A);  gives the determinant of coefficient matrix A

> AI:=inverse(A);  gives the inverse A-1 of coefficient matrix A and calls it AI

> multiply(AI,b);  multiplies A-1b, which is the solution x of Ax = b

  1. The linalg package has many other commands. For a complete list, enter

> ?linalg;