Warning: Undefined array key "do" in /home/levene/public_html/w/mst10030/lib/plugins/revealjs/action.php on line 14
Table of Contents
Chapter 2: The algebra of matrices
An $n\times m$ matrix is a grid of numbers with $n$ rows and $m$ columns: \[ A=\begin{bmatrix}a_{11}&a_{12}&\dots&a_{1m}\\a_{21}&a_{22}&\dots&a_{2m}\\\vdots&\vdots&&\vdots\\a_{n1}&a_{n2}&\dots&a_{nm}\end{bmatrix}\]
The $(i,j)$ entry of a matrix $A$ is $a_{ij}$, the number in row $i$ and column $j$ of $A$.
Examples
- $B=\begin{bmatrix} 99&3&5\\7&-20&14\end{bmatrix}$ is a $2\times 3$ matrix
- the $(1,1)$ entry of $B$ is $b_{11}=99$
- the $(1,3)$ entry of $B$ is $b_{13}=5$
- the $(2,1)$ entry of $B$ is $b_{21}=7$
- etc.
- $(3,2)$ entry of $B$?
- undefined!
Examples
- $\left[\begin{smallmatrix}3\\2\\4\\0\\-1\end{smallmatrix}\right]$ is a $5\times 1$ matrix.
- A column vector: matrix with just one column.
- $\begin{bmatrix}3&2&4&0&-1\end{bmatrix}$ is a $1\times 5$ matrix.
- A row vector: matrix with just one row.
- These have the same entries, but a different “shape”, or “size”.
- They are different matrices (not equal).
Size of a matrix
Two matrices $A$ and $B$ have the same size if they have the same number of rows, and they have the same number of columns.
If two matrices do not have the same size, we say they have different sizes.
Equality of matrices
Two matrices $A$ and $B$ are said to be equal if both of the following conditions hold:
- $A$ and $B$ have the same size; and
- every entry of $A$ is equal to the corresponding entry of $B$; in other words, for every $(i,j)$ so that $A$ and $B$ have an $(i,j)$ entry, we have $a_{ij}=b_{ij}$.
When $A$ and $B$ are equal matrices, we write $A=B$. Otherwise, we write $A\ne B$.
Examples
- $\begin{bmatrix}3\\2\\4\\0\\-1\end{bmatrix}\ne \begin{bmatrix}3&2&4&0&-1\end{bmatrix}$, since these matrices have different sizes: the first is $5\times 1$ but the second is $1\times 5$.
- $\begin{bmatrix}1\\2\end{bmatrix}\ne\begin{bmatrix}1 &0\\2&0\end{bmatrix}$
- not the same size.
- $\begin{bmatrix}1&0\\0&1\end{bmatrix}\ne \begin{bmatrix}1&0\\1&1\end{bmatrix}$
- same size but the $(2,1)$ entries are different.
- If $\begin{bmatrix}3x&7y+2\\8z-3&w^2\end{bmatrix}=\begin{bmatrix}1&2z\\\sqrt2&9\end{bmatrix}$ then we know that all the corresponding entries are equal
- We get four equations:\begin{align*}3x&=1\\7y+2&=2z\\8z-3&=\sqrt2\\w^2&=9\end{align*}
Operations on matrices
- Some (useful) ways of taking two matrices and making a new matrix.
- $1\times 1$ matrices are the same as numbers….
- ….we'll define some operations on matrices which generalise operations on numbers, like addition and multiplication
Matrix addition and subtraction
If $A$ and $B$ are matrices of the same size, then $A+B$ is defined to be the matrix with the same size as $A$ and $B$ so that the $(i,j)$ entry of $A+B$ is $a_{ij}+b_{ij}$, for every $i,j$.
If $A$ and $B$ are matrices of different sizes, then $A+B$ is undefined.
Examples
- $ \left[\begin{smallmatrix}1&2&-2\\3&0&5\end{smallmatrix}\right]+\left[\begin{smallmatrix}-2&2&0\\1&1&1\end{smallmatrix}\right]=\left[\begin{smallmatrix}-1&4&-2\\4&1&6\end{smallmatrix}\right].$
- $\left[\begin{smallmatrix}1&2&-2\\3&0&5\end{smallmatrix}\right]+\left[\begin{smallmatrix}-2&2\\1&1\end{smallmatrix}\right]\text{ is undefined.}$
Remarks
- For any matrices $A$ and $B$ with the same size: $A+B=B+A$. We say that matrix addition is commutative.
- For any matrices $A$, $B$ and $C$ with the same size: $(A+B)+C=A+(B+C)$. We say that matrix addition is associative.
The zero matrix
The $n\times m$ zero matrix is the $n\times m$ matrix so that every entry is $0$. We write this as $0_{n\times m}$. So \[ 0_{n\times m}=\begin{bmatrix} 0&0&\dots&0\\ 0&0&\dots&0\\ \vdots&\vdots&&\vdots\\ 0&0&\dots&0\end{bmatrix}\] where this matrix has $n$ rows and $m$ columns.
Exercise
Show that if $A$ is any $n\times m$ matrix, then \[ 0_{n\times m}+A=A=A+0_{n\times m}.\]
- Remember that when checking that matrices are equal, you have to check that they have the same size, and that all the entries are the same.
Definition of matrix subtraction
If $A$ and $B$ are matrices of the same size, then $A-B$ is defined to be the matrix with the same size as $A$ and $B$ so that the $(i,j)$ entry of $A-B$ is $a_{ij}-b_{ij}$, for every $i,j$.
If $A$ and $B$ are matrices of different sizes, then $A-B$ is undefined.
Examples
- $ \left[\begin{smallmatrix}1&2&-2\\3&0&5\end{smallmatrix}\right]-\left[\begin{smallmatrix}-2&2&0\\1&1&1\end{smallmatrix}\right]=\left[\begin{smallmatrix}3&0&-2\\2&-1&4\end{smallmatrix}\right].$
- $ \left[\begin{smallmatrix}1&2&-2\\3&0&5\end{smallmatrix}\right]-\left[\begin{smallmatrix}-2&2\\1&1\end{smallmatrix}\right]\text{ is undefined.}$
Scalars
- a scalar is just a fancy name for a number
- (in this course: a real number)
- Why use this strange-looking name?
- numbers are often used for scaling things up or down
- e.g. the scalar 3 is used to scale things up by a factor of 3 (by multiplying by 3).
Scalar multiplication of matrices
If $c$ is a real number and $A$ is an $n\times m$ matrix, then we define the matrix $cA$ to be the $n\times m$ matrix given by multiplying every entry of $A$ by $c$. In other words, the $(i,j)$ entry of $cA$ is $ca_{i,j}$.
Example
- If $A=\left[\begin{smallmatrix}1&0&-3\\3&-4&1\end{smallmatrix}\right]$, then $3A=\left[\begin{smallmatrix}3&0&-9\\9&-12&3\end{smallmatrix}\right]$.
- In other words, $ 3\left[\begin{smallmatrix}1&0&-3\\3&-4&1\end{smallmatrix}\right]=\left[\begin{smallmatrix}3&0&-9\\9&-12&3\end{smallmatrix}\right].$
The negative of a matrix
We write $-A$ as a shorthand for $-1A$; so the $(i,j)$ entry of $-A$ is $-a_{ij}$. For example, \[ -\begin{bmatrix}-1&0&3\\3&-4&1\end{bmatrix}=\begin{bmatrix}1&0&-3\\-3&4&-1\end{bmatrix}.\]
Exercise
Prove that $A-B=A+(-B)$ for any matrices $A$ and $B$ of the same size.
Row-column multiplication
- Let $a=[\begin{smallmatrix}a_1&a_2&\dots&a_n\end{smallmatrix}]$ be a $1\times n$ row vector and $b=\left[\begin{smallmatrix}b_1\\b_2\\\vdots\\b_n\end{smallmatrix}\right]$, an $n\times 1$ column vector.
- The row-column product of $a$ and $b$ is defined by \[\!\!\!\!\!\!\!\!\!\!ab=[\begin{smallmatrix}a_1&a_2&\dots&a_n\end{smallmatrix}]\left[\begin{smallmatrix}b_1\\b_2\\\vdots\\b_n\end{smallmatrix}\right]=a_1b_1+a_2b_2+\dots+a_nb_n.\]
- Sometimes we write $a\cdot b$ instead of $ab$.
- If $a$ and $b$ have a different number of entries, $ab$ is undefined.
Examples
- $\left[\begin{smallmatrix}1&2\end{smallmatrix}\right]\left[\begin{smallmatrix}3\\-1\end{smallmatrix}\right]=1\cdot 3+2\cdot(-1)=3+(-2)=1$.
- $\left[\begin{smallmatrix}1&2&7\end{smallmatrix}\right]\left[\begin{smallmatrix}3\\-1\end{smallmatrix}\right]$ is not defined.
- $\left[\begin{smallmatrix}2&3&5\end{smallmatrix}\right]\left[\begin{smallmatrix}x\\y\\z\end{smallmatrix}\right]=2x+3y+5z$.
- If $a=\left[\begin{smallmatrix}a_1&a_2&\dots&a_m\end{smallmatrix}\right]$ and $x=\left[\begin{smallmatrix}x_1\\x_2\\\vdots\\x_m\end{smallmatrix}\right]$, then $ax=a_1x_1+a_2x_2+\dots+a_mx_m$.
- So we can write any linear equation as a shorter matrix equation: $ax=b$.
Matrix multiplication
- We want to define $AB$ where $A$ and $B$ are matrices of “compatible” sizes (not just rows and columns)
- This will generalise row-column multiplication
- We build $AB$ from all possible row-column products.
- For example: \[\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \def\r{\left[\begin{smallmatrix}1&0&5\end{smallmatrix}\right]}\def\rr{\left[\begin{smallmatrix}2&-1&3\end{smallmatrix}\right]}\left[\begin{smallmatrix}1&0&5\\2&-1&3\end{smallmatrix}\right]\left[\begin{smallmatrix} 1&2\\3&4\\5&6\end{smallmatrix}\right]\def\s{\left[\begin{smallmatrix}1\\3\\5\end{smallmatrix}\right]}\def\ss{\left[\begin{smallmatrix}2\\4\\6\end{smallmatrix}\right]}=\left[\begin{smallmatrix}{\r\s}&{\r\ss}\\{\rr\s}&{\rr\ss}\end{smallmatrix}\right]=\left[\begin{smallmatrix}26&32\\14&18\end{smallmatrix}\right].\]

