# Given variables that can take on certain values, and the sum equals the determined total, how would you find the total number of combinations…?

The full question "Given variables that can take on certain values, and the sum of the values has to equal the determined total, how would you find the number of combinations that equal the total value and the number of permutations of the combinations?"

Imagine four particles within a box. The total energy of the particles can not exceed 5 units, for now it'll be MeV (Mega Electron Volts). Each particle can take on a value of 0≤X≤5 (Energy Level 0-5). There are six possible states (Ps) that these particles can be arranged in.

Ps One (P(1)): Particle One (Part1) through Part3 could be at energy level 0, while Part4 would be at energy level 5.

P(2): Part1-3 at energy level 1. Part4 at energy level 2.

P(3): Part1-2 at energy level 0. Part3 at energy level 1 and Part4 at energy level 4.

P(4): Part1-2 at energy level 0. Part3 at energy level 2 and Part4 at energy level 3.

P(5): Part1 at energy level 0 and Part2-3 at energy level 1. Part4 at energy level 3.

P(6): Part 1 at energy level 0 and Part2 at energy level 1. Part3-4 at energy level 2.

Now we come order. Each Ps (Possible State) has multiple possible arrangements when it comes to the order of the particles. These arrangements will from here forth be called microstates, Ms.

P(1)=4 Ms; P(2)=4 Ms; P(3)=12 Ms; P(4)=12 Ms; P(5)=12 Ms; P(6)=12 Ms.

This brings total number of mircostates to 56.

So, given the number of particles, x; the number of energy levels, y; and the the total energy level, z MeV; how would one determine the number of possible states and mircostates?

Also, the occurrence of particles within energy level 0 for P(1) is equal to the number of particles times the number of microstates, (3*4=12). This would be 12 occurrences within energy level 0 for P(1). Can you determined the total occurrences for each energy level for each possible state given x,y,z?

Also, would there be anyway to do this on a ti-84, specifically a ti-84 CE Plus? I'm open to writing custom programs or using preset functions.

Thanks.

The first step is to introduce a convenient notation for a particular microstate. It turns out that for this type of problems this will be of the form of a polynomial expression. Consider the following term $$x_1^{m_1} x_2^{m_2} x_3^{m_3} x_4^{m_4}$$ which we can use to represent a microstate of 4 particles $$x_1, x_2,x_3,x_4$$ that are found in respectively energy levels $$m_1,m_2,m_3,m_4$$, with $$m_i$$ a non-negative integers. The total energy of the state would correspond to $$M=\sum_{1=1}^4 m_i$$.
The next step is to create all possible microstates, for which we can evaluate the following expression: $$\prod_{i=1}^4 (1+x_i+x_i^2+x_i^3+x_i^4+x_i^5) = \prod_{i=1}^4 \left(\sum_{k=0}^5 x_i^k\right) \qquad \qquad \qquad (*)$$ where we use that any particle can be only in energy level $$0,1,\dots,5$$. Working this out will give all possible microstates with each of the 4 particles restricted to those couple of energy levels. To find the number of microstates with energy $$M=5$$ we only need to count the number of terms of order $$M$$. Since we do not have to know the actual microstate, but are only interested in the energy, we can do this somewhat simpler. Note that once we have all microstates and choose $$x_i=y$$, each allowed microstate will give a contribution $$y^M$$, and hence that the number of different microstates with energy $$M$$ will correspond to the coefficient of the term $$y^M$$ in $$\prod_{i=1}^4 (1+y+y^2+y^3+y^4+y^5) = 1 + 4 y + 10 y^2 + 20 y^3 + 35 y^4 + 56 y^5 + 80 y^6 + \dots$$ which in the case of $$M=5$$ gives indeed the 56 as in the example.
Now for counting the number of states. We can focus on unique arrangements within each state by requiring that $$m_1 \leq m_2 \leq m_3 \leq m_4$$. If we now introduce the numbers $$n_1=m_1$$ and $$n_i \equiv m_i - m_{i-1}$$ for $$i>1$$, we can rewrite such a particular microstate as $$x_1^{m_1} x_2^{m_2} x_3^{m_3} x_4^{m_4} = (x_1 x_2 x_3 x_4)^{n_1} (x_2 x_3 x_4)^{n_2} (x_3 x_4)^{n_3} (x_4)^{n_4}$$ where $$n_i \geq 0$$ and $$m_4=n_1+n_2+n_3+n_4\leq 5$$ (This automatically ensures that all $$m_i\leq5$$). We can use the same approach as before to generate all possible microstates with this type of arrangement by constructing $$\sum_{n_1=0}^5 (x_1 x_2 x_3 x_4)^{n_1} \sum_{n_2=0}^{5-n_1} (x_2 x_3 x_4)^{n_2} \sum_{n_3=0}^{5-n_1-n_2} (x_3 x_4)^{n_3} \sum_{n_4=0}^{5-n_1-n_2-n_3} (x_4)^{n_4}$$ the upper limits in the summations will ensure that all $$m_i \leq 5$$. This expression will give for each possible energy state exactly a single arrangement. Hence, counting the number of different states with energy $$M$$ will be again counting the number of terms of the corresponding order. Also here we can set $$x_i=y$$ and look for the coeficient of $$y^M$$ to find the number of different states. In this particular case we would find $$1+y+2y^2+3y^3+5y^4 + 6y^5 + 8 y^6 + \dots$$ and hence that there are 6 different states of energy level $$M=5$$.
Finding the number of microstates in a particular state with energy $$M$$ requires explicit knowledge of the numbers $$(m_1,m_2,m_3,m_4)$$ for one of its microstates. If that is known it is a simple combinatorical factor. Alternatively, you could consider $$(*)$$ and repeatedly modify the expression by replacing factors $$x_i^{m_i} x_j^{m_j}$$ by $$x_i^{m_j} x_j^{m_i}$$, whenever $$i and $$m_i>m_j$$. The final result would be a polynomial with every term corresponding to a unique state and the coefficient would correspond to the number of microstates within.