Simplify integral of exponential functions using the method of completing the square How can I simplify
$ 1 - \frac{1}{\sqrt{2\pi}\sigma}\int^{\infty}_{-\infty}e^{-kw}e^{\frac{-(w-\mu)^{2}}{2\sigma^{2}}}dw$
using the method of completing the square? I know that the answer must be
$ 1 - e^{- (k\mu - \frac{k^2\sigma^2}{2})}$
and that it must therefore probably involve the Gaussian integral at some point, but I just can't see what the intermediate steps would be.
 A: Let us foccus on the exponents. Multiplying out the squared brackets and adding the exponent $-kw$.
$$\frac{-(w^2-2w\mu+\mu^2)}{2\sigma^2}-kw\frac{2\sigma^2}{2\sigma^2}$$
$$\frac{-w^2+2w\mu-\mu^2}{2\sigma^2}-kw\frac{2\sigma^2}{2\sigma^2}$$
Collecting terms with the variable $w$
$$\frac{-w^2+(2\mu-2\sigma^2k)w}{2\sigma^2}-\frac{\mu^2}{2\sigma^2}$$
Completing the square
$$\frac{-w^2+(2\mu-2\sigma^2k)w-(\mu-\sigma^2k)^2}{2\sigma^2}-\frac{\mu^2-(\mu-\sigma^2k)^2}{2\sigma^2}$$
$$\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}-\frac{\mu^2-(\mu-\sigma^2k)^2}{2\sigma^2}$$
$$\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}-\frac{\mu^2}{2\sigma^2}+\frac{\mu^2-2\mu\sigma^2k+\sigma^4k^2}{2\sigma^2}$$
$$\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}\underbrace{-\frac{\mu^2}{2\sigma^2}+\frac{\mu^2}{2\sigma^2}}_{=0}+\frac{-2\mu\sigma^2k+\sigma^4k^2}{2\sigma^2}$$
Cancelling out $\sigma^2$ at the last fraction
$$\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}+\frac{-2\mu k+\sigma^2k^2}{2}$$
$$\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}-\mu k+\frac{\sigma^2k^2}{2}$$
Now we integrate
$$e^{-\mu k+\frac{\sigma^2k^2}{2}}\cdot \underbrace{\frac{1}{\sqrt{2\pi}\sigma}\cdot \int_{-\infty}^{\infty} e^{\frac{-(w-(\mu-\sigma^2k))^2}{2\sigma^2}} \, dw}_{=1}$$
