Here’s the Part 3 of our brief look into Linear Algebra, and we’ll learn about matrix-vector multiplication, matrix-matrix multiplication, as well as some essential matrix multiplication properties to note.


Matrix-Vector Multiplication

In matrix-vector multiplication, the number of columns of the matrix must equal the number of rows of the vector.

$$ \begin{bmatrix} 2&3&2 \\ 3&4&5 \end{bmatrix} * \begin{bmatrix} 3 \\ 0 \\ -1 \end{bmatrix} $$

$$ = \begin{bmatrix} 23& + &30& + &2*-1 \\ 3*3& + &4*0& + &5*-1 \end{bmatrix} $$

$$ = \begin{bmatrix} 4 \\ 4 \end{bmatrix} $$

The result is a vector.

Ideally, a (m * n) matrix multiplied by an (n * 1) vector is a m-dimensional vector, indicating that the resulting vector retains the same number of rows with the multiplied matrix.

You must have now noted how that an (m * n) matrix multiplied by an (n * 1) vector results in an (m * 1) vector.


Matrix-Matrix Multiplication

To multiply two matrices, the number of columns of the first matrix must equal the number of rows of the second matrix.

$$ \begin{bmatrix} 4&1&-2 \\ 3&0&1 \end{bmatrix} * \begin{bmatrix} 2&3 \\ 3&4 \\ 0&1 \end{bmatrix} $$

$$ = \begin{bmatrix} \begin{bmatrix} 4&1&-2 \\ 3&0&1 \end{bmatrix} * \begin{bmatrix} 2 \\ 3 \\ 0 \end{bmatrix} \begin{bmatrix} 3 \\ 4 \\ 1 \end{bmatrix} \end{bmatrix} $$

$$ = \begin{bmatrix} \begin{bmatrix} 42& + &13& + &-20 \\ 32& + &03& + &10 \end{bmatrix} \begin{bmatrix} 43& + &14& + &-21 \\ 33& + &04& + &11 \end{bmatrix} \end{bmatrix} $$

$$ = \begin{bmatrix} 11&14 \\ 6&10 \end{bmatrix} $$

Just as we noted in matrix-vector multiplication, an (m * n) matrix multiplied by an (n * o) matrix results in an (m * o) matrix.

In the above example, a (2 * 3) matrix multiplied by a (3 * 2) matrix resulted in a (2 * 2) matrix.


Matrix Multiplication Properties

  1. Matrices are not Cumulative Let A and B be matrices. Then $$ AB≠BA $$
  1. Associativity Matrices are not associative, that is ((AB)C≠A(BC)) Except for the condition that A is an (mp) matrix, B is a (pq) matrix, and C is a (q×n) matrix, then $$ (AB)C=A(BC) $$
  1. Identity matrices ((I)) have 1 along their diagonals, and 0 everywhere else. $$ \begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&1 \end{bmatrix} $$

For any (matrix A), $$ AI = IA = A $$

Note: Identity matrices can be cumulative.


Continue with “The Flow of Tensors” series in [The Flow of Tensors] — Linear Algebra for Machine Learning (Part 4 of 4).