# Evaluate $\int_{-\infty}^\infty x\cdot\exp(-x^2+ix)\,dx$ using complex analysis.

It is easy to evaluate $\int_{-\infty}^\infty x\cdot\exp(-x^2+ix)\,dx$ without using complex analysis, i.e.,

$\int_{-\infty}^\infty x\cdot\exp(-x^2+ix)\,dx=\exp(-\frac{1}{4})\int_{-\infty}^\infty x\cdot\exp(-(x-\frac{1}{2}i)^2)\,dx$ and then use substitution to get the answer $\exp(-\frac{1}{4})\frac{i}{2}\sqrt{\pi}$.

If we want to evaluate it using complex analysis, I know we need to construct a contour so that I can apply Cauchy integral formula (since there is no pole here so that we cannot use Residue theorem). However, I cannot find a contour and the functions to integrate on the complex plane so that the contour follows the part of the complex plane that describes the real-valued integral. Any suggestion or hint will be highly appreciated.

Your integrand is entire and so the residue theorem isn't of use here. What you want to do is use the fact that contour integral of a holomorphic function is zero. Technically, the change of variable you talked about is not well-posed in the sense of standard calculus because it's a change of variable with a complex number. The better way to view it is that you're doing a contour integral of that integrand around a rectangular box in the complex plane. The box has a bottom side on the real line and top side on the line $\frac{1}{2}i$. The two side edges go off to infinity and it's easy to argue that their contribution to the contour integral is zero. Then you can equate the two integrals (which justifies the change of variable) and you're done.