10. Operations on matrices

We will use the following operations of matrices:

Addition

To add two matrices they need to have the same size. We add matrices by their coefficients, e.g.:

    \[\left[\begin{array}{cc}1&2\\3&-1\\2&4\end{array}\right]+\left[\begin{array}{cc}-1&4\\-5&2\\0&1\end{array}\right]=\left[\begin{array}{cc}1-1&2+4\\3-5&-1+2\\2+0&4+1\end{array}\right]=\left[\begin{array}{cc}0&6\\-2&1\\2&5\end{array}\right]\]

Addition of matrices is associative and commutative, so for any matrices A,B,C, A+B=B+A and (A+B)+C=A+(B+C).

Multiplying a matrix by a scalar

Simply by coefficients, e.g:

    \[2\cdot \left[\begin{array}{ccc}2&3&1\\-1&2&3\end{array}\right]=\left[\begin{array}{ccc}4&6&2\\-2&4&6\end{array}\right]\]

Because of those operations it is easy to see that the set of matrices of given size is a linear space.

Matrix multiplication

To multiply matrices, the first has to have the same number of columns as the second one of rows. The resulting matrix will have as many rows as the first one, and as many columns as the second one. We multiply the rows of the first matrix by the columns of the second in the sense that in the resulting matrix in a place in i-th row and j-th column we write the result of multiplication of i-th row of the first matrix with the j-th column of the second one, where by multiplication of row and column we mean multiplication of pairs of subsequent numbers summed up. E.g.:

    \[\left[\begin{array}{ccc}2&3&1\\-1&2&3\\0&1&0\\1&0&-2\end{array}\right]\cdot\left[\begin{array}{cc}-1&4\\-5&2\\0&1\end{array}\right]=\]

    \[=\left[\begin{array}{cc}2\cdot(-1)+3\cdot(-5)+1\cdot 0&2\cdot 4+3\cdot 2+1\cdot 1\\ (-1)\cdot(-1)+2\cdot(-5)+3\cdot 0&(-1)\cdot 4+2\cdot 2+3\cdot 1\\ 0\cdot(-1)+1\cdot(-5)+0\cdot 0&0\cdot 4+1\cdot 2+0\cdot 1\\ 1\cdot(-1)+0\cdot(-5)+(-2)\cdot 0&1\cdot 4+0\cdot 2+(-2)\cdot 1\end{array}\right]=\]

    \[=\left[\begin{array}{cc}-17&13\\ -9&3\\ -5&2\\ -1&2\end{array}\right]\]

Matrix multiplication is associative, which means that for any A,B,C, A\cdot(B\cdot C)=(A\cdot B)\cdot C. But is not commutative! Notice that if the matrices are not square it is impossible to multiply them conversely. If they are square the result may be different.

Operations on rows of a matrix and multiplication of matrices

It is worth noticing that the standard operations on rows of matrices can be encoded as multiplication by some special matrices.

Let E_{ij}^n(a) be a n\times n matrix, where the element in the s-th row and t-th column equals to a\in K, if s=i,t=j, 1 when s=t and 0 otherwise.

Let T_{ij}^n be a n\times n matrix, where the element in the s-th row and t-th column equals to 1 if s=t\neq i,j or s=i,t=j or s=j,t=i and 0 otherwise.

Let I_{i}^n(a) be a n\times n matrix, where the element in the s-th row and t-th column equals to a, if s=t=i, 1, when s=t\neq i and zero otherwise.

In other words, E_{ij}^n(a) is the identity matrix with an additional a in i-th row and j-th column, T_{ij}^n is the identity matrix after swapping i-th and j-th rows, and I_{i}^n(a) is the identity matrix where the element on the diagonal in i-th row is changed to a instead of 1.

It is easy to check that given a n\times n matrix A,

  • matrix E_{ij}^n(a)\cdot A is a matrix obtained from A by adding to the i-th row j-th row multiplied by a,
  • matrix T_{ij}^n\cdot A is a matrix obtained from A by swapping i-th row with the j-th row,
  • matrix I_{i}^n(a)\cdot A is a matrix obtained from A by multiplication of the i-th row by a,
  • matrix A\cdot E_{ij}^n(a) is a matrix obtained from A by adding to the i-th column j-th column multiplied by a,
  • matrix A\cdot T_{ij}^nis a matrix obtained from A by swapping i-th column with the j-th column,
  • matrix A\cdot I_{i}^n(a) is a matrix obtained from A by multiplication of the i-th column by a,