<<xAct`xTensor`

$DefInfoQ=False;

Replace $ indices before displaying any equation.

$PrePrint=ScreenDollarIndices;

Define a manifold M4, and metric g.

DefManifold[M4,4,IndexRange[a,f]]

Define a metric with covariant derivative CD.

DefMetric[-1,g[-a,-b],CD]

Define a normal Nn to the surface.

DefTensor[Nn[a],M4,PrintAs->"n"]

Define the induced metric with intrinsic covariant derivative cd.

DefMetric[-1,h[-a,-b],cd,InducedFrom->{g,Nn},SymbolOfCovD->{":","D"}]

g[-a,-b]==MetricToProjector[g[-a,-b],h]

DefTensor[FMax[-a,-b],M4,Antisymmetric[{-a,-b}],PrintAs->"F"]

DefTensor[FMaxDual[-a,-b],M4,Antisymmetric[{-a,-b}],PrintAs->"*F"]

DefTensor[Electric[-a],M4,OrthogonalTo->{Nn[a]},ProjectedWith->{h[-b,a]},PrintAs->"E"]

DefTensor[Magnetic[-a],M4,OrthogonalTo->{Nn[a]},ProjectedWith->{h[-b,a]},PrintAs->"B"]

To convert equations to rules we can define two simple functions. The first allows metics, the other not.

EqToRule[expr_Equal]:=MakeRule[Evaluate[List@@expr],MetricOn->All,ContractMetrics->True]

EqToRuleN[expr_Equal]:=MakeRule[Evaluate[List@@expr],MetricOn->None,ContractMetrics->False]

FlipEquation[LHS_==RHS_]:=RHS==LHS

Define the electric and magnetic parts.

FMaxDualDef=FMaxDual[-a,-b]==1/2*epsilong[-a,-b,c,d]FMax[-c,-d]

ElectricDef=Electric[-a]==FMax[-a,-b]Nn[b]

MagneticDef=Magnetic[-a]==FMaxDual[-a,-b]Nn[b]

Calculations

epsilong[-a,-b,-c,-d]Magnetic[c]Nn[d]

%==ToCanonical[%/.EqToRule@MagneticDef]

ToCanonical@ContractMetric[%/.EqToRule@FMaxDualDef]

%/.EqToRule@FlipEquation@ElectricDef

NoScalar/@ToCanonical[PutScalar/@(Times[1/Scalar[Nn[-c] Nn[c]],#]&/@%)]

FMaxDecomposition=-%[[2,1]]==-%[[2,1]]+%[[2]]-%[[1]]

Example

DefTensor[U[],M4]

UDef=U[]==FMax[-a,-b]FMax[a,b]

ToCanonical@ContractMetric[UDef/.EqToRule@FMaxDecomposition]

UDecomposition=NoScalar/@ToCanonical[PutScalar/@%]