Using Law of Cosines To Prove Vector Algebra

Use the law of cosines $\displaystyle c^2 = a^2 + b^2 = 2ab \cos \theta$, where a, b and c are the lengths of the sides of a triangle and theta is the angle between sides a and b. To show:-

$\displaystyle U_x V_x + U_y V_y + U_z V_z = ||U|| ||V|| \cos \theta$

Hint: Set $\displaystyle c^2 = ||U - V||, a^2 = ||U||^2$ and $\displaystyle b^2 = ||V||^2$. Use the dot product properties.

I've had an attempt at this but I'm 99% certain I am going about this the wrong way.

$\displaystyle ||U-V|| = ||U||^2 + ||V||^2 = 2||U|| ||V|| \cos \theta = U \cdot V = ||U|| ||V|| \cos \theta$