\[ f(x) y(x)^2+g(x) y(x)+y'(x)=0 \] ✓ Mathematica : cpu = 0.595267 (sec), leaf count = 51
\[\left \{\left \{y(x)\to \frac {e^{\int _1^x -g(K[1]) \, dK[1]}}{c_1-\int _1^x f(K[2]) \left (-e^{\int _1^{K[2]} -g(K[1]) \, dK[1]}\right ) \, dK[2]}\right \}\right \}\]
✓ Maple : cpu = 0.037 (sec), leaf count = 28
\[ \left \{ y \left ( x \right ) ={\frac {{{\rm e}^{\int \!-g \left ( x \right ) \,{\rm d}x}}}{\int \!{{\rm e}^{\int \!-g \left ( x \right ) \,{\rm d}x}}f \left ( x \right ) \,{\rm d}x+{\it \_C1}}} \right \} \]
\begin {align} y^{2}f+gy+y^{\prime } & =0\nonumber \\ y^{\prime } & =-gy-y^{2}f\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. \(P\left ( x\right ) =0,Q\left ( x\right ) =-g,R\left ( x\right ) =f\). First step is to divide by \(y^{2}\)\begin {equation} \frac {y^{\prime }}{y^{2}}=-g\frac {1}{y}-f\tag {2} \end {equation}
Let \(u=\frac {1}{y}\), then \(u^{\prime }=\frac {-y^{\prime }}{y^{2}}\) and (2) becomes\begin {align*} -u^{\prime } & =-gu-f\\ u^{\prime }-gu & =f \end {align*}
Integrating factor is \(e^{-\int gdx}\) hence\begin {align*} d\left ( e^{-\int gdx}u\right ) & =fe^{-\int gdx}\\ e^{-\int gdx}u & =\int fe^{-\int gdx}dx+C\\ u & =e^{\int gdx}\left ( \int fe^{-\int gdx}dx+C\right ) \end {align*}
Hence \begin {align*} y & =\frac {1}{e^{\int gdx}\left ( \int fe^{-\int gdx}+C\right ) }\\ & =\frac {e^{-\int gdx}}{\int fe^{-\int gdx}dx+C} \end {align*}
Let \(\beta =e^{-\int gdx}\) then\[ y=\frac {\beta }{\int f\beta dx+C}\]
Verification
restart; eq:=diff(y(x),x)+f(x)*y(x)^2+g(x)*y(x) = 0; beta:=exp(-Int(g(x),x)): my_sol:=beta/(Int(f(x)*beta,x)+_C1); odetest(y(x)=my_sol,eq); 0