# Counting the micro-states of a set of harmonic oscillators

We have an isolated assembly of N indistinguishable harmonic oscillators, each has energy $$\epsilon_i=\hbar \omega/2 + n_i \hbar\omega$$, where $$n_i$$ is a non-negative integer. If the total energy of the system is $$E=N\hbar\omega/2 + M\hbar\omega$$, ($$N\gg 1$$) then each micro-state must satisfy $$\sum_{i=1}^{N}\epsilon_i =E\quad\Longrightarrow \quad \sum_{i=1}^N n_i=M$$ To determine micro-canonical entropy we need to know the number of possible ways for this relationship to be satisfied. I was trying to deduce a formula, or find some relationship of recurrence:

If $$M=0$$ $$n_i=0\quad\forall i\quad\Longrightarrow\quad\omega(E)=\dfrac{N!}{N!}=1,$$ If $$M=1$$ $$n_i=0\quad\forall i \not=j\;\;, \wedge, \;\; n_j=1\quad \Longrightarrow\quad\omega(E)=\dfrac{N!}{(N-1)!}=N,$$ If $$M=2$$ $$\begin{cases}n_i=0\quad\forall i \not=j&, \wedge, \;\; n_j=2\\ n_i=0\quad\forall i \not=j_1,j_2&, \wedge, \;\; n_{j_1}=1= n_{j_2} \end{cases} \quad\Longrightarrow\quad \begin{cases} \omega_1=\dfrac{N!}{(N-1)!}=N,\\ \omega_2=\dfrac{N!}{(N-2)!2!}=\dfrac{N(N-1)}{2},\\ \end{cases}\quad \Longrightarrow\omega(E)=\omega_1+\omega=\dfrac{N(N+1)}{2}$$ In the same way, if $$M=3$$ $$\begin{cases} \omega_1=N\\ \omega_2=\frac{N!}{(N-2)!}=N(N-1)\\ \omega_3=\frac{N!}{(N-3)!(3!)}=\frac{N(N-1)(N-2)}{3!} \end{cases}\Longrightarrow\quad\omega(E)=\omega_1+\omega_2+\omega_3=\frac{N(N+1)(N+2)}{3!}$$ Then for a non-negative integer $$M$$, $$\omega(E)=\frac{\displaystyle\prod_{i=0}^{M-1}(N+i) }{M!}\overset{?}{=}\frac{(N+M-1)!}{M!(N-1)!}= \begin{pmatrix} N+M-1\\N-1 \end{pmatrix}$$ But it is not clear to me, Is okay?, Is there another way to get this?, How I interpret this result?

Your answer is correct. Here is one way to think about the answer. The point of the microcanonical ensemble is that we fix the energy and the particle number and the more ways we can achieve this macrostate of fixed E and N, the more probable we are to be in this macrostate. Knowing this, we can see that the freedom we have in this problem is in choosing the $$n_i$$, the energy level for the $$i$$th particle. Using the formulas, this is the same statement as
$$M = \frac{E}{\hbar \omega}-\frac{N}{2}$$ where $$M = \sum_i^N n_i$$ and $$n_i \in \{0,1,2,...\}$$
So now our problem goes like this: how many different ways can we sum up $$N$$ integers to the value $$M$$? One way we can think about this problem is like this: say we have $$M$$ indistinguishable balls and we line them up. Then we divide up the balls into $$N$$ segments, which would require $$N-1$$ dividers (where two dividers can have $$0$$ balls in between them). Note: this is exactly our problem as $$n_i$$ would be the number of balls between two of the dividers. So we can say we have $$M+N-1$$ slots and we can put either a ball or a divider in a slot.
If the balls and the dividers were distinguishable, we would have $$(M+N-1)!$$ arrangements. But since they are indistinguishable, we really have $$\frac{(M+N-1)!}{M!(N-1)!}$$ arrangements (because for any arrangement we have to divide out the $$M!$$ different ways we can arrange the balls and the $$(N-1)!$$ different ways to arrange the dividers.)