Hi Giulia et al.,
This may indeed be a subtle bug... note that if you use VarD[g[e, f], PD][trial2], there is a nonzero result, but if you use VarD[g[e, f], CD][trial2], the result vanishes. At the very least this is inconsistent, because there are no derivatives involved, so why does the choice of second argument (PD vs CD) change the result?
You can track down the definition that's leading to this result by examining Definition[Detg]. When Detg is defined (see Sec. 14.1.5 of xTensor.nb), there is a definition set for VarD[Invg[a,b],PD][Detg[],rest] and VarD[g[-a,-b],PD][Detg[],rest].
1. Should this definition be for *any* CovD?
2. I think we can all agree that Sqrt[ +- Detg[] ] epsilong[a,b,c,d] should be independent of the metric (see e.g. MTW, Eq. (8.10a)). Then if there is a definition for VarD[..][Detg[]..], there should also be a corresponding definition for VarD[..][epsilong[..]..].
3. Is VarD acting correctly on tensors with general WeightOfTensor?
I have to defer to people who are more expert to answer these questions. Anybody have thoughts on the above?
L