TITLE: How to explain why the angle between two vectors in $\mathbb{R}^n$ is defined the way it is.
QUESTION [5 upvotes]: It is given in couple of the textbooks I have seen that they just define the angle between two vectors $\vec{x}, \vec{y} \in \mathbb{R}^n$ to be $\theta$ such that 
$$
\cos \theta = \frac{\vec{x} \cdot \vec{y} }{ \|\vec{x}\| \|\vec{y}\|}.
$$ 
I wanted to explain this to a first year undergraduate student why this makes some sense and that it is not completely arbitrary, but I wasn't really sure how to do so. I would greatly appreciate any explanation! Thank you!!

REPLY [3 votes]: We can fit our vectors $\vec x$ and $\vec y$ into a triangle

The law of cosines says
$$
\left\lVert\vec y-\vec x\right\rVert^2
= \left\lVert\vec x\right\rVert^2+\left\lVert \vec y\right\rVert^2
-2\left\lVert\vec x\right\rVert\left\lVert\vec y\right\rVert\cos\theta\tag{1}
$$
But we also have
$$
\left\lVert\vec y-\vec x\right\rVert^2
= \left(\vec y-\vec x\right)\cdot \left(\vec y-\vec x\right)
= \vec y\cdot\vec y+\vec x\cdot\vec x-2\,\vec x\cdot\vec y
= \left\lVert\vec y\right\rVert^2+\left\lVert\vec x\right\rVert^2-2\,\vec x\cdot\vec y\tag{2}
$$
Plugging (2) into (1) gives
$$
\left\lVert\vec y\right\rVert^2+\left\lVert\vec x\right\rVert^2-2\,\vec x\cdot\vec y=\left\lVert\vec x\right\rVert^2+\left\lVert \vec y\right\rVert^2
-2\left\lVert\vec x\right\rVert\left\lVert\vec y\right\rVert\cos\theta
$$
which simplifies to
$$
\vec x\cdot\vec y=\left\lVert\vec x\right\rVert\left\lVert\vec y\right\rVert\cos\theta
$$
Thus $\cos\theta$ can be expressed as
$$
\cos\theta=\frac{\vec x\cdot\vec y}{\left\lVert\vec x\right\rVert\left\lVert\vec y\right\rVert}
$$
as desired!
In other words, taking this equation as the definition of $\cos\theta$ matches our intuition developed in trigonometry.