To solve this second order, linear, homogeneous differential equation the unknown function $x(t)$, is written as a power series: \[ \begin{eqnarray} x(t) &=& \sum_{n=0}^{\infty} a_n t^n \\ \Big( x(t) &=& a_0 + a_1 t + a_2 t^2 + a_3 t^3 + ... \Big) \end{eqnarray} \]
The first and second time derivatives of function $x(t)$ thus write: \[ \begin{eqnarray} \dot{x}(t) &=& \sum_{n=1}^{\infty} n a_n t^{n-1} \\ \Big( \dot{x}(t) &=& a_1 + 2a_2 t + 3a_3 t^2 + ... \Big) \\ \ddot{x}(t) &=& \sum_{n=2}^{\infty} n(n-1)a_n t^{n-2} \\ \Big( \ddot{x}(t) &=& 2a_2 + 6a_3 t + ... \Big) \end{eqnarray} \] Using these expressions for $x(t)$ and $\ddot{x}(t)$ in the equation of motion we get: \[ \sum_{n=2}^{\infty} n(n-1)a_n t^{n-2} + \omega_0^2 \sum_{n=0}^{\infty} a_n t^n = 0 \] The next step is to keep only one sum ($\sum$)... \[ \sum_{n=0}^{\infty} \Big[ (n+2)(n+1)a_{n+2} + \omega_0^2 a_n \Big] t^n = 0 \] Each coefficients should be equal to $0$ for the power series to equal $0$, so that: \[ (n+2)(n+1)a_{n+2} + \omega_0^2 a_n = 0 \quad \forall n \in N \quad (n = 0,1,2,3,...) \] i.e.: \[ a_{n+2} = - \frac{a_n \omega_0^2}{(n+2)(n+1)} \quad \forall n \in N \quad (n = 0,1,2,3,...) \] This last recurrence expression together with the initial conditions (chosen as the conditions at time $t=0$) given below allow to solve the equation of motion by finding the value for each coefficient $a_n$: \[ \begin{eqnarray} a_0 &=& x(0) \qquad \textrm{this is the position at the origin of time}\\ a_1 &=& \dot{x}(0) \qquad \textrm{this is the speed at the origin of time} \\ a_2 &=& - \frac{\omega_0^2}{2 \times 1} a_0 \\ a_3 &=& - \frac{\omega_0^2}{3 \times 2} a_1 \\ a_4 &=& - \frac{\omega_0^2}{4 \times 3} a_2 = \frac{\omega_0^4}{4!} a_0 \\ a_5 &=& - \frac{\omega_0^2}{5 \times 4} a_3 = \frac{\omega_0^4}{5!} a_1 \\ \end{eqnarray} \] and so on.

Finally, $x(t)$ is found to be equal to: \[ \begin{eqnarray} x(t) &=& \sum_{n=0}^{\infty} a_n t^n \\ x(t) &=& a_0 + a_1 t + a_2 t^2 + a_3 t^3 + a_4 t^4 + a_5 t^5 + ... \\ x(t) &=& a_0 + a_1 t - \frac{\omega_0^2}{2!} a_0 t^2 - \frac{\omega_0^2}{3!} a_1 t^3 + \frac{\omega_0^4}{4!} a_0 t^4 + \frac{\omega_0^4}{5!} a_1 t^5 \end{eqnarray} \] Grouping the $a_0$ and $a_1$ terms, we get: \[ \begin{eqnarray} x(t) &=& a_0 \Big[ 1 - \frac{\omega_0^2 t^2}{2!} + \frac{\omega_0^4 t^4}{4!} - ... \Big] + a_1 \Big[ t - \frac{\omega_0^2 t^3}{3!} + \frac{\omega_0^4 t^5}{5!} - ... \Big] \\ x(t) &=& a_0 \Big[ 1 - \frac{(\omega_0 t)^2}{2!} + \frac{(\omega_0 t)^4}{4!} - ... \Big] + \frac{a_1}{\omega_0} \Big[ t - \frac{(\omega_0 t)^3}{3!} + \frac{(\omega_0 t)^5}{5!} - ... \Big] \\ x(t) &=& a_0 \cos (\omega_0 t) + \frac{a_1}{\omega_0} \sin (\omega_0 t) \end{eqnarray} \] as the expressions between brackets corresponds to the definitions of the cosine and sine functions.

The solution of equation of motion is thus: \[ x(t) = A\cos (\omega_0 t) + B \sin (\omega_0 t) \] where $A$ and $B$ are real quantities defined from the initial conditions.

The solution can also be written as: \[ x(t) = M\cos(\omega_0 t - \alpha) \\ \] with \[ \begin{eqnarray} M &=& \sqrt{A^2+B^2} \\ \tan \alpha &=& \frac{B}{A} \\ A &=& M \cos \alpha \\ B &=& M \sin \alpha \end{eqnarray} \] In a complex form: \[ x(t) = Ce^{i\omega_O t} + De^{-i\omega_0 t} \] where \[ \begin{eqnarray} C &=& A/2 + B/(2i) \\ D &=& A/2 - B/(2i) \end{eqnarray} \]