\[ f(x) (x y(x)-1)+y'(x)+y(x)^2=0 \] ✗ Mathematica : cpu = 21.1718 (sec), leaf count = 0 , could not solve
DSolve[y[x]^2 + f[x]*(-1 + x*y[x]) + Derivative[1][y][x] == 0, y[x], x]
✓ Maple : cpu = 0.345 (sec), leaf count = 49
\[ \left \{ y \left ( x \right ) ={1{{\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 \} \]
\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 first 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}\]