Prove $\int_0^\infty \frac{x^{k-1} + x^{-k-1}}{x^a + x^{-a}}dx = \frac{\pi}{a \cos(\frac{\pi k}{2a})}$.

Let $x=e^u$; then the integral is equal to

$$\int_{-\infty}^{\infty} du\, \frac{\cosh{k u}}{\cosh{a u}} $$

This integral may be evaluated by considering the following contour integral

$$\oint_C dz \, \frac{\cosh{k z}}{\cosh{a z}} $$

where $C$ is the rectangle having vertices $-R$, $R$, $R+i \pi/a$, and $-R+i \pi/a$. The contour integral is equal to

$$\int_{-R}^R dx \, \frac{\cosh{k x}}{\cosh{a x}} + i \int_0^{\pi/a} dy \, \frac{\cosh{k (R+i y)}}{\cosh{a (R+i y)}} \\ + \int_{-R}^R dx \, \frac{\cosh{[k (x+i \pi/a)]}}{\cosh{a x}}+i \int_{\pi/a}^0 dy \, \frac{\cosh{k (-R+i y)}}{\cosh{a (-R+i y)}}$$

Note that, because $0 \lt k \lt a$, the second and fourth integrals vanish as $R \to \infty$. Thus, in this limit, the contour integral is equal to

$$[1+ \cos{(\pi k/a)} ]\int_{-\infty}^{\infty} dx \, \frac{\cosh{k x}}{\cosh{a x}} -i \sin{(\pi k/a)} \int_{-\infty}^{\infty} dx \, \frac{\sinh{k x}}{\cosh{a x}} $$

Note that the second integral is zero because it is an odd integral over a symmetric interval.

By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue of the integrand at $z=i \pi/(2 a)$, or $(2 \pi/a) \, \cos{[\pi k/(2 a)]} $. The result is therefore

$$\int_{-\infty}^{\infty} dx \, \frac{\cosh{k x}}{\cosh{a x}} = \frac{\pi}{a} \frac{2 \cos{[\pi k/(2 a)]}}{1+ \cos{(\pi k/a)}} = \frac{\pi}{a} \sec{\left (\frac{\pi k}{2 a} \right )} $$

as was to be shown.


\begin{align*} I &= \int^\infty_0 \frac{x^{k - 1} + x^{-kn - 1}}{x^a + x^{-a}} \, dx\\ &= \int^\infty_0 \frac{x^{k - 1} + x^{-k - 1}}{x^{-a} (x^{2a} + 1)} \, dx\\ &= \int^\infty_0 \frac{x^{k + a -1} + x^{a - k - 1}}{x^{2a} + 1} \, dx \end{align*} Let $t = x^{2a}, x = t^{\frac{1}{2a}}, dx = \frac{1}{2a} t^{\frac{1 - 2a}{2a}} \, dt$ while the limits of integration remain unchanged. Thus \begin{align*} I &= \int^\infty_0 \frac{t^{\frac{k + a - 1}{2a}} + t^{\frac{a - k - 1}{2a}}}{1 + t} \cdot \frac{1}{2a} t^{\frac{1 - 2a}{2a}} \, dt\\ &= \frac{1}{2a} \int^\infty_0 \int^\infty_0 \frac{t^{\frac{k - a}{2a}} + t^{\frac{-a-k}{2a}}}{1 + t} \, dt\\ &= \frac{1}{2a} \int^\infty_0 \frac{t^{\frac{k + a}{2a} - 1}}{(1 + t)^{\frac{k + a}{2a} + \frac{a - k}{2a}}} \, dt + \frac{1}{2a} \int^\infty_0 \frac{t^{\frac{a - k}{2a} - 1}}{(1 + t)^{\frac{a - k}{2a} + \frac{k + a}{2a}}} \, dt\\ &= \frac{1}{2a} \mbox{B} \left (\frac{k + a}{2a}, \frac{a - k}{2a} \right ) + \frac{1}{2a} \mbox{B} \left (\frac{k - a}{2a}, \frac{a + k}{2a} \right ) \end{align*} Here $\displaystyle{\mbox{B} (m,n)}$ is the beta function. Since $\mbox{B}(m,n) = \mbox{B}(n,m)$ we have \begin{align*} I &= \frac{1}{a} \mbox{B} \left (\frac{k + a}{2a}, \frac{a - k}{2a} \right )\\ &= \frac{1}{a} \cdot \frac{\Gamma \left (\frac{k + a}{2a} \right ) \Gamma \left (\frac{a - k}{2a} \right )}{\Gamma \left (\frac{k + a}{2a} + \frac{a - k}{2a} \right )}, \quad \mbox{since} \,\, \mbox{B}(m,n) = \frac{\Gamma (m) \Gamma (n)}{\Gamma (m + n)}\\ &= \frac{1}{a} \Gamma \left (\frac{1}{2} + \frac{k}{2a} \right ) \Gamma \left (\frac{1}{2} - \frac{k}{2a} \right ), \quad \mbox{since} \,\, \Gamma (1) = 1\\ &= \frac{\pi}{a \cos \left (\frac{k\pi}{2} \right )} \end{align*} as required to show. Note in the last line the following reflection formula for the gamma function has been used $$\Gamma \left (\frac{1}{2} + x \right ) \Gamma \left (\frac{1}{2} - x \right ) = \frac{\pi}{\cos (x \pi)}.$$