Consider the vectors U and V (with respective magnitudes |U | and |V |). If those vectors enclose an angle θ then the dot product of those vectors can be written as:

$\mathbf {U} \cdot \mathbf {V} =|\mathbf {U} ||\mathbf {V} |\cos(\theta )$
If the vectors can be written as:

$\mathbf {U} =(U_{x},U_{y},U_{z})$
$\mathbf {V} =(V_{x},V_{y},V_{z})$
then the dot product is given by:

$\mathbf {U} \cdot \mathbf {V} =U_{x}V_{x}+U_{y}V_{y}+U_{z}V_{z}$
For example,

$(1,2,3)\cdot (2,2,2)=1(2)+2(2)+3(2)=12.$
and

$(0,5,0)\cdot (4,0,0)=0.$
We can interpret the last case by noting that the product is zero because the angle between the two vectors is 90 degrees.

Since

$|\mathbf {U} |={\sqrt {U_{x}^{2}+U_{y}^{2}+U_{z}^{2}}}$
and

$|\mathbf {V} |={\sqrt {V_{x}^{2}+V_{y}^{2}+V_{z}^{2}}}$
this means that

$\cos(\theta )={\frac {U_{x}V_{x}+U_{y}V_{y}+U_{z}V_{z}}{{\sqrt {U_{x}^{2}+U_{y}^{2}+U_{z}^{2}}}{\sqrt {V_{x}^{2}+V_{y}^{2}+V_{z}^{2}}}}}$