Integral of a complex gaussian function I am having difficulties to compute this integral
$$
\int_{-\infty}^\infty e^{\pm ix^2} \, dx.
$$
I tried to use complex integration and Cauchy's theorem but it didn't work. Can someone help me?
 A: First of all I would recommend to make the integral absolutely convergent. This can be done my multiplying the integrand with a suitable convergence factor. Here the obvious choice is a Gaussian. Thus we get:
$$I = \int_{-\infty}^{+\infty} e^{x^2(i-c)} dx$$
where $c$ is an arbitrarily small positive number. Now we use a well-known trick. We multiply our integral I by the same expression with integration variable $y$. We then introduce polar coordinates (r, $\phi$). This way we obtain a very simple integral, which can be evaluated without difficulty. The result is:
$$I^2 = \frac {\pi}{c-i}$$
We now take the square root of both sides. There are two possible solutions in the complex plane. We derive by comparison with the real case (evaluation of a real Gaussian integral, which clearly has a positive value), that the solution with a positive real part is the correct one. The last step is to take the limit of $c$ to zero. The final result is:
$$I = (1 + i) \sqrt{\pi/2}$$
A: Let $\mathcal{I}(a)=2\int_0^\infty e^{-ax^2}\mathrm dx$. Differentiating under the integral sign gives us
\begin{align}\mathcal{I}'(a)&=2\int_0^\infty -x^2 e^{-ax^2}\mathrm dx\\&=-\frac{1}{a\sqrt{a}}\int_0^\infty u^{1/2} e^{-u} \mathrm du\text{ , via substituting $u=ax^2$}\\&=\frac{-\Gamma(3/2)}{a\sqrt{a}}\\&=-\frac{\sqrt{\pi}}{2a\sqrt{a}}\end{align}
So, solve the differential equation by separating the variables to get
$$\mathcal{I}(a)=\sqrt{\frac{\pi}{a}}+C$$
where we know that $\mathcal{I}(1)=\sqrt{\pi}$, so $C=0$.
Therefore, $$\mathcal{I}(i)=\int_{-\infty}^{+\infty} e^{-ix^2}\mathrm dx=\sqrt{\frac{\pi}{i}}$$. Here, for convergence, $\Re(a)>0$
Similarly you can find for $a=-i$ also.
A: I wanted to add an answer that shows how to select the correct square root.
Consider the integral
$$I=\int_{-\infty}^\infty dx\,e^{-\frac{1}{2}ax^2},$$
for $a\in\mathbb{C}$ with $\Re a>0$. This integral clearly converges because the integrand is in $L^1(\mathbb{R})$ as shown by the usual procedure when $a\in\mathbb{R}$.
To compute this, let us consider $\sqrt{a}$ to be the square root of $a$ with positive real part. At the end we will see that we could've also considered the other square root and the result, if we are careful with signs an orientations, is the same at the end.
Now, we can do the change of variables $y=\sqrt{a}x$. This leaves with the integral
$$I=\frac{1}{\sqrt{a}}\int_{\sqrt{a}\mathbb{R}}dy\,e^{-\frac{1}{2}y^2}.$$
The integration contour is now the line spanned by $\sqrt{a}$ in the plane. The notation is a bit dangerous though because it hides the fact that we are also assuming that this line is oriented. Since we chose the square root with positive real part, this orientation goes from the infinity in the second or third quadrant, to the infinity in the first or fourth. Note that the slope of this line is always between $-\pi/2$ and $\pi/2$ due to our assumption that $\Re a$.
We would now like to return the integration contour back to the real line. Once we do this, we can use our usual Gaussian integration formulas. For this, let us remark that the integrand $e^{-\frac{1}{2}y^2}$ is analytic, so that we can alter integration contours however we want as long as we keep their endpoints fixed. We can also move the endpoints, as long as we only move them in a region which this vanishes. Given that
$$e^{-\frac{1}{2}y^2}=e^{-\frac{1}{2}((\Re y)^2-(\Im y)^2+2i\Re y\Im y)},$$
we see that this function only vanishes as $|y|\rightarrow\infty$ if we take the limit along lines for which $|\Re y|>|\Im y|$. But this are precisely the lines with slope between $-\pi/2$ and $\pi/2$.
With this, we conclude that we can simply rotate our contour $\sqrt{a}\mathbb{R}$ to $\mathbb{R}$ to obtain
$$I=\frac{1}{\sqrt{a}}\int_{-\infty}^\infty dy\,e^{-\frac{1}{2}y^2}=\sqrt{\frac{2\pi}{a}}.$$
Had we instead chosen $\sqrt{a}$ to be the one with the negative real part, we would only be able to rotate the contour back to the real line, without going through the disallowed regions, if we do it with the wrong orientation. Thus, in that case we would've obtained
$$I=\frac{1}{\sqrt{a}}\int_{\infty}^{-\infty} dy\,e^{-\frac{1}{2}y^2}=-\sqrt{\frac{2\pi}{a}}.$$
Of course, both are equivalent since in this case the square root with the positive real part is $-\sqrt{a}$.
In summary, the correct formula is
$$\int_{-\infty}^\infty dx\,e^{-\frac{1}{2}ax^2}=\sqrt{\frac{2\pi}{a}},$$
where $\Re a>0.$ An equivalent way of deriving this is to note that one can deform the contour to the one spanned by $1/\sqrt{a}$ (with its induced orientation) without going through the disallowed regions only if one takes the $\sqrt{a}$ with positive real part.
One can use this result to define the integral with $a=\pm i$ as the limit as $c\rightarrow 0^+$ of the case where $a=c\pm i$, as discussed in the previous answers. Thus
$$\int_{-\infty}^\infty e^{\pm i x^2}=\sqrt{\pm i \pi},$$
where the square root is the one with positive real part.
