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 :

{\mu,\nu}::Indices(vector).
\partial{#}::PartialDerivative.
{u,g_R,g_L,h}::Depends(\partial{#}).
\dagger::Symbol.
{u,g_R,g_L,h,(u)^\dagger}::NonCommuting.
ex:=i{(u)^{\dagger} (\partial_{\mu}(u)-i r_{\mu} u)-u (\partial_{\mu}((u)^\dagger)-i \ell_{\mu} 
(u)^\dagger)};
substitute(ex,$u->g_R u h^\dagger$);
product_rule(_);

I want to make

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

can be true, how to achieve this?

asked in General questions by (1k 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 ):
         rep=$P$
         lst=[]
         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} $)
         rep.top().name=r"\prod"
         node.replace(rep)
   return ex

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

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

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.

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

Hope this helps.

answered by (62.3k 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
(U^\dagger)^\dagger=U

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:

i^\dagger=-i

and

H^\dagger=H

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.

...