Evaluating $\int_0^\infty\frac{x\tan(ax)}{x^2+b^2}\, \mathrm dx$ 
The question asks to show that
$$\mathcal{I}=\int_0^\infty \dfrac{x\tan(ax)}{x^2+b^2}\mathrm dx=\frac{\pi}{e^{2ab}+1}$$
for $a>0$, $b>0$.

I found this on the internet but searched using Approachzero but found no question. I have been trying this to evaluate using Real methods. Substituting $ax=u$, I got
\begin{align}\mathcal{I}&=a^2\int_0^\infty \frac{u\tan u}{u^2+a^2b^2}\, \mathrm du\\&=\frac{a^2}{2}\int_0^\infty \tan u\, \mathrm d(\ln(a^2b^2+u^2))\end{align}
Applying Integration by part here seems problematic since the first term seems to diverge. Probably this method cannot be applied. Then I searched Wolfram Alpha to find ''Computational time exceeded.'' With Wolfram, I found one result that
$$\mathcal{M}\bigg(\frac{1}{x^2+b^2}\bigg)=\int_0^\infty \frac{x^{s-1}}{x^2+b^2}\mathrm dx=\frac{\pi}{2}b^{s-2}\csc\bigg(\frac{\pi s}{2}\bigg)$$
, where $\mathcal{M}$ denotes the Mellin Transform. I have just learned some basics of Mellin Transform so I don't know how this can help with this question. How can I solve this question or at least can you give some hints?
Edit: After comments by @Dr. Wolfgang Hintze, I searched the book ''Table of Integrals, Series and Products by I S Gradshteĭn'' book and found the same integral without proof.
 A: Due to the simple poles of $\tan(ax)$ and the slow decay of $\frac{x}{x^2+b^2}$, the integral should be interpreted in a very careful way. So here is one way to make sense of the integral:

Let $(R_k)_{k\geq1}$ be an increasing sequence in $(0, \infty)$ satisfying the following conditions:

*

*$R_k \to +\infty$ as $k \to \infty$, and

*there exists $\delta > 0$ such that $\lvert R_k - \frac{\pi}{2a}(2n-1) \rvert \geq \delta $ for any $k, n \geq 1$. That is, each $R_k$ is at least at a distance $\delta$ from any of the poles of $\tan(ax)$. (For example, $R_k = \frac{\pi k}{a}$ works.)

Then
$$ \mathcal{I} := \lim_{k\to\infty} \operatorname{PV}\!\!\int_{0}^{R_k} \frac{x \tan(ax)}{x^2+b^2} \, \mathrm{d}x = \frac{\pi}{e^{2ab} + 1}. $$

For the interested user, here is the graph of $R \mapsto \operatorname{PV}\!\!\int_{0}^{R} \frac{x \tan(ax)}{x^2+b^2} \, \mathrm{d}x $ when $a = b = 1$:


Sketch of the 1st Proof. We find that $2\mathcal{I}$ can be written as
\begin{align*}
2\mathcal{I}
&= \lim_{k\to\infty} \operatorname{PV}\!\!\int_{-a R_k}^{a R_k} \frac{y \tan y}{y^2+(ab)^2} \, \mathrm{d}x \tag{$y = ax$}\\
&= \lim_{N\to\infty} \sum_{k=-N}^{N} \int_{-\pi/2}^{\pi/2} \frac{1}{2} \left( \frac{1}{y + k\pi + iab} + \frac{1}{y + k\pi - iab} \right) \tan y \, \mathrm{d}y
\end{align*}
Then by utilizing the partial fraction decomposition of the cotangent,
$$ \cot z = \lim_{N\to\infty} \sum_{k=-N}^{N} \frac{1}{z - \pi k}, $$
we get
$$ 2\mathcal{I}
= \int_{-\pi/2}^{\pi/2} \frac{\cot(y + iab) + \cot(y - iab)}{2} \tan y \, \mathrm{d}y. $$
By utilizing trigonometric identities, we find that the integrand simplifies as follows:
$$ \frac{\cot(y + iab) + \cot(y - iab)}{2} \tan y = \frac{\sin^2 y}{\cosh^2(ab) - \cos^2 y}. $$
Therefore
\begin{align*}
2\mathcal{I}
&= \int_{-\pi/2}^{\pi/2} \frac{\sin^2 y}{\cosh^2(ab) - \cos^2 y} \, \mathrm{d}y \\
&= \int_{-\infty}^{\infty} \left( \frac{1}{t^2+1} - \frac{\sinh^2(ab)}{\cosh^2(ab) t^2 + \sinh^2(ab)} \right) \, \mathrm{d}y \tag{$t = \tan y$} \\
&= \pi - \pi \tanh(ab)
= \frac{2\pi}{e^{2ab} + 1}.
\end{align*}
Therefore the desired equality follows.

Sketch of the 2nd Proof. Let me only sketch the proof of this equality. We will instead study
$$ 2\mathcal{I} = \lim_{k\to\infty} \operatorname{PV}\!\!\int_{-R_k}^{R_k} \frac{x \tan(ax)}{x^2+b^2} \, \mathrm{d}x. $$
To this end, let $0 < \epsilon < b < T$ and $R > 0$. If $\Gamma$ is a counter-clockwise rectangular contour with the four corners $\pm R + i\epsilon$ and $ \pm R + iT$, then
$$ \int_{\Gamma} \frac{z \tan(az)}{z^2+b^2} \, \mathrm{d}z = 2\pi i \, \underset{z=ib}{\mathrm{Res}} \, \frac{z \tan(az)}{z^2+b^2} = -\pi \tanh(ab). $$
Moreover, as $R \to \infty$ along the sequence $(R_k)_{k \geq 1}$ and $\epsilon \to 0^+$,
$$ \int_{-R+i\epsilon}^{R+i\epsilon} \frac{z \tan(az)}{z^2+b^2} \, \mathrm{d}z \quad \longrightarrow \quad 2\mathcal{I} - \pi i \lim_{k\to\infty} \sum_{\substack{\xi : |\xi| < R; \\ \tan(a\xi) = 0 }} \underset{z=\xi}{\mathrm{Res}} \, \frac{z \tan(az)}{z^2+b^2} = 2\mathcal{I}, $$
since
$$ \sum_{\substack{\xi : |\xi| < R; \\ \tan(a\xi) = 0 }} \underset{z=\xi}{\mathrm{Res}} \, \frac{z \tan(az)}{z^2+b^2}
= \sum_{\substack{\xi : |\xi| < R; \\ \tan(a\xi) = 0 }} \frac{a \xi \sec^2(a\xi)}{\xi^2+b^2}
= 0 $$
by the symmetry. Finally, consider the integral
$$ \int_{\gamma} \frac{z \tan(az)}{z^2+b^2} \, \mathrm{d}z $$
along the polygonal path $\gamma$ from $R+i\epsilon$ to $R+iT$ to $-R+iT$ to $-R+i\epsilon$. To study the behavior of this integral, we make the following observations:

*

*$ \tan(z) \to i $ uniformly as $\operatorname{Im}(z) \to +\infty$.


*The argument change along $\gamma$, viewed from any given point, is $\pi + o(1)$ as $R, T \to \infty$ and $\epsilon \to 0^+$
So we expect that
$$ \int_{\gamma} \frac{z \tan(az)}{z^2+b^2} \, \mathrm{d}z \approx \frac{i}{2} \int_{\gamma} \left( \frac{1}{z+ib} + \frac{1}{z-ib} \right) \, \mathrm{d}z \approx \frac{i}{2} (i\pi + i\pi) = -\pi $$
and the error in the above approximate equalities will vanish along the limit. Therefore
$$ 2\mathcal{I} - \pi = \lim_{\substack{R_k\to\infty \\ T \to \infty \\ \epsilon \to 0^+}} \int_{\Gamma} \frac{z \tan(az)}{z^2+b^2} \, \mathrm{d}z = -\pi \tanh(ab), $$
and solving this for $\mathcal{I}$ yields the desired equality.
