Solution (source code)

= Solution

The fixed common <temperature>, rigid external container and fixed <particle> numbers on either side make the total <Helmholtz free energy> the appropriate <thermodynamic potential>. Let the barrier have cross-sectional area $A$, and let increasing $x$ expand the left compartment. Then $dV_1=A\,dx$ and $dV_2=-A\,dx$. At fixed <temperature> and <particle> number, $dF_j=-p_j\,dV_j$, so
$$
F(x)=F_1(T,V_1(x),N_1)+F_2(T,V_2(x),N_2),\qquad
\frac{dF}{dx}=A(p_2-p_1).
$$
Thus <mechanical equilibrium>, $p_1=p_2$, makes $F$ stationary. The physical <force> on the barrier towards increasing $x$ is $f=A(p_1-p_2)=-F'(x)$. If the barrier is displaced slightly from $x_*$, strict <mechanical stability> requires a restoring <force>:
$$
f(x_*+\delta x)=A\left(\frac{\partial p_1}{\partial x}-\frac{\partial p_2}{\partial x}\right)_{x_*}\delta x+O(\delta x^2),
\qquad f'(x_*)<0.
$$
Consequently
$$
\boxed{F''(x_*)=A\left(\frac{\partial p_2}{\partial x}-\frac{\partial p_1}{\partial x}\right)_{x_*}>0.}
$$
The <Taylor expansion> $F(x_*+\delta x)=F(x_*)+\tfrac12F''(x_*)\delta x^2+O(\delta x^3)$ proves that <thermodynamic equilibrium> is a strict local minimum of the <Helmholtz free energy>, rather than merely a <stationary point>.

For individually stable gases, the positive <isothermal compressibilities> $\kappa_{T,j}=-(1/V_j)(\partial V_j/\partial p_j)_{T,N_j}$ make the sign especially transparent:
$$
\frac{\partial p_1}{\partial x}=-\frac{A}{V_1\kappa_{T,1}},\qquad
\frac{\partial p_2}{\partial x}=\frac{A}{V_2\kappa_{T,2}},\qquad
F''=A^2\left(\frac1{V_1\kappa_{T,1}}+\frac1{V_2\kappa_{T,2}}\right)>0.
$$
If these inequalities hold throughout the accessible interval, $F$ is a <strictly convex function> and an interior <stationary point> is the unique global minimum of the <Helmholtz free energy>. Stability at one point alone proves only the local statement. A vanishing restoring <derivative> describes marginal stability and requires examining higher-order terms.