# Explicit dependent

Hi everyone, I'm trying to derive the equations of motion of a scalar field with a potential $V(\phi)$, $S:= -\int \sqrt{-g}(\frac{1}{2}g^{\mu \nu} \partial_{\mu}{\phi} \partial_{\nu}{\phi}+V )d^4x$; however when I compute the variational derivative of the action with respect to $\phi$ the potential does not appear (due to property V::Depends(x), only allow to make objects implicitly dependent on the coordinates). Is there any property in Cadabra which Makes an object explicitly dependent on other objects, like $V(\phi)$?

Thank you !!

This is not automatic (yet), but it's not difficult to work around it by simply adding another rule for how $V$ should vary. Something like

\partial{#}::PartialDerivative;
\delta{#}::Accent;
g^{\mu\nu}::Symmetric;
S:= \int{ \sqrt{-g} ( 1/2 g^{\mu\nu}\partial_{\mu}{\phi} \partial_{\nu}{\phi} + V) }{x};
rl:= \phi -> \delta{\phi}, V -> V' \delta{\phi};
vary(S, rl)
sort_product(S)
canonicalise(_)

will produce

$$\int \sqrt{-g}(\partial_{\mu} \delta{\phi} \partial_{\nu} \phi g^{\mu\nu} + V^\prime \delta{\phi}) {\rm d}x$$

after which you can do

distribute(_)
integrate_by_parts(_, $\delta{\phi}$)
factor_out(_, $\delta{\phi}$);

to get things in an equation-of-motion form.

by (65.1k points)
$$S=\int d^{3}x\sqrt{-g}\left( \mathcal{R}-2\partial _{\mu }\phi \partial ^{\mu }\phi -F^{2}-V\left( \phi \right) \right)$$