$y' = x - 2y$

$\dfrac{dy}{dx} + 2y = x$ → linear in y

Hence,

$P = 2$

$Q = x$

Integrating factor:

$\displaystyle e^{\int P \, dx} = e^{\int 2 \, dx}$

$\displaystyle e^{\int P \, dx} = e^{2x}$

Thus,

$\displaystyle ye^{\int P\,dx} = \int Qe^{\int P\,dx} \, dx + C$

$\displaystyle ye^{2x} = \int xe^{2x} \, dx + c$

Using integration by parts

$u = x$, $du = dx$

$dv = e^{2x} \, dx$, $v = \frac{1}{2}e^{2x}$

$\displaystyle ye^{2x} = \frac{1}{2}xe^{2x} - \frac{1}{2}\int e^{2x} \, dx + c$

$ye^{2x} = \frac{1}{2}xe^{2x} - \frac{1}{4}e^{2x} + \frac{1}{4}c$

Multiply by 4e^{-2x}

$4y = 2x - 1 + ce^{-2x}$ *answer*