# Evaluate: $\int_{0}^\infty e^{-x^2} \cos^n(x) dx$

How to evaluate: $$\int_0^\infty e^{-x^2} \cos^n(x) dx$$

Someone has posted this question on fb. I hope it's not duplicate.

-
yeah I am looking for closed expression. The $\cos^n(x)$ be expanded in terms of $\cos (kx)$ and evaluated in terms of series. –  Santosh Linkha Feb 23 '13 at 9:44
Mh Mathematica doesn't give a closed expression, but for some tries he gave me an analytical result –  Dominic Michaelis Feb 23 '13 at 10:27
Nice question (+1) –  Chris's sis the artist Feb 23 '13 at 10:30
what is fb ???? –  0x90 Feb 23 '13 at 10:35
@ox90 short for facebook –  Dominic Michaelis Feb 23 '13 at 10:36

I found a way to do it for $n \in \mathbb{N}$. We begin with

$$\cos^n(x)=\left(\frac{e^{ix}+e^{-ix}}{2}\right)^n = \frac{1}{2^n e^{inx}}(1+e^{2ix})^n = \frac{1}{2^n e^{inx}}\sum_{r=0}^n \binom{n}{r}e^{2irx}$$

Therefore

\begin{aligned}\int_{-\infty}^\infty e^{-x^2}\cos^n(x)dx &=\int_{-\infty}^\infty e^{-x^2}\frac{1}{2^n e^{inx}}\sum_{r=0}^n \binom{n}{r}e^{2irx} dx \\ &=\frac{1}{2^n}\sum_{r=0}^n \binom{n}{r}\int_{-\infty}^\infty e^{-x^2+(2ir-in)x}dx\end{aligned}

Here we can use the formula, $\int_{-\infty}^\infty e^{-x^2+bx+c}dx=\sqrt{\pi}e^{b^2/4+c}$. Applying it gives

$$\int_{-\infty}^\infty e^{-x^2}\cos^n(x)dx= \frac{\sqrt{\pi}}{2^n}\sum_{r=0}^n \binom{n}{r}\exp\left({\frac{-(2r-n)^2}{4}}\right)$$

The integrand is even, so

$$\int_0^\infty e^{-x^2}\cos^n(x)dx=\boxed{\displaystyle \frac{\sqrt{\pi}}{2^{n+1}}\sum_{r=0}^n \binom{n}{r}\exp\left({\frac{-(2r-n)^2}{4}}\right)}$$

-
all the functions are symmetric so divide it by two –  0x90 Feb 23 '13 at 10:34
@Dominic Michaelis: I corrected my answer. –  Integrals and Series Feb 23 '13 at 10:34
It should be $2^{n+1}$. –  Chris's sis the artist Feb 23 '13 at 10:35
@Chris's sister and Pals:Thank you for pointing that out. I think I might have made a typo. –  Integrals and Series Feb 23 '13 at 10:38
@ShobhitBhatnagar Your final expression doesn't give correct results. For $n = 3$, Mathematica says the integral evaluates to $\frac{\sqrt{\pi }}{8 e^{9/4}}+\frac{3 \sqrt{\pi }}{8 \sqrt[4]{e}}$. However, yours gives $\frac{3 \sqrt{\pi }}{16 e^{81/4}}+\frac{\sqrt{\pi }}{16 e^{225/4}}+\frac{\sqrt{\pi }}{4 e^{9/4}}$. Probably a small mistake somewhere. –  Ayman Hourieh Feb 23 '13 at 10:42

Using the power reduction formula for $\cos$ for odd powers:

\begin{align} I &= \int_0^\infty e^{-x^2} \cos^n(x) \, dx \\ &= \int_0^\infty e^{-x^2} \left( \frac{2}{2^n} \sum_{k=0}^{(n-1)/2} \binom{n}{k} \cos{((n-2k)x)} \right) \, dx \\ &= \frac{2}{2^n} \sum_{k=0}^{(n-1)/2} \binom{n}{k} \int_0^\infty e^{-x^2} \cos{((n-2k)x)} \, dx \\ \end{align}

The inner integral is a generalization of the Gaussian integral and can be evaluated using differentiation under the integral sign: $$\int_0^\infty e^{-x^2} \cos{((n-2k)x)} \, dx = \frac{1}{2} \sqrt{\pi} e^{-\frac{1}{4}(n-2 k)^2}$$

Therefore, we have:

$$I = \frac{\sqrt{\pi}}{2^n} \sum_{k=0}^{(n-1)/2} \binom{n}{k} e^{-\frac{1}{4}(n-2 k)^2} \qquad n \text{ odd}$$

I don't think there is a nice closed form for this sum.

As for even powers, the same method yields:

\begin{align} I &= \int_0^\infty e^{-x^2} \cos^n(x) \, dx \\ &= \int_0^\infty e^{-x^2} \left( \frac{1}{2^n} \binom{n}{n/2} + \frac{2}{2^n} \sum_{k=0}^{n/2-1} \binom{n}{k} \cos{((n-2k)x)} \right) \, dx \\ &= \frac{\sqrt{\pi}}{2^{n+1}} \binom{n}{n/2} + \frac{2}{2^n} \sum_{k=0}^{n/2-1} \binom{n}{k} \int_0^\infty e^{-x^2} \cos{((n-2k)x)} \, dx \end{align}

Therefore:

$$I = \frac{\sqrt{\pi}}{2^{n+1}} \binom{n}{n/2} + \frac{\sqrt{\pi}}{2^n} \sum_{k=0}^{n/2-1} \binom{n}{k} e^{-\frac{1}{4}(n-2 k)^2} \qquad n \text{ even}$$

-
I think the top is $\lfloor {n \over 2} \rfloor$ let's see what pops up –  Santosh Linkha Feb 23 '13 at 11:12
@experimentX The expression in my answer is for odd powers. It's slightly different for even powers. I'll add it when I get a chance. –  Ayman Hourieh Feb 23 '13 at 12:04