How to integrate $\int_{-\infty}^{+\infty}\frac{1}{\sqrt{2\pi}}e^{iaz-z^{2}/2}dz$? I have tried to evaluate this integral, but failed to get a result. Wolfram alpha gives me $e^{-\frac{a^2}{2}}$ but I don't know how to get this result.
 A: Note that after completing the square and enforcing the substitution $z\to z+ia$ yields 
$$\begin{align}\frac1{\sqrt{2\pi}} \int_{-\infty}^\infty e^{iaz-z^2/2}\,dz&=\frac1{\sqrt{2\pi}} e^{-a^2/2}\int_{-\infty}^\infty e^{-\frac12(z-ia)^2}\,dz\\\\
&=\frac1{\sqrt{2\pi}} e^{-a^2/2}\int_{-\infty-ia}^{\infty-ia} e^{-\frac12 z^2}\,dz \tag 1\\\\
\end{align}$$
Now, from Cauchy's Integral Theorem , since $e^{-\frac12z^2}$ is analytic then 
$$\oint_{C}e^{-\frac12 z^2}\,dz=0 \tag 2$$
for any rectifiable path $C$.  
Let $R_1>0$ and $R_2>0$ and let $C$ in $(2)$ to be the closed path comprised of (i) the real segment from $-R_1-ia$ to $R_2-ia$; (ii) the line segment from $R_2-ia$ to $R_2$; (iii) the line segment from $R_2$ to $-R_1$; and (iv) the line segment from $-R_1$ to $-R_1-ia$.
Then, we have from $(2)$
$$\begin{align}
\int_{C}e^{-\frac12 z^2}\,dz&=\int_{-R_1-ia}^{R_2-ia}e^{-\frac12 z^2}\,dz+\int_{R_2-ia}^{R_2}e^{-\frac12 z^2}\,dz+\int_{R_2}^{-R1}e^{-\frac12 z^2}\,dz+\int_{-R_1}^{-R_1-ia}e^{-\frac12 z^2}\,dz \tag 3\\\\&=0
\end{align}$$
As $R_1\to \infty$ and $R_2\to \infty$, the second and fourth integrals on the right-hand side of $(3)$ tend to $0$, the first integral approaches the integral on the right-hand side of $(1)$, and the third integral approaches $\sqrt{2\pi}$.
Putting it all together, we obtain the coveted result
$$\frac1{\sqrt{2\pi}} \int_{-\infty}^\infty e^{iaz-z^2/2}\,dz=e^{-\frac12 a^2}$$
A: as you added the tag 'complex-analysis' I'll assume you understand the analytic continuation. 
as Yuri said, you can complete the square, but only when $ia$ is real. this way, you get some expression for $$F(c) = \int_{-\infty}^\infty e^{cx - x^2/2} dx$$
for any $c \in \mathbb{R}$, and since the obtained function $F(c)$ is an entire function of $c$, because of analytic continuation, it stays true even when $c \not \in \mathbb{R}$.
A: A slightly different approach: As noted by @user1952009, $F(z):=\int_{-\infty}^\infty {1\over \sqrt{2\pi}}e^{zt-t^2/2}\,dt$ defines an entire function of the complex variable $z$. The function $G(z):=e^{z^2/2}$ is also an entire function. Finally, the "complete the square" trick works to evaluate $F$ on the real axis, yielding  $F(x+0i)=G(x+0i)$ for all real $x$.  But two entire functions that agree on a set with a finite limit point (such as the real axis) must be identical. Thus $F(z)=G(z)=\exp(z^2/2)$ for all $z\in\Bbb C$.
A: Call this integral $f\left(a\right)$. The integrand's imaginary part is odd, so $$f=\int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}}e^{-z^2/2}\cos az dz.$$I'll leave it as an exercise to prove by integration by parts that $f'=-af$. It's well known $f\left(0\right)=1$, so $f=e^{-a^2/2}$.
A: $\dfrac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-\frac{1}{2}(z^2-2iaz+i^2a^2-i^2a^2)}dz=\dfrac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-\frac{1}{2}(z-ia)^2-\frac{a^2}{2}}dz$
$=\dfrac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-\frac{1}{2}(z-ia)^2}e^{-\dfrac{a^2}{2}}dz=\dfrac{e^{-\frac{a^2}{2}}}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-\frac{1}{2}(z-ia)^2}=\dfrac{e^{-\frac{a^2}{2}}}{\sqrt{2\pi}}\cdot\sqrt{2\pi}=e^{-\dfrac{a^2}{2}}$
