If $\theta$ is the angle between vectors $\overrightarrow{A}$ and $\overrightarrow{B}$,then by the definition of the scalar product:
$\overrightarrow{A} \cdot \overrightarrow{B} = AB \cos \theta$
Rearranging the formula to solve for $\cos \theta$:
$\cos \theta = \frac{\overrightarrow{A} \cdot \overrightarrow{B}}{|\overrightarrow{A}| |\overrightarrow{B}|} = \frac{\overrightarrow{A} \cdot \overrightarrow{B}}{AB}$
Therefore,the angle $\theta$ is given by:
$\theta = \cos^{-1} \left( \frac{\overrightarrow{A} \cdot \overrightarrow{B}}{AB} \right)$
In a Cartesian coordinate system,where $\overrightarrow{A} = A_x \hat{i} + A_y \hat{j} + A_z \hat{k}$ and $\overrightarrow{B} = B_x \hat{i} + B_y \hat{j} + B_z \hat{k}$,the expression becomes:
$\cos \theta = \frac{A_x B_x + A_y B_y + A_z B_z}{\sqrt{A_x^2 + A_y^2 + A_z^2} \sqrt{B_x^2 + B_y^2 + B_z^2}}$