Next: TYPES and TYPE Up: A Short Maple Primer Previous: EQUATIONS

VECTORS and MATRICES

Before starting matrix calculations, load the linear algebra package:

> with(linalg):

Vectors and matrices are created with the commands vector and matrix respectively. A vector (which is not a special case of a matrix) is regarded as a column vector by multiplication. Some examples:


> A:=matrix([[4,34],[-a,sqrt(2)]]):
> a12:=A[1,2]:
> v:=vector([x,-12]):
> w:=v[2]:

The command array can also be used to create a matrix.

Whenever doing matrix calculations the function evalm has to be applied. Matrix multiplication is written &* which has to be surrounded by spaces. Multiplication with a scalar is called * Thus to perform , where the operands are matrices, you type

> A:=evalm(2* transpose(B) &* C + D);

The characteristic polynomial of A with s as variable is obtained by > charpoly(A,s);and > eigenvals(A); gives the eigenvalues of A as an expression sequence. Example:


> B:=matrix([[1, sqrt(2)], [-ln(3), 3]]):
> evalf([eigenvals(B)],5);

                    [2. + .74404 I, 2. - .74404 I]


bondaren@thsun1.jinr.ru