Evaluate $I_n=\int_0^{\pi/2} \frac{1}{\left( a\cos^2x+b\sin^2x\right)^n} \, dx$ I would like to evaluate (using elementary methods if possible)   : (for $a>0,\ b>0$)

$$
I_n=\int_0^{\pi/2} \frac{1}{( a\cos^2x+b\sin^2x)^n} \, dx,\quad \ n=1,2,3,\ldots
$$
I thought about using $u=\tan(x)$ or $u=\frac{\pi}{2}-x$ but did not work. wolfram alpha evaluates the indefinite integral  but not definite integral???

 A: Per geometric summation
\begin{align}
 \sum_{n\ge 1}I_n t^n=&
\int_0^{\frac{\pi}{2}} \sum_{n\ge 1}\frac{t^n}{(a \cos^2x+ b \sin^2x)^n}dx\\
=&\int_0^{\frac{\pi}{2}}\frac{t}{a\cos^2x+ b\sin^2x-t}dx
=\frac{\pi}{2}\frac{t}{\sqrt{(a-t )(b-t )}}\\
 =&\sum_{n\ge 1}\frac{\pi}{2^{2n-1}}\sum_{i+j+1=n} \frac{1}{a^{i+1/2} b^{j+1/2}} {2i\choose i}{2j\choose j} t^n
\end{align}
where the Taylor series $ \frac{1}{\sqrt{a-t}}=\sum_{i\ge 0}\frac{2i\choose i }{2^{2i} a^{i+1/2}}t^i$ is applied in the last step. Thus
$$I_n= \frac{\pi}{2^{2n-1}\sqrt{ab}}\sum_{i+j+1=n} \frac{{2i\choose i}{2j\choose j}}{a^{i} b^{j}}
$$
which, in particular, results in
\begin{align}
&I_1 =\frac\pi{2\sqrt{ab}}\\
& I_2 =\frac\pi{4\sqrt{ab}}\left(\frac1a+\frac1b\right)\\
& I_3 =\frac\pi{16\sqrt{ab}}\left(\frac3{a^2}+\frac2{ab}+\frac3{b^2}\right)\\
&I_4=\cdots
\end{align}
A: You may just use the residue theorem. $a$ and $b$ are interchangeable via $x\mapsto\frac{\pi}{2}-x$, so it is safe to assume $c\stackrel{\text{def}}{=}\frac{b}{a}\in(0,1)$ (since the case $a=b$ is trivial) and study
$$ I_n(a,b) = \frac{1}{a^n}\int_{0}^{\pi/2}\frac{d\theta}{(\cos^2\theta+c\sin^2\theta)^n}\stackrel{\theta\mapsto\arctan u}{=}\frac{1}{a^n}\int_{0}^{+\infty}\frac{du}{(1+u^2)\left(\frac{1+cu^2}{1+u^2}\right)^n}$$
which is
$$ \frac{1}{2a^n}\int_{\mathbb{R}}\frac{(1+u^2)^{n-1}}{(1+cu^2)^{n}}\,du =\frac{\pi i}{a^n}\operatorname*{Res}_{u=i/\sqrt{c}}\frac{(1+u^2)^{n-1}}{(1+cu^2)^n}.$$
$u=\frac{i}{\sqrt{c}}$ is clearly a pole of order $n$ for $\frac{(1+u^2)^{n-1}}{(1+cu^2)^n}$, hence the RHS equals
$$\frac{\pi i}{(n-1)! a^n c^n}\lim_{u\to \frac{i}{\sqrt{c}}} \frac{d^{n-1}}{du^{n-1}}\frac{(1+u^2)^{n-1}}{\left(u+\frac{i}{\sqrt{c}}\right)^n}. $$
A: Hint:Use Feynman’s Trick: differentiate  the integral with respect to the parameters   $a$ and $b$, and it can be shown that: 
$$\frac{\partial {{I}_{n}}}{\partial a}+\frac{\partial {{I}_{n}}}{\partial b}=-n{{I}_{n+1}}$$
This recursion can be re-written alternatively as:
$${{I}_{n}}=-\frac{1}{n-1}\left( \frac{\partial {{I}_{n-1}}}{\partial a}+\frac{\partial {{I}_{n-1}}}{\partial b} \right),\quad n=2,3,...$$
and notice that ${{I}_{1}}$ can be evaluated rather easily using $u=\tan \left( x \right)$ to get ${{I}_{1}}=\frac{\pi }{2\sqrt{ab}}$.
A: This is not an answer but it is too long for a comment.
For the antiderivative, Wolfram Alpha (and other CAS) return, for $$J_n(x)=(n-1)(a-b) I_n(x)$$s the messy expression
$$2^{n-1} \csc (2 x) \sqrt{\frac{(a-b) \sin ^2(x)}{a}} \sqrt{\frac{(b-a) \cos ^2(x)}{b}}$$ $$
   ((a-b) \cos (2 x)+a+b)^{1-n}$$ $$
   F_1\left(1-n;\frac{1}{2},\frac{1}{2};2-n;\frac{a+b+(a-b) \cos (2 x)}{2
   b},\frac{a+b+(a-b) \cos (2 x)}{2 a}\right)$$ where appears
The problem is that both $J_n\left(\frac{\pi }{2}\right)$ and $J_n\left(0\right)$ result in indeterminate forms and that the limits need to be worked.
These would be
$$J_n\left(\frac{\pi }{2}\right)=-\frac{\sqrt{\pi } \sqrt{1-\frac{a}{b}} \sqrt{1-\frac{b}{a}}\, b^{1-n}\, \Gamma (2-n)}{2
  \, \Gamma \left(\frac{3}{2}-n\right)}\, _2F_1\left(\frac{1}{2},1-n;\frac{3}{2}-n;\frac{b}{a}\right)$$
$$J_n\left(0\right)=\frac{\sqrt{\pi } \sqrt{1-\frac{a}{b}} \sqrt{1-\frac{b}{a}} \,a^{1-n}\, \Gamma (2-n)}{2\,
   \Gamma \left(\frac{3}{2}-n\right)}\, \, _2F_1\left(\frac{1}{2},1-n;\frac{3}{2}-n;\frac{a}{b}\right)$$
Have fun !
