Table of Contents

The dot product

Definition of the dot product

Let $\def\m#1{\left[\begin{smallmatrix}#1\end{smallmatrix}\right]}\vec v=\m{v_1\\v_2\\\vdots\\v_n}$ and $\vec w=\m{w_1\\w_2\\\vdots\\w_n}$ be two vectors in $\mathbb{R}^n$.

The dot product of $\vec v$ and $\vec w$ is the number $\vec v\cdot \vec w$ given by \[ \color{red}{\vec v\cdot\vec w=v_1w_1+v_2w_2+\dots+v_nw_n}.\]

Note that while $\vec v$ and $\vec w$ are vectors, their dot product $\vec v\cdot \vec w$ is a scalar.

Example

If $\vec v=\m{3\\5}$ and $\vec w=\m{4\\-7}$, then $\vec v\cdot \vec w=\m{3\\5}\cdot \m{4\\-7} = 3(4)+5(-7)=-23$.

Properties of the dot product

For any vectors $\vec v$, $\vec w$ and $\vec u$ in $\mathbb{R}^n$, and any scalar $c\in \mathbb{R}$:

  1. $\def\dp#1#2{\vec #1\cdot \vec #2}\dp vw=\dp wv$ (the dot product is commutative)
  2. $\vec u\cdot(\vec v+\vec w)=\dp uv+\dp uw$
  3. $(c\vec v)\cdot \vec w=c(\dp vw)$
  4. $\dp vv=\|\vec v\|^2\ge 0$, and $\dp vv=0 \iff \vec v=0_{n\times 1}$

The proofs of these properties are exercises.

Angles and the dot product

Theorem: the relationship between angle and the dot product

If $\vec v$ and $\vec w$ are non-zero vectors in $\mathbb{R}^n$, then \[ \dp vw=\|\vec v\|\,\|\vec w\|\,\cos\theta\] where $\theta$ is the angle between $\vec v$ and $\vec w$.

The proof will be given soon, but for now here is an example.

Example

If $\vec v=\m{1\\2}$ and $\vec w=\m{-2\\1}$, then $\dp vw=1(-2)+2(1)=-2+2=0$. On the other hand, we have $\|\vec v\|=\sqrt5=\|\vec w\|$, so the angle $\theta$ between $\vec v$ and $\vec w$ satisfies \[ 0=\dp vw=\sqrt 5\times \sqrt 5 \times \cos\theta\] so $5\cos\theta=0$, so $\cos\theta=0$, so $\theta=\pi/2$ or $\theta=3\pi/2$ (measuring angles in radians). This tells us that the angle between $\vec v$ and $\vec w$ is a right angle. We say that these vectors are orthogonal. We can draw a convincing picture which indicates that these vectors are indeed at right angles:

Proof of the Theorem

We wish to show that $\def\vv{\vec v} \def\ww{\vec w}\vv\cdot\ww=\|\vv\|\,\|\ww\|\cos\theta$ where $\theta$ is the angle between $\vv$ and $\ww$.

Recall the cosine rule:

Consider a triangle with two sides $\vv$ and $\ww$. By the triangle rule for vector addition, the third side $\vec x$ has $\ww+\vec x=\vv$, so $\vec x=\vv-\ww$:

Applying the cosine rule gives \[ \|\vv-\ww\|^2=\|\vv\|^2+\|\ww\|^2-2\|\vv\|\,\|\ww\|\,\cos\theta.\] On the other hand, we know that $\|\vec x\|^2=\vec x\cdot\vec x$, so \begin{align*}\|\vv-\ww\|^2&=(\vv-\ww)\cdot(\vv-\ww)\\&=\vv\cdot\vv+\ww\cdot\ww-\ww\cdot\vv-\vv\cdot\ww\\&=\|\vv\|^2+\|\ww\|^2-2\vv\cdot\ww.\end{align*} So \[\|\vv\|^2+\|\ww\|^2-2\|\vv\|\,\|\ww\|\,\cos\theta=\|\vv\|^2+\|\ww\|^2-2\vv\cdot\ww\cos\theta.\] Subtracting $\|\vv\|^2+\|\ww\|^2$ from both sides and dividing by $-2$ gives $\vv\cdot\ww=\|\vv\|\,\|\ww\|\cos\theta$. ■

Corollary

If $\vv$ and $\ww$ are non-zero vectors and $\theta$ is the angle between them, then $\cos\theta=\displaystyle\frac{\vv\cdot\ww}{\|\vv\|\,\|\ww\|}$.

Corollary

If $\vv$ and $\ww$ are non-zero vectors with $\vv\cdot\ww=0$, then $\vv$ and $\ww$ are orthogonal: they are at right-angles.

Examples

  1. The angle $\theta$ between $\def\c#1#2{\begin{bmatrix}#1\\#2\end{bmatrix}}\c12$ and $\c3{-4}$ has \[ \cos\theta=\frac{\c12\cdot\c3{-4}}{\left\|\c12\right\|\,\left\|\c3{-4}\right\|} =\frac{3-8}{\sqrt5\sqrt{25}}=-\frac1{\sqrt5},\] so $\theta=\cos^{-1}(-1/\sqrt5) \approx 2.03\,\text{radians}\approx 116.57^\circ$.
  2. The points $A=(2,3)$, $B=(3,6)$ and $C=(-4,5)$ are the vertices of a right-angled triangle. Indeed, we have $\vec{AB}=\c36-\c23=\c13$ and $\vec{AC}=\c{-4}5-\c23=\c{-6}2$, so $\vec{AB}\cdot\vec{AC}=\c13\cdot\c{-6}2=1(-6)+3(2)=0$, so the sides $AB$ and $AC$ are at right-angles.
  3. To find a unit vector orthogonal to the vector $\vv=\c12$, we can first observe that $\ww=\c{-2}1$ has $\vv\cdot\ww=0$, so $\vv$ and $\ww$ are orthogonal; and then consider the vector $\vec u=\frac1{\|\ww\|}\ww$, which is a unit vector in the same direction as $\ww$, so is also orthogonal to $\vv$. Hence $\vec u=\frac1{\sqrt5}\c{-2}1=\c{-2/\sqrt5}{1/\sqrt5}$ is a unit vector orthogonal to $\vv=\c12$.