Complex representation of SHM
For physical $x = a_0\cos(\omega t+\phi)$, write $$ z = a_0 e^{i(\omega t+\phi)} = A e^{i\omega t}, \quad A\in\C. $$
Physical values: $$\begin{align*} x &= \Re z \\ \dot x &= \Re\dot z = \Re i\omega z = -\omega\Im z \\ \ddot x &= \Re\ddot z = -\omega^2\Re z \\ U &= \frac12 k(\Re z)^2 \\ K &= \frac12 m(\Re \dot z)^2 = \frac12 k(\Im z)^2 \end{align*}$$