A matrix is a rectangular array of numbers. Here are some examples of matrices: \begin{align} \mathbf{A} = \begin{pmatrix} 4 & -1 \\ 9 & 3 \end{pmatrix} && \mathbf{B} =\begin{pmatrix} 2 & 0 & -5 \end{pmatrix} && \mathbf{C} = \begin{pmatrix} 6 & \tfrac{1\,}{2\,} \\ 1 & 0 \\ -8 & 11 \end{pmatrix} \end{align}
When giving the size of a matrix, we state its number of rows and number of columns, in that order. Matrix $\mathbf{A}$ has two rows and two columns, therefore it is a $2 \times 2$ matrix. Similarly, $\mathbf{B}$ is $1 \times 3$ and $\mathbf{C}$ is $3 \times 2$.
The numbers in matrices (referred to as 'cells' or 'elements') can be any integer, fraction, real or complex number. Matrices are usually labelled using capital letters, to distinguish them from numerical values which are usually given lower-case labels. A general matrix A with $m$ rows and $n$ columns would be written:
\[\mathbf{A} = \begin{pmatrix} a_{11} & a_{12} & \dotso & a_{1n}\\ a_{21} & a_{22} & \dotso & a_{2n}\\ \vdots & \vdots & \ddots & \vdots\\ a_{m1} & a_{m2} & \dotso & a_{mn} \end{pmatrix}\]
The symbol $a_{21}$ represents the element in the second row of the first column.
A square matrix has the same number of rows as columns.
A diagonal matrix is a square matrix with zeroes everywhere except on the diagonal which runs from top left to bottom right.
An identity matrix, sometimes called a unit matrix, is a diagonal matrix with all its diagonal elements equal to $1$, and zeroes everywhere else.
The letter $\mathbf{I}$ is usually used to label identity matrices. We can use a subscript to indicate the size of a particular identity matrix, e.g. $\mathbf{I}_2$.
Here are identity matrices with $2$, $3$ and $4$ rows and columns.
\begin{align} \mathbf{I}_2 &= \begin{pmatrix} 1 & 0\\ 0 & 1 \end{pmatrix} & \mathbf{I}_3 &= \begin{pmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix} & \mathbf{I}_4 &= \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{pmatrix} \end{align}
Two matrices must be compatible for them to added or subtracted. Matrices are said to be compatible when they have the same size.
The sum (or difference) of two compatible matrices is a matrix of the same size, with each element the sum (or difference) of the corresponding elements of the two matrices.
\begin{align} \begin{pmatrix} a & b \\ c & d \end{pmatrix} \pm \begin{pmatrix} e & f\\ g & h \end{pmatrix} =\begin{pmatrix} a\pm e & b\pm f\\ c\pm g & d\pm h \end{pmatrix} \end{align}
Let $\mathbf{A} = \begin{pmatrix} 2 & -1 \\4 & 9 \end{pmatrix}$ and $\mathbf{B} = \begin{pmatrix} -3 & 6\\ 0 & 1 \end{pmatrix}$, then calculate
a) $\mathbf{A} + \mathbf{B}$
b) $\mathbf{A} - \mathbf{B}$
a)
\begin{align} \mathbf{A} + \mathbf{B} &= \begin{pmatrix} 2 & -1\\4 & 9\end{pmatrix} + \begin{pmatrix} -3&6\\0&1\end{pmatrix} \\\\ &= \begin{pmatrix}2+(-3)&(-1)+6\\4+0&9+1\end{pmatrix} \\\\ &= \begin{pmatrix}-1 & 5\\4&10\end{pmatrix} \end{align}
b)
\begin{align} \mathbf{A} - \mathbf{B} &= \begin{pmatrix} 2 & -1\\4 & 9\end{pmatrix} - \begin{pmatrix} -3&6\\0&1\end{pmatrix} \\ \\ &= \begin{pmatrix}2-(-3)&(-1)-6\\4-0&9-1\end{pmatrix} \\ \\ &=\begin{pmatrix}5 & -7\\4&8\end{pmatrix} \end{align}
A scalar multiple of a matrix with a real number (known as a “scalar” because it can be thought of as scaling the matrix) is a matrix of the same size, where each element is the product of the corresponding element from the original matrix and the scalar. \begin{align} \lambda \begin{pmatrix} a & b\\ c & d \end{pmatrix} = \begin{pmatrix} \lambda a & \lambda b \\ \lambda c & \lambda d \end{pmatrix} \end{align}
Let $\mathbf{A} = \begin{pmatrix}4 & -1\\0 &7\end{pmatrix}$, then calculate
a) $2 \mathbf{A}$
b) $-3 \mathbf{A}$
a) \begin{align} 2 \mathbf{A} &= 2\begin{pmatrix}4&-1\\0&7\end{pmatrix} \\ \\ &= \begin{pmatrix}2\times 4 &2\times(-1)\\2\times 0 & 2\times 7 \end{pmatrix} \\ \\ &= \begin{pmatrix}8 & -2\\0 & 14\end{pmatrix} \end{align}
b)
\begin{align} -3 \mathbf{A} &= -3\begin{pmatrix}4&-1\\0&7\end{pmatrix} \\ \\ &= \begin{pmatrix}(-3)\times 4 &(-3)\times(-1)\\(-3)\times 0 & (-3)\times 7 \end{pmatrix} \\ \\ &= \begin{pmatrix}-12 & 3\\0 & -21\end{pmatrix} \end{align}
Two matrices can only be multipled together if the number of columns in the first is the same as the number of rows in the second.
A $p \times q$ matrix can only be multiplied by an $r \times s$ matrix if $q = r$. The resulting matrix will be of size $p \times s$.
Suppose we wish to compute $\mathbf{AB}$, the product of two compatible matrices $\mathbf{A}$ and $\mathbf{B}$. To compute the value of the element $c_{ij}$ in $\mathbf{AB}$, belonging to row $i$ and column $j$, read across row $i$ of $\mathbf{A}$ and down column $j$ of $\mathbf{B}$, multiplying the corresponding elements with each other. The value of $c_{ij}$ is the sum of those products.
It can be easier to think of this process graphically:
\[c_{ij} = \overrightarrow{ \begin{pmatrix} a_{i1} & a_{i2} & a_{i3} & \dots \end{pmatrix} } \left. \begin{pmatrix} b_{1j} \\ b_{2j} \\ b_{3j} \\ \vdots \end{pmatrix} \right\downarrow = a_{i1}b_{1j} + a_{i2}b_{2j} + a_{i3}b_{3j} + \dots\]
Note: Matrix multiplication does not commute: the order of multiplication does matter, and multiplying two matrices the other way round can give a different result. This is a very important fact to remember!
For reference, here are the products of a general $2 \times 2$ matrix with, respectively, a $2 \times 1$ column matrix and another $2 \times 2$ matrix.
\begin{align} \begin{pmatrix} a & b\\ c & d \end{pmatrix} \begin{pmatrix} e\\ f \end{pmatrix} = \begin{pmatrix} ae + bf\\ ce + df \end{pmatrix} \end{align}
\begin{align} \begin{pmatrix} a & b\\ c & d \end{pmatrix} \begin{pmatrix} e & f\\ g & h \end{pmatrix} = \begin{pmatrix} ae + bg & af + bh\\ ce + dg & cf + dh \end{pmatrix} \end{align}
Let $\mathbf{A} = \begin{pmatrix} 4 & -1 \end{pmatrix}$ and $\mathbf{B} = \begin{pmatrix}-2 \\ 5 \end{pmatrix}$, then calculate
a) $\mathbf{AB}$
b) $\mathbf{BA}$
a) \begin{align} \mathbf{AB} &= \begin{pmatrix} 4 & -1\\ \end{pmatrix} \begin{pmatrix} -2\\ 5 \end{pmatrix} \\ &= \begin{pmatrix} 4\times (-2) + (-1)\times 5 \end{pmatrix} \\ \\ &= \begin{pmatrix} (-8) + (-5) \end{pmatrix}\\ &= \begin{pmatrix} -13 \end{pmatrix} \end{align}
Note: Do not write just $-13$. It is still a 1$\times$1 matrix, not a scalar, so should be wrapped in brackets.
b)
\begin{align} \mathbf{BA} &= \begin{pmatrix} -2\\ 5 \end{pmatrix} \begin{pmatrix} 4 & -1\\ \end{pmatrix} \\ \\ &= \begin{pmatrix} (-2)\times 4 & (-2)\times (-1)\\ 5\times 4 & 5\times(-1) \end{pmatrix} \\ &= \begin{pmatrix} -8&2\\ 20&-5 \end{pmatrix} \end{align}
Let $\mathbf{A} = \begin{pmatrix}2 & 0 \\ -1 & 5 \end{pmatrix}$ and $\mathbf{B} = \begin{pmatrix} -2 & 4 \\ -2 & 8 \end{pmatrix}$, then calculate
a) $\mathbf{AB}$
b) $\mathbf{BA}$
a)
\begin{align} \mathbf{AB} &= \begin{pmatrix} 2 & 0\\ -1 & 5 \end{pmatrix} \begin{pmatrix} -2 & 4\\ -2 & 8 \end{pmatrix} \\ \\ &= \begin{pmatrix} 2\times(-2) + 0\times (-2) & 2\times 4 + 0\times 8\\ (-1)\times(-2) + 5\times(-2) & (-1)\times 4 + 5\times 8 \end{pmatrix} \\ \\ &= \begin{pmatrix} (-4)+0 & 8+0\\\\ 2+(-10) & (-4)+40 \end{pmatrix} \\ \\ &= \begin{pmatrix} -4 & 8\\ -8 & 36 \end{pmatrix} \end{align}
b)
\begin{align} \mathbf{BA} &= \begin{pmatrix} -2 & 4\\ -2 & 8 \end{pmatrix} \begin{pmatrix} 2 & 0\\ -1 & 5 \end{pmatrix} \\ \\ &= \begin{pmatrix} (-2)\times 2 + 4\times (-1) & (-2)\times 0 + 4\times 5\\ (-2)\times 2 + 8\times(-1) & (-2)\times 0 + 8\times 5 \end{pmatrix} \\ \\ &= \begin{pmatrix} (-4)+(-4) & 0+20 \\ (-4)+(-8) & 0+40 \end{pmatrix} \\ \\ &= \begin{pmatrix} -8 & 20\\ -12 & 40 \end{pmatrix} \end{align}
To take the transpose of a matrix, the rows and columns of the matrix are switched, so that the first row becomes the first column, the second row becomes the second column, and so on.
For a matrix $\mathbf{A} = \begin{pmatrix}a & b\\c&d \end{pmatrix}$, the transpose, denoted $\mathbf{A} ^\intercal$, is \[\mathbf{A} ^\intercal = \begin{pmatrix} a & c\\ b & d \end{pmatrix}\]
A symmetric matrix is a square matrix which is symmetric about its leading diagonal, for example $\mathbf{A} = \begin{pmatrix} a & b\\ b & c \end{pmatrix}$. Every symmetric matrix has the property $\mathbf{A} = \mathbf{A} ^\intercal$ - it is its own transpose.
Find the transpose of $\mathbf{A} = \begin{pmatrix}3 & 1 \\ 0 & 6\end{pmatrix}$.
\[\mathbf{A} ^\intercal = \begin{pmatrix} 3 & 0 \\ 1 & 6\end{pmatrix}\]
Find the transpose of $\mathbf{A} = \begin{pmatrix} 2 & 9 & 4 \\ 3 & 0 & 1 \end{pmatrix}$.
\[\mathbf{A} ^\intercal = \begin{pmatrix} 2 & 3 \\ 9 & 0 \\ 4 & 1 \end{pmatrix}\]
Hayley Bishop performs matrix arithmetic on two $2\times 2$ matrices.
These workbooks produced by HELM are good revision aids, containing key points for revision and many worked examples.
Test yourself: Numbas test on matrix arithmetic