1
$\begingroup$

Suppose I have lot of product terms of Bose operators, e.g:

a a SuperDagger[a] SuperDagger[a] a a SuperDagger[a] SuperDagger[a] SuperDagger[a] SuperDagger[a]  a a a a 

and I want to turn them into normal ordering using Boson commutation relations

Writing each term as:

NCM[a, a, SuperDagger[a], SuperDagger[a], a, a, SuperDagger[a], SuperDagger[a], SuperDagger[a], SuperDagger[a],  a, a, a, a]

can be time consuming if you have many terms. Is there a way to work around this point? Can I somehow achieve the normal ordering by something like

f[a a SuperDagger[a] SuperDagger[a] a a SuperDagger[a] SuperDagger[a] SuperDagger[a] SuperDagger[a]  a a a a]

where f does the same thing as NCM?

$\endgroup$
1
$\begingroup$

You can do:

SetAttributes[f, HoldFirst]
f[_[args___]] := NonCommutativeMultiply[args]

Try it out:

a a SuperDagger[a] SuperDagger[a] a a SuperDagger[a] SuperDagger[a] \
  SuperDagger[a] SuperDagger[a] a a a a // f

Note that you cannot let Times evaluate at any time because that will re-order the arguments. So you cannot do something like:

expr = a SuperDagger[a] SuperDagger[a] a;
f[expr]
f[Evaluate[expr]]

What you can do:

expr = Inactivate[a SuperDagger[a] SuperDagger[a] a, Times];
f[Evaluate[expr]]

Edit

Here's another idea:

ClearAll[f]
SetAttributes[f, HoldFirst]
f[expr_] := Block[{Times = NonCommutativeMultiply}, expr]

In this case, the following will also work:

expr := a SuperDagger[a] SuperDagger[a] a;
f[expr]
$\endgroup$
2
  • $\begingroup$ Thanks for the answer.I have a question: a a SuperDagger[a] SuperDagger[a] a a SuperDagger[a] SuperDagger[a] SuperDagger[a] SuperDagger[a] a a a a // f works fine, but I don't have to use Inactivate. Only when I am assigning it to expr I have to use Inactivate? Seems so $\endgroup$
    – geom
    Dec 7 '20 at 11:45
  • 1
    $\begingroup$ @geom Yes, that is correct. The HoldFirst attribute of f prevents Times from evaluating when in the first example. In the second example, Times would evaluate while evaluating expr, so the HoldFirst attribute cannot help you there. I do have another idea, though. Let me update the answer. $\endgroup$ Dec 7 '20 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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