\[ \boxed { {\frac {{\rm d}^{2}}{{\rm d}{x}^{2}}}y \left ( x \right ) =-{\frac {a \left ( n-1 \right ) \sin \left ( 2\,ax \right ) {\frac {\rm d}{{\rm d}x}}y \left ( x \right ) }{ \left ( \cos \left ( ax \right ) \right ) ^{2}}}-{\frac {n{a}^{2} \left ( \left ( n-1 \right ) \left ( \sin \left ( ax \right ) \right ) ^{2}+ \left ( \cos \left ( ax \right ) \right ) ^{2} \right ) y \left ( x \right ) }{ \left ( \cos \left ( ax \right ) \right ) ^{2}}}=0} \]
Mathematica: cpu = 0.248031 (sec), leaf count = 67 \[ \left \{\left \{y(x)\to c_1 e^{-\sqrt {-a^2} x} \cos ^{n-1}(a x)+\frac {c_2 e^{\sqrt {-a^2} x} \cos ^{n-1}(a x)}{2 \sqrt {-a^2}}\right \}\right \} \]
Maple: cpu = 0.063 (sec), leaf count = 27 \[ \left \{ y \left ( x \right ) ={\it \_C1}\, \left ( \cos \left ( ax \right ) \right ) ^{n}+{\it \_C2}\, \left ( \cos \left ( ax \right ) \right ) ^{n-1}\sin \left ( ax \right ) \right \} \]