I am attempting to solve the Hamilton-Jacobi Equation in the case of a simple harmonic oscillator, to recover the associated generating function and the generated canonical transformation.
Consider the Hamiltonian: $$\mathcal H=\frac{1}{2}\omega^2(p^2+mx^2)$$ where $\omega^2=k/m$.
Applying the Hamilton-Jacobi Equation: $$\mathcal H\Big(x,\frac{\partial S}{\partial x},t\Big)+\frac{\partial S}{\partial t}=0$$ and substituing our Hamiltonian: $$\frac{1}{2}mx^2+\frac{1}{2}\omega^2\Big(\frac{\partial S}{\partial x}\Big)^2=-\frac{\partial S}{\partial t}$$ However due to time independence of our Hamiltonian (and thus conservation of energy $E$), we know that: $$S=f(x)-Et$$ and therefore: $$\frac{1}{2}mx^2+\frac{1}{2}\omega^2\Big(f'(x)\Big)^2=E$$ Rearranging: $$f'(x)=\frac{1}{\omega}\sqrt{2E-mx^2}$$ and then integrating, we find: $$f(x)=\frac{1}{\omega}\int{\sqrt{2E-mx^2}dx}=\frac{\sqrt{2E}}{\omega}\int{\sqrt{1-\frac{mx^2}{2E}}dx}=\frac{E}{\omega}\sqrt{\frac{2}{m}}\Bigg[\arccos\Bigg(\sqrt{\frac{m}{2E}}x\Bigg)-x\sqrt{1-\frac{mx^2}{2E}}\sqrt\frac{m}{2E}\Bigg]$$ and thus our type-II generating function S is given by: $$S(x,P,t)=\frac{E}{\omega}\sqrt{\frac{2}{m}}\Bigg[\arccos\Bigg(\sqrt{\frac{m}{2E}}x\Bigg)-x\sqrt{1-\frac{mx^2}{2E}}\sqrt\frac{m}{2E}\Bigg]-Et$$ Note that within the Hamilton-Jacobi formalism, the new canonical coordinates satisfy $\dot P=\dot Q=0$, which is where I'm stuck, how do I know what $P$ and $Q$ are? Or is it just an arbitrary choice that must satisfy the conditions of a type-II generating function:
$$ \left\{ \begin{array}{c} p=\frac{\partial S}{\partial x} \\ Q=\frac{\partial S}{\partial P} \\ K=H+\frac{\partial S}{\partial t} \\ \end{array} \right. $$ and then that's it? So all I need to do is choose $P$ such that it contains no explicit time-dependence correct?
I tried setting $P=\arccos\Big(x\sqrt{\frac{m}{2E}}\Big)$, so now my generating function is given by: $$S(x,P,t)=\frac{E}{\omega}\sqrt{\frac{2}{m}}\Bigg[P-x\sqrt\frac{m}{2E}P\Bigg]-Et$$ and then I recovered $Q=\frac{1}{2\sqrt{k}}-4m\sqrt{k}E x^2$ but I just don't see how this canonical transformation produces the good old simple harmonic motion written in the normal cooridnates. Is my reasoning correct, and if yes, then how does this canonical transformation recover the simple harmonic motion in the original coordinates?