\[ y'(x)-y(x)^2-x y(x)-x+1=0 \] ✓ Mathematica : cpu = 0.0728682 (sec), leaf count = 50
\[\left \{\left \{y(x)\to \frac {e^{\frac {x^2}{2}-2 x}}{c_1-\frac {\sqrt {\frac {\pi }{2}} \text {erfi}\left (\frac {x-2}{\sqrt {2}}\right )}{e^2}}-1\right \}\right \}\] ✓ Maple : cpu = 0.052 (sec), leaf count = 39
\[ \left \{ y \left ( x \right ) =-1+{\frac {1}{{\it \_C1}+{\frac {i}{2}}\sqrt {\pi }{{\rm e}^{-2}}\sqrt {2}{\it Erf} \left ( {\frac {i}{2}}\sqrt {2} \left ( x-2 \right ) \right ) }{{\rm e}^{{\frac {x \left ( x-4 \right ) }{2}}}}} \right \} \]
\begin {align} y^{\prime }-y^{2}-xy-x+1 & =0\nonumber \\ y^{\prime } & =x-1+xy+y^{2}\tag {1} \end {align}
This is Riccati first order non-linear ODE of the form. The general form is\[ y^{\prime }=P\left ( x\right ) +Q\left ( x\right ) y+R\left ( x\right ) y^{2}\] Where \(P\left ( x\right ) =x-1,Q\left ( x\right ) =x,R\left ( x\right ) =1\). We see that \(y_{p}=-1\) is a particular solution, therefore we use the substitution \(y=y_{p}+\frac {1}{u}\), hence \(y^{\prime }=-\frac {u^{\prime }}{u^{2}}\) and equating this to (1) we obtain\begin {align*} -\frac {u^{\prime }}{u^{2}} & =x-1+xy+y^{2}\\ & =x-1+x\left ( -1+\frac {1}{u}\right ) +\left ( -1+\frac {1}{u}\right ) ^{2}\\ & =x-1-x+\frac {x}{u}+\left ( 1+\frac {1}{u^{2}}-\frac {2}{u}\right ) \\ & =\frac {x}{u}+\frac {1}{u^{2}}-\frac {2}{u} \end {align*}
Hence\begin {align*} u^{\prime } & =-u^{2}\left ( \frac {x}{u}+\frac {1}{u^{2}}-\frac {2}{u}\right ) \\ & =-xu-1+2u\\ u^{\prime }+xu-2u & =-1\\ u^{\prime }+u\left ( x-2\right ) & =-1 \end {align*}
Integration factor is \(e^{\int \left ( x-2\right ) dx}=e^{\frac {x^{2}}{2}-2x}=e^{\frac {1}{2}x\left ( x-4\right ) }\), therefore\[ d\left ( e^{\frac {1}{2}x\left ( x-4\right ) }u\right ) =-e^{\frac {1}{2}x\left ( x-4\right ) }\] Integrating both sides\[ e^{\frac {1}{2}x\left ( x-4\right ) }u=-\int e^{\frac {1}{2}x\left ( x-4\right ) }+C \] But \[ \int e^{\frac {1}{2}x\left ( x-4\right ) }=\frac {1}{e^{2}}\sqrt {\frac {\pi }{2}}\operatorname {erfi}\left ( \frac {x-2}{\sqrt {2}}\right ) \] Hence\[ u\left ( x\right ) =e^{\frac {-1}{2}x\left ( x-4\right ) }\left ( \frac {-1}{e^{2}}\sqrt {\frac {\pi }{2}}\operatorname {erfi}\left ( \frac {x-2}{\sqrt {2}}\right ) +C\right ) \] Since \(y=y_{p}+\frac {1}{u}\) then\[ y=-1+\frac {1}{e^{\frac {-1}{2}x\left ( x-4\right ) }\left ( \frac {-1}{e^{2}}\sqrt {\frac {\pi }{2}}\operatorname {erfi}\left ( \frac {x-2}{\sqrt {2}}\right ) +C\right ) }\] Or\[ y=\frac {e^{\frac {1}{2}x\left ( x-4\right ) }}{C-\frac {1}{e^{2}}\sqrt {\frac {\pi }{2}}\operatorname {erfi}\left ( \frac {x-2}{\sqrt {2}}\right ) }-1 \]