ODE No. 103

\[ -x^3-\left (2 x^2+1\right ) y(x)+x y'(x)+x y(x)^2=0 \] Mathematica : cpu = 0.160966 (sec), leaf count = 90

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

\[\left \{\left \{y(x)\to \frac {x \left (e^{\sqrt {2} x^2}+\sqrt {2} e^{\sqrt {2} x^2}+e^{2 \sqrt {2} c_1}-\sqrt {2} e^{2 \sqrt {2} c_1}\right )}{e^{\sqrt {2} x^2}+e^{2 \sqrt {2} c_1}}\right \}\right \}\] Maple : cpu = 0.034 (sec), leaf count = 29

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

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

Hand solution

\begin {equation} xy^{\prime }-xy^{2}-\left ( 2x^{2}+1\right ) y-x^{3}=0\nonumber \end {equation} This is Riccati non-linear first order. Converting it to standard form\begin {align} y^{\prime } & =x^{2}+\frac {\left ( 2x^{2}+1\right ) }{x}y+y^{2}\tag {1}\\ & =f_{0}+f_{1}y+f_{2}y^{2}\nonumber \end {align}

Using standard transformation \(y=-\frac {u^{\prime }}{uf_{2}}=-\frac {u^{\prime }}{u}\), therefore\[ y^{\prime }=-\frac {u^{\prime \prime }}{u}+\frac {\left ( u^{\prime }\right ) ^{2}}{u^{2}}\] Equating the above to RHS of (1) gives\begin {align} -\frac {u^{\prime \prime }}{u}+\frac {\left ( u^{\prime }\right ) ^{2}}{u^{2}} & =x^{2}-\frac {\left ( 2x^{2}+1\right ) }{x}\frac {u^{\prime }}{u}+\left ( -\frac {u^{\prime }}{u}\right ) ^{2}\nonumber \\ -\frac {u^{\prime \prime }}{u} & =x^{2}-\frac {\left ( 2x^{2}+1\right ) }{x}\frac {u^{\prime }}{u}\nonumber \\ -u^{\prime \prime } & =ux^{2}-\frac {\left ( 2x^{2}+1\right ) }{x}u^{\prime }\nonumber \\ -u^{\prime \prime }+\frac {\left ( 2x^{2}+1\right ) }{x}u^{\prime }-ux^{2} & =0\nonumber \\ xu^{\prime \prime }-\left ( 2x^{2}+1\right ) u^{\prime }+ux^{3} & =0\tag {2} \end {align}

This is second order linear ODE (Sturm-Liouville). Using the transformation \(t=\frac {x^{2}}{2}\), then \(\frac {dt}{dx}=x\) and \[ \frac {du}{dx}=\frac {du}{dt}\frac {dt}{dx}=x\frac {du}{dt}=\sqrt {2t}\frac {du}{dt}\] And\begin {align*} \frac {d^{2}u}{dx^{2}} & =\frac {d}{dx}\left ( \frac {du}{dx}\right ) \\ & =\frac {d}{dx}\left ( x\frac {du}{dt}\right ) \\ & =\frac {du}{dt}+x\frac {d^{2}u}{dt^{2}}\frac {dt}{dx}\\ & =\frac {du}{dt}+x\frac {d^{2}u}{dt^{2}}x\\ & =\frac {du}{dt}+x^{2}\frac {d^{2}u}{dt^{2}}\\ & =\frac {du}{dt}+2t\frac {d^{2}u}{dt^{2}} \end {align*}

Hence (2) can be written as\begin {align*} \sqrt {2t}\left ( \frac {du}{dt}+2t\frac {d^{2}u}{dt^{2}}\right ) -\left ( 2\left ( 2t\right ) +1\right ) \sqrt {2t}\frac {du}{dt}+u\left ( 2t\right ) ^{\frac {3}{2}} & =0\\ \sqrt {2t}\frac {du}{dt}+\sqrt {2t}2t\frac {d^{2}u}{dt^{2}}-\left ( 4t+1\right ) \sqrt {2t}\frac {du}{dt}+u\left ( \sqrt {2t}\right ) ^{3} & =0\\ \frac {du}{dt}+2t\frac {d^{2}u}{dt^{2}}-\left ( 4t+1\right ) \frac {du}{dt}+2tu & =0\\ \frac {du}{dt}+2t\frac {d^{2}u}{dt^{2}}-4t\frac {du}{dt}-\frac {du}{dt}+2tu & =0\\ 2t\frac {d^{2}u}{dt^{2}}-4t\frac {du}{dt}+2tu & =0\\ 2t\left ( \frac {d^{2}u}{dt^{2}}-2\frac {du}{dt}+u\right ) & =0 \end {align*}

Hence\[ \frac {d^{2}u}{dt^{2}}-2\frac {du}{dt}+u=0 \] This is linear second order with constant coefficients. The indicial equation is \(\lambda ^{2}-2\lambda +1=0\) with roots \(\lambda =\frac {-b\pm \sqrt {b^{2}-4ac}}{2a}=\frac {2\pm \sqrt {4-4}}{2}=1\) double root. Hence\[ u\left ( t\right ) =Ae^{t}+tBe^{t}\]

Since \(t=\frac {x^{2}}{2}\) then\[ u\left ( x\right ) =Ae^{\frac {x^{2}}{2}}+\frac {x^{2}}{2}Be^{\frac {x^{2}}{2}}\] But \(y=-\frac {u^{\prime }}{u}\) therefore\begin {align*} u^{\prime } & =Axe^{\frac {x^{2}}{2}}+\left ( xBe^{\frac {x^{2}}{2}}+\frac {x^{2}}{2}xBe^{\frac {x^{2}}{2}}\right ) \\ & =Axe^{\frac {x^{2}}{2}}+xBe^{\frac {x^{2}}{2}}+\frac {x^{3}}{2}Be^{\frac {x^{2}}{2}} \end {align*}

Hence\[ y=-\frac {Axe^{\frac {x^{2}}{2}}+xBe^{\frac {x^{2}}{2}}+\frac {x^{3}}{2}Be^{\frac {x^{2}}{2}}}{Ae^{\frac {x^{2}}{2}}+\frac {x^{2}}{2}Be^{\frac {x^{2}}{2}}}=-\frac {Axe^{\frac {x^{2}}{2}}+B\left ( xe^{\frac {x^{2}}{2}}+\frac {x^{3}}{2}e^{\frac {x^{2}}{2}}\right ) }{Ae^{\frac {x^{2}}{2}}+\frac {x^{2}}{2}Be^{\frac {x^{2}}{2}}}\] Let \(C=\frac {A}{B}\)\begin {align*} y & =-\frac {xe^{\frac {x^{2}}{2}}\left ( C+1+\frac {x^{2}}{2}\right ) }{e^{\frac {x^{2}}{2}}\left ( C+\frac {x^{2}}{2}\right ) }\\ & =-\frac {x\left ( C+1+\frac {x^{2}}{2}\right ) }{C+\frac {x^{2}}{2}}\\ & =-\frac {x\left ( 2C+2+x^{2}\right ) }{2C+x^{2}}\\ & =-\frac {x\left ( C_{1}+2+x^{2}\right ) }{C_{1}+x^{2}} \end {align*}

Verification

restart; 
ode:=x*diff(y(x),x)-x*y(x)^2-(2*x^2+1)*y(x)-x^3; 
my_solution:=-(x*(_C1+2+x^2))/(_C1+x^2); 
odetest(y(x)=my_solution,ode); 
0