How to integrate $\cos t e^{-t^2/2}$? I'd like to solve the D.E. $$y'=xy+\cos{x}$$
where $y(0)=1$. So, with Cauchy formula I get
$$e^\frac{x^2}{2}\left(C+\int \cos{t}\cdot e^\frac{-t^2}{2}dt\right) $$
So the question is how to solve this integral?
 A: The solution to your differential equation is, using the method of integrating factors,
$$y(x)=e^{x^2/2}+e^{x^2/2}\int_0^x e^{-t^2/2}\cos(t)\,dt$$
You have that
$$\frac{y(x)}{e^{x^2/2}}\to1+\int_0^\infty e^{-t^2/2}\cos(t)\,dt=1+\sqrt{\frac{\pi}{2e}}\qquad \text{ as } x\to\infty.$$
Hence,
$$y(x)=e^{x^2/2}\left(1+\sqrt{\frac{\pi}{2e}}\right)+o\big(e^{x^2/2}\big).$$
We can be more precise about the error term $o\big(e^{x^2/2}\big)$. Denote
$$R(x)=\left|y(x)- e^{x^2/2}\left(1+\sqrt{\frac{\pi}{2e}}\right)\right|.$$
Thus we have that
$$
\begin{aligned}
R(x)&\le e^{x^2/2} \int_x^\infty e^{-t^2}\,dt\\
&\le \frac{1}{2} e^{x^2/2} \int_{x^2}^\infty e^{-t/2}t^{-1/2}\,dt \\
&\le \frac{1}{x}.
\end{aligned}$$
A: $$I=\int\cos (t)\,e^{-\frac{t^2}{2}} \cos (t)\,dt=\Re\int e^{it} \,e^{-\frac{t^2}{2}} \,dt$$
Completing the square
$$\int e^{it} \,e^{-\frac{t^2}{2}} \,dt=\int e^{-\frac{t^2-2it+i^2+1}{2}} \,dt=\frac 1{\sqrt e}\int e^{-\frac{(t-i)^2} 2}\,dt=\sqrt{\frac{\pi }{2 e}} \text{erf}\left(\frac{t-i}{\sqrt{2}}\right)$$
$$I=\frac{1}{2} \sqrt{\frac{\pi }{2 e}} \left(\text{erf}\left(\frac{t-i}{\sqrt{2}}\right)+\text{erf}\left(\frac{t+
   i}{\sqrt{2}}\right)\right)$$
