# 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.

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}$$

• I have two questions. First, between line 2 and 3, why does the k disappear? Shouldn't it be $-2\sigma^{2}k$ at the numerator (same for the 4th line)? The second question I have is about the reason why the last integral is equal to one. Is there a specific formula I should be using? – Arnaud Wolff Nov 5 '19 at 20:36
• It is really a little mysterious where the k has disappeared. I will check it. – callculus Nov 5 '19 at 20:39
• @ArnaudWolff Good catch. You was right. I´ve made an edit. You can regard the function at the integral as a pdf of normal distributed variable with standard deviation $\sigma$ and expected value=$\mu-\sigma^2k$. And the integral of the pdf of normal distributed variable from $-\infty$ to $\infty$ always integrates to 1. I also noticed that I´ve omitted a factor. Arrghh. – callculus Nov 5 '19 at 20:47
• Thank you very much for your time. – Arnaud Wolff Nov 5 '19 at 20:51
• @ArnaudWolff You are welcome. You can mark the answer as accepted if you have no questions anymore. – callculus Nov 5 '19 at 20:52