## Vector dot product

This is another one of my “reminder” posts, so look away now if you are familiar with vector dot products.

If we had a two dimensional vector $X$ and vector $Y$ then the dot product would be $(X.x)(Y.y) + (X.y)(Y.y)$.

But this can also be expressed as $\mid X \mid \mid Y \mid cos \theta$ (where $\theta$ is the angle between the two vectors).

Let $Q$ be the angle $X$ makes to the x-axis and $P$ the angle made by $Y$, then $X.x = \mid X \mid cos Q$, $X.y = \mid X \mid sin Q$, $Y.x = \mid Y \mid cos P$ and $Y.y = \mid Y \mid sin P$.

Then the dot product can be rewritten as:

$\mid X \mid cos Q \mid Y \mid cos P + \mid X \mid sin Q \mid Y \mid sin P$

= $\mid X \mid \mid Y \mid (cos P cos Q + sin P sin Q)$

As $P = \theta + Q$ we can rewrite this as:

$\mid X \mid \mid Y \mid (cos(\theta + Q)cos Q + sin(\theta + Q) sin Q)$

Now $sin(a + b) = sin(a) cos( b )+ cos (a) sin( b)$ and $cos (a + b) = cos( a) cos (b )- sin (a )sin (b)$

so we can rewrite the dot product as $\mid X \mid \mid Y \mid$ $(cos^2 Q cos \theta - cos Q sin \theta sin Q$ $+ sin^2 Q cos \theta + sin Q cos Q sin \theta)$

As $sin^2 \alpha + cos ^2 \alpha = 1$ we have $\mid X \mid \mid Y \mid cos \theta$.