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.

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