# 01. Matrices

## Matrices

### Vectors in the plane

A vector is an arrow in the plane (later we'll deal with vectors in higher-dimensional spaces). We encode this arrow as a pair of numbers $\begin{pmatrix}x\\ y\end{pmatrix}$ . The number $x$ tells us how far to the right the arrow points; the number $y$ tells us how far upwards it points. If the arrow points to the left then $x$ is negative; if it points downwards then $y$ is negative.

Can you match up the vectors $\begin{pmatrix}x\\ y\end{pmatrix}$ with those in the diagram? (Some of the vectors are not depicted).

$\begin{pmatrix}1\\ 2\end{pmatrix},\qquad\begin{pmatrix}0\\ 1\end{pmatrix},\qquad\begin{pmatrix}1\\ 1\end{pmatrix},$ $\begin{pmatrix}1\\ 0\end{pmatrix},\qquad\begin{pmatrix}-1\\ -1\end{pmatrix},\qquad\begin{pmatrix}2\\ 1\end{pmatrix}.$

A lot of this module will focus on the interplay between algebra (like column vectors) and geometry (like arrows in the plane).

Suppose $v=\begin{pmatrix}x\\ y\end{pmatrix}$ is a vector. What is it's length? By Pythagoras's theorem, it's $\sqrt{x^{2}+y^{2}}$ . I'll write this as $|v|$ , which you can read out loud as "norm $v$ ". The angle that $v$ makes with the horizontal is $\theta=\arctan(y/x)$ (by trigonometry). If we want to write $x$ and $y$ in terms of $|v|$ and $\theta$ , we get (again, using trigonometry): $x=|v|\cos\theta,\qquad y=|v|\sin\theta.$ So $v=\begin{pmatrix}|v|\cos\theta\\ |v|\sin\theta\end{pmatrix}$ .

### 2-by-2 matrices

What happens if I rotate $v$ by an angle $\phi$ anticlockwise? We get a new vector $w$ , which we can express in terms of $v$ and $\phi$ .

Rotation preserves lengths, so $|w|=|v|$ .

The angle that $w$ makes with the horizontal is $\theta+\phi$ . Therefore $w=\begin{pmatrix}|v|\cos(\theta+\phi)\\ |v|\sin(\theta+\phi)\end{pmatrix}.$

We can expand this using the trigonometric addition formulae: $w=\begin{pmatrix}|v|\cos(\theta+\phi)\\ |v|\sin(\theta+\phi)\end{pmatrix}=\begin{pmatrix}|v|\cos\theta\cos\phi-|v|\sin% \theta\sin\phi\\ |v|\sin\theta\cos\phi+|v|\cos\theta\sin\phi\end{pmatrix}.$

Using $x=|v|\cos\theta$ and $y=|v|\sin\theta$ , we get $w=\begin{pmatrix}x\cos\phi-y\sin\phi\\ x\sin\phi+y\cos\phi\end{pmatrix}.$

This expresses $w$ in terms of the original vector $v=\begin{pmatrix}x\\ y\end{pmatrix}$ and the angle $\phi$ of rotation. We now invent a piece of notation which separates out the dependence of $w$ on $v$ from its dependence on $\phi$ : we write $w=\begin{pmatrix}\cos\phi&-\sin\phi\\ \sin\phi&\cos\phi\end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix}.$ You can just think of this as a shorthand for $\begin{pmatrix}x\cos\phi-y\sin\phi\\ x\sin\phi+y\cos\phi\end{pmatrix}$ , keeping track of where all the coefficients sit.

More generally, given a 2-by-2 array of numbers $M=\begin{pmatrix}a&b\\ c&d\end{pmatrix}$ and a vector $v=\begin{pmatrix}x\\ y\end{pmatrix}$ , we define the product $Mv=\begin{pmatrix}a&b\\ c&d\end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix}:=\begin{pmatrix}ax+by\\ cx+dy\end{pmatrix}.$ This defines the action of a matrix on a vector. This notation completely separates out the rotation ($M$ ) from the vector we started with ($v$ ).

Now we don't have to limit ourselves to rotations: any matrix $\begin{pmatrix}a&b\\ x&d\end{pmatrix}$ defines a geometric transformation of the plane. This is the transformation $\begin{pmatrix}x\\ y\end{pmatrix}\mapsto\begin{pmatrix}ax+by\\ cx+dy\end{pmatrix}.$ We'll see lots of examples in the next video (rotations, reflections, shears,...).

### Mnemonic

How do you remember the formula for a matrix acting on a vector? The mnemonic I like is as follows. To get the first entry of $Mv$ , you multiply the top row of $M$ into $v$ '', that is you perform the multiplications $ax$ and $by$ (working across the top row of $M$ and down the column of $v$ ) and sum them.

To get the second entry, you multiply the second row of $M$ into $v$ .

In the next video, we'll see lots of examples of transformations of the plane coming from 2-by-2 matrices.