Proving  $\langle x, y\rangle  = \lVert x\rVert\, \lVert y\rVert\cos \theta$ via hint I am solving problems in Axler's Linear Algebra done right, and this one has me stumped. It says

Prove $\langle x, y\rangle  = \lVert x\rVert\, \lVert y\rVert\cos \theta$ 
  using the law of cosines and drawing the triangle formed by $x$, $y$, $x-y$. 

Both $x$ and $y$ are coming out of origin, and we are working in $\mathbb{R}^2$. How can this hint be used to answer the proof?
 A: The vectors $x$, $y$, and $x-y$ form a triangle with vertices at the origin, the endpoint of $x$, and the endpoint of $y$. The law of cosines says that for any triangle with sides of length $a$, $b$, and $c$,
$$c^2 = a^2+b^2 - 2ab\cos(\theta),$$
where $\theta$ is the angle opposite the side $c$.
Apply the Law of cosines to the angle formed between $x$ and $y$ at the origin. The lengths of the sides that form that angle are precisely $\lVert x\rVert$ and $\lVert y\rVert$. So from the law of cosines you would have
$$\lVert x-y\rVert^2 = \lVert x\rVert^2 + \lVert y\rVert^2 - 2\lVert x\rVert\,\lVert y\rVert\cos\theta.$$
Now use the fact that
$$\lVert x-y\rVert^2 = \langle x-y,x-y\rangle,\quad \lVert x\rVert^2 = \langle x,x\rangle,\quad\text{and}\quad \lVert y\rVert^2 = \langle y,y\rangle.$$
Expand $\langle x-y,x-y\rangle$, and simplify.
A: The law of cosines says that for a triangle with sides of length $a,b,$ and $c$, $$c^2 = a^2+b^2-2ab \cos \theta,$$ where $\theta$ is the angle opposite the side of length $c$.  Rewriting this in vector notation (so $a = |x|$, $b = |y|$, and $c = |x-y|$) gives
$$
|x-y|^2 = |x|^2 + |y|^2 - 2|x||y| \cos \theta.
$$
Expanding the left hand side gives:
$$
|x-y|^2 = \langle x-y, x-y \rangle = |x|^2-2 \langle x, y \rangle + |y|^2.
$$ 
Subtracting $|x|^2+|y|^2$ from both sides and dividing by $-2$ then yields the result.  
