\[ y'(x)-a x^n \left (y(x)^2+1\right )=0 \] ✓ Mathematica : cpu = 0.178547 (sec), leaf count = 21
DSolve[-(a*x^n*(1 + y[x]^2)) + Derivative[1][y][x] == 0,y[x],x]
\[\left \{\left \{y(x)\to \tan \left (\frac {a x^{n+1}}{n+1}+c_1\right )\right \}\right \}\] ✓ Maple : cpu = 0.058 (sec), leaf count = 23
dsolve(diff(y(x),x)-a*x^n*(y(x)^2+1) = 0,y(x))
\[y \left (x \right ) = \tan \left (\frac {a \left (x^{n +1}+\left (n +1\right ) c_{1}\right )}{n +1}\right )\]
Hand solution
\begin {align} y^{\prime }-ax^{n}\left ( y^{2}+1\right ) & =0\nonumber \\ y^{\prime } & =ax^{n}+ax^{n}y^{2}\nonumber \\ & =P\left ( x\right ) +Q\left ( x\right ) y+R\left ( x\right ) y^{2}\tag {1} \end {align}
This is Ricatti first order non-linear ODE. \(P\left ( x\right ) =ax^{n},Q\left ( x\right ) =0,R\left ( x\right ) =ax^{n}\). But this is separable also. Hence\begin {align*} \frac {y^{\prime }}{\left ( y^{2}+1\right ) } & =ax^{n}\\ \frac {dy}{\left ( y^{2}+1\right ) } & =ax^{n}dx \end {align*}
Integrating\[ \arctan \left ( y\left ( x\right ) \right ) =a\frac {x^{n+1}}{n+1}+C \] Or\[ y\left ( x\right ) =\tan \left ( a\frac {x^{n+1}}{n+1}+C\right ) \]
Verification
restart; eq:=diff(y(x),x)-a*x^n*(y(x)^2+1) = 0; sol:=tan(a*x^(n+1)/(n+1)+_C1); odetest(y(x)=sol,eq); 0