Matrices
A matrix is a table or array of numbers or letters arranged in rows and columns. The table is delimited by brackets [ ] or parentheses ( ). The plural of matrix is matrices.
These are four examples of matrices of different sizes: $$$ \begin{pmatrix}1&2&3\\4&5&6\end{pmatrix},\quad \begin{bmatrix}1&x\\1&y\\1&z \end{bmatrix},\quad \begin{pmatrix}1&1\\0&1\end{pmatrix},\quad \begin{bmatrix}1\\0\\-1\end{bmatrix} $$$
The numbers contained within a matrix are called elements or entries.
The order of a matrix is written as $$m \times n$$, where $$m$$ is the number of rows and $$n$$ is the number of columns. This is read as "$$m$$ by $$n$$". The order is also called the size of the matrix.
The matrix $$\displaystyle\begin{pmatrix}0&1&0\\-1&0&0\end{pmatrix}$$ is a $$2\times 3$$ matrix. It has $$2$$ rows, $$3$$ columns and $$6$$ entries.
We can find the number of elements by multiplying $$m$$ and $$n$$. Even though an $$m \times n$$ and an $$n \times m$$ matrix have the same number of elements, they do not have the same order.
A $$2\times 3$$ matrix and a $$3\times 2$$ matrix have different sizes though they have same number of elements (6).
The following matrices $$$ \begin{pmatrix}1&2&3\\4&5&6\end{pmatrix},\quad \begin{bmatrix}1&x\\1&y\\1&z \end{bmatrix},\quad \begin{pmatrix}1&1\\0&1\end{pmatrix},\quad \begin{bmatrix}1\\0\\-1\end{bmatrix} $$$ are of order $$2\times 3$$, $$3\times2$$, $$2\times 2$$ and $$3\times 1$$.
There are special type of matrices depending on their size.
- A square matrix has the same number of rows and columns.
- A row matrix is a matrix with one row only. It is also called a row vector.
- A column matrix is a matrix with one column only. It is also called a column vector.
Examples of a square matrix, a row vector and a column vector:
$$$ \begin{pmatrix}1&2\\-1&0\end{pmatrix},\quad \begin{pmatrix}1&2\end{pmatrix},\quad \begin{pmatrix}1\\0\\3\end{pmatrix}. $$$There are distinctive types of matrices depending on their elements.
- A zero matrix is a matrix with zeroes everywhere.
- An identity matrix is a square matrix with ones on the main diagonal (upper left to lower right) and zeroes off the diagonal. This matrix is usually given the symbol $$I$$.
Examples of a zero matrix and an identity matrix.
$$$ \begin{pmatrix}0&0\\0&0\\0&0 \end{pmatrix},\quad \begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}. $$$To multiply a matrix by a number we multiply all the entries of the matrix by this number. This number is often called a scalar.
$$$ \Tred{2}\begin{pmatrix}1&2\\-1&0\end{pmatrix} = \begin{pmatrix}\Tred{2}\times 1&\Tred{2}\times 2\\\Tred{2}\times -1&\Tred{2}\times 0\end{pmatrix} = \begin{pmatrix}2&4\\-2&0\end{pmatrix} $$$
To add two matrices, we add each entry of one matrix to the corresponding entry of the matrix.
$$$ \begin{pmatrix}\Tred{1}&\Tblue{2}\\\Tgreen{-1}&\Torange{0}\end{pmatrix} + \begin{pmatrix}\Tred{-3}&\Tblue{1}\\\Tgreen{1}&\Torange{2}\end{pmatrix} = \begin{pmatrix}\Tred{1-3}&\Tblue{2+1}\\\Tgreen{-1+1}&\Torange{0+2}\end{pmatrix} = \begin{pmatrix}\Tred{-2}&\Tblue{3}\\\Tgreen{0}&\Torange{2}\end{pmatrix} $$$The two matrices must have the same size. The resulting matrix has the same size.
The sum below is NOT defined because the two matrices don't have the same size. $$$ \begin{pmatrix}1&2\\-1&3\end{pmatrix} + \begin{pmatrix}1\\-2\end{pmatrix} $$$
The multiplication $$A\times B$$ of two matrices $$A$$ and $$B$$ is not straightforward. We assume that $$A$$ has size $$m_A\times n_A$$ and $$B$$ has size $$m_B\times n_B$$.
- Size requirement. We must have $$$ n_A = m_B$$$
- Size of the product The matrix $$A\times B$$ has size $$m_A\times n_B$$..
- To compute one entry, we isolate one row in $$A$$ and one column in $$B$$. We multiply each pairing terms and we add them. We repeat the process for each row of $$A$$ and each column of $$B$$.
The following products are not defined because the matrices have incompatible sizes.
$$$ \begin{pmatrix} 1&0\\ 1&2\\ 0&1 \end{pmatrix} \times \begin{pmatrix} 0&1\\ 0&1\\ 1&0 \end{pmatrix},\; \begin{pmatrix} 1&0 \end{pmatrix} \times \begin{pmatrix} 0&1\\ 0&1\\ 1&0 \end{pmatrix},\; \begin{pmatrix} 1\\ 0 \end{pmatrix} \times \begin{pmatrix} 1\\ 0 \end{pmatrix}. $$$
Unlike the multiplication we do with real numbers, the order in which we multiply matrices is important. We say that the matrix product is noncommutative.
- Size: If $$A$$ has size $$2\times3$$ and $$B$$ has size $$3\times1$$, we can compute $$A\times B$$, because the number of columns of $$A$$ is equal to the number of rows of $$B$$. But we cannot compute $$B\times A$$, because the number of columns of $$B$$ is not equal to the number of rows of $$A$$.
- Order: When the matrices are square and have the same size, we can compute $$A\times B$$ and $$B\times A$$. However the resulting matrices will usually not be the same.
Operation | Scalar multiplication | Addition | Multiplication |
---|---|---|---|
Notation | $$$x A$$$ | $$$A+B$$$ | $$$A\times B$$$ |
Computation | $$$\begin{pmatrix} 0&2\\ 2&4 \end{pmatrix}$$$ | $$$\begin{pmatrix} 1&3\\ 1&1 \end{pmatrix}$$$ | $$$\begin{pmatrix} 0&-1\\ 1&0 \end{pmatrix}$$$ |
Restrictions | None | Matrices must be the same size | Number of columns of $$A$$ = number of rows of $$B$$ |