2.16   ODE No. 16

$f(x) (x y(x)-1)+y'(x)+y(x)^2=0$ Mathematica : cpu = 0.0372842 (sec), leaf count = 186

$\left \{\left \{y(x)\to \frac {\exp \left (\int _1^x\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right ) \int _1^x\exp \left (-\int _1^{K[2]}\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right )dK[2]+c_1 \exp \left (\int _1^x\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right )+x}{x \left (\exp \left (\int _1^x\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right ) \int _1^x\exp \left (-\int _1^{K[2]}\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right )dK[2]+c_1 \exp \left (\int _1^x\frac {f(K[1]) K[1]^2+2}{K[1]}dK[1]\right )\right )}\right \}\right \}$ Maple : cpu = 0.088 (sec), leaf count = 49

$\left \{ y \left ( x \right ) ={{{\rm e}^{\int \!{\frac {-{x}^{2}f \left ( x \right ) -2}{x}}\,{\rm d}x}} \left ( -{\it \_C1}+\int \!{{\rm e}^{\int \!{\frac {-{x}^{2}f \left ( x \right ) -2}{x}}\,{\rm d}x}}\,{\rm d}x \right ) ^{-1}}+{x}^{-1} \right \}$

Hand solution

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

This is Riccati ﬁrst order non-linear ODE of the form. We can see a particular solution is $$y_{p}=\frac {1}{x}$$, therefore, we use the substitution\begin {align*} y\left ( x\right ) & =y_{p}\left ( x\right ) +\frac {1}{u\left ( x\right ) }\\ & =\frac {1}{x}+\frac {1}{u} \end {align*}

Hence\begin {align} y^{\prime }\left ( x\right ) & =y_{p}^{\prime }\left ( x\right ) -\frac {u^{\prime }\left ( x\right ) }{u^{2}\left ( x\right ) }\nonumber \\ & =\frac {-1}{x^{2}}-\frac {u^{\prime }\left ( x\right ) }{u^{2}\left ( x\right ) }\tag {2} \end {align}

Equating (1) and (2) gives\begin {align*} \left ( -xy+1\right ) f-y^{2} & =\frac {-1}{x^{2}}-\frac {u^{\prime }}{u^{2}}\\ \left ( -x\left ( \frac {1}{x}+\frac {1}{u}\right ) +1\right ) f-\left ( \frac {1}{x}+\frac {1}{u}\right ) ^{2} & =\frac {-1}{x^{2}}-\frac {u^{\prime }}{u^{2}}\\ \left ( \left ( -1-\frac {x}{u}\right ) +1\right ) f-\left ( \frac {1}{x^{2}}+\frac {1}{u^{2}}+\frac {2}{xu}\right ) & =\frac {-1}{x^{2}}-\frac {u^{\prime }}{u^{2}}\\ -\frac {x}{u}f-\left ( \frac {1}{x^{2}}+\frac {1}{u^{2}}+\frac {2}{xu}\right ) & =\frac {-1}{x^{2}}-\frac {u^{\prime }}{u^{2}}\\ -\frac {x}{u}f-\frac {1}{x^{2}}-\frac {1}{u^{2}}-\frac {2}{xu} & =\frac {-1}{x^{2}}-\frac {u^{\prime }}{u^{2}}\\ -xuf-1-\frac {2u}{x} & =-u^{\prime }\\ u^{\prime } & =xuf+1+\frac {2u}{x} \end {align*}

Hence$u^{\prime }-\left ( xf+\frac {2}{x}\right ) u=1$ Integrating factor is $$\mu =e^{\int \left ( xf+\frac {2}{x}\right ) dx}$$, hence the solution is$d\left ( \mu u\right ) =\mu$ Integrating both sides\begin {align*} \mu u & =\int \mu dx+C\\ u & =e^{-\int \left ( xf+\frac {2}{x}\right ) dx}\int e^{\int \left ( xf+\frac {2}{x}\right ) dx}dx+Ce^{-\int \left ( xf+\frac {2}{x}\right ) dx}\\ & =e^{-\int \left ( xf+\frac {2}{x}\right ) dx}\left ( \int e^{\int \left ( xf+\frac {2}{x}\right ) dx}dx+C\right ) \end {align*}

Hence\begin {align*} y & =y_{p}+\frac {1}{u}\\ & =\frac {1}{x}+\frac {1}{e^{-\int \left ( xf+\frac {2}{x}\right ) dx}\left ( \int e^{\int \left ( xf+\frac {2}{x}\right ) dx}dx+C\right ) } \end {align*}

Hence$y\left ( x\right ) =\frac {1}{x}+e^{\int \left ( xf+\frac {2}{x}\right ) dx}\left ( \int e^{\int \left ( xf+\frac {2}{x}\right ) dx}dx+C\right ) ^{-1}$