Solution (source code)

= Solution

Use the <four-momentum> convention $p^\mu=(E/c,\mathbf p)$, with Minkowski signature $(+,-,-,-)$. For a particle of rest mass $m>0$ and three-velocity $\mathbf v$,
$$
\boxed{p^\mu=m\gamma(c,\mathbf v),\qquad\gamma=\frac1{\sqrt{1-|\mathbf v|^2/c^2}}.}
$$
Here $E=\gamma mc^2$ and $\mathbf p=\gamma m\mathbf v$, so $p^\mu p_\mu=m^2c^2$.