How to prove $\int_{0}^{\infty}\frac{\tan^{a} (x) \;dx}{x^2+b^2}=\frac{\pi}{2b}\frac{\tanh^{a} (b)}{\cos\frac{a\pi}{2}}$ I'm having trouble to prove the following:
$$
\int_{0}^{\infty}\frac{\tan^{a}\left(x\right)}
{x^{2} + b^{2}}\,\mathrm{d}x =
\frac{\pi}{2b}\,\frac{\tanh^{a}\left(b\right)}{\cos\left(\pi a/2\right)}\quad
\mbox{where}\ \left\vert a\right\vert < 1\
\mbox{and}\ b > 0
$$
The main difficulty is that the sign of the $\tan\left(x\right)$  alternates between positive and negative and so we need $\left(-1\right)$ to raise to power of noninteger number $a$.
I have no idea how to proceed.
 A: The integrand has poles at $x=\pm ib$ and singularities on the real axis at $x=(2n+1)\frac{\pi}{2}$ with cuts where the tangent becomes negative. Nevertheless, the integral can be viewed as a complex contour in the upper half-plane with the segment $(-\infty,\infty)$ shifted slightly by $+i0$ to avoid the singularities and make the integrand holomorphic in the upper half-plane except at $x=ib$. Let
$$C_R=(-R,R) \cup \gamma_R$$
be the closed contour where $\gamma_R$ is the large semi-circle counter-clockwise in the upper half-plane of radius $R$ s.t. $R\neq (2n+1)\frac{\pi}{2}$. Since the tangent is bounded on $\gamma_R$, the integral over the arc $\gamma_R$ vanishes in the limit $R \rightarrow \infty$. Using the residue theorem for the limiting closed contour $C_\infty$, we arrive at
$$\frac{\pi}{b} \, \tan^a(ib) = \int_{C_\infty} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x = \int_{-\infty+i0}^{\infty+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x = (e^{i\pi a}+1) \int_0^{\infty} \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x  \,. \tag{1}$$
Rearranging gives the desired result.
Technically the last step is a bit more intricate than it appears at first sight. When substituting $x\rightarrow -x$ for the segment $(-\infty+i0,i0)$, it becomes $(-i0,\infty-i0)$ which matters because it changes the phase of the tangent. When $\tan(x)$ becomes negative, it has phase $+\pi$ for $\Im(x)>0$ and $-\pi$ for $\Im(x)<0$. This can be seen for e.g. $x\in(-\pi/2+i0,i0)$ and the fact that for $x$ close to $0$, $\tan(x) \approx x$ and hence they share the same phase properties i.e. $$\arg(\tan(x))=\arg(x)=\arg(-1+i0)=\arg(e^{i\pi})=\pi$$ and by the periodicity this translates to $\mathbb{R}$.
Therefore the correct sequence of steps leading to the RHS of (1) is as follows:
$$\int_{i0}^{\infty+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x + \int_{-i0}^{\infty-i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x \\
=\sum_{n=0}^\infty  \int_{n\pi + i0}^{n\pi +\pi/2+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x + \sum_{n=0}^\infty \int_{n\pi + \pi/2 + i0}^{n\pi + \pi+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x \\
+ \sum_{n=0}^\infty  \int_{n\pi - i0}^{n\pi +\pi/2 - i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x + \sum_{n=0}^\infty \int_{n\pi + \pi/2 - i0}^{n\pi +\pi - i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x \, .$$
The argument inside $(\dots)^a$ of the first and last term is positive (on this part of the decomposed domain), i.e. the integrand has phase $0$ and both terms can be combined to $\int_0^\infty \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x$. The second term has $\Im(x)>0$ and thus phase $+\pi$. Likewise in the third term $\Im(x)<0$ and hence $-\tan(x)$ has phase $+\pi$ also. Pulling out the phase and using absolute values instead, these two terms combine to $e^{i\pi a} \int_0^\infty \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x$
giving the RHS of (1).
A: if we try letting $x=iy\Rightarrow dx=idy$ and $(0,\infty)\rightarrow(0,\infty)$. We then know that:
$$\tan(iy)=i\tanh(y)$$
$$\frac{1}{(iy)^2+b^2}=\frac{1}{b^2-y^2}$$
so our integral becomes:
$$\int_0^\infty\frac{i^{a+1}\tanh^a(y)}{b^2-y^2}dy$$
now you can do factor: $b^2-y^2=(b+y)(b-y)$ and also notice that:
$$i^{a+1}=(e^{i\pi/2})^{a+1}=\cos\left(\frac{(a+1)\pi}{2}\right)+i\sin\left(\frac{(a+1)\pi}{2}\right)$$
