>
with(linalg):
A:=linalg[matrix](3,3,[4,1,-5,-2,3,1,3,-1,4]);
Warning, new definition for norm
Warning, new definition for trace
>
IDM:=matrix([[1,0,0],[0,1,0],[0,0,1]]);
Definition: An identity matrix is a square matrix which has one on the main diagonal and 0 everywhere else, such as the matrix IDM shown above. Multiplying Matrix A by the identity matrix would return the A matrix as expected.
>
C:=evalm(A&*IDM);
We can expand a matrix by using the two commands agument or concat as shown below:
>
a := matrix([[1,2],[2,3]]);
>
b := matrix(2,3,[3,4,5,6,7,8]);
>
augment(a,b);
>
v := vector(2,[1,2]);
>
concat(v,b,v);
In the above examples we create a new matrix by joining a and b, or joing a vector, a matrix and a vector. This is a useful tool for solving equation sytems. See page 223 of the text and the following example.
Suppose you want to solve the following sytems of equations for x1 and x2:
2x1 + 12x2 = 40
8x1 + 4x2 =28
>
a:=matrix([[2,12],[8,4]]);
>
b:=matrix([[40],[28]]);
>
C:=augment(a,b);
By appropriate additions and subtractions for rows and cols, we can reduce the C matrix to:
>
Note that 2 is the solution for x1, and 3 is the solution for x2, and the first part is just an identity
matrix.