Matrix operations, a jump ahead
We begin by formally defining operations of matrices which will permit our equations to be meaningful. As stated above, our equations are to be thought of as
where, in our example, we have
> A:=matrix(3,3,[0,1,2,1,-1,3,2,1,11]),X=matrix(3,1,[x,y,z]),B=matrix(3,1,[1,3,1]);
Clearly, we want the quantity
to denote the column of the three left hand sides of the equations. This suggests that we define the matrix
times the column
as obtained by multiplying each row of
by the column
and stacking up the answers. Further each row times the column is obtained by multiplication of corresponding entries and adding up the result. Thus
More generally a matrix
and a matrix
can be multiplied to produce
where each entry in the
-th row and
-th column of
is produced by multiplying the
-th row of
with the
-th column of
.
It is essential that the rows of
and columns of
have the same sizes. For example:
>
U:=matrix(3,2,[1,2,3,4,5,6]):V:=matrix(2,2,[a,b,c,d]):
op(U),op(V),evalm(U&*V);
Here is a formal precise definition. Let
and
be the entries of the matrices
in the
-position. Then the entry in the
-position of the product
can be defined as
where it is understood that
has
columns and
has
rows. The entries
give the
-th row of
as
runs from
to
, while the entries
, give the
-th column of
.
There is another way of thinking of the product which is very useful. The matrix
can be thought of as three columns augmented together and each is a coefficient of one of the variables. So the equations become:
> A:=matrix(3,3,[0,1,2,1,-1,3,2,1,11]):B=matrix(3,1,[1,3,1]):
> x*submatrix(A,1..3,[1])+y*submatrix(A,1..3,[2])+z*submatrix(A,1..3,[3])=B;
>
Thus in general, we can think of the product
as giving the various combinations columns of
where the coefficients of each combination come from the entries of columns of
.
A similar explanation can be given as combinations of rows of
stacked together. Compare the example above.
All these views have useful applications.
The column combinations noted above, suggest a natural way to add matrices, namely add two matrices together, if they have the same sizes. The rule shall be to simply add the corresponding entries and arrange in the same shape.
Also, if we wish to multiply a matrix by a single number, it seems natural to multiply all entries by the same number. Thus, for example:
> L1:=matrix(2,2,[1,2,3,4]);L2:=matrix(2,2,[4,3,2,1]);
> `L1+L2`=evalm(L1+L2),`3L1`=evalm(3*L1),`2L1-3L2`=evalm(2*L1-3*L2);
>