How to solve heat equation on the semi-infinite rod by Fourier Transform Question
Solve the following heat equation on the semi-infinite rod by Fourier Transform
$$u_t=ku_{xx}$$ where $x,t>0$ and
$u_x(0,t) =0$ and $u(x,0)=\begin{cases} 
      1, & 0 < x <2 \\
      0, &  2\leq x  
   \end{cases}
$
My attempt
If we apply Fourier Trans. to both sides, we get
$ \frac{\partial \mathcal{F} \{U(w,t)\}}{\partial t} = -kw^{2} \mathcal{F} \{U(w,t)\}$              
Solving the ODE, we have
$U(w,t)=C(w)e^{-kw^2t}$
to find $C(w)$ we use the initial condt. $u(x,0)$
$C(w)=\mathcal{F} \{u(x,0)\}=\frac{1}{(2\pi)^{1/2}}\int_{-\infty}^{\infty} u(x,0) e^{-iwx} \ dx $
Could you help me to solve the rest? What is the solution $$u\left(x,t\right)=\mathrm{TF}^{-1}\{U(w,t)\}=\frac{1}{(2\pi)^{1/2}}\intop_{x\in\mathbb{R}}C(w)e^{-kw^2t}e^{iwx}dw$$?
(I can't calculate $C(w)$ since $u(x,0)$ is undefined on $-\infty<x<0$ )
 A: Let $u_0(x) =u(x,0)$ then 
$$C(w)=\mathcal{F} \{u_0\}(w)=\frac{1}{2\pi}\int_{-\infty}^{\infty} u(x,0) e^{-iwx} \ dx$$
We also know the following
$$ e^{-kw^2t} = \mathcal{F}\left(\frac{1}{\sqrt{2kt}} \displaystyle{e^{-\frac{x^2}{4kt}}}\right)(w)$$
Whence it follows that, 
$$U(w,t)= C(w)e^{-kw^2t}=\mathcal{F} \{u_0\}(w)\cdot\mathcal{F}\left(\frac{1}{\sqrt{2kt}} \displaystyle{e^{-\frac{x^2}{4kt}}}\right)(w)$$ 
Using the product rule for Fourier we have 
$$u\left(x,t\right)=\mathcal{F}^{-1}\{U(w,t)\} =\mathcal{F}^{-1}\left\{\mathcal{F} \{u_0\}\cdot\mathcal{F}\left(\frac{1}{\sqrt{2kt}} \displaystyle{e^{-\frac{x^2}{4kt}}}\right)\right\}\\= u_0\star\frac{1}{\sqrt{2kt}} \displaystyle{e^{-\frac{x^2}{4kt}}}~~~\text{convolution }\\=
\frac{1}{\sqrt{2kt}}\int_\Bbb R u_0(y)e^{-\frac{(x-y)^2}{4kt}}dy 
\\=\frac{1}{\sqrt{2kt}}\int_{2}^{\infty} \underbrace{u_0(y)}_{0}e^{-\frac{(x-y)^2}{4kt}}dy
+\frac{1}{\sqrt{2kt}}\int_{0}^{2} \underbrace{u_0(y)}_{1}e^{-\frac{(x-y)^2}{4kt}}dy \\+\frac{1}{\sqrt{2kt}}\int_{-\infty}^{2}\underbrace{u_0(y)}_{?}e^{-\frac{(x-y)^0}{4kt}}dy\\=\frac{1}{\sqrt{2kt}}\int_{0}^{2} e^{-\frac{(x-y)^2}{4kt}}dy +\frac{1}{\sqrt{2kt}}\int_{-\infty}^{2}\underbrace{u_0(y)}_{?-u_0~~is ~~not~~define}e^{-\frac{(x-y)^0}{4kt}}dy $$
YOU HAVE TO DEIFNE $u_0$ FOR $x<0$
A: The separated solutions $X(x)T(t)$ must solve
$$
        \frac{T'(t)}{kT(t)} = -\lambda = \frac{X''(x)}{X(x)},\;\; X'(0)=0.
$$
The solutions have the form $T(t)=Ce^{-\lambda t}$, $X(x)=D\cos(\sqrt{\lambda}x)$, and $\lambda > 0$ is natural in order to have boundedness in time and space of the separated solutions. Letting $\lambda=s^2$ gives a trial solution
$$
                u(x,t)=\int_{0}^{\infty}F(s)e^{-s^2t}\cos(sx)ds.
$$
In order to satisfy the condition on $u(x,0)$, it is necessarily to determine a coefficient function $F$ such that
$$
          \int_{0}^{\infty}F(s)\cos(sx)ds=\chi_{[0,2]}(x),
$$
which is solved by the inverse Fourier cosine transform:
\begin{align}
  F(s) & = \frac{2}{\pi}\int_{0}^{\infty}\chi_{[0,2]}(x)\cos(sx)dx \\
       & = \frac{2}{\pi}\int_{0}^{2}\sin(sx)dx= -\frac{2}{\pi}\frac{\cos(2s)-1}{s}.
\end{align}
Therefore,
$$
           u(x,t) = \frac{2}{\pi}\int_{0}^{\infty}e^{-s^2 t}\frac{1-\cos(2s)}{s}\cos(sx)ds.
$$
