A system of Hamiltonian equations in generalized coordinate $q$ and momentum $p$ is given by
$$ \frac{d q}{d t}=\frac{\partial H}{\partial p}, \ \ \ \ \frac{d p}{d t}=-\frac{\partial H}{\partial q} $$
where $H=\frac{1}{2} (p^{2}+k^{2}q^{2}).$
Show that the canonical transform from $q,p$ to $Q,P$ given by $$ q=\sqrt{2Q/k} \ \cos P, \ \ \ \ p=\sqrt{2Qk} \ \sin P, $$
will result in a new Hamiltonian system of equations given by $$ \frac{d Q}{d t}=\frac{\partial K}{\partial P}, \ \ \ \ \frac{d P}{d t}=-\frac{\partial K}{\partial Q}, $$
where $K=kQ$ ?
I have been unable to solve this seemingly simple problem (it comes from Whittaker's book, p.307). In my calculations, I get a tangent function, namely, $dQ/dt=(dP/dt) \ (2Q \tan 2P)$.
Any suggestions would be appreciated.
Hamilton's equations in $(q,p)$ coordinates give $$ \dot{q} = p, \qquad \dot{p} = -k^2q. $$ Inverting the coordinate transformation gives $$ Q=\frac{1}{2k}(p^2+k^2q^2), \qquad P = \tan^{-1}\frac{p}{kq} $$ (the latter expression for $q>0$; other quadrants of the $(q,p)$-plane are related by $\pm\pi$). Then $$ \dot{Q} = \frac{1}{k}(p\dot{p} + k^2q\dot{q}) = \frac{1}{k}(-k^2pq+k^2qp)=0=\frac{\partial K}{\partial P}, $$ while $$ \dot{P} = \frac{1}{1+\frac{p^2}{k^2q^2}}\left(\frac{\dot{p}}{kq} -\frac{p\dot{q}}{kq^2}\right) = \frac{1}{1+\frac{p^2}{k^2q^2}}\left(-k-\frac{p^2}{kq^2}\right) = -k = -\frac{\partial K}{\partial Q}. $$