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

Following is my code :

ex:=i{(u)^{\dagger} (\partial_{\mu}(u)-i r_{\mu} u)-u (\partial_{\mu}((u)^\dagger)-i \ell_{\mu} 
substitute(ex,$u->g_R u h^\dagger$);

I want to make

 (A B C...)^\dagger=... C^\dagger B^\dagger A^\dagger 
 U^\dagger U=U U^\dagger=1

can be true, how to achieve this?

in General questions by (1.0k points)
edited by

1 Answer

+1 vote

We are in the process of making this properly supported, but in the meantime, give this function a shot (you need to build Cadabra from source for this, the functionality is not yet in any of the binary packages):

def expand_conjugate(ex):
   tst:= (A??)^{\dagger};
   for node in ex:
      if tst.matches( node ):
         for prod in node["\\prod"]:
            for factor in prod.factors():
               lst.append($ @(factor) $)
         for factor in list(reversed(lst)):
            rep.top().append_child($ @(factor)^{\dagger} $)
   return ex

If you stick the above in a cell and evaluate it, you can then do

ex:= (A B C)^{\dagger} + Q + (D E)^{\dagger};

to produce

$$C^{\dagger} B^{\dagger} A^{\dagger} + Q + E^{\dagger} D^{\dagger}$$

There will be better support for generic conjugation operations in Cadabra soon.

For the other two lines, try simple substitution with a rule of the type

rl:= { (A?^{\dagger})^{\dagger} = A?, 
         ( (A??)^{\dagger} )^{\dagger} = A??,
         A?^{\dagger} A? = 1,
         A? A^{\dagger} = 1,
         (A??)^{\dagger} A?? = 1,
         A?? (A??)^{\dagger} = 1 };

You can then do e.g.

ex:= ( U^{\dagger}  )^{\dagger} + U^{\dagger} U 
        + (A B)^{\dagger} + ( (A B)^{\dagger} )^{\dagger};
substitute(ex, rl);

Hope this helps.

by (64.9k points)
edited by

How to make "repeat" operation become effective? The other two functions also don't work, i.e.:

 U^\dagger U=U U^\dagger=1

I have updated my original answer to your question, let me know if anything else is missing.

Thanks, Kasper. There seem to be some bugs in your code , Cadabra reports "kernel crash". PS1: I also wish that Cadabra could know following rule in next version:




where H is Hermitian operator( including real number).

PS2: By the way, do you konw how to achieve following operation?

a b c... d e...->d e... a b c...

Following is my attempt:

ex:=a b c... d e...;
substitute(_,$A?? d B??-> d B?? A??$);

it does't work. I want to implement cyclicity of trace

tr(a b c)=tr(c a b)=tr(b c a)

PS3: I don't find any easy ways to compute the traces of gamma matrices in cadabra, are there any plans to do this work?

You need the latest from github for this to work.