Answer
$y=\frac{1}{(1+x^2)(-\frac{1}{2}\ln (1+x^2)+1)}$
Work Step by Step
Given:
$$\frac{dy}{dx}+\frac{2x}{1+x^2}y=xy^2$$
This equation is in form of Bernoulli equation, where $p(x)=\frac{2x}{1+x^2}, q(x)=x$ and $n=2$
Dividing both sides by $y^{2}$
$$\frac{1}{y^2}\frac{dy}{dx}+\frac{1}{y}\frac{2x}{1+x^2}y=x$$
Let $u=y^{-1} \rightarrow \frac{du}{dx}=-\frac{1}{y^2}\frac{dy}{dx}$
Then it becomes:
$$-\frac{du}{dx}+\frac{2x}{1+x^2}u=x$$
$$\frac{du}{dx}-\frac{2x}{1+x^2}u=-x$$
The integrating factor is:
$$I(x)=e^{-\int \frac{2x}{1+x^2}dx}=$$
To solve this, we let:
$1 +x^2 =t \rightarrow 2xdx=dt$
Hence,
$I=e^{-\int \frac{1}{t}dt}=e^{-\ln t}=e^{-\ln 1+x^2}=\frac{1}{1+x^2}$
The equation becomes:
$$\frac{d}{dx}(\frac{1}{1+x^2}u)=-\frac{2x}{(1+x^2)^2}u+(\frac{1}{1+x^2})\frac{du}{dx}$$
$$\frac{d}{dx}(\frac{1}{1+x^2}u)=-\frac{x}{1+x^2}$$
Integrating both sides:
$$\int \frac{1}{1+x^2}u=-\int \frac{x}{1+x^2}dx$$
$$\frac{1}{1+x^2}u=-\frac{1}{2}\ln (1+x^2)+C$$
where $C$ is a constant of integration
Then:
$$u=(1+x^2)(-\frac{1}{2}\ln (1+x^2)+C)$$
Subtitute when $u=y^{-1}$ we have:
$$\rightarrow y^{-1}=(1+x^2)(-\frac{1}{2}\ln (1+x^2)+C)$$
$$\rightarrow y=\frac{1}{1+x^2)(-\frac{1}{2}\ln (1+x^2)+C}$$
We are given $y(0)=1$
Substituting:
$$1=\frac{1}{(1+0^2)(-\frac{1}{2}\ln (1+0^2)+C)}$$
$\rightarrow C=1$
Hence here, the solution is:
$$y=\frac{1}{(1+x^2)(-\frac{1}{2}\ln (1+x^2)+1)}$$