# evaluation of definite integral

#### pantboio

##### Member
I'm struggling for a long time to solve this integral
$$\int_0^\infty e^{-x^2}cos(kx)dx$$
with $k>0$

I know there are a number of ways, but I'm interested in using complex integration. In particular, I believe that we can solve by integrating $e^{-z^2}$ over the boundary of the rectangule $[-R,R]\times[0,h]$ for a suitable $h$.
What $h$ do you think i should use?

#### topsquark

##### Well-known member
MHB Math Helper
I'm struggling for a long time to solve this integral
$$\int_0^\infty e^{-x^2}cos(kx)dx$$
with $k>0$

I know there are a number of ways, but I'm interested in using complex integration. In particular, I believe that we can solve by integrating $e^{-z^2}$ over the boundary of the rectangule $[-R,R]\times[0,h]$ for a suitable $h$.
What $h$ do you think i should use?
Personally I wouldn't use the rectangle. I'd note that the integrand is even so
$$\int_0^{\infty} e^{-z^2}cos(kz)~dz = \frac{1}{2}\int_{-\infty}^{\infty} e^{-z^2}cos(kz)~dz$$
and integrate over the upper half plane. (The circular part goes to zero by Jordan's lemma.)

-Dan

#### chisigma

##### Well-known member
I'm struggling for a long time to solve this integral
$$\int_0^\infty e^{-x^2}cos(kx)dx$$
with $k>0$

I know there are a number of ways, but I'm interested in using complex integration. In particular, I believe that we can solve by integrating $e^{-z^2}$ over the boundary of the rectangule $[-R,R]\times[0,h]$ for a suitable $h$.
What $h$ do you think i should use?
A very comfortable way is the use of the Laplace Transform, using the relation...

$\displaystyle \mathcal{L} \{e^{- t^{2}}\}= \frac{\sqrt{\pi}}{2}\ e^{\frac{s^{2}}{4}}\ \text{erfc} (\frac{s}{2})$ (1)

... obtaining...

$\displaystyle \int_{0}^{\infty} e^{- t^{2}} \cos k t\ dt = \frac{\sqrt{\pi}}{2}\ e^{- \frac{k^{2}}{4}}\ \text{Re} \{ \text{erfc} (\frac{i\ k}{2})\} = \frac{\sqrt{\pi}}{2}\ e^{- \frac{k^{2}}{4}}$ (2)

Kind regards

$\chi$ $\sigma$

Last edited:

#### pantboio

##### Member
my solution:
let $\gamma_R$ be the boundary of the rectangle $[-R,R]\times[0,h]$,for $h$ to determine. Let $f(z)=e^{-z^2}$. Thus
$$\oint_{\gamma_R}f(z)dz=0$$
...but we also have

$$\oint_{\gamma_R}f(z)dz=\oint_{\gamma_1}f +\oint_{\gamma2}f+\oint_{\gamma3}f+\oint_{\gamma_4}f$$
where $\gamma_1(t)=t,t\in[-R,R]$, $\gamma_2(t)=R+ti,t\in[0,h]$ ,$-\gamma_3(t)=t+hi,t\in[-R,R]$ and $-\gamma_4(t)=-R+ti,t\in[0,h]$
Hence we have

$$\oint_{\gamma_1} e^{-z^2}dz=\int_{-R}^{R}e^{-t^2}dt$$

$$\oint_{\gamma_3}e^{-z^2}dz=-\int_{-R}^{R}e^{-(t+hi)^2}dt=-e^{h^2}\int_{-R}^{R}e^{-t^2}e^{i(-2ht)}dt$$

Using the fact that sine is odd, the second integral is

$$-e^{h^2}\int_{-R}^{R}e^{-t^2}cos(2ht)dt$$

Now, settin $I_j=\oint_{\gamma_j}$ , $I$=the integral we want to compute, and choosing $h=\frac{k}{2}$ we have

$0=\int_{-R}^{R}e^{-t^2}dt +I_2+I_4-e^{\frac{k^2}{4}}\int_{-R}^{R}e^{-t^2}cos(kt)dt$

Claim: $I_2$ and $I_4$ go to zero for $r$ going to infinite. If so, passing to the limit i get

$$\sqrt\pi-e^{\frac{k^2}{4}}I=0$$
from which
$I=\frac{\sqrt\pi}{2}e^{-\frac{k^2}{4}}$
So we are left to prove:
1)$I_2$ and $I_4$ tends to zero as $R\rightarrow\infty$

2)$\int_{-\infty}^{\infty}e^{-t^2}dt=\sqrt{\pi}$

Last edited:

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
$$\int_0^\infty e^{-x^2}cos(kx)dx$$
with $k>0$
First: why k > 0 ?

second : I will try to solve it and confirm your result , which is surely correct .

$$\int_0^\infty e^{-x^2}cos(kx)dx$$

I will use the substitution $$x^2 = t$$

$$\int_0^\infty e^{-t}\frac{cos(k\sqrt{t})}{2\sqrt{t}}dt$$

$$\int_0^\infty e^{-t}\, \frac{\sum^{\infty}_{n=0}\, \frac{(-1)^n(k\sqrt{t})^{2n}}{(2n)!}}{2\sqrt{t}}dt$$

$$\frac{1}{2}\int_0^\infty e^{-t}\, \sum^{\infty}_{n=0} \frac{(-1)^n k^{2n}t^{n-\frac{1}{2}}}{(2n)!}\,dt$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{(-1)^n k^{2n}}{(2n)!}\,\int_0^\infty e^{-t}t^{n-\frac{1}{2}}\, \,dt$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{(-1)^n k^{2n}\Gamma{(n+\frac{1}{2})}}{(2n)!}$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{(-1)^n k^{2n}\frac{2^{1-2n}\sqrt{\pi}\Gamma{(2n)}}{\Gamma{(n)}}}{(2n)!}\,$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{2\sqrt{\pi}(-k^2)^{n}\Gamma{(2n)}}{4^n(2n)!\Gamma{(n)}}\, \,$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{2\sqrt{\pi}(-k^2)^{n}(2n-1)!}{(2n)4^n(2n-1)!(n-1)!}\, \,$$

$$\frac{1}{2}\sum^{\infty}_{n=0} \frac{\sqrt{\pi}(-\frac{k^2}{4})^{n}}{(n!)}\, \,= \frac{\sqrt{\pi}}{2}e^{-\frac{k^2}{4}}$$

Clearly we don't need the condition k>0 !

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
Personally I wouldn't use the rectangle. I'd note that the integrand is even so
$$\int_0^{\infty} e^{-z^2}cos(kz)~dz = \frac{1}{2}\int_{-\infty}^{\infty} e^{-z^2}cos(kz)~dz$$
and integrate over the upper half plane. (The circular part goes to zero by Jordan's lemma.)

-Dan
How , would you please illustrate ?

#### topsquark

##### Well-known member
MHB Math Helper
How , would you please illustrate ?
Let's take a contour such that we include the whole real axis (from -infinity to infinity) and close it off with a semi-circle going from infinity to -infinty. Of course we really have a half-circle with radius R and we take the limit of R as it goes to infinity at the end.

So the integral will be composed of two parts: the real line and the semi-circle. So we have:

$$\int_c = \int_{-\infty}^{\infty} + \int_{R} = 2 \pi i \sum \text{residues in upper half plane}$$

The nice thing about this is that the integral over the semi-circle goes to zero by Jordan's Lemma. So all you are left with calculating the residues in the upper half plane.

-Dan

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
Let's take a contour such that we include the whole real axis (from -infinity to infinity) and close it off with a semi-circle going from infinity to -infinty. Of course we really have a half-circle with radius R and we take the limit of R as it goes to infinity at the end.

So the integral will be composed of two parts: the real line and the semi-circle. So we have:

$$\int_c = \int_{-\infty}^{\infty} + \int_{R} = 2 \pi i \sum \text{residues in upper half plane}$$

The nice thing about this is that the integral over the semi-circle goes to zero by Jordan's Lemma. So all you are left with calculating the residues in the upper half plane.

-Dan
Well, that is not completely correct , first you have to prove that the integral over the semi-circle is zero . Second, the function $e^{-z^2}\cos(kz)$ is entire that means if we enclose it by any simply-connected contour the integral is zero . Actually there are no residues since the function has no singularities so if what you are implying is correct then $\int_c = \int_{-\infty}^{\infty} +0 =0$ that means the integral is equal to zero !

#### topsquark

##### Well-known member
MHB Math Helper
Well, that is not completely correct , first you have to prove that the integral over the semi-circle is zero . Second, the function $e^{-z^2}\cos(kz)$ is entire that means if we enclose it by any simply-connected contour the integral is zero . Actually there are no residues since the function has no singularities so if what you are implying is correct then $\int_c = \int_{-\infty}^{\infty} +0 =0$ that means the integral is equal to zero !
Hmmmm...maybe I need to brush up on Jordan's lemma.

-Dan

#### sbhatnagar

##### Active member
The integral may be rewritten as

\begin{aligned} I=\int_0^\infty e^{-x^2}\cos(kx) dx &= \frac{1}{2}\int_{-\infty}^{\infty} e^{-x^2}\cos(kx) dx \\ &= \frac{1}{2} \text{Re} \left[\int_{-\infty}^{\infty} e^{-x^2+ikx} dx\right]\end{aligned}

Here, we can use the general formula

$$\int_{-\infty}^\infty e^{-x^2+bx+c}dx = \sqrt{\pi} e^{b^2/4+c}$$

with $b=ik$ and $c=0$.

$$I =\frac{1}{2} \text{Re} \left[\sqrt{\pi} e^{-k^2/4}\right] = \frac{\sqrt{\pi}}{2} e^{-k^2/4}$$

The formula, I have used can be proved in the following manner:

\begin{aligned} \int_{-\infty}^\infty e^{-x^2+bx+c}dx &= \int_{-\infty}^{\infty} \exp \left\{{-\left( x^2-bx+\frac{b^2}{4}-c-\frac{b^2}{4}\right)} \right\}dx \\ &= e^{b^2/4+c} \int_{-\infty}^\infty e^{-(x-b/2)^2}dx \\ &= \sqrt{\pi} e^{b^2/4+c} \end{aligned}

The last integral has been done with the substitution $t=x-b/2$.

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
The formula, I have used can be proved in the following manner:

\begin{aligned} \int_{-\infty}^\infty e^{-x^2+bx+c}dx &= \int_{-\infty}^{\infty} \exp \left\{{-\left( x^2-bx+\frac{b^2}{4}-c-\frac{b^2}{4}\right)} \right\}dx \\ &= e^{b^2/4+c} \int_{-\infty}^\infty e^{-(x-b/2)^2}dx \\ &= \sqrt{\pi} e^{b^2/4+c} \end{aligned}

The last integral has been done with the substitution $t=x-b/2$.
This is not enough to deduce that the formula can be analytically continued to be used for b is complex .

Last edited:

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
\begin{aligned} \int_{-\infty}^\infty e^{-x^2+bx+c}dx &= \int_{-\infty}^{\infty} \exp \left\{{-\left( x^2-bx+\frac{b^2}{4}-c-\frac{b^2}{4}\right)} \right\}dx \\ &= e^{b^2/4+c} \int_{-\infty}^\infty e^{-(x-b/2)^2}dx \\ &= \sqrt{\pi} e^{b^2/4+c} \end{aligned}

The last integral has been done with the substitution $t=x-b/2$.
So we have the integral $\int_{-\infty}^\infty e^{-(x-b/2)^2}dx$

Now if we assume that b is complex the substitution you made is a bit tricky .why ?
Assume that $b= ic$ for simplicity Re(b)=0 .
So let us make the substitution $t= x-\frac{b}{2}= x-\frac{ic}{2}$ but we know that when making a substitution this applies to the bounds of integration as well , but wait how do we do that ?
Well, the limits of integration after substitution will not still be the same so they will change.

$$\lim_{R\to \infty }\int^{R-\frac{ic}{2}}_{-R-\frac{ic}{2}}e^{-t^2}\, dt$$

Now this looks familiar in the complex plane it is an integration a long a closed rectangle contour the has and infinite width along the x-axis and a height equal to c/2 .
To solve this we apply the method that pantboio described earlier which is a contour integration .