2.29   ODE No. 29

\[ y'(x)-x y(x)^2-3 x y(x)=0 \]

Mathematica : cpu = 0.0578186 (sec), leaf count = 39

DSolve[-3*x*y[x] - x*y[x]^2 + Derivative[1][y][x] == 0,y[x],x]
 
\[\left \{\left \{y(x)\to -\frac {3 e^{\frac {3 x^2}{2}+3 c_1}}{-1+e^{\frac {3 x^2}{2}+3 c_1}}\right \}\right \}\]

Maple : cpu = 0.009 (sec), leaf count = 19

dsolve(diff(y(x),x)-x*y(x)^2-3*x*y(x) = 0,y(x))
 
\[y \left (x \right ) = \frac {3}{-1+3 \,{\mathrm e}^{-\frac {3 x^{2}}{2}} c_{1}}\]

Hand solution

\begin{align} y^{\prime }-xy^{2}-3xy & =0\nonumber \\ y^{\prime } & =3xy+xy^{2}\nonumber \\ & =P\left ( x\right ) +Q\left ( x\right ) y+R\left ( x\right ) y^{2}\tag {1}\end{align}

This is Bernoulli first order non-linear ODE since \(P\left ( x\right ) =0\). To solve Bernoulli we always start by dividing by \(y^{2}\)

\[ \frac {y^{\prime }}{y^{2}}=\frac {3x}{y}+x \]

Then we let \(u=\frac {1}{y}\), hence \(u^{\prime }=\frac {-y^{\prime }}{y^{2}}\), therefore the above becomes

\begin{align*} -u^{\prime } & =3xu+x\\ u^{\prime }+3ux & =-x \end{align*}

Integrating factor is \(e^{\int 3xdx}=e^{\frac {3x^{2}}{2}}\), hence

\[ d\left ( e^{\frac {3x^{2}}{2}}u\right ) =-xe^{\frac {3x^{2}}{2}}\]

Integrating both sides gives

\begin{align*} e^{\frac {3x^{2}}{2}}u & =\int -xe^{\frac {3x^{2}}{2}}dx+C\\ & =-\frac {1}{3}e^{\frac {3x^{2}}{2}}+C \end{align*}

Hence from above

\[ u=e^{\frac {-3x^{2}}{2}}\left ( -\frac {1}{3}e^{\frac {3x^{2}}{2}}+C\right ) \]

And since \(y=\frac {1}{u}\) then

\[ y=\frac {e^{\frac {3x^{2}}{2}}}{C-\frac {1}{3}e^{\frac {3x^{2}}{2}}}\]

Verification

eq:=diff(y(x),x)-x*y(x)^2-3*x*y(x) = 0; 
sol:=exp(3*x^2/2)/(_C1- 1/3*exp(3*x^2/2)); 
odetest(y(x)=sol,eq); 
0