Sec2-2-BasicMatOps.mws

Linear Algebra Powertool

BASIC MATRIX OPERATIONS

Worksheet by Russell Blyth

> with(linalg):

Warning, the protected names norm and trace have been redefined and unprotected

Enter some matrices

> A:=matrix([[1,-2],[0,3]]);

A := matrix([[1, -2], [0, 3]])

> B:=matrix([[-3,4],[2,1]]);

B := matrix([[-3, 4], [2, 1]])

Try to add A and B:

> A+B;

A+B

Maple treats matrices like functions rather than like variables which have values. You have to "evaluate to a matrix" using the evalm command:

> evalm(A+B);

matrix([[-2, 2], [2, 4]])

Scalar multiplication:

> evalm(2*B);

matrix([[-6, 8], [4, 2]])

Solve a matrix equation:

> evalm(solve(3*X+A=B,X));

matrix([[-4/3, 2], [2/3, -2/3]])

Matrix multiplication uses a new operator, &*

> evalm(A&*B);

matrix([[-7, 2], [6, 3]])

A matrix can be transposed:

> transpose(A);

matrix([[1, 0], [-2, 3]])

Individual entries can be extracted (and computed with):

> d:=A[1,2];

d := -2

>

>