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

Dear community.

I've been reviewing the Poincare algebra notebook, and trying to include the commutations with the momentum operator $P$. In the generalization, I noticed that even if the substitution rule \commutator{J}{P} is defined, expressions including the \commutator{P}{J} do not get substituted.

I included an extra commutation rule by hand and everything worked properly.

Question: Is there a way to automate the definition of the commuted commutator?


Update 1.

After the answer by Kasper, let me provide a piece of code,

First, some definitions from the example in the webpage,

{a,b,c,d,m,n,p,q,r,s,t}::Indices.
{a,b,c,d,m,n,p,q,r,s,t}::Integer(0..3).
\eta_{a b}::KroneckerDelta.
\delta{#}::KroneckerDelta.
e_{a b c d}::EpsilonTensor(delta=\delta).
J_{a b}::AntiSymmetric.
J_{a b}::SelfNonCommuting.
{ J_{a b}, P_{a}, W_{a} }::NonCommuting.
{ J_{a b}, P_{a}, W_{a} }::Depends(\commutator{#}).

def post_process(ex):
   unwrap(ex)
   eliminate_kronecker(ex)
   canonicalise(ex)
   rename_dummies(ex)
   collect_terms(ex)

The commutator substitution:

subs := \commutator{J_{a b}}{P_{c}} -> \eta_{a c} P_{b} - \eta_{b c} P_{a};

If we apply the substitution to the commutator in the reversed order, even if the commutator is an skew-symmetric operator, it returns the initial expression

ex1 := \commutator{P_{c}}{J_{a b}};
substitute(ex1, subs);

$[P{c},J{a b}]$

while the substitution on the expression written in the "right" order returns the expected result,

ex2 := \commutator{J{a b}}{P{c}}; substitute(ex2, subs);

$\eta{a c} P{b}-\eta{b c} P{a}$

Re-stated question(s)

  • Is it possible to generate an "automatic" substitution rule for \commutator{B}{A} if the rule \commutator{A}{B} is provided?
  • Could this be an interesting feature request?
  • If the above sounds interesting, it might be generalised to the anticommutator operator.
in General questions by (15.1k points)
edited by

2 Answers

+1 vote
 
Best answer

As you didn't give any explicit code I am guessing about what you want to do precisely. But in general, Cadabra never automatically makes substitutions. If you want something (substitution, simplification, factor collection, ...) to happen at every step of your computation, you need to put it in the post_process function. To illustrate: if you do

rl:= \commutator{A??}{B??} -> A?? B?? - B?? A??;

def post_process(ex):
   substitute(ex, rl)
   collect_terms(ex)

then the input

ex:=\commutator{P}{Q};

will immediately produce

P Q - Q P;

Hopefully you can generalise from here.

by (83.0k points)
selected by

Hi K. Thank you for the quick answer (as usual). In order to clarify my question/interest I've updated the question.

;-)

+1 vote

Answers to your re-stated questions: no, yes, yes.

by (83.0k points)
...