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.
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.
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)}$$
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} $$