Gaussian Integration, Trouble with Error Function

I'm tasked with evaluating this integral for class:

$$\int_{-\infty}^\infty e^{-(x-\mu)^2 / (2\sigma^2)} \, dx$$, assume $$\mu$$ and $$\sigma^2$$ are real scalars and $$\sigma^2 > 0$$.

At one point in my solution, I come up against the error function. I've gone over the math a few times and can't seem to figure out what happens. It'll be obvious where my question is in the work below. Let the Gaussian integral equal $$I$$ such that

Firstly, take $$a = 1/(2\sigma^2)$$, $$u = x-\mu$$, $$du = dx$$. Notice that when $$x=0$$, $$u=-\mu$$. Now, the integral we must solve is the following: $$$$\int_{0}^\infty e^{-(x-\mu)^2 / (2\sigma^2)} \, dx = \int_{-\mu}^\infty e^{-a u^2} \, du \nonumber$$$$ To further simplify this expression, take $$t = \sqrt{a} \, u$$. Note that when $$u = \mu$$, $$t = -\sqrt{a} \, \mu$$. Then, \begin{align} \int_{-\mu}^\infty e^{-a u^2} \, du &= \dfrac{1}{\sqrt{a}} \int_{-\mu \sqrt{a}}^\infty e^{-t^2} \, dt \nonumber \\[.5em] &= \dfrac{1}{\sqrt{a}} \int_{-\mu \sqrt{a}}^0 e^{-t^2} \, dt + \dfrac{1}{\sqrt{a}} \int_{0}^\infty e^{-t^2} \, dt \nonumber \\[.5em] &= -\dfrac{1}{\sqrt{a}} \int_0^{-\mu \sqrt{a}} e^{-t^2} \, dt + \dfrac{1}{\sqrt{a}} \int_{0}^\infty e^{-t^2} \, dt. \label{eq:hw1_prob1.2} \end{align} We should pause here and take a look at each expression in the sum separately. First, we should note the expression of the Error Function, $$$$Erf(z) = \dfrac{2}{\sqrt{\pi}} \int_0^z e^{-t^2} \, dt. \nonumber$$$$ Applying this to the first expression in our sum, we have

BREAK

At this point in my work, I assume the following expression is true. I know the final answer is correct, but unless $$-Erf(-z) = Erf(z)$$ (I'm not sure this is true), I'm not sure why this works.

$$$$-\dfrac{1}{\sqrt{a}} \int_0^{-\mu \sqrt{a}} e^{-t^2} \, dt = \dfrac{1}{\sqrt{a} \,}Erf{\left(\dfrac{\mu}{\sigma \sqrt{2}}\right)} \nonumber$$$$

Now, let's turn our focus to the second sum. Using the 'polar' method of solving this expression, we have \begin{align} I &= \int_0^\infty e^{-t^2} \, dt = \dfrac{1}{2} \int_{-\infty}^\infty e^{-t^2} \, dt \nonumber \\[.5em] I^2 &= \dfrac{1}{4} \int_{-\infty}^\infty \int_{-\infty}^\infty e^{-(x^2 + y^2)} \, dx dy. \nonumber \end{align} Take $$x = r\cos{\theta}$$, $$y = r \sin \theta$$, $$dx dy = r \, dr d\theta$$ such that $$$$\dfrac{1}{4} \int_0^{2\pi} \int_{-\infty}^\infty r e^{-r^2} \, dr d\theta. \nonumber$$$$ Now, let $$u = -r^2$$ so that $$du = -2 r dr$$. So, $$$$I^2 = -\dfrac{1}{8} 2\pi \int_0^\infty e^u \, du = \dfrac{\pi}{4}, \nonumber$$$$ and $$$$I = \dfrac{\sqrt{\pi}}{2}. \nonumber$$$$

Putting this all together and skipping over some tedious algebra, we have $$$$\boxed{ \int_{0}^\infty e^{-(x-\mu)^2 / (2\sigma^2)} \, dx = \sigma \sqrt{\dfrac{\pi}{2}} \left[ 1 + Erf\left(\dfrac{\mu}{\sigma\sqrt{2}}\right) \right] } \nonumber$$$$

Any help with this is appreciated. I'm sure it's a simple mistake that I am overlooking.

• It is true that $-\text{erf}(-x) = \text{erf}(x)$, which can be seen by making the substitution $x \to -x$. Commented Jan 20, 2021 at 3:20
• phew, thank you. If you write out a solution, I'll mark you as the correct answer.
– NoVa
Commented Jan 20, 2021 at 3:41

1 Answer

Your approach is unnecessarily complicated. $$\int_Re^{-(x-\mu)^2/(2\sigma^2)}dx=\int_Re^{(-y^2)/(2\sigma^2)}dy=\sigma \int_Re^{-u^2/2}du=\sigma\sqrt{2\pi}$$

The error function is needed when you integrate over part of the real line.

• I know, but I needed to show it in the form with the error function.
– NoVa
Commented Jan 20, 2021 at 4:23
• Split the integral into $(-\infty ,0)$ and $(0,\infty)$ Each part will contain erf term which will add up to simple sum. Commented Jan 20, 2021 at 19:28