y'=(y-xy^2)/(x+x^2); dy/dx=y(1-xy)/(x(1+x));
Let y=vx^n, then dy/dx=vnx^(n-1)+x^ndv/dx.
vnx^(n-1)+x^ndv/dx=y(1-xy)/(x(1+x)).
Substitute for y:
vnx^(n-1)+x^ndv/dx=vx^n(1-vx^(n+1))/(x(1+x)).
Divide through by x^n:
nv/x+dv/dx=v(1-vx^(n+1))/(x(1+x)).
Then by v: (1/v)dv/dx=(1-vx^(n+1))/(x(1+x))-n/x.
For the purpose of separating the variables, put n=-1, making y=v/x or v=xy:
(1/v)dv/dx=(1-v)/(x(1+x))+1/x.
dv/(v(1-v))=1/(x(1+x))+1/x=(1+1+x)/(x(1+x))=(x+2)/(x(1+x)).
Let A/v+B/(1-v)=1/(v(1-v)) where A and B are constants.
A-Av+Bv=1 so A=1 and -A+B=0, B=A.
dv/v+dv/(1-v)=((x+2)/(x(1+x)))dx=(A/x+B/(1+x))dx where A and B are different constants.
A+Ax+Bx=x+2; A=2; A+B=1, B=-1, so:
dv/v+dv/(1-v)=2dx/x-dx/(1+x).
Now we can integrate both sides:
ln|v|-ln|1-v|=2ln|x|-ln|1+x|; ln|v/(1-v)|=ln|ax^2/(1+x)| where a is integration constant.
Therefore, xy/(1-xy)=ax^2/(1+x), simplifying to y/(1-xy)=ax/(1+x).
Inverting: (1-xy)/y=(1+x)/ax; 1/y-x=(1+x)/ax; 1/y=x+(1+x)/ax=(ax^2+x+1)/ax; y=ax/(ax^2+x+1).