TITLE: Using Fourier Transform to solve heat equation
QUESTION [5 upvotes]: the heat equation of $U(x,t)$ on $-\infty<x<+\infty$ and $t>0$ is
$$U_t=U_{xx}+\exp\left({\frac{-x^2}{2}}\right)$$
where
$$U(x,t)\rightarrow 0 \quad as\quad x\rightarrow\pm\infty$$
and the initial condition is $$U(x,0)=0$$
That's what i tried... I not sure if it's correct, but use the cos transform to solve this equation 
by firstly, let
$$u(s,t)=\int_{0}^{+\infty}{U(x,t)\cos(sx)}dx$$ 
then, taking the fourier cos transform for both side of the PDE
$$u_t=\int_{0}^{+\infty}{U_{xx}\cos(sx)}dx+\int_{0}^{+\infty}{\exp\left({\frac{-x^2}{2}}\right)\cos(sx)}dx$$
$$u_t=[\cos(sx) U_x]_{0}^{+\infty} + s\int_{0}^{+\infty}{U_{x}\sin(sx)}dx +\sqrt{\frac{\pi}{2}}\exp\left({\frac{-x^2}{2}}\right)$$
$$u_t=[\cos(+\infty s)U_x(+\infty,s) - U_x(0,s)] + s\{[\sin(sx)U]_{0}^{+\infty}- s\int_{0}^{+\infty}{U\cos(sx)}dx\} +\sqrt{\frac{\pi}{2}}\exp\left({\frac{-x^2}{2}}\right)$$
by appling the properities and conditions, I got
$$u_t=[0 - 0] + s\{0- su\} +\sqrt{\frac{\pi}{2}}\exp\left({\frac{-s^2}{2}}\right)$$
finaly get the $1^st$ order ODE
$$u_t + s^2 u = \sqrt{\frac{\pi}{2}}\exp\left({\frac{-s^2}{2}}\right)$$
Up to here, I thinks there should have some mistakes in the processes... but I cannot find them..or my approaching is in a wrong method...?

REPLY [4 votes]: Why are you restricting yourself to $x \in (0,\infty)$ when the domain is for the entire real line?  In this case, it seems easier to go with Fourier transforms, i.e.,
$$u(s,t) = \int_{-\infty}^{\infty} dx \, U(x,t) \, e^{i s x}$$
Then the PDE becomes
$$u_t + s^2 u = \sqrt{2 \pi} \, e^{-s^2/2} = e^{-s^2 t}\frac{d}{dt}\left [e^{s^2 t} u \right ]$$
$$u(s,0)=0$$
$$\implies u(s,t) = \sqrt{2 \pi} \, e^{-s^2/2} \frac{1-e^{-s^2 t}}{s^2} $$
Now inverse FT...use the fact that
$$\frac{1-e^{-s^2 t}}{s^2} = \int_0^t dt' \, e^{-s^2 t'}$$
and get
$$U(x,t) = \int_0^t dt' \, (1+2 t')^{-1/2} \, e^{-x^2/[2 (1+2 t')]}$$