The total action of the known gravitational system is:
In gravity, the field equations are obtained by varying with respect to the metric and not treating the connection independently. The main steps are the same as in the case of the variation of the Hilbert-Einstein action but there are also some important differences.
The variation of the determinant is
The Ricci scalar is defined as
Therefore the variation with respect to the inverse metric is given by
Since is the difference of two connections, it should transform as a tensor. Therefore, using and , it can be written as
Substituting into the yeilds:
where "" is the covariant derivative and is the D'Alembert operator acting on the function . Let us consider now a generic analytic function obeying the variational principle . We have
For the second item, performing integration by parts (, ) and ignoring the divergence term will lead to
Thus
On the other hand, the variation of the action of the material part is