I am slowly learning how to use Feyncalc, and I have a quick question.

I have a third rank tensor B[mu,nu,tao] and I also have a four-vector FV[W,mu]. I would like to contract the first two indices of "B" to get a four-vector, and then contract the result with "W" to obtain a scalar result. So I wrote this:


But this does not seem to be working, I get error messages and/or results that don't make sense. Is there a better way to write the formula for "res"? Thanks for any assistance.

  • 1
    $\begingroup$ It seems DeclareFCTensor[B]; Contract[B[mu, nu, tao] FV[W, tao]] doesn't work. In my program Package-X, you would do Contract[LTensor[B, mu, nu, tau] LTensor[W, tau]]. I wonder what the analog of LTensor in FeynCalc is. $\endgroup$
    – HirenPatel
    Oct 27, 2020 at 23:21
  • 1
    $\begingroup$ The indices inside B should be wrapped into LorentzIndex: DeclareFCTensor[B]; Contract[B[LorentzIndex[mu], LorentzIndex[mu], LorentzIndex[tao]]* FV[W, tao]]. This is because FeynCalc internally "sees" FV[W,tao] as Pair[LorentzIndex[tao], Momentum[W]], so that B must be written in a similar fashion. $\endgroup$
    – vsht
    Oct 27, 2020 at 23:31
  • $\begingroup$ Thank you vsht. I tried this code: DeclareFCTensor[B]. Then I wrote H:=Contract[B[LorentzIndex[mu],LorentzIndex[mu],LorentzIndex[tao]]*FV[W,tao]. And I also wrote B[mu_,nu_,tao_]:=MT[mu,nu]*FV[v,tao]. This failed. So I am flummoxed. $\endgroup$ Oct 28, 2020 at 0:22

1 Answer 1


If B is a generic tensor, you have to explicitly wrap the indices into LorentzIndex

Contract[B[LorentzIndex[mu], LorentzIndex[mu], LorentzIndex[tao]]* FV[W, tao]]

Notice that DeclareFCTensor is only needed if you also want to be able to uncontract the indices as in

Uncontract[B[LorentzIndex[mu], LorentzIndex[mu], Momentum[W]], W, 
 Pair -> All]

Otherwise you could also omit DeclareFCTensor.

Now, if B is just a shortcut for a tensor made out of products of 4-vectors and metric tensors, things become much simpler: you can define it as one would define a generic function in Mathematica

Contract[B[mu, mu, tao]*FV[W, tao]]

Notice that

Contract[B[LorentzIndex[mu], LorentzIndex[mu], LorentzIndex[tao]]*
  FV[W, tao]]

also works, because LorentzIndex[LorentzIndex[mu]] is evaluated to LorentzIndex[mu].

Extended FeynCalc-related questions are probably best asked in the new forum on GitHub (which is much easier to use than the old, now retired, mailing list)


  • $\begingroup$ Thanks vsht. In the future I will use GitHub. I am still getting a crazy result. Please note that before I ran this code, I shut down and restarted my computer, and reloaded Feyncalc, so hopefully this cleared any cache. I will now show the exact code and the exact result.... B1[La_,be_,cu_]:=MT[be,cu]*FV[v,La]; res=Contract[B1[mu,mu,om]] The crazy result is a sum of three fractions all having the same denominator which is 2mu. The sum of these three numerators is -(2mu-om)Bsubscript0(mu,mu,om)-Asubscript0(om)+Asubscript0(mu) What am I doing wrong? $\endgroup$ Oct 28, 2020 at 20:52
  • 1
    $\begingroup$ This is because B1 and A0 are already defined in FeynCalc to denote something else (Passarino-Veltman functions). Hence, when you try to use them as tensors, things get maximally messed up. So just use different names that are still free. You can always use ?myVar to check if there are any definitions already attached to myVar. If not, you will see something like Missing[UnknownSymbol,myVar] $\endgroup$
    – vsht
    Oct 29, 2020 at 10:02
  • $\begingroup$ Thank you vsht! I will try this when I get home. $\endgroup$ Oct 29, 2020 at 15:22
  • $\begingroup$ I have accepted this answer. Also, I posted a separate issue at GitHub (under the username "Ferrylodge"). Thanks again. $\endgroup$ Oct 31, 2020 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.