Solution (source code)

= Solution

Treat each species as a dilute classical ideal gas: molecules of the same species are indistinguishable, while different species are distinguishable. Let $N_i$ be the number of molecules of species $i$, $q_i(T,V)$ its <molecular partition function> with energies measured from a chosen internal reference, and $\varepsilon^{0,i}$ that reference energy per molecule relative to a common chemical energy convention. Then the mixture's <canonical partition function> factorizes:
$$
Q=\prod_i\frac{q_i^{N_i}}{N_i!}\exp[-\beta N_i\varepsilon^{0,i}],
\qquad \beta=\frac1{k_{\mathrm B}T}.
$$
The $N_i!$ corrects the overcounting of <indistinguishable particles>. The exponential restores the species-dependent reference energies that matter for reactions. Thus the <Helmholtz free energy> is
$$
A=-k_{\mathrm B}T\sum_i\left[N_i\ln q_i-\ln(N_i!)\right]
+\sum_iN_i\varepsilon^{0,i}.
$$
Using <Stirling's approximation>, $\ln(N_i!)\simeq N_i\ln N_i-N_i$, and differentiating at fixed $T,V,N_{j\ne i}$ yields
$$
\boxed{\mu_i=\left(\frac{\partial A}{\partial N_i}\right)_{T,V,N_{j\ne i}}
=-k_{\mathrm B}T\ln\frac{q_i}{N_i}+\varepsilon^{0,i}.}
$$
The ideal-gas $q_i$ does not depend on the number of molecules, so no additional $\partial q_i/\partial N_i$ term appears. These are chemical potentials per molecule; multiply by the <Avogadro constant> for a molar chemical potential. The result assumes the thermodynamic, nondegenerate-gas limit.