Solution (source code)

= Solution

On an interval with $x\ne-1$, an <integrating factor> is $(x+1)^{-2}$. Multiplication gives
$$
\frac d{dx}\left(\frac{y}{(x+1)^2}\right)=x+1.
$$
Integration therefore yields
$$
\boxed{y=\frac12(x+1)^4+C(x+1)^2.}
$$
The polynomial formula has a smooth continuation at $x=-1$, but the original coefficient $2/(x+1)$ is undefined there. Solution intervals for the stated equation must avoid that point, and the constants on its two sides need not agree.