For example if we need to get number of degenerate states for a particle confined in a 3D box that have energy $$E=41\frac{\pi ^2 \bar{h}^2}{2m_e L^2}$$ I know that $$E=\frac{n^2 \pi ^2 \bar{h}^2}{2 m_e L^2} $$ and $$n^2=n_x ^2+ n_y ^2 +n_z ^2$$ $$\Rightarrow n_x ^2+ n_y ^2 +n_z ^2=41$$ But how do I get all the different values of $ (n_x, n_y, n_z)$?
1 Answer
What you have here could be described as a subset sum problem. Given $n$ can take any integer value (not including zero), you have the set of squares up to $36$,
$S = \{1,4,9,16,25,36\}$
and you wish to find subsets of three which sum to $41$. Looking at the subset sum problem this can not be solved analytically but algorithms can be employed.
To do this vigorously you need to form a 3D matrix $6 \times 6 \times 6$ by summing together the relevant squares and then read off the indices where $41$ is achieved, a task made easier with a bit easier with a computer script.
You must also note that any summation where $n_x \neq n_y \neq n_z$ will form a 6-fold permutation, sets with 2 distinct values will form a 2-fold permutation, whereas for $n_x = n_y = n_z$ the solution is unique.