Solution (source code)

= Solution

Let $M_{ij}=\partial y_i/\partial x_j$ be the Jacobian of an invertible change of phase coordinates, and set $K(y,t)=H(x(y),t)$. The <chain rule> gives $\nabla_xH=M^T\nabla_yK$, whence
$$
\dot y=MJM^T\nabla_yK.
$$
Therefore the necessary and sufficient condition to retain <Hamilton's equations> for arbitrary Hamiltonians is
$$
\boxed{MJM^T=J,}
$$
equivalently $M^TJM=J$. In one degree of freedom this is the <Poisson bracket> condition $\{Q,P\}=Q_qP_p-Q_pP_q=1$.

Put $D=p^2+\alpha^2q^2$. On a smooth branch of the angular coordinate,
$$
Q_q=\frac{\alpha p}{D},\quad Q_p=-\frac{\alpha q}{D},\quad P_q=\alpha q,\quad P_p=p/\alpha.
$$
Consequently $Q_qP_p-Q_pP_q=(p^2+\alpha^2q^2)/D=1$. \b[The transformation is canonical for every real $\alpha\ne0$ on each angular-coordinate chart.] The origin is excluded and a single-valued arctangent cannot give a global chart on the punctured plane; using an angle modulo $2\pi$ accounts for the usual branch qualification.