If you have a background in basic Vectors and Matrices - including Matrix Addition, Subtraction, Multiplication, Inverse and Transpose -, you can skip this lesson, but otherwise this should give you a good primer.

Intro to Matrices and Vectors

A matrix is essentially a collection of numbers. It is physically represented as a rectangle of numbers.

$$ \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} $$

A matrix is not exactly just a collection of numbers, in that their position also matters. For example,

$$ \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \neq \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ \end{bmatrix} $$

A vector, on the other hand, is a one dimensional matrix, meaning that it can be represented by a single column/row. Here's what a vector could look like:

$$ \begin{bmatrix} 1 \\ 0 \\ \end{bmatrix} $$

Like with matrices (plural for matrix), the following statement is true:

$$ \begin{bmatrix} 1 \\ 0 \\ \end{bmatrix} \neq \begin{bmatrix} 0 \\ 1 \\ \end{bmatrix} $$

Matrix Operations: Addition and Subtraction

When you add two matrices, you produce another matrix with the same dimensions/shape where each element is the sum of the corresponding elements. You'll see what that means in a second, but an important note is that when adding two matrices, the two must be of the same shape. Here's an example:

$$ \begin{bmatrix} 1 & 2 \\ 0 & 3 \\ \end{bmatrix} + \begin{bmatrix} 0 & 9 \\ 3 & 2 \\ \end{bmatrix}

\begin{bmatrix} 1+0 & 2+9 \\ 0+3 & 3+2 \\ \end{bmatrix}

\begin{bmatrix} 1 & 11 \\ 3 & 5 \\ \end{bmatrix} $$

As you can see, all we need to do is add together elements that are in the same position.

But what about addition as shown below?

$$ \begin{bmatrix} 1 & 2 \\ 1 & 2 \\ \end{bmatrix} + \begin{bmatrix} 1 & 2 & 3 \\ 1 & 2 & 3 \\ \end{bmatrix} = \text{?} $$

Since these two matrices have different shapes, there's no way we can add together corresponding terms, so they cannot be summed.