dy/dx + (2x^2 + 1)y + y^2 + (x^4 + x^2 + 2x) = 0

General solution

Let y = y1 + y2

where y1 = -x^2 is a solution

Then,

d(y1+y2)/dx + (2x^2 + 1)(y1+y2) + (y1+y2)^2 = -(x^4 + x^2 + 2x)

dy1/dx + dy2/dx + (2x^2 + 1)y1 + (2x^2 + 1)y2 + y1^2 + 2y1y2 + y2^2 = -(x^4 + x^2 + 2x)

[dy1/dx + (2x^2 + 1)y1 + y1^2 + (x^4 + x^2 + 2x)] + dy2/dx + (2x^2 + 1)y2 + 2y1y2 + y2^2 = 0

Since [dy1/dx + (2x^2 + 1)y1 + y1^2 + (x^4 + x^2 + 2x)] =0,

Then dy2/dx + (2x^2 + 1)y2 + 2y1y2 + y2^2 = 0

i.e. dy2/dx + (2x^2 + 1)y2 - 2x^2y2 + y2^2 = 0, using y1 = -x^2

dy2/dx + y2 + y2^2 = 0

dy2/(y2(1 + y2)) = -dx

Using partial fractions,

dy2/y2 - dy2/(1+y2) = -dx

integrating both sides,

ln(y2/[K(1 + y2)] = -x

y2/(1 + y2) = Ke^(-x)

(1 + y2)/y2 = Ce^x

1/y2 + 1 = Ce^x

1/y2 = Ce^x - 1

y2 = 1/(Ce^x - 1)

Therefore y = y1 + y2

i.e. **y(x) = -x^2 + 1/(Ce^x - 1)**