# Thermodynamics: A piston can freely move inside a horizontal cylinder which is closed from both ends

Is it safe to say that regardless of where the piston is, the final pressure on each side of it would remain the same. And if yes, then why?

Suppose the piston is a diathermal wall (i.e., it allows the exchange of energy between the two subregions it divides the volume). In that case, the conditions for thermodynamic equilibrium of the global isolated system (at fixed total energy $$E=E_1+E_2$$, and total volume $$V=V_1+V_2$$) correspond to maximizing entropy with respect to the energy $$E_1$$, and volume $$V_1$$. This maximum implies $$\frac{\partial S_1}{\partial E_1} = \frac{\partial S_2}{\partial E_2},$$ i.e. the temperatures of the two subvolumes must be equal: $$\frac{1}{T_1}=\frac{1}{T_2}.\tag{1}$$ Moreover, we have $$\frac{\partial S_1}{\partial V_1} = \frac{\partial S_2}{\partial V_2} ~~~~~~\Rightarrow~~~~~~~\frac{P_1}{T_1}=\frac{P_2}{T_2}.$$ Using the condition on the equality of temperatures, we get the equality of pressures.