Solution (source code)

= Solution

Solving $\dot x=p/m$, $\dot p=-m\omega^2x$ gives the linear phase flow
$$
\begin{pmatrix}x(t)\\p(t)\end{pmatrix}
=\begin{pmatrix}\cos\omega t&\sin\omega t/(m\omega)\\
-m\omega\sin\omega t&\cos\omega t\end{pmatrix}
\begin{pmatrix}x_0\\p_0\end{pmatrix}.
$$
Its <Jacobian determinant> is
$$
\boxed{\frac{\partial(x(t),p(t))}{\partial(x_0,p_0)}
=\cos^2\omega t+\sin^2\omega t=1.}
$$
Hence every patch keeps its area $dx\,dp$, directly verifying <Liouville's theorem>. The <energy> ellipses are also invariant, but area preservation applies to arbitrary patches, not just whole <energy> shells.

In scaled <canonical coordinates> $X=\sqrt{m\omega}\,x$, $P=p/\sqrt{m\omega}$ the flow is a rigid clockwise <rotation>, $(X,P)=(X_0\cos\omega t+P_0\sin\omega t,-X_0\sin\omega t+P_0\cos\omega t)$. The following original plot follows an off-center patch and shows equal areas at successive times.

\Image[/past-exam-of-the-classical-mechanics-course-of-part-b-of-the-physics-course-of-the-university-of-oxford/2016-harmonic-phase-volume.png]
{title=Area-preserving harmonic-oscillator flow: the same phase-space patch at four times, with a focusing squeeze that trades position width against momentum width}