Answer
$y = e^{-x^2}\int e^{x^2}~dx+Ce^{-x^2}$
or:
$y = e^{-x^2}~[-i\frac{\sqrt{\pi}}{2}~erf(ix)+C]$
Work Step by Step
A first-order linear differential equation is one that can be put into the form:
$\frac{dy}{dx} + P(x)~y = Q(x)$
We can consider the given equation:
$y' + 2xy = 1$
Let $P(x) = 2x$
Let $Q(x) = 1$
We can find the integrating factor:
$I(x) = e^{\int 2x ~dx} = e^{x^2}$
We can multiply by the integrating factor:
$e^{x^2}~y'+2xe^{x^2}~y = e^{x^2}$
$\frac{d}{dx}(e^{x^2}~y) = e^{x^2}$
We can integrate both sides of the equation:
$e^{x^2}~y = \int e^{x^2}~dx$
$e^{x^2}~y = -i\frac{\sqrt{\pi}}{2}~erf(ix)+C$
$y = e^{-x^2}~[-i\frac{\sqrt{\pi}}{2}~erf(ix)+C]$