Show that $x(t) = e^{- \gamma t} \cos(\omega t) x(0)$ is the solution a diffusion equation. I am working through Kurt Jacob's Stochastic Processes for Physicists and came across a question I am unsure about on linear diffusions.

The equation for the damped harmonic oscillator is
\begin{align} m \frac{\mathrm{d}^2 x}{\mathrm{d}^2 t}  + 2 \gamma m
 \frac{\mathrm{d} x}{\mathrm{d} t} + kx = 0 . \end{align}
Assume that $\gamma < \sqrt{k/m}$, in which the resonator is said to
be "under-damped". Show that
$$ x(t) = e^{- \gamma t} \cos(\omega t) x(0)$$
is the solution to the equation above, and find the expression for the
frequency $\omega$ in terms of $m,k$ and $\gamma$.
(pg 24 Question 1)

 A: Let the solution be $ce^{zt}$ where $c$ and $z$ are complex numbers. The equation turns to
$$c(mz^2+2\gamma mz+k)e^{zt}=0.$$
By solving the quadratic we have
$$z=-\gamma\pm i \sqrt{\frac km-\gamma^2},$$ which gives you $\omega$.
Note that the initial condition $x(0)$ is not sufficient to make the answer unique. You also need a second one, such as $x'(0)$.
A: An explanation "keeping in mind" for the students:
The equation for your damped oscillator is:
$$m \frac{\mathrm{d}^2 x}{\mathrm{d}^2 t}  + 2 \gamma m \frac{\mathrm{d} x}{\mathrm{d} t} + kx = 0$$
To show that $$ x(t) = e^{- \gamma t} \cos(\omega t) x(0)$$  is the solution to the above equation, recall the fact that $x(t)$  can only be a solution to the equation if it satisfies the differential equation. I am not solving the differential equation as it has already been solved previously. If you want to solve this equation there are many ways of doing it, from complex exponentials to Laplace transform and what not. Usually sometimes we also assume functions of some specific form to be the solution and carry on the analysis to find it.
Calculate the derivatives :
$$ x(t) =  x(0)\ e^{- \gamma t} \cos(\omega t)$$
$$ x'(t) = x(0)[- \gamma  e^{- \gamma t} \cos(\omega t) - \omega e^{- \gamma t} \sin(\omega t)]$$
$$ x''(t) = x(0)[ \gamma^2  e^{- \gamma t} \cos(\omega t) +\gamma \omega e^{- \gamma t} \sin(\omega t) - \omega^2e^{- \gamma t} \cos (\omega t) + \gamma \omega e^{- \gamma t} \sin(\omega t)]$$
Now, put $x(t)$ in the differential equation to get:
$$m x(0)[ \gamma^2  e^{- \gamma t} \cos(\omega t) +\gamma \omega e^{- \gamma t} \sin(\omega t) - \omega^2e^{- \gamma t} \cos (\omega t) + \gamma \omega e^{- \gamma t} \sin(\omega t)] + 2 x(0)[- \gamma  e^{- \gamma t} \cos(\omega t) - \omega e^{- \gamma t} \sin(\omega t)] + kx(0)\ e^{- \gamma t} \cos(\omega t) = 0$$
When you solve it further, you will get this equation:
$$[m(\gamma^2 - \omega^2) - 2m \gamma^2 + k]e^{-\gamma \omega t}\cos{\omega t} = 0$$
or
$$[k - m(\gamma^2 + \omega^2)]e^{-\gamma \omega t}\cos{\omega t} = 0$$
This is the condition that should be satisfied for $x(t)$ to be a solution of the equation. What does this mean? This means that this particular complex exponential should be 0.
The factor $\cos{\omega t}$ becomes 0 when $\omega t = (2n+1) \frac{\pi}{2}$
The factor $e^{-\gamma \omega t} = 0$ when $\gamma \omega t$ becomes infinitely large.
But the first factor becomes 0 when,
$$k - m(\gamma^2 + \omega^2)=0$$
or
$$\omega^2 = \frac{k}{m} - \gamma^2$$
giving you the result for $\omega$ as
$$\omega = \sqrt{\frac{k}{m} - \gamma^2}$$
In the question it has been given that
$$\gamma^2 \lt \frac{k}{m}$$ which makes your system underdamped and if you see the equation for $\omega$ you will see it will come out as positive. Now, there are lots of things in this, first there is a relation between these oscillations and phasors. Then there are ways to solve this equation involving many techniques. One of the technique has been shared as the answer. You can also have a pole plot analysis for looking at the stability. But from the student's point of view I think this is enough.
PS: You can solve this equation using complex exponentials, and then make the imaginary part as $0$ in the previous answer.
Hope this helps...
