# Forcing Mathematica's Integrate to give more general answers

I have a simple gaussian integral: $$\int^{\infty}_{-\infty}dx\:e^{i\alpha x^2}$$.

If $$\alpha \in \mathbb{R}$$, then:

$$\int^\infty_{-\infty} dx\; e^{i \, \alpha x^2} = \sqrt{\frac \pi {-i \alpha}} \qquad \qquad \alpha <0$$

Now if $$\alpha \in \mathbb{C}$$ then we obtain the same answer but with different conditions:

$$\int^\infty_{-\infty} dx\; e^{i \, \alpha x^2} = \sqrt{\frac \pi {-i \alpha}} \qquad \qquad Im(\alpha)>0$$

These can be combined into a simple answer with an OR statement:

$$\int^\infty_{-\infty} dx\; e^{i \, \alpha x^2} = \sqrt{\frac \pi {-i \alpha}} \qquad \qquad Im(\alpha)=0 \, \& \, Re(\alpha) <0 \quad|| \quad Im(\alpha)>0$$

When I I ask Mathematica to solve this for me

Integrate[E^(I x^2 a), {x, -∞, ∞}]


Mathematica returns only one of these cases:

ConditionalExpression[Sqrt[π]/Sqrt[-I a], Im[a] > 0]


I have tried specifying $$Im(\alpha)\geq 0$$ in the Assumptions but Mathematica disregards this and gives the same result. It can of course find the answer for $$\alpha \in \mathbb{R}$$ but it cannot seem to give a fully general answer where both conditions are present.

• Where did this integral come up? – mjw Mar 7 at 18:45

If $$\alpha$$ is complex, then yes, The imaginary part of alpha should be strictly greater than zero. If $$\alpha$$ is real, does it converge? If you complete the contour in the complex plane, with a semicircle, and replace $$x$$ by $$z=x+ i y$$, I do not see the integral converging along the semicircle.

$$\mathbf{UPDATE:}$$

Okay, I looked the integral up in Gradshteyn and Ryzhik, Table of Integrals, Series, and Products, 6$$^\textrm{th}$$ edition, p. 333. Looks like the integral for $$\alpha$$ real converges for $$\alpha<0$$ but with limits zero to infinity.

$$\displaystyle \int_0^\infty e^{-i\lambda x^2} dx = \frac{1}{2} \sqrt{\frac{\pi}{\lambda}} e^{-i\pi/4}, \quad (\lambda>0)$$.

We can infer from this (let $$w=-x$$ $$\Rightarrow$$ $$dw = - dx$$)

$$\displaystyle \int_{-\infty}^\infty e^{-i\lambda x^2} dx = \sqrt{\frac{\pi}{\lambda}} e^{-i\pi/4}, \quad (\lambda>0)$$.

Replacing $$\lambda$$ by $$-\lambda$$ we get the complex conjugate:

$$\displaystyle \int_{-\infty}^\infty e^{i\lambda x^2} dx = \sqrt{\frac{\pi}{-\lambda}} e^{i\pi/4}, \quad (\lambda<0)$$.

Combining these:

$$\displaystyle \int_{-\infty}^\infty e^{-i\lambda x^2} dx = \sqrt{\frac{\pi}{\lambda}} e^{ - i\pi \,\textrm{sign }{(\lambda)} /4}, \quad (\lambda \ne 0, \lambda \in \Re)$$.

This is consistent with what Mathematica (Version 11.2.0.0, Mac OS X) gives:

Assuming[Element[a,Reals],Integrate[Exp[I a x^2],{x,-Infinity,Infinity}]


returning

Sqrt[Pi]/2 (1+ I Sign[a])/Sqrt[Abs[a]]


If anybody has an idea how to compute this integral with contour integration (or otherwise) from first principals, that would be interesting!

Also, we still haven't answered why Mathematica assumes that $$\alpha$$ is not real if $$\alpha \in \mathbb{C}$$!

$$\mathbf{ADDITIONAL \,\, UPDATE:}$$

This will take into account each case, and output the result or indicate if the integral does not converge:

q[a_] := Integrate[Exp[I a x^2], {x, -Infinity, Infinity}];
integral[a_] := If[Element[a, Reals], Assuming[Element[a, Reals], q[a]], q[a]];


Here are a few examples:

• I don't think Mathematica gave the proper response $\alpha<0$. If it converges for $\alpha<0$ why not $\alpha>0$. and does it converge? – mjw Mar 7 at 15:38
• I have assumed $x \in \mathbb{R}$ so convergence in that sense has not been accounted for. – OldTomMorris Mar 7 at 16:28
• Well, I believe Gradshteyn and Ryzhik's listing. We can then make some substitutions to compute what happens for $\alpha>0$. Mathematica (ver. 11.2) gives an answer that is consistent. Obviously, the integral diverges for $\alpha=0$. Mathematica's result $\rightarrow \infty$ there. – mjw Mar 7 at 18:44
• "Also, we still haven't answered why Mathematica assumes that 𝛼 is not real if 𝛼 ∈ ℂ!". This is exactly my problem! – OldTomMorris Mar 8 at 10:26
• Agreed! I've updated my answer to output what we would have liked to have seen for cases when $\alpha$ is real and when $\alpha$ has a nonzero imaginary part. – mjw Mar 8 at 18:36

By default, Mathematica assumes all symbols are complex valued, so this is what you get if you don't specify. You can see all the variations by making assumptions:

Integrate[E^(I x^2 a), {x, -∞, ∞}, Assumptions -> #]
& /@ {a ∈ Complexes, a ∈ Reals, Im[a] == 0,
Im[a] < 0, Im[a] > 0, Re[a] == 0, Im[a] >= 0, a == 0, a < 0}


One of these doesn't converge and another is equal to infinity, but they do give the full range of possibilities.