# Substituting a real variable for a complex variable (integration by substitution)

If I have an integral such as:

$$\int_{ - \infty}^{ \infty} e^{-(x+i)^2}dx$$

Now of course there is the weird substitution $$u = x + i$$.

Does this substitution always work? If not when does it not work?

• I do not think it is valid, since $i$ is not real. Commented Oct 26, 2021 at 13:17
• The thing is I tried to use this method and I ended up with the correct result, so maybe this implies that the method is valid in some cases? Commented Oct 26, 2021 at 13:18

This is valid, but you have to be careful. We need some complex analysis to do this. Consider the function $$f : \mathbb C \rightarrow \mathbb C$$ such that $$f(z) = e^{-z^2}$$, and let the contour $$\gamma_R$$ be defined by $$\gamma_R : [-R,R] \rightarrow \mathbb C, \gamma_R(t)=t+i$$. Then we can say $$\int_{-\infty}^{\infty}f(t+i)dt=\lim_{R\to\infty}\int_{\gamma_R}f(z)dz,$$ where the former is the integral you want. So, if interpreted as an integral over a contour, then yes, the substitution is valid, but it has to be treated with the proper formalism of complex analysis. You cannot non-chalantly replace $$u=x+i$$ as you would in a real-analytic calculus course, since then you would have the problem of giving meaning to the bounds $$-\infty+i$$ and $$\infty+i$$, which you cannot really do in a way that is consistent.
This happens to work in this case because the integral $$\int_\gamma e^{-z^2} \, dz$$ over any closed curve is zero, according to Cauchy's integral theorem.
If you choose $$\gamma$$ as the boundary of the rectangle with corners $$-R, +R, +R+i, -R+i$$ then $$0 = \int_{-R}^R e^{-x^2} \, dx + \int_0^1 e^{(R+iy)^2} i\, dy - \int_{-R}^R e^{-(x+i)^2} \, dx - \int_0^1 e^{(-R+iy)^2} i\, dy \, .$$ The integrals of the “vertical” parts of the curve converge to zero for $$R \to \infty$$, and that is why $$\int_{ - \infty}^{ \infty} e^{-x^2} \, dx = \lim_{R \to \infty} \int_{-R}^R e^{-x^2} \, dx = \lim_{R \to \infty}\int_{-R}^R e^{-(x+i)^2} \, dx = \int_{ - \infty}^{ \infty} e^{-(x+i)^2} \, dx \, .$$