Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes


At first, thank you for inventing this very good tools

i wondering is there other way to split index

if i use split_index command to split index m to \mu and 5,

i get

A^{m} B_{m} = A^{\mu} B_{\mu} + A^{5} A_{5} 


i want this to be

A^{m} B_{m} = A^{\mu} B_{\mu} - A^{5} A_{5}

Is there any good way?

Thank you

in General questions by

2 Answers

+1 vote

In Cadabra the Einstein index summation convention always means just a plain sum, without sign factors. Did you really mean those indices to one upper, one lower? Or does this sign come from a suppressed metric?

by (76.5k points)
+1 vote

With the version of Cadabra currently on github ( you can write a small function which examines every term in the expression, counts the number of '5' indices, and flips the sign if there is an odd number of pairs. Starting from

{\mu,\nu}::Indices(subspace, parent=space);
ex:=A^{m n} B_{m n};
split_index(ex, $m, \mu, 5$, repeat=True);

which produces $$A^{\mu \nu} B_{\mu \nu}+A^{\mu 5} B_{\mu 5}+A^{5 \mu} B_{5 \mu}+A^{5 5} B_{5 5},$$ you can define

def flip5(ex):
   for node in ex:
      for term in node.terms():
         for index in term.indices():
             if index.name=="1" and index.multiplier==5:
         term.multiplier *= (-1)**(cnt//2)
   return ex

and then do


to get $$A^{\mu \nu} B_{\mu \nu}-A^{\mu 5} B_{\mu 5}-A^{5 \mu} B_{5 \mu}+A^{5 5} B_{5 5}$$

by (76.5k points)