Calculating initial average energy of a thermal state We are given a system with the Hamiltionian 
$$H = \sum_i \omega_i a^{\dagger}_ia_i \tag{1}$$
where $a^{\dagger}_i, a_i$ are creation and anihilation operators. I did the calculations and got the result that the Hamiltonian from eq. (1) can be expressed as 
$$H = \sum_i n \omega  \mid n\rangle\langle n\mid \tag{2}$$
The system is in a thermal state where the density matrix is defined as
$$\tau = \frac{e^{-\beta H}}{\mathrm{Tr}(e^{-\beta H})} \tag{3}$$
If we plug (1) into (3) we obtain
$$\tau = (1-e^{-\beta \omega})\sum_n e^{n \beta \omega} \mid n\rangle\langle n\mid\tag{4}$$
Now I was asked to calculate the initial average energy of such a thermal state. What I did was
$$E(\tau) = \mathrm{Tr}(\tau H) = (1-e^{\beta \omega})\sum_n n\omega\cdot e^{-\beta \omega n}\tag{5}$$
But for some reason this is not correct. The correct answer is supposed to be 
$$E(\tau) = \omega\cdot \varepsilon_0 = \omega \cdot \frac{e^{-\beta \omega}}{1-e^{-\beta \omega}}\tag{6}$$
Can someone explain to me how the result from eq. (6) is obtained?
 A: What you obtain for (5) is also correct. To bring it into the same form as (6) you have to calculate the sum, which gives according to WolframAlpha:
$$\sum_{n=0}^{\infty} n \omega \cdot e^{-\beta \omega n} = \frac{\omega e^{\beta \omega}}{\left( e^{\beta \omega} - 1 \right)^2} = \frac{\omega e^{-\beta \omega}}{\left( 1 - e^{-\beta \omega} \right)^2}$$
In the last step I multiplied numerator and denominator by $e^{-2 \beta \omega}$. Now if you use this result in (5) you get:
$$(5) = \left( 1 - e^{-\beta \omega} \right) \cdot \frac{\omega e^{-\beta \omega}}{\left( 1 - e^{-\beta \omega} \right)^2} = \omega \cdot \frac{e^{-\beta \omega}}{1 - e^{-\beta \omega}}$$
A: As addendum to the answer by A. P. I will show how to evaluate such sums by hand:
\begin{align*}
  \sum_{n=0}^\infty n\omega e^{-\beta\omega n} &= - \partial_\beta \sum_{n=0}^\infty e^{-\beta \omega n} = -\partial_\beta \frac{1}{1 - e^{-\beta \omega}} = \frac{\omega e^{-\beta \omega}}{\big( 1 - e^{-\beta\omega} \big)^2}.
\end{align*}
The first step is to simplify the sum to the derivative of a geometric series, the second is to evaluate the geometric series, and the last is to evaluate the derivative.
Such sums are very common for the sums occurring in thermostatistics, so it is quite useful to know some tricks to handle them.
