Solution (source code)

= Solution

Free expansion into vacuum performs no work and receives no heat, so the initial and final internal energies agree. If $C_V$ is temperature independent, the preceding energy expression gives
$$
C_V(T_2-T_1)=aN^2\left(\frac1{V_2}-\frac1{V_1}\right),\qquad
\boxed{T_2=T_1-\frac{aN^2}{C_V}\left(\frac1{V_1}-\frac1{V_2}\right).}
$$
The gas cools for positive $a$ and $V_2>V_1$. Genuine free expansion is irreversible and not quasistatic; the endpoint energy calculation remains valid without the prompt's quasistatic qualification. Use of equilibrium thermodynamic identities only requires the two endpoint states to be equilibrated.