\[ y''(x)=-a^2 n y(x) \sec ^2(a x) \left ((n-1) \sin ^2(a x)+\cos ^2(a x)\right )-a (n-1) \sin (2 a x) \sec ^2(a x) y'(x) \] ✓ Mathematica : cpu = 0.252065 (sec), leaf count = 62
\[\left \{\left \{y(x)\to \frac {1}{2} e^{-\sqrt {-a^2} x} \left (\frac {c_2 e^{2 \sqrt {-a^2} x}}{\sqrt {-a^2}}+2 c_1\right ) \cos ^{n-1}(a x)\right \}\right \}\]
✓ Maple : cpu = 0.076 (sec), leaf count = 27
\[ \left \{ y \left ( x \right ) ={\it \_C1}\, \left ( \cos \left ( ax \right ) \right ) ^{n}+{\it \_C2}\,\sin \left ( ax \right ) \left ( \cos \left ( ax \right ) \right ) ^{n-1} \right \} \]