\[ x y'(x)+x y(x)^2-y(x)=0 \] ✓ Mathematica : cpu = 0.00970096 (sec), leaf count = 18
\[\left \{\left \{y(x)\to \frac {2 x}{2 c_1+x^2}\right \}\right \}\] ✓ Maple : cpu = 0.014 (sec), leaf count = 16
\[ \left \{ y \left ( x \right ) =2\,{\frac {x}{{x}^{2}+2\,{\it \_C1}}} \right \} \]
\begin {align} xy^{\prime }+xy^{2}-y & =0\nonumber \\ y^{\prime } & =\frac {1}{x}y-y^{2}\tag {1} \end {align}
This is of the form \(y^{\prime }=f_{0}+f_{1}y+f_{2}y^{2}\) with \(f_{0}=0,f_{1}=\frac {1}{x},f_{2}=-1\). Since \(f_{0}=0\) this is Bernoulli differential equation. We always start by dividing by \(y^{2}\)\[ \frac {y^{\prime }}{y^{2}}=\frac {1}{x}\frac {1}{y}-1 \] Then \(u=\frac {1}{y}\) or \(y=\frac {1}{u}\), therefore \(y^{\prime }=-\frac {u^{\prime }}{u^{2}}\). Equating this to RHS of (1) gives\begin {align*} -\frac {u^{\prime }}{u^{2}}u^{2} & =\frac {1}{x}u-1\\ -u^{\prime } & =\frac {u}{x}-1\\ u^{\prime }+\frac {u}{x} & =1 \end {align*}
Integrating factor is \(e^{\int \frac {1}{x}dx}=x\) and the above becomes\[ d\left ( xu\right ) =x \] Integrating\begin {align*} xu & =\frac {x^{2}}{2}+C\\ u & =\frac {x}{2}+\frac {C}{x}\\ & =\frac {x^{2}+2C}{2x} \end {align*}
Hence \begin {align*} y & =\frac {1}{u}\\ & =\frac {2x}{x^{2}+2C} \end {align*}
Verification
restart; ode:=x*diff(y(x),x)+x*y(x)^2-y=0; my_solution:=2*x/(x^2+2*_C1); odetest(y(x)=my_solution,ode); 0