Solving $u_t=ku_{xx}$ for $\ t\ge 0,-\infty
Solve $$u_t=ku_{xx}\\u(x,0)=g(x)$$ for $t\ge 0, -\infty<x<\infty$, where $$g(x) = \begin{cases}
1, \quad \lvert x \rvert < 1 \\
0, \quad \lvert x \rvert > 1
\end{cases}$$
Solution.
We have that the solution is given by 
\begin{align}
u(x,t) &= \frac{1}{\sqrt{4\pi kt}}\int_{-1}^1e^{-(x-y)^2/4kt} \cdot 1 dy \\
&= \frac{-1}{\sqrt\pi}\int_{\frac{x-1}{\sqrt{4kt}}}^{\frac{x+1}{\sqrt{4kt}}} e^{-p^2}dp
\end{align}
if we consider  $p=\frac{(x-y)}{\sqrt{4kt}}$ in the solution formula.
Is my solution correct so far? If yes, how do I integrate the integral with the $p$ variable? 
I was thinking to separate the integral like 
$$\int_{-a}^a=\int_{-a}^0+\int_0^a$$
but I'm not sure that 
$$\frac{x-1}{\sqrt{4kt}}<0$$
 A: To answer your question on how to rewrite the integral in terms of the error function, you are close to the result. To start, you already recognized that
$$\begin{align}
u(x,t) &= \frac{1}{\sqrt{4\pi kt}}\int_{\mathbb{R}}\exp\left(-\frac{(x-y)^2}{4kt}\right)\,g(y)\,dy\\
&=\frac{1}{\sqrt{4\pi kt}}\int_{|x|<1}\exp\left(-\frac{(x-y)^2}{4kt}\right)(1)\,dy + \frac{1}{\sqrt{4\pi kt}}\int_{|x|>1}\exp\left(-\frac{(x-y)^2}{4kt}\right)(0)\,dy\\
&=\frac{1}{\sqrt{4\pi kt}}\int_{-1}^1\exp\left(-\frac{(x-y)^2}{4kt}\right)\,dy
\end{align}$$
is the solution to the given PDE given the boundary conditions. Applying the change of variable $p = \frac{x-y}{\sqrt{4kt}}$ gives
$$u(x,t) = -\frac{1}{\sqrt{\pi}}\int_{\frac{x+1}{\sqrt{4kt}}}^{\frac{x-1}{\sqrt{4kt}}}e^{-p^2}dp$$
Now split up the integral as per your intuition told you.
$$u(x,t) = -\frac{1}{\sqrt{\pi}}\left[\int_0^{\frac{x-1}{\sqrt{4kt}}}e^{-p^2}dp+\int_{\frac{x+1}{\sqrt{4kt}}}^0e^{-p^2}dp\right]
= \frac{1}{\sqrt{\pi}}\left[\int_0^{\frac{x+1}{\sqrt{4kt}}}e^{-p^2}dp-\int_0^{\frac{x-1}{\sqrt{4kt}}}e^{-p^2}dp\right]$$
Applying the definition of the error function in the comments above will give the simply represented solution to the PDE.
$$\begin{align}
u(x,t) &= \frac{1}{\sqrt\pi}\left[\frac{\sqrt\pi}{2}\text{ erf}\left(\frac{x+1}{\sqrt{4kt}}\right)-\frac{\sqrt\pi}{2}\text{ erf}\left(\frac{x-1}{\sqrt{4kt}}\right)\right]\\
&=\frac{1}{2}\left[\text{ erf}\left(\frac{x+1}{\sqrt{4kt}}\right)-\text{ erf}\left(\frac{x-1}{\sqrt{4kt}}\right)\right]
\end{align}$$
Here is a quick and dirty graphical solution of the PDE using the error function. Notice it has a maximum value of $1$ at $t=0$ (boundary condition) and the curve decreases as time passes. This is the general behavior of the heat/dilution equation.

