=== Examples === * $\begin{bmatrix}3\\2\\4\\0\\-1\end{bmatrix}$ is a $5\times 1$ matrix. A matrix like this with one column is called a **column vector**. * $\begin{bmatrix}3&2&4&0&-1\end{bmatrix}$ is a $1\times 5$ matrix. A matrix like this with one row is called a **row vector**. Even though the row matrix and the column matrix above have the same entries, they have a different "shape", or "size", so we must think of them has being different matrices. Let's give the definitions to make this precise. === Definition === {{page>same size}} === Definition === {{page>equal matrices}} === 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}$ since these matrices are not the same size. * $\begin{bmatrix}1&0\\0&1\end{bmatrix}\ne \begin{bmatrix}1&0\\1&0\end{bmatrix}$ because even though they have the same size, 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, so we get four equations:\begin{align*}3x&=1\\7y+2&=2z\\8z-3&=\sqrt2\\w^2&=9\end{align*} ===== Operations on matrices ===== We want to define operations on matrices: some (useful) ways of taking two matrices and making a new matrix. Before we begin, a remark about $1\times 1$ matrices. These are of the form $[a_{11}]$ where $a_{11}$ is just a number. The square brackets $[\,]$ don't really matter here; they just keep the inside of a matrix in one place. So really: a $1\times 1$ matrix is just a number. This means that special cases of the operations we define will be operations on ordinary numbers. You should check that in the special case when all the matrices involved are $1\times 1$ matrices, the operations become the ordinary operations on numbers, so we are //generalising// the familiar operations (addition, subtraction, multiplication and so on) from numbers to matrices. ==== Matrix addition and subtraction ==== === Definition of matrix addition === {{page>matrix addition}} === Example === \[ \begin{bmatrix}1&2&-2\\3&0&5\end{bmatrix}+\begin{bmatrix}-2&2&0\\1&1&1\end{bmatrix}=\begin{bmatrix}-1&4&-2\\4&1&6\end{bmatrix}.\] === Example === \[ \begin{bmatrix}1&2&-2\\3&0&5\end{bmatrix}+\begin{bmatrix}-2&2\\1&1\end{bmatrix}\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//. === Definition of the zero matrix === {{page>zero matrix}} === 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 === {{page>matrix subtraction}} === Example === \[ \begin{bmatrix}1&2&-2\\3&0&5\end{bmatrix}-\begin{bmatrix}-2&2&0\\1&1&1\end{bmatrix}=\begin{bmatrix}3&0&-2\\2&-1&4\end{bmatrix}.\] === Example === \[ \begin{bmatrix}1&2&-2\\3&0&5\end{bmatrix}-\begin{bmatrix}-2&2\\1&1\end{bmatrix}\text{ is undefined.}\] ==== Scalar multiplication ==== === Definition of a scalar === {{page>scalar}} === Definition of scalar multiplication of matrices === {{page>scalar multiplication of matrices}} === Example === If $A=\begin{bmatrix}1&0&-3\\3&-4&1\end{bmatrix}$, then $3A=\begin{bmatrix}3&0&-9\\9&-12&3\end{bmatrix}$. In other words, \[ 3\begin{bmatrix}1&0&-3\\3&-4&1\end{bmatrix}=\begin{bmatrix}3&0&-9\\9&-12&3\end{bmatrix}.\] === The negative of a matrix === {{page>matrix negation}} === Exercise === Prove that $A-B=A+(-B)$ for any matrices $A$ and $B$ of the same size. ==== Row-column multiplication ==== === Definition of row-column multiplication === {{page>row-column multiplication}} === Examples === * $\begin{bmatrix}1&2\end{bmatrix}\begin{bmatrix}3\\-1\end{bmatrix}=1\cdot 3+2\cdot(-1)=3+(-2)=1$. * $\begin{bmatrix}1&2&7\end{bmatrix}\begin{bmatrix}3\\-1\end{bmatrix}$ is not defined. * $\begin{bmatrix}2&3&5\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix}=2x+3y+5z$. * Generalising the previous example: if $a=\begin{bmatrix}a_1&a_2&\dots&a_m\end{bmatrix}$ and $x=\begin{bmatrix}x_1\\x_2\\\vdots\\x_m\end{bmatrix}$, then $ax=a_1x_1+a_2x_2+\dots+a_mx_m$. So we can write any [[linear equation]] $a_1x_1+a_2x_2+\dots+a_mx_m=b$ as a shorter matrix equation: $ax=b$. ==== Matrix multiplication ==== This generalises row-column multiplication. The idea is that you build a new matrix from all possible row-column products. The formal definition will appear later, but here's an example: \[ \def\r{\begin{bmatrix}1&0&5\end{bmatrix}}\def\rr{\begin{bmatrix}2&-1&3\end{bmatrix}}\begin{bmatrix}1&0&5\\2&-1&3\end{bmatrix}\begin{bmatrix} 1&2\\3&4\\5&6\end{bmatrix} \def\s{\begin{bmatrix}1\\3\\5\end{bmatrix}}\def\ss{\begin{bmatrix}2\\4\\6\end{bmatrix}} = \begin{bmatrix}{\r\s}&{\r\ss}\\{\rr\s}&{\rr\ss}\end{bmatrix}=\begin{bmatrix}26&32\\14&18\end{bmatrix}.\]