When encountering the integral $$\int_0^\pi i^{\tan x} d x,$$ I feel interesting and wonder of its value. Since it is improper at $x=\frac{\pi}{2},$ I start to split into two intervals and investigate each of them. $$\int_0^\pi i^{\tan x} d x = \underbrace{ \int_0^\frac\pi2 i^{\tan x} d x}_{J} + \underbrace{\int_ \frac\pi2 ^\pi i^{\tan x} d x}_{K} .$$ Using the period of $\tan x$, I change the the second integral $K$ by the substitution $x\mapsto \pi-x$. $$ K =\int_0^{\frac{\pi}{2}} i^{\tan (\pi-x)} d x =\int_0^{\frac{\pi}{2}} i^{-\tan x} d x $$ Combining them yields $$ \begin{aligned} I & =\int_0^{\frac{\pi}{2}}\left(e^{\frac{\pi}{2} i \tan x}+ e^{-\frac{\pi}{2} i \tan x}\right) d x\\ & =\int_0^{\frac{\pi}{2}}\left(e^{\frac{\pi}{2} i \tan x}+ \overline{ e^{\frac{\pi}{2} i \tan x}}\right) d x\\ & =2 \int_0^{\frac{\pi}{2}} \cos \left(\frac{\pi}{2} \tan x\right) d x \end{aligned} $$ which is surprisingly real.
Naturally, putting $t=\tan x$ transforms the integral into $$ \begin{aligned} I & =2 \int_0^{\infty} \frac{\cos \left(\frac{\pi}{2} t\right)}{1+t^2} d t \\ & =\int_{-\infty}^{\infty} \frac{\cos \left(\frac{\pi}{2} t\right)}{1+t^2} d t\\&=\Re \int_{-\infty}^{\infty} \frac{e^{\frac{\pi}{2} t i}}{1+t^2}dt \\ & =\Re \oint_\gamma \frac{e^{\frac{\pi}{2} z i}}{1+z^2} d z \end{aligned} $$ using contour integration along anti-clockwise direction of the path $$\gamma=\gamma_{1} \cup \gamma_{2} \textrm{ where } \gamma_{1}(t)=t+i 0(-R \leq t \leq R) \textrm{ and } \gamma_{2}(t)=R e^{i t} (0<t<\pi) \textrm{ as } R \rightarrow \infty. $$ \begin{aligned} I & =\Re\left[2 \pi i \lim _{z \rightarrow i}(z-i) \frac{e^{\frac{\pi}{2} z i}}{z^2+1}\right] \\ & =\Re\left[2 \pi i \frac{e^{-\frac{\pi}{2}}}{2 i}\right] \\ & =\pi e^{-\frac{\pi}{2}} \end{aligned} My Question
Is there any real method to deal with integral?
Your comments and alternative methods are highly appreciated.