$$\require{cancel}$$
$E = \text{constant} - \textbf{p}_m \cdot \textbf{B}. \label{7.7.1}$
For a derivation of this, see the derivation in Section 3.4 for the potential energy of an electric dipole in an electric field. Also, verify that the dimensions of the right hand side of equation \ref{7.7.1} are $$\text{ML}^2 \text{T}^{−2}$$ (energy).