TITLE: For two vectors $a$ and $b$, why does $\cos(θ)$ equal the dot product of $a$ and $b$ divided by the product of the vectors' magnitudes?
QUESTION [8 upvotes]: While watching a video about dot products (https://www.youtube.com/watch?v=WDdR5s0C4cY), the following formula is presented for finding the angle between two vectors:

For vectors $a$, and $b$,
  $$\cos( \theta ) =  \frac{(a, b)}{  \|  a  \|   \| b \| }$$
  where $(a,b)$ is the dot product of $a$ and $b$.

How is this formula derived?

REPLY [2 votes]: It's a trig identity, really.
Two vectors determine a plane. Without loss of generality, we'll take that to be the $xy$-plane. Now, let $A$ and $B$ be the angles that $\overrightarrow{a}$ and $\overrightarrow{b}$ make with the (positive) $x$-axis; and let $r$ and $s$ be the respective magnitudes. Then, the $xy$-coordinates of the vectors can be written as
$$\overrightarrow{a}= r\,(\cos A, \sin A) \qquad\text{and}\qquad \overrightarrow{b} = s \,(\cos B, \sin B )$$
so that

$$\overrightarrow{a}\cdot\overrightarrow{b} = r s \cos A \cos B + r s\sin A \sin B = r s \cos(A-B)$$