4.4.37 \(x y'(x)=a x^n (x-y(x))^2-y(x)+2 x\)

ODE
\[ x y'(x)=a x^n (x-y(x))^2-y(x)+2 x \] ODE Classification

[[_1st_order, _with_linear_symmetries], _rational, _Riccati]

Book solution method
Riccati ODE, Generalized ODE

Mathematica
cpu = 0.523851 (sec), leaf count = 126

\[\left \{\left \{y(x)\to \frac {x^{-n} \left (2 a c_1 \sqrt {(n-1)^2} x^{n+1}+2 a x^{n+\sqrt {(n-1)^2}+1}-c_1 \left (-n+\sqrt {(n-1)^2}+1\right ) (n-1)-\left (n+\sqrt {(n-1)^2}-1\right ) x^{\sqrt {(n-1)^2}}\right )}{2 a \left (c_1 \sqrt {(n-1)^2}+x^{\sqrt {(n-1)^2}}\right )}\right \}\right \}\]

Maple
cpu = 0.104 (sec), leaf count = 50

\[ \left \{ {\frac {-a{\it \_C1}\, \left ( x-y \left ( x \right ) \right ) {x}^{n}+xy \left ( x \right ) + \left ( n-1 \right ) {\it \_C1}-{x}^{2}}{a \left ( x-y \left ( x \right ) \right ) {x}^{n}-n+1}}=0 \right \} \] Mathematica raw input

DSolve[x*y'[x] == 2*x + a*x^n*(x - y[x])^2 - y[x],y[x],x]

Mathematica raw output

{{y[x] -> (-((-1 + Sqrt[(-1 + n)^2] + n)*x^Sqrt[(-1 + n)^2]) + 2*a*x^(1 + Sqrt[(
-1 + n)^2] + n) - (1 + Sqrt[(-1 + n)^2] - n)*(-1 + n)*C[1] + 2*a*Sqrt[(-1 + n)^2
]*x^(1 + n)*C[1])/(2*a*x^n*(x^Sqrt[(-1 + n)^2] + Sqrt[(-1 + n)^2]*C[1]))}}

Maple raw input

dsolve(x*diff(y(x),x) = 2*x-y(x)+a*x^n*(x-y(x))^2, y(x),'implicit')

Maple raw output

(-a*_C1*(x-y(x))*x^n+x*y(x)+(n-1)*_C1-x^2)/(a*(x-y(x))*x^n-n+1) = 0