# Harmonic oscillator at finite temperature: taking expectation values of operators

I have the Hamiltonian of an harmonic oscillator (with $\hbar=1$) $$H = \omega \left(a^\dagger a + \dfrac{1}{2} \right) \;,$$ and the associated (canonical) partition function $$Z = \text{Tr}\left[e^{-\beta H} \right] = \dfrac{1}{2} \text{csch}\left(\dfrac{\beta \omega}{2}\right) \;,$$ where $\beta = 1/T$ is the inverse temperature (with $k_B=1$).

For the operator $$O = A(a+a^\dagger)+B(a+a^\dagger)^2 \;,$$ where $A$ and $B$ are real constants, I want to know its expectation value when evaluated on the harmonic oscillator at finite $\beta$.

Since this expectation value is given by $$\langle O \rangle = \dfrac{\text{Tr}\left[O e^{-\beta H} \right]}{Z} \;,$$ the sum at the numerator can be easily computed if $O$ and $H$ can be diagonalised in the same basis. However, what should I do when this is not the case?

• Welcome to Physics Stack Exchange. We support questions like this only when the author shows effort and identifies a specific aspect on which they are stuck. – DanielSank Oct 2 '17 at 16:54
• @DanielSank, I'll add some more details. – m137 Oct 2 '17 at 20:46

You can always go straightforward and use that you know how $\hat{a}$ and $\hat{a}^\dagger$ act on the basis $|n\rangle$. Let's write down straightforwadly what $\mathrm{Tr}$ is \begin{equation} \mathrm{Tr}\Big(\hat{O}e^{-\beta\hat{H}}\Big)=\sum_n\langle n|\hat{O}e^{-\beta\hat{H}}|n\rangle=\sum_n e^{-\beta(n+1/2)}\langle n|\hat{O}|n\rangle \end{equation} Now, your operators can be written in the form, \begin{equation} \hat{O}=\sum_{lk}o_{lk}\Big(\hat{a}^\dagger\Big)^l \Big(\hat{a}\Big)^k \end{equation} As trace is linear that implies that, \begin{equation} \mathrm{Tr}\Big(\hat{O}e^{-\beta\hat{H}}\Big)=\sum_{nlk}e^{-\beta(n+1/2)}o_{lk}\langle n|\Big(\hat{a}^\dagger\Big)^l \Big(\hat{a}\Big)^k|n\rangle \end{equation} Now remember that, \begin{equation} a^\dagger|n\rangle=\sqrt{n+1}|n+1\rangle,\quad a|n\rangle=\sqrt{n}|n-1\rangle \end{equation} That means that, \begin{equation} \langle n|\Big(\hat{a}^\dagger\Big)^l \Big(\hat{a}\Big)^k|n\rangle\sim \langle n|n+l-k\rangle \end{equation} But as $\langle n|m\rangle=\delta_{nm}$ that means that only when $l=k$ this product is nonzero. So you need to take into account only such terms in $\hat{O}$. From here I think it's easy to do the rest.
If $\hat H$ admits of the basis $\hat H |n\rangle = E_n|n\rangle$ and this basis resolves the identity $\hat 1 = \sum_n |n\rangle\langle n|$, then we can insert this twice and use the cyclic permutativity rule of trace to rewrite $$\operatorname{Tr}\left(\hat O~e^{-\beta \hat H}\right) = \sum_{m,n}\langle m|\hat O|n\rangle~\langle n|e^{-\beta \hat H}|m\rangle=\sum_n\langle n|\hat O|n\rangle e^{-\beta E_n}.$$ This is not the only basis which makes things simple, but it's probably the most straightforward in general, and in your case where you can define $x = a^\dagger + a$ as one of the quadratures of your system (different people normalize this in different ways) and then have $O = A x+ Bx^2,$ this is likely to just be $$\sum_n e^{-\beta~\hbar\omega~n} \int_{-\infty}^\infty dx~ \psi_n^*(x)~ \psi_n(x)~(A x + B x^2).$$ The $A x$ term probably vanishes completely due to symmetry and the $x^2$ is probably not too complicated to work out.