# How does one compute the integral $\int\limits_{-L}^{L} e^{-ax^2-Ax} d{x}$?

As stated in the title, I am having difficulty finding an expression for $\int\limits_{-L}^{L} e^{-ax^2-Ax}d{x}$. I can expand the integrand in a Taylor Series and integrate term-by-term, and then simplify the result with a binomial expansion, but that leads to a very ugly result. Is there a cleaner way to do it?

• The exact value of the integral is given by an error function (en.wikipedia.org/wiki/Error_function) that is a well-known non-elementary function. However, there are plenty of good approximations, especially approximations exploiting probabilistic arguments or continued fractions. – Jack D'Aurizio May 16 '16 at 3:37

This is an alternate form of Gaussian Integral
The basic Gaussian Integral is $\int_{-\infty}^{\infty}e^{-x^2}dx=\sqrt\pi$
Other common forms are:
$\int_{-\infty}^{\infty}e^{-ax^2}dx=\sqrt\frac{\pi}{a}$
$\int_{-\infty}^{\infty}x^2e^{-ax^2}dx=\frac{1}{2a}\sqrt\frac{\pi}{a}$
$\int_{-\infty}^{\infty}x^4e^{-ax^2}dx=\sqrt\frac{\pi}{a}$

$\int_{-\infty}^{\infty}e^{-ax^2+Ax}dx=\int_{-\infty}^{\infty}e^{-a(x-A/2a)^2+A^2/4a}dx=\sqrt\frac{\pi}{a}e^{A^2/4a}$

• Given integral is not an improper integral. – choco_addicted May 16 '16 at 4:33
• I agree that the given integral would be Gaussian if the limits of integration went to infinity. Is there a way, however, to do my integral when the limits are not infinite? – Saroj Chintakrindi May 16 '16 at 10:47

Consider first completig the square $$a x^2+A x=\left(\sqrt{a} x+\frac{A}{2 \sqrt{a}}\right)^2-\frac{A^2}{4 a}$$ Now, change variable $$\sqrt{a} x+\frac{A}{2 \sqrt{a}}=y\implies x=\frac{2 \sqrt{a} y-A}{2 a}\implies dx=\frac{dy}{\sqrt{a}}$$ This makes $$I=\int e^{-a x^2-Ax}dx=\frac{e^{\frac{A^2}{4 a}}}{\sqrt{a}} \int e^{-y^2} dy=\frac{\sqrt{\pi }\,e^{\frac{A^2}{4 a}} }{2 \sqrt{a}}\text{erf}(y)$$ Back to $x$ $$I=\frac{\sqrt{\pi } e^{\frac{A^2}{4 a}} }{2 \sqrt{a}}\text{erf}\left(\frac{2 a x+A}{2 \sqrt{a}}\right)$$ So $$\int_{-L}^{L} e^{-ax^2-Ax} d{x}=\frac{\sqrt{\pi } e^{\frac{A^2}{4 a}} }{2 \sqrt{a}}\left(\text{erf}\left(\frac{A+2 a L}{2 \sqrt{a}}\right)-\text{erf}\left(\frac{A-2 a L}{2 \sqrt{a}}\right) \right)$$ If you do not access the $\text{erf}(z)$ function, you need to use numerical approximations (there are plenty of them - see here); a simple one is $$\text{erf}(z)\approx \text{sgn}(z) \sqrt{1 - \exp\left(-z^2\frac{\frac{4}{\pi} + az^2}{1 + az^2}\right)}$$ using $$a=\frac{8 (\pi -3)}{3 (4-\pi ) \pi }$$