Solution (source code)

= Solution

Write $g=\det(g_{ab})$. The <Jacobi formula> gives $\delta g=g\,g^{ab}\delta g_{ab}$. Since a <Lorentzian metric> of signature $(+---)$ has negative <determinant>,
$$
\boxed{\delta\sqrt{-g}
=\frac12\sqrt{-g}\,g^{ab}\delta g_{ab}.}
$$
The <variation of metric volume density> therefore has the opposite sign when expressed using the inverse <metric tensor>: $\delta\sqrt{-g}=-\sqrt{-g}\,g_{ab}\delta g^{ab}/2$. This follows immediately from the <variation of inverse metric> and explains the volume term in the field-equation derivation.