The solution of the following differential equation $$ -kx(t) = m \frac{d^{2}x}{dt^{2}}, $$ with $\omega = \sqrt{k/m}$, is $$ x(t) = C_{1}e^{-i\omega t} + C_{2}e^{i\omega t}.$$ The real part of this, $$ x(t) = x_0 e^{i(-\omega t + \phi)},$$ is the solution of my differential where $x_0$ is the amplitude of a harmonic oscillator and $\phi$ being a phase difference.
I have found another form of the general solution of this differential equation is $$ x(t) = C_1 \cos(\omega t) + C_2 \sin(\omega t).$$ With the following parameters $x_0 = \sqrt{C_{1}^{2} + C_{2}^{2}}$ , $\cos\phi = C_1/x_0$ and $\sin\phi=-C_2/x_0$ you can write $$x(t) = x_0\cos(\omega t + \phi),$$ which is equivalent of the $\Re\{x_0e^{i(-\omega t + \phi)}\}$. But I don't understand how the general solution of the differential equation can be written in these two ways.