I'm having trouble evaluating the following integral: $$\int_{0}^{\infty} \frac{\cos^k(x)}{a^2+x^2} \, dx \,\text{ where } k \in \mathbb{N} \text{ and } a >0$$ I've tried to follow this question which approaches tan instead. $$I = \frac{1}{2} \int_{-\infty}^{\infty} \frac{\cos^k(x)}{a^2 + x^2} \, dx$$
$$I = -i \int_{0}^{i \infty} \frac{\cosh^k(x)}{(a-x)(a+x)} \, dx$$ From here, I'm not sure how to progress. I am aware of the following expansions of $\cos^n$: $$\cos^{2n} (z) = 2^{-2n} \binom{2n}{n} + 2^{1-2n} \sum_{k=0}^{n-1} \binom{2n}{k} \cos(2(n-k)z)$$ $$\cos^{2n} (z) = 1 + 2^{1-2n} \sum_{k=0}^{n-1} \binom{2n}{k}( \cos(2(n-k)z)-1)$$ $$\cos^{2n+1} (z) = 2^{-2n} \sum_{k=0}^{n} \binom{2n+1}{k} \cos((2n-2k+1)z)$$ $$\cos^{n} (z) = 2^{-n} \binom{n}{\frac{n}{2}}(1- \, n \text{ mod } 2) + 2^{1-n} \sum_{k=0}^{ \lfloor{\frac{n-1}{2}\rfloor}} \binom{n}{k} \cos((n-2k)z)$$ Based on @Claude Leibovici response, it is possible to evaluate the following two equations: \begin{equation} \int_{0}^{\infty} \frac{\cos^{2n} (x)}{a^2+x^2} \, dx = \frac{\sqrt{\pi } \Gamma \left(n+\frac{1}{2}\right) \left(1-2 \, _2F_1\left(1,-n;n+1;-e^{2 a}\right)\right)}{2 a \Gamma (n+1)}+\frac{\pi 4^{-n} e^{-2 a n} \left(e^{2 a}+1\right)^{2 n}}{a} \end{equation} \begin{equation} \int_{0}^{\infty} \frac{\cos^{2n+1} (x)}{a^2+x^2} \, dx = \frac \pi a e^{-a (2 n+1)} (1-\tanh (a))^{-(2 n+1)}- \frac{\sqrt{\pi } e^a \Gamma \left(n+\frac{3}{2}\right)}{a \Gamma (n+2)}{}_2F_1\left(1,-n;n+2;-e^{2 a}\right) \end{equation}