This question is motivated by a Quantum mechanical problem - but in explaining the problem - I assume no knowledge of quantum mechanics.
I want to define a function that can expand and simplify the following operator polynomial: $(\hat{a}^\dagger + \hat{a})^n\vert0\rangle$. The usual Expand function in Mathematica assumes commutativity of the two terms in the brackets, but of course here we have $[\hat{a}, \hat{a}^\dagger] = 1$, and so care with ordering must be used.
Indeed the expansion can be done easily since the expansion can be considered binary terms, i.e. (omitting the hats on the operators A and B):
(A+B)^n = AAA + AAB + ABA + ABB + BAA + BAB + BBA + BBB
which can be identified as the numbers from 0 to 7 if we re-label $A = 0$ and $B = 1$. Indeed I have also let $A = \hat{a}^\dagger$ and $B = \hat{a}$. Now since all of the terms in this expansion then operates on the vacuum state, we have the following properties:
- Any terms ending with $B$ is zero and so has no contribution. This is since $\hat{a}\vert0\rangle = 0$.
- Terms that have more $B$'s than $A$'s will also evaluate to zero.
So for example the terms $AAB$, $ABB$, $BAB$, $BBA$ and $BBB$ will have no contribution to the total evaluation of $(\hat{a}^\dagger + \hat{a})^n\vert0\rangle$. I would like to apply these rules for the expansion of the polynomial for general $n$ so that the output is greatly simplified.
There will be another further rule that must be considered for higher $n$ since there will be a greater variety of terms that the above rules do not consider. For example, for $n=5$, the following term will also be zero:
- $AABBA\vert0\rangle=0$
The easiest way to think why this is the following rules of the annihilation and creation operators: $\hat{a}\vert0\rangle = 0$ (as written above) and $\hat{a}^\dagger\vert0\rangle = \vert1\rangle$. So the operator of $B$ on $\vert0\rangle$ minuses 1 from the index, whilst $A$ adds one to the index. If the evaluation, beginning from the right, yields at any point a negative number, the term has no contribution to the expansion of the polynomial. So in the above example (Rule 3), we start from right-hand side, The A increases 0 to 1, B then decreases this to 0 and the second-B from the right decrease this to -1: hence the term has no contribution.