I want to do math that involves a series of ladder operators. In the past I've tried to get it working with a 20 year old Mathematica package. But my feeling is that this is a very unused package and that it may be better to just work with NCAlgebra package instead.
Ultimately, I often have expressions that I need to work with and simplify. I have a series of ladder operators $a_i$. They have the commutation relationship:
$$[a_i, a_j^\dagger] = \delta_{ij},$$
For example, if I have a messier non-commuting polynomial of this, such as: $$ a_4**(k a_1**a_2**a_1^\dagger+c*a_2**a_1**a_3), $$ I want a general way that I can define my operators, their commutation relations, and provide a simplification such that it organizes the operators in increasing ordering and uses the commutator to flip them so that it is in the expanded form:
$$ka_2 + ka_1^\dagger a_1 a_2+ c*a_1**a_2**a_3$$
With all of the daggers in the leftmost side.
Similar to this question, I am looking for something like a "commutator expand," but with the daggers being placed on the left (instead of the right which is done with this commutator expand.). What is the most straightforward way of doing this, and can the NCAlgebra tools be useful in this case?
Also, in a more general question I asked, it was mentioned in the comments that a solution is provided 12 years ago here:
prod[u___, x_ + y_, v___] := prod[u, x, v] + prod[u, y, v];(*expand sums*) prod[u___, x_?NumericQ, v___] := x prod[u, v];(*pull out c-numbers*) prod[u___, prod[x___], v___] := prod[u, x, v]; This seems like a simple solution which doesnt need NCAlgebra, but it doesnt seem to work in some cases. For example with the code:
H = \[Omega]a prod[ad, a] + \[Omega]b prod[bd, b]; prod[H, a] - prod[a, H] // Simplify This does not actually simplify it out, and instead returns:
-prod[a, \[Omega]a prod[ad, a]] - prod[a, \[Omega]b prod[bd, b]] + prod[\[Omega]a prod[ad, a], a] + prod[\[Omega]b prod[bd, b], a] So I either need a solution to this problem via NCAlgebra, or at least a fix for this issue in the solution that doesnt use NCAlgebra.
prod[u___, x_?(FreeQ[#, prod] &) w_, v___] := x prod[u, w, v]to expand out nestedprodexpressions such as yours that contain non-numeric coefficients. Actually, to control expression evaluation better, I prefer to use<rule> <pattern> :> <replacement>rather than<pattern> := <replacement>. $\endgroup$