Entropy maximization under thermal contact (source code)

= Entropy maximization under thermal contact

If two otherwise isolated systems freely exchange energy while $E_1+E_2$ remains fixed, their total entropy is
$$
S_{\mathrm{tot}}(E_1)=S_1(E_1)+S_2(E-E_1).
$$
At an interior maximum, $\partial S_1/\partial E_1=\partial S_2/\partial E_2$. Since <thermodynamic temperature> satisfies $1/T=\partial S/\partial E$, the systems have equal temperatures at <thermal equilibrium>.