Solution (source code)

= Solution

The <action variable> for a regular periodic one-degree-of-freedom Hamiltonian orbit is $I(E)=(2\pi)^{-1}\oint p\,dq$, with orientation along the motion. Along its energy curve, implicit differentiation gives $\partial p/\partial E=1/H_p=1/\dot q$. Differentiating the loop integral branchwise gives
$$
\frac{dI}{dE}=\frac1{2\pi}\oint\frac{dq}{\dot q}=\frac1{2\pi}\oint dt,
\qquad \boxed{T=2\pi\frac{dI}{dE}.}
$$
At simple turning points the two momentum branches join and their endpoint contributions cancel, so the integrable turning-point singularities do not spoil this differentiation. The formula concerns regular periodic levels, not a separatrix of infinite period.