The *dot product* $v\cdot w$
is the number ${v}_{1}{w}_{1}+\mathrm{\cdots}+{v}_{n}{w}_{n}$
.

# 09. Dot product, 1

## 09. Dot product, 1

### Dot product

Given two vectors $v=\left(\begin{array}{c}\hfill {v}_{1}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {v}_{n}\hfill \end{array}\right)$ and $w=\left(\begin{array}{c}\hfill {w}_{1}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {w}_{n}\hfill \end{array}\right)$ in ${\mathbf{R}}^{n}$ , what is the angle between them?

To define angles in ${\mathbf{R}}^{n}$ , note that the two vectors $v$ and $w$ are contained in a unique 2-plane, and we mean the usual angle between $v$ and $w$ inside that plane.

To compute that angle, we introduce the *dot product* $v\cdot w$
.

If $\theta $ is the angle between $v$ and $w$ then $$v\cdot w=|v||w|\mathrm{cos}\theta .$$ Recall that $|v|$ means the length of $v$ .

We will prove this in due course, but first we'll explore it a little.

Let $v=\left(\begin{array}{c}\hfill 1\hfill \\ \hfill 0\hfill \end{array}\right)$ and $w=\left(\begin{array}{c}\hfill 0\hfill \\ \hfill 1\hfill \end{array}\right)$ . We have $v\cdot w=1\times 0+0\times 1=0$ .

This makes sense: the angle between $v$
and $w$
is $\pi /2$
radians, and $\mathrm{cos}(\pi /2)=0$
. In this case, we say the vectors are *orthogonal to one another* (equivalent to "perpendicular" or "at right angles").

Let $v=\left(\begin{array}{c}\hfill 1\hfill \\ \hfill 1\hfill \end{array}\right)$ and $w=\left(\begin{array}{c}\hfill 1\hfill \\ \hfill 0\hfill \end{array}\right)$ . We can see the angle between them should be 45 degrees ($\pi /4$ radians).

Let's confirm this: we have $v\cdot w=1\times 1+0\times 1=1$ . We also have $|v|=\sqrt{1+1}=\sqrt{2}$ by Pythagoras and $|w|=1$ , so $$1=v\cdot w=|v||w|\mathrm{cos}\theta =\sqrt{2}\mathrm{cos}\theta ,$$ so $\mathrm{cos}\theta $ should be $1/\sqrt{2}$ . Indeed, $\mathrm{cos}(\pi /4)=1/\sqrt{2}$ .

Even if you didn't know the angle, you could figure it out as $\mathrm{arccos}(1/\sqrt{2})$ . You might object that $\mathrm{arccos}$ is multivalued, for example $\mathrm{cos}(\pi /4)=\mathrm{cos}(3\pi /4)$ . This just corresponds to the fact that there are different ways of picking "the" angle between $v$ and $w$ (e.g. clockwise or anticlockwise).