Matrix Operations

Matrices can by added and multiplied. Matrix multiplication and addition have some properties that mirror addition and multiplication of numbers and some properties that don’t.

The Essentials

Two matrices being added (or subtracted) need to have the same size (the same number of rows and columns). To perform matrix addition, add each component of the first matrix to the corresponding component of the second matrix:

\[ \begin{bmatrix} 1 & 2 & -3\\ 2 & 3 & 4 \end{bmatrix} + \begin{bmatrix} 3 & 5 & 1\\ 1 & 0 & -2 \end{bmatrix} = \begin{bmatrix} 4 & 7 & -2\\ 3 & 3 & 2 \end{bmatrix} \]

When multiplying two matrices, the number of columns of the first needs to be equal to the number of rows of the second. The resulting matrix will have the same number of rows as the first and the same number of columns as the second:

\[ \begin{bmatrix} * & * & * \\ * & * & * \end{bmatrix} \begin{bmatrix} * & * & * & * \\ * & * & * & * \\ * & * & * & * \end{bmatrix} = \begin{bmatrix} * & * & * & * \\ * & * & * & * \end{bmatrix} \]
\[ [ \textcolor{blue}{2} x \textcolor{red}{3}]\;\;\;\;\;\;\;\;\;\;\;\;\;[ \textcolor{red}{3} x \textcolor{ForestGreen}{4}]\;\;\;\;\;\;\;=\;\;\;\;\;\;\;\;\;[ \textcolor{blue}{2} x \textcolor{ForestGreen}{4} ] \]

To perform the matrix multiplication AB, the ith row and jth column of AB is equal to the dot product of the ith row of A and the jth column of B:

\[ \begin{bmatrix} * & * & *\\ \textcolor{red}{*} & \textcolor{red}{*} & \textcolor{red}{*} \end{bmatrix} \begin{bmatrix} * & * &\textcolor{red}{*} & *\\ * & * &\textcolor{red}{*} & *\\ * & * &\textcolor{red}{*} & * \end{bmatrix} = \begin{bmatrix} * & * & * & * \\ * & * & \textcolor{red}{*} & * \end{bmatrix} \]

Matrix addition has a commutative law \( A+B=B+A \), a distributive law \( c(A+B)=cA+cB \), and an associative law \( A+(B+C)=(A+B)+C \). Matrix multiplication has a distributive law \( A(B+C)=AB+AC \) and \( (A+B)C=AC+AB \), an associative law \( A(BC)=(AB)C \), but not a commutative law \( AB\neq BA \)

Example

Practice

For the following two matrices:

\[ \begin{bmatrix} 1 & 2 & 1\\ 2 & 2 & 0\\ 0 & 4 & -2 \end{bmatrix}, \begin{bmatrix} 2 & 2 & 2\\ -1 & 0 & -1 \\ 4 & 0 & 8 \end{bmatrix} \]
  1. Add the two matrices.
  2. Multiply the first times the second.
  3. If the first were a 4 by 3 matrix and the second a 3 by 3 matrix, would you be able to multiply the first by the second? Would you be able to multiply the second by the first? What dimentions would the solution have?

Solutions:

  1. \[ \begin{bmatrix} 3 & 4 & 3 \\ 1 & 2 & -1 \\ 4 & 4 & 6 \end{bmatrix} \]
  2. \[ \begin{bmatrix} 4 & 2 & 8 \\ 2 & 4 & 2 \\ -12 & 0 & -20 \end{bmatrix} \]
  3. You could multiply the first by the second, which would result in a 4 by 3, but not the second by the first.