# $2^{\text{nd}}$ order ODE: How come the complex solution becomes real?

So I am studying spring mass systems, and I'm confused by why the solution, which is complex, becomes real. Such that

$$x(t) = C_1\cos(\omega t)+iC_2\sin(\omega t) = C_1\cos(\omega t)+C_2\sin(\omega t)$$

Why does the imaginary term just become an arbitrary constant?

Also the general solution is also simplified to:

$$x(t)=A\cos(\omega t+\phi)$$

How do you get that result?

I tried drawing sine and cosine waves to correlate them, but I don't see it. I also looked at some trig identities, but no avail.

A typical spring-mass oscillator has the formulation

$$\ddot x +\omega^2 x = 0$$

The general solution for this linear DE with lumped parameters is

$$x = C_0 e^{\lambda t}$$

after substitution we have

$$C_0\left(\lambda^2+\omega^2\right)e^{\lambda t}=0$$

so this cancels for all $t$ iif $\lambda = \pm i \omega$ so

$$x = C_1 e^{i\omega t}+ C_2 e^{-i\omega t}$$

here $C_1, C_2$ are suitable complex constants such that the contour conditions are obeyed. Note that $x(t)$ should be real.

Now using the de Moivre's identity

$$x(t) = C_1(\cos(\omega t)+i\sin(\omega t))+C_2(\cos(\omega t)-i\sin(\omega t)))$$

or

$$x(t) = (C_1+C_2)\cos(\omega t)+i(C_1-C_2)\sin(\omega t)$$

or

$$x(t) = C_1'\cos(\omega t)+C_2'\sin(\omega t)$$

at this point defining

$$\cos\phi_0 = \frac{C_1}{\sqrt{C_1'^2+C_2'^2}}\\ \sin\phi_0 = \frac{C_1}{\sqrt{C_2'^2+C_2'^2}}$$

we have

$$x(t) = \sqrt{C_1'^2+C_2'^2}\left(\cos\phi_0 \cos(\omega t)+\sin\phi_0\sin(\omega t)\right)$$

etc.