Solution (source code)

= Solution

The <characteristic equation> of the <damped harmonic oscillator> is $r^2+\gamma r+\omega_0^2=0$. In the underdamped case its <roots> are $-\gamma/2\pm i\omega_d$, where $\omega_d=\sqrt{\omega_0^2-\gamma^2/4}$. Thus the exact real solution is $y=Ae^{-\gamma t/2}\cos(\omega_dt+\alpha)$. For $\gamma\ll\omega_0$, $\omega_d=\omega_0+O(\gamma^2/\omega_0)$, giving the requested leading approximation
$$
\boxed{y(t)\simeq y_0e^{-\gamma t/2}\cos(\omega_0t+\alpha).}
$$
For <mass> $m$ and <spring constant> $m\omega_0^2$, the <mechanical energy> is $E=\tfrac12m(\dot y^2+\omega_0^2y^2)$. Differentiating and using the <differential equation> gives $\dot E=-m\gamma\dot y^2$. In particular, <energy decay of a viscously damped harmonic oscillator> is not an exact pointwise <exponential decay>: $\dot E=0$ at a turning point. To leading order in $\gamma/\omega_0$, the <period average> is
$$
\boxed{\overline E(t)\simeq\frac12m\omega_0^2y_0^2e^{-\gamma t},\qquad \overline P_{\mathrm{loss}}\simeq\gamma\overline E.}
$$
The <quality factor> is $Q=2\pi\overline E/(\text{energy lost in one cycle})$. Using the <period> $T\simeq2\pi/\omega_0$ and the small fractional loss $\gamma T$ gives $\boxed{Q\simeq\omega_0/\gamma}$. Equivalently, the energy-decay definition $Q=\omega_0\overline E/\overline P_{\mathrm{loss}}$ yields the same leading result. Replacing $\omega_d$ by $\omega_0$ in the oscillatory phase is not uniform over arbitrarily long times; its phase error is $O(\gamma^2t/\omega_0)$.