We have an expression for $\Omega$ (occupation of each macrostate) in terms of $n_i$ (occupation numbers) . We want to find the $n_i$ which maximises $\Omega$.
We now that
Using stirlings approximation we can write this as
We are subject to two constraints 1. Total number of particles remain constant
- Total internal energy remains constant
$$U=constant: \sum_i\epsilon_i dn_i=0$$
We now use lagrange's method of undetermined multipliers.
This implies that
So, we have three things which must be zero simultaneously. We can multiple zero by any factor and still have zero so,
$$\sum_iln[n_i]dn_i=0, \alpha\sum_i\epsilon_i dn_i=0, \beta\sum_idn_i=0 $$
We can combine these expressions to write our overall maximisation problem as:
$$\sum_i(ln[n_i]+\alpha+\beta\epsilon_i)dn_i=0 \forall \alpha,\beta$$
Now the part I raise issue with is: apparently the only way for this to be solved is that every term in the sum has to be zero. So
$$ln[n_i]+\alpha+\beta\epsilon_i=0 \forall i,$$ but specific $\alpha$ and $\beta$.
However, surely, we are doing a sum here, there is no requirement that this be zero at all points. For instance, the sum may be zero, but part of the sum might be positive, but this is canceled by a negative part.
Anyway, just to finish the derivation, this rearranges to
Solving for $n_i$