# How to effectively substitute variables in xAct?

I am trying to find the gauge field equation by varying the Born-Infeld Action with the help of xact package. I use the following VarAction function for this purpose as defined below:

<< xActxPert

$CovDFormat = "Prefix"; (*Varying the action: general implementation*) PerturbAction[expr_, g_?MetricQ[a_?UpIndexQ, b_?UpIndexQ] | g_?MetricQ[a_?DownIndexQ, b_?DownIndexQ]] := Module[{pertexpr, res, dgloc,(*dummyloc,*)hp}, (* We define the metric perturbation, if not defined already *) dgloc = SymbolJoin["δ", g]; hp = Head@Perturbation[g[DownIndex@a, DownIndex@b]]; If[hp === Perturbation, DefMetricPerturbation[g, dgloc, SymbolJoin["ϵ", g]], dgloc = hp]; Block[{$DefInfoQ = False},

(* We perturb wrt to the metric and if it is the inverse metric we \
put a minus sign *)
pertexpr = (If[DownIndexQ[a], 1, -1])*
ToCanonical@
ContractMetric@ExpandPerturbation@Perturbation[expr] /.
Perturbation[tens_] :> 0;

(*We then use VarD.
It happens that some trivial Kronecker appear which need to be \
handle manually *)
res =
ToCanonical[(SameDummies@
ContractMetric@
VarD[dgloc[LI[1], a, b], CovDOfMetric[g]][pertexpr]) /.
delta[-LI[n_], LI[m_]] :>
KroneckerDelta[NoScalar[n], NoScalar[m]]];
];
res
]
PerturbAction[expr_, tensor_?xTensorQ, covd_] :=
Module[{res, dummyloc, pertexpr, inds},
Block[{$DefInfoQ = False}, (* We use a dummy name for the variation of the tensor, and use it to replace the formal first order perturbation the \ tensor *) (* So first we define this dummy tensor *) dummyloc = SymbolJoin["Var", tensor]; inds = DummyIn /@ SlotsOfTensor[tensor]; If[! xTensorQ[dummyloc], DefTensor[dummyloc @@ inds, First@DependenciesOfTensor@tensor]]; SymmetryGroupOfTensor[dummyloc] ^= SymmetryGroupOfTensor[tensor]; (* Then we perturb the action and replace Perturbation[ Tensor[..]] by this dummy tensor *) pertexpr = (ToCanonical@ ContractMetric[ ExpandPerturbation@Perturbation[expr] /. Perturbation[tens_?((# =!= tensor) &)[ar___]] :> 0 /. Perturbation[tensor[ind___]] :> dummyloc[ind]]); (* With this simple head, VarD works correctly. Again we need to handel some trivial Kronecker *) res = ToCanonical[(SameDummies@ ContractMetric@VarD[dummyloc @@ inds, covd][pertexpr]) /. delta[-LI[n_], LI[m_]] :> KroneckerDelta[NoScalar[n], NoScalar[m]]]; ]; res ] PerturbAction[expr_, tensor_[inds___]] := PerturbAction[expr, tensor[inds], CovDOfMetric@First@$$Metrics] PerturbAction[expr_, tensor_?xTensorQ[inds___], covd_] := Module[{res, dummyloc, pertexpr}, Block[{$$DefInfoQ = False}, dummyloc = SymbolJoin["Var", tensor]; If[! xTensorQ[dummyloc], DefTensor[dummyloc[inds], First@DependenciesOfTensor@tensor]]; SymmetryGroupOfTensor[dummyloc] ^= SymmetryGroupOfTensor[tensor]; (* Perturbation with xPert*) pertexpr = (ToCanonical@ ContractMetric[ ExpandPerturbation@Perturbation[expr] /. Perturbation[tens_?((# =!= tensor) &)[ar___]] :> 0 /. Perturbation[tensor[ind___]] :> dummyloc[ind]]); (* VarD and removal of KroneckerDelta*) res = ToCanonical[(SameDummies@ ContractMetric@VarD[dummyloc[inds], covd][pertexpr]) /. delta[-LI[n_], LI[m_]] :> KroneckerDelta[NoScalar[n], NoScalar[m]]]; ]; res ] VarAction[expr_, g_?MetricQ[as__?((UpIndexQ[#] || DownIndexQ[#]) &)]] := Module[{sqrtg}, sqrtg = Sqrt[SignDetOfMetric[g] Determinant[g][]]; ToCanonical[ PerturbAction[expr, g[as]] + ReplaceDummies@expr*PerturbAction[sqrtg, g[as]]/sqrtg ] ] VarAction[expr_, tensor_?((xTensorQ[#] && Not[MetricQ[#]]) &), g_?MetricQ] := PerturbAction[expr, tensor, CovDOfMetric[g]] VarAction[expr_, tensor_?((xTensorQ[#] && Not[MetricQ[#]]) &)] := VarAction[expr, tensor, First@$Metrics];

VarAction[expr_,
tensor_?((xTensorQ[#] && Not[MetricQ[#]]) &)[inds___], g_?MetricQ] :=
PerturbAction[expr, tensor[inds], CovDOfMetric[g]]
VarAction[expr_,
tensor_?((xTensorQ[#] && Not[MetricQ[#]]) &)[inds___]] :=
VarAction[expr, tensor[inds], First@\$Metrics];


The details of my Born-Infeld action, vectors, scalars, tensors and the used metric are as below:

dimension = 5;
DefManifold[M5, dimension, {μ, ν, δ, η, χ}];

DefMetric[-1, g[-μ, -ν], CD, {";", "∇"}, PrintAs -> "g"];

DefConstantSymbol[b]
DefTensor[A[-μ], M5](* Vector field *)
DefTensor[ϕ[], M5](* Scalar field *)
DefTensor[F[-μ, -ν], M5,
Antisymmetric[{-μ, -ν}]] (* Maxwell strength tensor*)
DefScalarFunction[V](* A potential *)
DefScalarFunction[f] (*A general scalar function*)

L = RicciScalarCD[] +
f[ϕ[]] b^2 (1 - Sqrt[
1 + (F[-μ, -ν] F[μ, ν])/(2 b^2)]) -
1/2 CD[μ]@ϕ[] CD[-μ]@ϕ[] - V[ϕ[]]


Now, if I define my electromagnetic field tensor in terms of vector potential as:

F[a_, b_] := CD[a][A[b]] - CD[b][A[a]]


and then try to find the gauge field equation by varying the action w.r.t. $$A^\mu$$ by:

gaugefieldeqn = VarAction[L, A[μ]] // Simplification


I get my answer in terms of vector potentials. The desired solution is:

$$\triangledown_\mu\left[\sqrt{-g}\frac{f(\phi)}{\sqrt{1+\frac{F^2}{2b^2}}}F^{\mu\nu}\right]$$

How do I convert gaugefieldeqn to electromagnetic field tensor form($$F^{\mu\nu}$$) to get the desired solution?