Integral $\int_{-\pi/2}^{\pi/2}\cos^2(x)\cos(a+b\tan(x))dx$ 
Evaluate
  $$\int_{-\pi/2}^{\pi/2}\cos^2(x)\cos(a+b\tan(x))\mathrm dx$$

I tried the following ideas:
$u=a+b\tan(x)$, $du=b\sec^2(x)dx$
$$\frac{1}{b}\int \cos^4(x)\cos(u)du$$
using $1+\tan^2(x)=\sec^2(x)$
$$b^3\int \frac{\cos(u)du}{(u-a)^4}$$
I am stuck at this point. Any help?
 A: $$I=\int_{-\pi/2}^{\pi/2}\cos^2(x)\cos(a+b\tan(x))\mathrm dx\overset{x\to -x}=\int_{-\pi/2}^{\pi/2}\cos^2(x)\cos(a-b\tan(x))\mathrm dx$$
Summing up the two integrals from above gives us:
$$ 2I= 2\cos a \int_{-\pi/2}^{\pi/2} \cos^2 x \cos(b\tan x) dx\Rightarrow I=2\cos a\int_0^{\pi/2}\cos^2 x\cos(b\tan x) dx$$
$$\overset{\tan x=t}=2\cos a\int_0^\infty \frac{\cos(b t)}{(1+t^2)^2}dt\overset{bt=x}=2b^3 \cos a\int_0^\infty \frac{\cos x}{(b^2+x^2)^2}dx$$
Consider the following integral, found here: $$I(b)=\int_0^\infty \frac{\cos x}{b^2+x^2}dx=\frac{\pi}{2b e^{b}}\Rightarrow I'(b)=-2b\int_0^\infty \frac{\cos x}{(b^2+x^2)^2}dx$$
$$\Rightarrow I= -2b^3\cos a\cdot \frac{1}{2b}I'(b)= \frac{\pi}{2}\cos a\frac{b+1}{ e^b}$$
A: Setting $I_{a,b} $ equal to the original integral and assuming $b > 0$, we get, with your substitution $b\tan(x) = u-a$,
$$\begin{split}
I_{a,b} &= \frac 1b \int_{-\infty}^{+\infty} \cos^4(x) \cos(u) \mathop{}\!du = \frac 1b \int_{-\infty}^{+\infty} \frac{\cos(u) \mathop{}\! du}{\sec^4(x)} = \frac1 b\int_{-\infty}^{+\infty} \frac{\cos(u)\mathop{}\! du}{(1+\tan^2(x))^2} \\
&= \frac 1 b \int_{-\infty}^{+\infty} \frac{b^4\cos(u)\mathop{}\!du}{(b^2 + (u-a)^2)^2} = b^3 \int_{-\infty}^{+\infty} \frac{\cos(s+a) \mathop{}\!ds}{(b^2 + s^2)^2} = \int_{-\infty}^{+\infty} \frac{\cos(bt + a)}{(1+t^2)^2}dt.
\end{split}$$
The last integral can be solved in two ways:
Direct contour integration. Consider the complex integral
$$J_{a,b} = \lim_{r\to\infty} e^{ia}\int_{\Gamma_r} \frac{e^{ibz}}{(1 + z^2)^2}\mathop{}\!dz \tag 1$$
where the closed contour $\Gamma_r = [-r,r] \cup \gamma_{0,r,\curvearrowleft}$ indicates the concatenation of a segment of length $2r$ lying on the real line and a semicircle lying in the upper half-plane. The integral can be split into two components,
$$\int_{\Gamma_r} \frac{e^{ibz}}{(1 + z^2)^2}\mathop{}\!dz = \int_{[-r,r]} \frac{e^{ibz}}{(1 + z^2)^2}\mathop{}\!dz + \int_{\gamma_{0,r,\curvearrowleft}} \frac{e^{ibz}}{(1 + z^2)^2}\mathop{}\!dz,  $$
and since the second integral vanishes thanks to the Jordan lemma, we are led to
$$J_{a,b} = \lim_{r\to\infty} \int_{[-r,r]} \frac{e^{i(bz+a)}}{(1+z^2)^2} \mathop{}\!dz = \lim_{r\to\infty} \int_{-r}^r \frac{e^{i(bt+a)}}{(1+t^2)^2} \mathop{}\!dt = \int_{-\infty}^{+\infty} \frac{e^{i(bt+a)}}{(1+t^2)^2} \mathop{}\!dt, $$
whence it is clear that $$\operatorname{Re}(J_{a,b}) = I_{a,b}. \tag2$$
Applying the residue theorem to the integral in $(1)$ entails
$$\begin{split}
J_{a,b} &= e^{ia} \lim_{r\to\infty} \left(2\pi i \operatorname*{Res}\limits_{z=i} \frac{e^{ibz}}{(1 + z^2)^2}  \right) \\
&= 2\pi i\ e^{ia} \left( -\frac{b+1}{4e^b}i \right) = \frac \pi 2 e^{ia} \frac{b+1}{e^b},
\end{split}$$
and by $(2)$ we obtain
$$I_{a,b} = \boxed{ \frac \pi 2 \cos(a) \frac{b+1}{e^b}} $$
The Feynman trick, then contour integration. Let us introduce the following parameter-dependent integral:
$$ K_{a,b}(\lambda) = \int_{-\infty}^{+\infty} \frac{\cos(bt+a)}{\lambda^2 + t^2} \mathop{}\!dt. $$
Differentiating w.r.t. $\lambda$ yields
$$K_{a,b}'(\lambda)=\frac{dK_{a,b}}{d\lambda}(\lambda) = \int_{-\infty}^{+\infty} \frac{\partial}{\partial\lambda} \left(\frac{\cos(bt+a)}{\lambda^2 + t^2}\right) \mathop{}\!dt = -2\lambda \int_{-\infty}^{+\infty} \frac{\cos(bt+a)}{(\lambda^2 + t^2)^2} \mathop{}\!dt.  $$
By a procedure which is almost identical to the one seen above, we may calculate
$$K_{a,b}(\lambda) = \operatorname{Re} \left( 2\pi i\ e^{ia} \operatorname*{Res}\limits_{z=\lambda i} \frac{e^{ibz}}{\lambda^2 + z^2} \right) = \operatorname{Re}\left(2\pi i\ e^{ia} \frac{-i}{2\lambda e^{b \lambda}} \right) = \pi \frac{\cos(a)}{\lambda e^{b\lambda}} ,$$
so that
$$K_{a,b}'(\lambda) = - \pi\cos(a) \frac{e^{-b\lambda} (b\lambda +1)}{\lambda^2}.  $$
We conclude by observing
$$ I_{a,b} = -\frac 1 2 K'_{a,b}(1) = \boxed{ \frac \pi 2 \cos(a) \frac{b+1}{e^{b}}} $$
