Solution (source code)

= Solution

At a fixed subcritical temperature, coexistence requires equal pressure and equal <chemical potential> of the liquid and gas. The <Maxwell equal-area construction> chooses $p_0$ and the two outer intersection volumes $V_l,V_g$ so that
$$
\boxed{p(V_l)=p(V_g)=p_0,\qquad\int_{V_l}^{V_g}[p(V)-p_0]\,dV=0.}
$$
Indeed $d\mu=(V/N)dp$, and integration by parts gives $N(\mu_g-\mu_l)=p_0(V_g-V_l)-\int_{V_l}^{V_g}p(V)\,dV$, so the equal-area condition is exactly equality of <chemical potentials>.

Let $V_{s,l}<V_{s,g}$ be the two spinodal volumes where $p'(V)=0$. A homogeneous phase is mechanically unstable on $V_{s,l}<V<V_{s,g}$, since $p'>0$ gives negative compressibility. The negative-slope branches $V_l<V<V_{s,l}$ and $V_{s,g}<V<V_g$ are metastable homogeneous liquid and gas respectively: they resist small perturbations but a two-phase state has lower free energy. The single-phase stable branches are $V<V_l$ and $V>V_g$. Throughout the coexistence interval $[V_l,V_g]$, the equilibrium state is a mixture at pressure $p_0$ with its phase fractions chosen to produce the total volume. The preceding figure labels both the formal homogeneous branches and the equilibrium coexistence segment.