Cosine Formula for Dot Product

Theorem
Let $\mathbf u$ and $\mathbf v$ be vectors in the vector space $\R^n$.

Let $\mathbf u \cdot \mathbf v$ be the dot product of $\mathbf u$ and $\mathbf v$, $\left\|{ \mathbf u }\right\|$ be the length of $\mathbf u$, $\left\|{ \mathbf v }\right\|$ be the length of $\mathbf v$, and $\angle \mathbf u, \mathbf v$  be the angle between the vector arrows $\mathbf u$ and $\mathbf v$, taken on the interval from  $0$ to $\pi$.

Then $\mathbf u \cdot \mathbf v = \left\|{ \mathbf u }\right\| \left\|{ \mathbf v }\right\| \cos \angle \mathbf u, \mathbf v$.

Proof
There are two cases, the first where the two vectors are scalar multiples of each other, and the second where they are not.

Case 1
Let $\mathbf u = \left({ u_1, u_2 , \ldots , u_n }\right)$ and $\mathbf v = \left({ v_1 , v_2 , \ldots , v_n }\right)$.

Let $\mathbf u = c \mathbf v$, where $c$ is some scalar. If $c > 0$, then $\angle \mathbf u, \mathbf v = 0$, and $\cos \angle \mathbf u , \mathbf v = 1$. If $c < 0$, then $\angle \mathbf u, \mathbf v = 0$, and $\cos \angle \mathbf u , \mathbf v = -1$.

Suppose $c \ne 0$.

Then:

Suppose $c = 0$.

Then $\mathbf u \cdot \mathbf v = 0 = \left\Vert{ \mathbf u }\right\Vert = \left\Vert{ \mathbf u }\right\Vert \left\Vert{ \mathbf v}\right\Vert \cos \angle \mathbf u, \mathbf v$

and the result still holds.

Case 2

 * Cosine Formula for Dot Product Diagram.png

Let the two vectors $\mathbf u$ and $\mathbf v$ not be scalar multiples of each other. Then when their tails are placed at the same point, they form two sides of a triangle as shown above.

Call this third side $\mathbf x$, and denote its length $\left\Vert{ \mathbf x }\right\Vert$.

By the Law of Cosines:


 * $\left\Vert{ \mathbf x }\right\Vert^2 = \left\Vert{ \mathbf u }\right\Vert^2 + \left\Vert{ \mathbf v }\right\Vert^2 - 2 \left\Vert{ \mathbf u }\right\Vert \left\Vert{ \mathbf v }\right\Vert \cos \angle \mathbf u, \mathbf v$.

However, we can also see that $\mathbf x = \mathbf u - \mathbf v$ (this follows from the Parallelogram Law). Thus

Equating these two expressions for $\left\Vert{ \mathbf x }\right\Vert^2$ gives

Which is exactly the desired result.