How to solve this $\frac{dy}{dx} + 2y = 2 + e^{-x^2}$ $\frac{dy}{dx} + 2y = 2 + e^{-x^2}$ ,  $y(0)=0$
This is LDE of first order. So solving this in usual way i got stuck at at integration of 
$\int e^{2x}e^{-x^2}dx$. How do i proceed? Thanks
 A: Hint:
The integral 
$$
\int e^{2x}e^{-x^2} dx
$$
has no solution with elementary functions.  You can use the error function $\mbox{erf}(x)$, for which we know that (by definition):
$$
\frac{d}{dx} \mbox{erf}(x)=\frac{2}{\sqrt{\pi}}e^{-x^2}
$$
so, we have
$$
\frac{d}{dx} \mbox{erf}(1-x)=\frac{2}{\sqrt{\pi}}e^{-(1-x)^2}=\frac{2}{\sqrt{\pi}}e^{-1-x^2+2x}=\frac{2}{e\sqrt{\pi}}e^{2x}e^{-x^2}
$$
so, adjusting the constant factor, you have your integral
A: The solution of the homogeneous $y'+2y=0$ is $y=Ce^{-2x}$
Considering the non-homogeneous ODE, let : $y=f(x)e^{-2x}$
$$e^{-2x}f'=2+e^{-x^2}$$
$$f(x)=\int (2+e^{-x^2})e^{2x}dx$$
$\int 2e^{2x}dx=e^{2x}+$constant
$\int e^{-x^2}e^{2x}dx=e\int e^{-(x-1)^2}dx=e\frac{\sqrt\pi}{2}$erf$(x-1)+$constant
$y(x)=Ce^{-2x}+1+\frac{\sqrt\pi}{2}e^{-2x+1}$erf$(x-1)$
A: HINT:
$$\frac{\text{d}y(x)}{\text{d}x}+2y(x)=2+e^{-x^2}\Longleftrightarrow$$
$$y'(x)+2y(x)=2+e^{-x^2}\Longleftrightarrow$$

Let $\mu(x)=e^{\int2\space\text{d}x}=e^{2x}$.
Multiply both sides by $\mu(x)$:

$$e^{2x}y'(x)+(2e^{2x})y(x)=-e^{2x}\left(-e^{-x^2}-2\right)\Longleftrightarrow$$

Substitute $2e^{2x}=\frac{\text{d}}{\text{d}x}\left(e^{2x}\right)$:

$$e^{2x}y'(x)+\frac{\text{d}}{\text{d}x}\left(e^{2x}\right)y(x)=-e^{2x}\left(-e^{-x^2}-2\right)\Longleftrightarrow$$

Apply the reverse product rule $g\frac{\text{d}f}{\text{d}x}+f\frac{\text{d}g}{\text{d}x}=\frac{\text{d}}{\text{d}x}(fg)$ to the left-hand side:

$$\frac{\text{d}}{\text{d}x}\left(e^{2x}y(x)\right)=-e^{2x}\left(-e^{-x^2}-2\right)\Longleftrightarrow$$
$$\int\frac{\text{d}}{\text{d}x}\left(e^{2x}y(x)\right)\space\text{d}x=\int-e^{2x}\left(-e^{-x^2}-2\right)\space\text{d}x$$
