TransWikia.com

grouping common powers of Bose operators

Mathematica Asked on January 20, 2021

I compute a product of Bose operators and turn it into normal ordering using Boson commutation relations, e.g:

c1 * SuperDagger[a] ** SuperDagger[a] ** a ** a + 
c2 * SuperDagger[a] ** SuperDagger[a] ** SuperDagger[a] ** a ** a ** a

and generally more terms. In the above c1, c2 are scalars while a, SuperDagger[a] are the Bose operators.

I can convert it to a more readable form by adding

/.NonCommutativeMultiply[a___] :> Infix[NonCommutativeMultiply[a],"[InvisibleTimes]"]

at the end of the evaluation command, which makes the ** symbol invisible (output is not displayed correctly here, sorry).

I would like to know whether I can make such expressions more readable by having in the output the various terms in the form SuperDagger[a]^3 a^3 and NOT like
SuperDagger[a] SuperDagger[a] SuperDagger[a] a a a

Also how can I isolate specific powers e.g SuperDagger[a]^2 a^2 in a long expression involving many different powers of SuperDagger[a]^n a^n and get their display only, e.g:

(3 * c1 + 5 * c0 + 7 * c6) SuperDagger[a] ** SuperDagger[a] ** a ** a

Collect doesn’t do the trick.

One Answer

Would this work?

expr = c1*SuperDagger[a] ** SuperDagger[a] ** a ** a + 
        c2*SuperDagger[a] ** SuperDagger[a] ** SuperDagger[a] ** a ** a ** a

ClearAll[collectPowers]
collectPowers[expr_] := 
  ReplaceRepeated[
    expr,
    {NonCommutativeMultiply[x_, x_] :> x^2,
     NonCommutativeMultiply[Power[x_, i_], x_] :> Power[x, i + 1]}
  ]


collectPowers[expr]

(* Out: c1 (SuperDagger[a])^2 ** a^2 + c2 (SuperDagger[a])^3 ** a^3 *)

Correct answer by MarcoB on January 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP