Solution (source code)

= Solution
{c}

Treat $t,T$ as independent variables, with $T=\epsilon^2t$. The <chain rule> gives
$$
\frac d{dt}=\partial_t+\epsilon^2\partial_T,\qquad
\frac{d^2}{dt^2}=\partial_t^2+
2\epsilon^2\partial_t\partial_T+\epsilon^4\partial_T^2.
$$
Therefore the <method of multiple scales> is
$$
\boxed{y_{tt}+y+\epsilon\cos t\,y+
\epsilon^2(2y_{tT}+a_2y)+\epsilon^4y_{TT}
+O(\epsilon^4)y=0.}
$$
The unspecified $O(\epsilon^4)$ term includes the higher correction in $a$. Only the displayed terms through order $\epsilon^2$ are needed to determine the leading slow-amplitude system.