Integration by part with substitution Question: Show that

$$\begin{align}u(x,t) &=c\sqrt{\frac{k}{\pi}}\int^t_0s^{-1/2}e^{-x^2/4ks}\,ds\\
&=c\sqrt{\frac{4kt}{\pi}}e^{-x^2/4kt}-cx\,\text{erfc}\frac{x}{\sqrt{4kt}}\end{align}$$

The book where the question is found gives a hint that "subtitute $\sigma=x/\sqrt{4ks}$ and then integrate by part". So here are my attempts and obstacles:


*

*The substitute yields $d\sigma=-x/2\sqrt{4ks^3}\,ds$, but the original function lacks $s^{-1}$ in the integrand.

*Immediate integration by part before substitution will make $s^{-1/2}$ to $s^{-3/2}$, but I don't know how can I integrate the other part. This action seems to contradict our reason of substitution.

*I would like to write
$$\text{erfc}\frac{x}{\sqrt{4kt}}=\frac{2}{\sqrt{\pi}}\int^\infty_{x/\sqrt{4kt}}e^{-s^2}\,ds$$
in form of
$$A\int^\infty_tg(s)\,ds$$
to see if it makes things clearer. But it is unlikely.


I appreciate for any help.
 A: I believe the hint does help you out, but you need an extra step in the substitution.
Applying the substitution in details gives you: 
$\sigma = \frac{x}{\sqrt{4k}}s^{-1/2}$, so then $\frac{\text{d}\sigma}{\text{d}s} = \frac{-1}{2} \frac{x}{\sqrt{4k}}s^{-3/2}$. This last term does not really match the factors we have in the integral so we cannot easily replace the $\text{d}s$ term by $\text{d}\sigma$. But we can rewrite it.
So we write $s^{-1/2} \sqrt{\frac{k}{x}} \text{d}s= (\frac{-1}{4} s^{-1} \frac{x^{3/2}}{k})^{-1}(\frac{-1}{4} s^{-1} \frac{x^{3/2}}{k})  s^{-1/2} \sqrt{\frac{k}{x}} \text{d}s = (\frac{-1}{4} s^{-1} \frac{x^{3/2}}{k})^{-1} \text{d} \sigma.$
Now notice that the correction term $(\frac{-1}{4} s^{-1} \frac{x^{3/2}}{k})^{-1} = (-\frac{1}{\sqrt{x}} \sigma^2)^{-1}$.
So then we get: 
$u(t,x) = \sqrt{x} c \int_{\dots}^{\dots} -\sigma^{-2}e^{-\sigma^2} \text{d} \sigma. $
Adjusting for the bounds gives us:
$u(t,x) = \sqrt{x} c \int_{\frac{x}{\sqrt{4kt}}}^{\infty} -\sigma^{-2}e^{-\sigma^2} \text{d} \sigma. $ 
Now this is an integral we can integrate by parts which will result in some expression involving the error function. If you have any questions I can work it out later, but that is it basically. I hope I havent made any error, as I wrote this down very fast.
A: $$u(x,t) =c\sqrt{\frac{k}{\pi}}\int^t_0s^{-1/2}e^{-x^2/4ks}\,ds=$$
With $s=x^2/(4k\sigma^2)$ and $ds=-(2x^2)/(4k\sigma^3)d\sigma$
$$=c\sqrt{\frac{k}{\pi}}\frac{2x}{\sqrt{4k}}\int^{x/\sqrt{4kt}}_{-\infty}-\sigma^{-2}e^{-\sigma^2}\,d\sigma$$
$\begin{cases}
  u=-e^{-\sigma^2}\;;du=2\sigma e^{-\sigma^2}d\sigma\\
  dv=d\sigma/\sigma^2\;;v=-1/\sigma
\end{cases}$
$$u(x,t)=c\frac{x}{\sqrt{\pi}}\left[\frac{e^{-\sigma^2}}{\sigma}\right]^{x/\sqrt{4kt}}_{-\infty}+cx\frac{2}{\sqrt{\pi}}\int^{x/\sqrt{4kt}}_{-\infty}e^{-\sigma^2}$$
$u=-\sigma$
$$\frac{2}{\sqrt{\pi}}\int^{x/\sqrt{4kt}}_{-\infty}e^{-\sigma^2}d\sigma=\frac{2}{\sqrt{\pi}}\int_{-x/\sqrt{4kt}}^{+\infty}e^{-u^2}du=-\frac{2}{\sqrt{\pi}}\int_{x/\sqrt{4kt}}^{+\infty}e^{-u^2}du=-\text{erfc}\left(\frac{x}{\sqrt{4kt}}\right)$$
$$u(x,t)=c\frac{x}{\sqrt{\pi}}\frac{e^{-x^2/4kt}}{x/\sqrt{4kt}}-cx\,\text{erfc}\left(\frac{x}{\sqrt{4kt}}\right)=$$
$$=c\sqrt{\frac{4kt}{\pi}}e^{-x^2/4kt}-cx\,\text{erfc}\left(\frac{x}{\sqrt{4kt}}\right)$$
