Cosine Formula for Dot Product

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

Let $\left\|{ \vec u }\right\|$ be the length of $\vec u$, $\left\|{ \vec v }\right\|$ be the length of $\vec v$, and $\angle \vec u, \vec v$  be the angle between $\vec u$ and $\vec v$ (taken on the interval from  $0$ to $\pi$).

Then $\vec u \cdot \vec v = \left\|{ \vec u }\right\| \left\|{ \vec v }\right\| \cos \angle \vec u, \vec 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 $\vec u = \left({ u_1, u_2 , \ldots , u_n }\right)$ and $\vec v = \left({ v_1 , v_2 , \ldots , v_n }\right)$.

Let $\vec u = c \vec v$, where $c$ is some scalar. If $c > 0$, then $\angle \vec u, \vec v = 0$, and $\cos \angle \vec u , \vec v = 1$. If $c < 0$, then $\angle \vec u, \vec v = 0$ and $\cos \angle \vec u , \vec v = -1$. If $c = 0$, then $\angle \vec u, \vec v$ is undefined, but we shall see that this doesn't matter.

Case 2


Let the two vectors $\vec u$ and $\vec 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 thrid side $\vec x$, and denote it's length $\left\Vert{ \vec x }\right\Vert$.

By the Law of Cosines:


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

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

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

Which is exactly the desired result.