Metric field equations for the Jordan-Brans-Dicke action Considering the Jordan-Brans-Dicke action:
$$S=\int d^4x\sqrt{-g}\left(\phi R+\frac\omega\phi(\partial\phi)^2+\mathfrak{L_{m}}(\psi)\right).$$
I was trying to get the metric field equations by varying the metric and got this:
$$ -\frac{1}{2}g_{\mu\nu}R+R_{\mu\nu}+\frac{\omega}{\phi^2}[-\frac{1}{2}g_{\mu\nu}(\partial\phi)^2+\partial_\mu\phi\partial_\nu\phi]-\frac{1}{2\phi}g_{\mu\nu}\mathfrak{L_{m}}(\psi)=0 $$
I varied the terms $\sqrt{-g}$, $R_{\mu\nu}$ , $g^{\mu\nu}$ and $\partial_\mu \phi \partial_\nu \phi g^{\mu\nu}$. If we are only conserned for the equations of the metric field then this is it right? If I wanted the equations for the gravitational field we would have to vary w.r.t. the metric and the field $\phi$ right?
EDIT: On the 2nd Leibniz rule I considered:
$$ -\nabla^{\alpha}\nabla_{\alpha}(g_{\mu\nu}\phi\delta g^{\mu\nu}) = -g_{\mu\nu}\nabla^{\alpha}\nabla_{\alpha}(\phi) \delta g^{\mu\nu}-g_{\mu\nu}\nabla^{\alpha} (\phi)\nabla_{\alpha}(\delta g^{\mu\nu})-g_{\mu\nu}\nabla_{\alpha} (\phi)\nabla^{\alpha}( \delta g^{\mu\nu})-g_{\mu\nu} \phi \nabla^{\alpha}\nabla_{\alpha}(\delta g^{\mu\nu}) $$
I pulled out the metric so I dont have to deal with 6 terms. The ones we want are only the first and second in the RHS of this equation
 A: The $\delta(\phi R)$ term will be:
$$\delta(\phi R) = \delta(\phi g^{\mu\nu}R_{\mu\nu}) = \phi\delta g^{\mu\nu}R_{\mu\nu} +\phi\delta R_{\mu\nu}g^{\mu\nu} $$
The term:  $\phi\delta g^{\mu\nu}R_{\mu\nu}$ is ready, here the variation of the inverse metric tensor is already a multiplying factor. Now the second term is:
$$\phi\delta R_{\mu\nu}g^{\mu\nu}  = \phi (g_{\mu\nu}\Box - \nabla_{\mu}\nabla_{\nu})\delta g^{\mu\nu}$$
where i've used the Palatini Identity. Now we have for example for the box term:
$$\phi g_{\mu\nu}\Box\delta g^{\mu\nu} = \phi g_{\mu\nu}\nabla^{\alpha}\nabla_{\alpha}\delta g^{\mu\nu} =\nabla^{\alpha}(\phi g_{\mu\nu}\nabla_{\alpha}\delta g^{\mu\nu}) -\nabla^{\alpha}\phi g_{\mu\nu}\nabla_{\alpha}\delta g^{\mu\nu}  $$
The first term is a total derivative. We will ignore it as a boundary term. Now we use Leibniz rule once again:
$$-\nabla^{\alpha}\phi g_{\mu\nu}\nabla_{\alpha}\delta g^{\mu\nu} = -\nabla^{\alpha}\nabla_{\alpha}(g_{\mu\nu}\phi\delta g^{\mu\nu}) + g_{\mu\nu}\delta g^{\mu\nu}\nabla^{\alpha}\nabla_{\alpha}(\phi)$$
where i've used metric compatibillity. So we have:
$$\phi g_{\mu\nu}\Box\delta g^{\mu\nu} = g_{\mu\nu}\delta g^{\mu\nu}\nabla^{\alpha}\nabla_{\alpha}(\phi) = g_{\mu\nu}\delta g^{\mu\nu} \Box \phi$$
One has to do the same procedure for the two covariant derivatives. The other terms seem correct.
The problem here is that the Ricci Scalar is coupled with $\phi$. When i first came across such coupling terms i had the same problem. In the context of General relativity, the action is:
$$S = \int d^4x \sqrt{-g}R. $$
The variation gives rise to the term $g^{\mu\nu}\delta R_{\mu\nu}$. We can show that this term is a total derivative term and cancel it. In the context of Brans Dicke (or other geometric modifications to Einstein Gravity, $f(R)$ for example, Horndeski, or matter fields non-minimally coupled to gravity) this term is no longer a total divergence. Here, this term is : $\phi\delta R_{\mu\nu}g^{\mu\nu}$. $\phi$ makes things tricky, we cannot now discard this term as it is, it is not a total derivative term. Thus, we follow the procedure i described above.
Regarding the second part of the question, yes you have to vary also with respect to $\phi$. Here $\phi$ is not a matter field, it is a geometric quantity.
