Our previous method easily becomes to complicated when considering more complex systems, thus we will look into non isolated systems where temperature is constant but no energy.
π³ Take-away: For macroscopic systems results can be more easily obtained by regarding the temperature, rather then the energy, as fixed.
πΌ Case: Consider a system $S$ in contact with a heat bath $R$, the whole forming a single isolated system with energy $E_0$ which is fixed but can move
Since the $S$ and $R$ are independent
$$ \Omega=\Omega_S\Omega_R $$
πΌπ€― Caseception: Consider we specify that $S$ is in the $i$th state with energy $\epsilon_i$
$\Omega_S=1$ due to Caseception, thus $\Omega(E_0,\epsilon_i)=\Omega_R(E_0-\epsilon_i)$, using the relation with entropy
$$ p_i\propto \Omega_R(E_0-\epsilon_i)=\exp \left \{ S_R\,\frac{E_0-\epsilon_i}{k_B}\right \} $$
ποΈ Note: $R$ must be much larger than $S$ to be useful so $\epsilon_i \ll E_0$
Expanding $S_R$ about $S_R(E_0)$ we get
$$ S_R(E_0-\epsilon_i)=S_R(E_0)-\epsilon_i \left . \frac{\partial S_R}{\partial E} \right |{V,N}+\frac 12 \epsilon^2_i\left . \frac{\partial^2 S_R}{\partial E^2} \right |{V,N}+ \ldots $$
where the derivatives are at $E_0$
Using these equations to simplify the derivative and dropping the third term as negligibly small
$$ p_i\propto \exp\left \{ \frac{S_R(E_0)}{k_B}-\frac{\epsilon_i}{k_B T} \right \}\propto \exp \left \{ -\frac{\epsilon_i}{k_B T} \right \} $$
<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/369dfa6b-d4d9-4cf2-a446-e369553b6347/865b0295-f5ca-420f-851d-aecac0647571/Boltzmann_distribution.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/369dfa6b-d4d9-4cf2-a446-e369553b6347/865b0295-f5ca-420f-851d-aecac0647571/Boltzmann_distribution.png" width="40px" /> Boltzmann distribution: If a system is in contact with a heat bath at temperature $T$ the probability that it is in the $i$th microstate with energy $\epsilon_i$ is
$$ p_i=\frac{\exp \left [ -\frac{\epsilon_i}{k_BT}\right ]}{Z} \quad \text{where} \quad Z=\sum_j \exp \left [ - \frac{\epsilon_j}{k_B T}\right ] $$
</aside>
ποΈ Note:
πΌ Case: Consider a spin-$\frac 12$ paramagnet in a magnetic field $B$ with $\epsilon_\uparrow=-\mu B$ and $\epsilon_\downarrow=\mu B$
Using Boltzmann distribution
$$ \begin{aligned} p_\uparrow &=\frac{\exp \left [ \frac{\mu B}{k_BT}\right ]}{Z_1} \\ p_\downarrow &=\frac{\exp \left [- \frac{\mu B}{k_BT}\right ]}{Z_1} \\ Z_1 &=\exp \left [ \frac{\mu B}{k_BT}\right ]+\exp \left [ -\frac{\mu B}{k_BT}\right ] \end{aligned} $$
ποΈ Note: name $Z_1$ because it is the state of a single particle
In the Whole system of $N$ atoms we have $\lang n_\uparrow \rang =Np_\uparrow$ thus
$$ \frac{\lang n_\downarrow \rang }{\lang n_\uparrow \rang }=\exp \left [ -\frac{2\mu B}{k_BT} \right ] $$
ποΈ Note: this is consistent with what we found previously
π³ Take-away: This