~~REVEAL~~ ====== Chapter 2: The algebra of matrices ====== ==== ==== {{page>matrix}} {{page>(i,j) entry}} ==== 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 ==== {{page>same size}} ==== Equality of matrices ==== {{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}$ * 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 ==== {{page>matrix addition}} ==== 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 ==== {{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}} ==== 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 ==== {{page>scalar multiplication of matrices}} ==== 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 ==== {{page>matrix negation}} ==== 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].\]