ODE No. 101

\[ x y'(x)+x y(x)^2-y(x)=0 \] Mathematica : cpu = 0.0825238 (sec), leaf count = 18

DSolve[-y[x] + x*y[x]^2 + x*Derivative[1][y][x] == 0,y[x],x]
 

\[\left \{\left \{y(x)\to \frac {2 x}{x^2+2 c_1}\right \}\right \}\] Maple : cpu = 0.013 (sec), leaf count = 16

dsolve(x*diff(y(x),x)+x*y(x)^2-y(x) = 0,y(x))
 

\[y \left (x \right ) = \frac {2 x}{x^{2}+2 c_{1}}\]

Hand solution

\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