15th century printers pioneered the use of movable type printing. Mirror images of each letter were cast in metal. These were arranged, letter by letter, in frames which printed one page at a time. A frame was called a matrix, several frames were called matrices. In mathematics, a matrix is a frame used to hold numbers or variables. Matrices were used before computers were invented but the advent of computers has made the use of matrices much more common.

A 2x2 matrix looks like this $\begin{bmatrix} 1 & 2 \\[0.3em] 4 & -3 \end{bmatrix}$

Matrices are always rectangular and can be any size. The size of an array is called its order.

Matrices are generally represented by capital letters and the individual numbers, called elements, are represented by lowercase letters. Annoyingly, the subscripts are written row then column.

$A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$

**Figure 9.0:** Matrix $A$ with elements $a_{ij}$

You can add and subtract matrices of the same order. To add two matrices together you need to add the corresponding terms.

If $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ and $B=\begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ | ||

then $A+B$ | $=$ | $\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}+ \begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ |

$=$ | $\begin{bmatrix} a_{11}+b_{11} & a_{12}+b_{12} \\[0.3em] a_{21}+b_{21} & a_{22}+b_{22} \end{bmatrix}$ |

**Example 9.1**: Find $A+B$ given $A=\begin{bmatrix}
1 & 3 \\[0.3em]
-5 & 2
\end{bmatrix}$
and $B=\begin{bmatrix}
-2 & 4 \\[0.3em]
3 & 1
\end{bmatrix}$

$A+B$ | $=$ | $\begin{bmatrix} 1+-2 & 3+4 \\[0.3em] -5+3 & 2+1 \end{bmatrix}$ |

$A+B$ | $=$ | $\begin{bmatrix} -1 & 7 \\[0.3em] -2 & 3 \end{bmatrix}$ |

To subtract one matrix from another you need to subtract the corresponding terms.

If $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ and $B=\begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ | ||

then $A-B$ | $=$ | $\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}- \begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ |

$=$ | $\begin{bmatrix} a_{11}-b_{11} & a_{12}-b_{12} \\[0.3em] a_{21}-b_{11} & a_{22}-b_{22} \end{bmatrix}$ |

**Example 9.1a**: Find $A-B$ given $A=\begin{bmatrix}
1 & 3 \\[0.3em]
-5 & 2
\end{bmatrix}$
and $B=\begin{bmatrix}
-2 & 4 \\[0.3em]
3 & 1
\end{bmatrix}$

$A-B$ | $=$ | $\begin{bmatrix} 1-(-2) & 3-4 \\[0.3em] -5-3 & 2-1 \end{bmatrix}$ |

$A-B$ | $=$ | $\begin{bmatrix} 3 & -1 \\[0.3em] -8 & 1 \end{bmatrix}$ |

To multiply a matrix by a scalar you multiply each of the elements by the scalar.

If $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ and $c$ is a scalar then $cA=\begin{bmatrix} ca_{11} & ca_{12} \\[0.3em] ca_{21} & ca_{22} \end{bmatrix}$

**Example 9.2**: Given $A=\begin{bmatrix}
1 & 3 \\[0.3em]
-5 & 2
\end{bmatrix}$
and $c=3$ find $cA$.

$cA$ | $=$ | $\begin{bmatrix} 3\times1 & 3\times3 \\[0.3em] 3\times(-5) & 3\times2 \end{bmatrix}$ |

$cA$ | $=$ | $\begin{bmatrix} 3 & 9 \\[0.3em] -15 & 6 \end{bmatrix}$ |

You can multiply two matrices **iff** (iff means if and only if) the number of columns in the first matrix is equal to the number of rows in the second.

If $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ and $B= \begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ then the matrices can be multiplied together because the number of columns in $A$ is the same as the number of rows in $B$.

To multiply $A$ by $B$ we take the first column of $B$ and put it over $A$, multiply then sum the corresponding terms.

If $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ and $B=\begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ | ||

then $A \times B$ | $=$ | $\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix} \times \begin{bmatrix} b_{11} & b_{12} \\[0.3em] b_{21} & b_{22} \end{bmatrix}$ |

$=$ | $\begin{bmatrix} a_{11} \times b_{11} + a_{12} \times b_{21} & a_{11} \times b_{12} + a_{12} \times b_{22} \\[0.3em] a_{21} \times b_{11} + a_{22} \times b_{21} & a_{21} \times b_{12} + a_{22} \times b_{22} \end{bmatrix}$ |

**Example 9.3**: Find $A \times B$ given $A=\begin{bmatrix}
1 & 3 \\[0.3em]
-5 & 2
\end{bmatrix}$
and $B=\begin{bmatrix}
-2 & 4 \\[0.3em]
3 & 1
\end{bmatrix}$

$A \times B$ | $=$ | $\begin{bmatrix} 1 & 3 \\[0.3em] -5 & 2 \end{bmatrix} \times \begin{bmatrix} -2 & 4 \\[0.3em] 3 & 1 \end{bmatrix}$ |

$=$ | $\begin{bmatrix} 1 \times (-2) + 3 \times 3 & 1 \times 4 + 3 \times 1 \\[0.3em] -5 \times (-2) + 2 \times 3 & -5 \times 4 + 2 \times 1 \\[0.3em] \end{bmatrix}$ | |

$A \times B$ | $=$ | $\begin{bmatrix} 7 & 7 \\[0.3em] 16 & -18 \end{bmatrix}$ |

Matrix division does not exist. If you want to find $X$ in the matrix equation $AX=C$ where $A$, $X$ and $C$ are matrices you first need to find the inverse of matrix $A$. When you multiply $A$ by it's inverse, $A^{-1}$, the result is the identity matrix, that is a matrix with $1$s on the main diagonal and $0$s everywhere else.

The inverse of $A$ is $A^{-1}$ where $A \times A^{-1} = I$

If $A$ was a $3\times3$ matrix $I$ would be
$\begin{bmatrix}
1&0&0\\[0.3em]
0&1&0\\[0.3em]
0&0&1
\end{bmatrix}$

Having found $A^{-1}$ we can write:

$A X$ | $=$ | $C$ |

$A A^{-1} X$ | $=$ | $CA^{-1}$ |

$A A^{-1}$ | $=$ | $I$ |

so $X$ | $=$ | $CA^{-1}$ |

The determinant of a matrix can be thought of as the magnitude of the matrix. You can only calculate determinants for square matrices. For a 2x2 matrix, $A=\begin{bmatrix} a_{11} & a_{12} \\[0.3em] a_{21} & a_{22} \end{bmatrix}$ the determinant is given by $a_{11} \times a_{22} - a_{12} \times a_{21}$.

**Example 9.5.1**: Find the determinant of $A=\begin{bmatrix}
1 & 3 \\[0.3em]
-5 & 2
\end{bmatrix}$.

$|A|$ | $=$ | $ 1 \times 2 - 3 \times (-5)$ |

$|A|$ | $=$ | $17$ |

To find the determinant of a 3x3 matrix take each term in the top row one at a time. Ignore the row and column that contain the term.

What is left is a 2x2 matrix that we can evaluate as shown above.

At the end of this first step we have

$a_{11} \times (a_{22} \times a_{33} - a_{23} \times a_{32})$

For the next step we take $a_{12}$. We ignore the top row and middle column which gives us

$a_{12} \times (a_{21} \times a_{33} - a_{23} \times a_{31})$

There is an added complication. The signs on the top row alternate as shown below.

This means we need to change the sign of the middle term. If it is negative we make it positive. If it is positive . . .

We repeat the process for the last term so we giving us the determinant of $|A|$ as:

$a_{11} \times (a_{22} \times a_{33} - a_{23} \times a_{32})$ | ||

$|A|$ | $=$ | $-a_{12} \times (a_{21} \times a_{33} - a_{23} \times a_{31})$ |

+$a_{13} \times (a_{21} \times a_{32} - a_{22} \times a_{31})$ |

**Example 9.5.3**: Find the determinant of $A=\begin{bmatrix}
2 & 5 & 3\\[0.3em]
-1 & 6 & 2\\[0.3em]
3 & -1 & 2
\end{bmatrix}$.

$2 \times (6 \times 2 - 2 \times (-1))$ | ||

$|A|$ | $=$ | $-5 \times (-1 \times 2 - 2 \times 3)$ |

$+3 \times (-1 \times (-1) - 6 \times 3)$ | ||

$=$ | $2 \times 14 -5 \times (-8) +3 \times (-17)$ | |

$=$ | $28 + 40 - 51$ | |

$|A|$ | $=$ | $17$ |

The question should really be 'Where do we not use matrices?' There was a time when matrices were only used in specialist applications like mathematics and quantum mechanics but since computers became commonplace matrices underpin pretty much every computer application.

The name of the popular program MatLab is a concatenation of Matrix Laboratory. Artificial Intelligence, neural networks, statistical, drafting, analysis and modelling software are all based on matrices.

Computer graphics would be virtually impossible without the use of matrices. You can easily imagine a computer display as a 2D matrix but computer graphics, using matrices, take it a lot further than that. Movement in 3D, reflection of light, the shadows are all calculated using matrices. In the still from the film Gravity below the only real items in the image are the faces of the actors. Everything else looks real, moves as if it is real but is computer generated.

Imagine you have the 2D coordinates of an object in an array $A$. To scale the object you would multiply $A$ by the scaling matrix $S=\begin{bmatrix}S_x&0\\[0.3em]0&S_y\end{bmatrix}$.

To rotate $A$ you would multiply by the rotation matrix $R=\begin{bmatrix}cos(\theta)&sin(\theta)\\[0.3em]-sin(\theta)&cos(\theta)\end{bmatrix}$

This video shows how characters are animated by the film company Pixar.