Computing $\int\limits_{-\pi/2}^{\pi/2} \cos(\tan x)\,dx$ 
How to compute $\int\limits_{-\pi/2}^{\pi/2} \cos(\tan x)\,dx$?

I tried the usual Riemann integral method but could not figure out and thought of contour integral and seemed working. But whenever I tried to find the residue at the essential singularity of $f(z)=\cos (\tan z)$ at $\frac{\pm \pi}{2}$, I got stuck there.

For a non-complex solution: Using the sub $\tan x\mapsto x$ we get the integral $$\int_{-\infty}^{\infty} \frac{\cos x}{1+x^2}$$
Introduce the parameter $$f(\alpha) = \int_{-\infty}^{\infty} \frac{\cos (\alpha x)}{1 + x^2} \, \mathrm{d}x$$
Now differentiate: $$f'(\alpha) = -\int_{-\infty}^{\infty} \frac{x\sin (\alpha x)}{1+x^2} \, \mathrm{d}x$$
And again 
$$\begin{align*}f''(\alpha) &= -\int_{-\infty}^{\infty} \frac{x^2 \cos (\alpha x)}{1+x^2} \, \mathrm{d}x \\ & =-\int_{-\infty}^{\infty} \frac{(x^2+1) \cos (\alpha x) - \cos (\alpha x)}{1+x^2} \, \mathrm{d}x \\ &=  \int_{-\infty}^{\infty}\frac{ \cos (\alpha x)}{1+x^2} \, \mathrm{d}x  - \int_{-\infty}^{\infty} \cos \alpha x \, \mathrm{d}x\\ & = f(\alpha)\end{align*}$$
This gives $f''(\alpha) -f(\alpha) = 0$ and so $$f(\alpha) = ae^{\alpha} + be^{-\alpha}$$
But $f(0) = a+b = \pi$ and $\lim_{\alpha \to \infty} = 0 \Rightarrow a = 0 $ so $$f(\alpha) = \pi e^{-\alpha}$$
Now recover your integral using $f(1) = \pi e^{-1}$.
